From ebd7a7bced8ed99dae96495bdf0811a6a61896d6 Mon Sep 17 00:00:00 2001 From: Lawrence Date: Sat, 13 Jan 2018 10:44:22 -0500 Subject: [PATCH] startup and install apps as non-root user --- docker/Dockerfile | 8 +++----- docker/startmeshcentral.sh | 13 +++++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 7f8b551d..c7e3d8f3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,12 +11,10 @@ RUN apt-get update \ && rm -rf lzma1604 \ && npm install -g forever -RUN npm install greenlock-cli \ +RUN adduser --quiet meshcentral \ && chmod +x /startmeshcentral.sh \ - && adduser --quiet meshcentral - -RUN su - meshcentral \ - && npm install meshcentral node-7z + && su - meshcentral \ + && npm install meshcentral node-7z greenlock-cli ENV PORT 443 ENV REDIRPORT 80 diff --git a/docker/startmeshcentral.sh b/docker/startmeshcentral.sh index 8553950c..740756b7 100644 --- a/docker/startmeshcentral.sh +++ b/docker/startmeshcentral.sh @@ -12,11 +12,15 @@ fi cd /home/meshcentral npmbin=$(which node) -$npmbin install meshcentral foreverbin=$(which forever) -$foreverbin start node_modules/meshcentral/meshcentral.js --cert $HOSTNAME -sleep 10 -$foreverbin stop node_modules/meshcentral/meshcentral.js +$npmbin install meshcentral + +if ! [ -f node_modules/.meshcentral-data/agentserver-cert-private.key ] ;then + $foreverbin start node_modules/meshcentral/meshcentral.js --cert $HOSTNAME + sleep 10 + $foreverbin stop node_modules/meshcentral/meshcentral.js +fi + if [ -f ssl.key ]; then ln -sf ssl.key node_modules/.meshcentral-data/agentserver-cert-private.key ln -sf ssl.cert node_modules/.meshcentral-data/agentserver-cert-public.crt @@ -27,5 +31,6 @@ if [ -f ssl.key ]; then ln -sf ssl.key node_modules/.meshcentral-data/mpsserver-cert-private.key ln -sf ssl.cert node_modules/.meshcentral-data/mpsserver-cert-public.crt fi + $foreverbin start node_modules/meshcentral/meshcentral.js --port $PORT --redirport $REDIRPORT \ No newline at end of file