From c2c106088f2121e5b46131ff47afa7ff15dea736 Mon Sep 17 00:00:00 2001 From: hilschernetpi Date: Sat, 10 Jul 2021 04:41:14 +0000 Subject: [PATCH] settings.js folder moved --- Dockerfile | 13 +++++-------- README.md | 2 ++ auth/user-authentication_v2.js | 2 +- init.d/entrypoint.sh | 17 +++++++++++++++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 76f3c21..20572de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,7 @@ LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.vcs-ref=$VCS_REF #version -ENV HILSCHERNETPI_NODERED_VERSION 1.7.5 +ENV HILSCHERNETPI_NODERED_VERSION 1.7.6 #labeling LABEL maintainer="netpi@hilscher.com" \ @@ -109,13 +109,10 @@ RUN curl https://codeload.github.com/HilscherAutomation/${FIELDBUS_NODE}/tar.gz/ && echo ' "dependencies": {' >> package.json \ && echo ' }' >> package.json \ && echo '}' >> package.json \ -#generate keys and self-signed certificate +#prepare separate settings.js folder for Node-RED + && mkdir /root/settings/ \ + && cd /root/settings/ \ && npm install when request \ - && mkdir -p /root/.node-red/certs \ - && cd /root/.node-red/certs \ - && openssl genrsa -out ./node-key.pem 2048 \ - && openssl req -new -sha256 -key ./node-key.pem -out ./node-csr.pem -subj "/C=DE/ST=Hessen/L=Hattersheim/O=Hilscher/OU=Hilscher/CN=myown/emailAddress=myown@hilscher.com" \ - && openssl x509 -req -in ./node-csr.pem -signkey ./node-key.pem -out ./node-cert.pem \ # -------------------- Install GPIO python lib -------------------------------------- && pip install wheel \ && pip install RPi.GPIO \ @@ -277,7 +274,7 @@ RUN curl https://codeload.github.com/HilscherAutomation/${FIELDBUS_NODE}/tar.gz/ # -------------------- Do all necessary copies -------------------- -COPY "./auth/*" /root/.node-red/ +COPY "./auth/*" /root/settings/ #copy bluez tools from builder container COPY --from=builder /usr/bin/bluetoothctl /usr/bin/btmon /usr/bin/rctest /usr/bin/l2test /usr/bin/l2ping \ diff --git a/README.md b/README.md index b0bd6c9..b437496 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,8 @@ A `docker-compose.yml` file could look like this environment: - FIELD=pns + volumes: + nodered: ### Container access The container starts Node-RED and all involved services automatically when deployed. diff --git a/auth/user-authentication_v2.js b/auth/user-authentication_v2.js index 2a96699..b768071 100644 --- a/auth/user-authentication_v2.js +++ b/auth/user-authentication_v2.js @@ -12,7 +12,7 @@ module.exports = { }, authenticate: function(username,password) { return new Promise(function(resolve) { - var auth = 'Basic ' + new Buffer(username + ':' + password).toString('base64'); + var auth = 'Basic ' + new Buffer.from(username + ':' + password).toString('base64'); var url = 'https://127.0.0.1/cockpit/login' request.get({ url : url, diff --git a/init.d/entrypoint.sh b/init.d/entrypoint.sh index 49b9921..0a690a0 100755 --- a/init.d/entrypoint.sh +++ b/init.d/entrypoint.sh @@ -74,7 +74,17 @@ fi if [ ! -e container_first_start ]; then echo "Container is starting the first time" - touch container_first_start + + #copy the settings file to the correct location + cp /usr/lib/node_modules/node-red/settings.js /root/settings/settings.js + + + #generate keys and self-signed certificate + + mkdir -p /root/.node-red/certs + openssl genrsa -out /root/.node-red/certs/node-key.pem 4096 + openssl req -new -sha256 -key /root/.node-red/certs/node-key.pem -out /root/.node-red/certs/node-csr.pem -subj "/C=DE/ST=Hessen/L=Hattersheim/O=Hilscher/OU=Hilscher/CN=$HOSTNAME/emailAddress=myown@hilscher.com" + openssl x509 -req -days 365 -in /root/.node-red/certs/node-csr.pem -signkey /root/.node-red/certs/node-key.pem -out /root/.node-red/certs/node-cert.pem #make hardware dependent nodes dynamically available @@ -119,6 +129,9 @@ if [ ! -e container_first_start ]; then ln -s -f /usr/lib/node_modules_tmp/fieldbus /usr/lib/node_modules/fieldbus fi fi + + touch container_first_start + fi # start bluetooth if support allows it @@ -170,7 +183,7 @@ if [ ! "$FIELD" = "none" ]; then fi # start Node-RED as background task -/usr/bin/node-red flows.json & +/usr/bin/node-red --settings /root/settings/settings.js flows.json & # wait forever not to exit the container while true