Skip to content

Commit

Permalink
settings.js folder moved
Browse files Browse the repository at this point in the history
  • Loading branch information
hilschernetpi committed Jul 10, 2021
1 parent ea810d3 commit c2c1060
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion auth/user-authentication_v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 15 additions & 2 deletions init.d/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c2c1060

Please sign in to comment.