From a1a82ae9766cba179d5b7e689586a6c2a9599cc4 Mon Sep 17 00:00:00 2001
From: Eldon Koyle <eldon.koyle@corelight.com>
Date: Tue, 29 Aug 2023 09:30:39 -0600
Subject: [PATCH 1/2] Set SHARKD_SOCKET to be usable by `node` user

 * set SHARKD_SOCKET=/home/node/sharkd.sock in Dockerfile
 * closes #23
---
 Dockerfile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Dockerfile b/Dockerfile
index df2de00..112765b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -32,6 +32,7 @@ COPY --from=intermediate /out /out
 RUN cd / && tar zxvf /out/sharkd.tar.gz && rm -rf /out/sharkd.tar.gz
 
 ENV CAPTURES_PATH=/captures/
+ENV SHARKD_SOCKET=/home/node/sharkd.sock
 
 # RUN git clone --single-branch --branch master https://github.com/qxip/node-webshark /usr/src/node-webshark
 COPY --chown=node . /usr/src/node-webshark

From bb9f2e44c3856b79dba4608c7c9ef1eb6f467cca Mon Sep 17 00:00:00 2001
From: Eldon Koyle <eldon.koyle@corelight.com>
Date: Tue, 29 Aug 2023 09:57:56 -0600
Subject: [PATCH 2/2] Don't try to remove a socket that doesn't exist

---
 entrypoint.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/entrypoint.sh b/entrypoint.sh
index 0ecfa64..9b3a452 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 
 # sharkd daemon fails to start if the socket already exists
-rm "$SHARKD_SOCKET"
+[ -f "$SHARKD_SOCKET" ] && rm "$SHARKD_SOCKET"
 
 exec npm start