From 95af2c3acfc39862d6f3acdb228912a535288730 Mon Sep 17 00:00:00 2001 From: andre <> Date: Wed, 27 Nov 2019 21:47:51 +0100 Subject: [PATCH] moving changes to different architectures --- aarch64/Dockerfile | 55 +++++++++++++++------------- aarch64/scripts/iobroker_startup.sh | 44 +++++++++++++++++++--- aarch64/scripts/setup_avahi.sh | 2 +- aarch64/scripts/setup_zwave.sh | 4 +- amd64/Dockerfile | 28 +++++++------- armv7hf/Dockerfile | 57 +++++++++++++++-------------- armv7hf/scripts/iobroker_startup.sh | 44 +++++++++++++++++++--- armv7hf/scripts/setup_avahi.sh | 2 +- armv7hf/scripts/setup_zwave.sh | 4 +- 9 files changed, 155 insertions(+), 85 deletions(-) diff --git a/aarch64/Dockerfile b/aarch64/Dockerfile index 69f7db8..4551331 100644 --- a/aarch64/Dockerfile +++ b/aarch64/Dockerfile @@ -4,23 +4,27 @@ MAINTAINER Andre Germann ENV DEBIAN_FRONTEND noninteractive -# Install prerequisites +# Install prerequisites (as listed in iobroker installer.sh) RUN apt-get update && apt-get upgrade -y && apt-get install -y \ - acl \ - apt-utils \ - build-essential \ - curl \ - git \ - gnupg2 \ - libcap2-bin \ - libpam0g-dev \ - libudev-dev \ - locales \ - procps \ - python \ - gosu \ - unzip \ - wget \ + acl \ + apt-utils \ + build-essential \ + curl \ + git \ + gnupg2 \ + gosu \ + libavahi-compat-libdnssd-dev \ + libcap2-bin \ + libpam0g-dev \ + libudev-dev \ + locales \ + pkg-config \ + procps \ + python \ + python-dev \ + sudo \ + unzip \ + wget \ && rm -rf /var/lib/apt/lists/* # Install node10 @@ -56,14 +60,14 @@ RUN apt-get update \ # Install node-gyp WORKDIR /opt/iobroker/ -RUN npm config set unsafe-perm true # To fix "Error: could not get uid/gid" RUN npm install -g node-gyp # Backup initial ioBroker-folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker -# Setting up iobroker-user -RUN chsh -s /bin/bash iobroker +# Setting up iobroker-user (shell and home directory) +RUN chsh -s /bin/bash iobroker \ + && usermod --home /opt/iobroker iobroker # Setting up ENVs ENV DEBIAN_FRONTEND="teletype" \ @@ -71,14 +75,13 @@ ENV DEBIAN_FRONTEND="teletype" \ LANGUAGE="de_DE:de" \ LC_ALL="de_DE.UTF-8" \ TZ="Europe/Berlin" \ - PACKAGES="nano" \ + PACKAGES="vi" \ + ADMINPORT=8081 \ + SETUID=1000 \ + SETGID=1000 \ AVAHI="false" \ - SETUID=1000 \ - SETGID=1000 \ - ZWAVE="false" - -# Setting up EXPOSE for Admin -EXPOSE 8081/tcp + ZWAVE="false" \ + USBDEVICES="none" # Run startup-script ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] diff --git a/aarch64/scripts/iobroker_startup.sh b/aarch64/scripts/iobroker_startup.sh index 68e9537..4e40f6f 100644 --- a/aarch64/scripts/iobroker_startup.sh +++ b/aarch64/scripts/iobroker_startup.sh @@ -2,10 +2,12 @@ # Reading ENV packages=$PACKAGES -avahi=$AVAHI +adminport=$ADMINPORT uid=$SETUID gid=$SETGID zwave=$ZWAVE +avahi=$AVAHI +usbdevices=$USBDEVICES # Getting date and time for logging dati=`date '+%Y-%m-%d %H:%M:%S'` @@ -34,8 +36,10 @@ echo -n "----- " && echo -n "$(printf "%-10s %-23s" node: $(node - echo -n "----- " && echo -n "$(printf "%-10s %-23s" npm: $(npm -v))" && echo " -----" echo "----- -----" echo "----- ENV -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ADMINPORT: $ADMINPORT)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETGID: $SETGID)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETUID: $SETUID)" && echo " -----" echo "$(printf -- '-%.0s' {1..60})" @@ -125,8 +129,8 @@ if [ -f /opt/iobroker/.install_host ] then echo "Looks like this is a new and empty installation of ioBroker." echo "Hostname needs to be updated to " $(hostname)"..." - sh /opt/iobroker/iobroker host $(cat /opt/iobroker/.install_host) - rm -f /opt/iobroker/.install_host + sh /opt/iobroker/iobroker host $(cat /opt/iobroker/.install_host) + rm -f /opt/iobroker/.install_host echo 'Done.' echo ' ' fi @@ -141,7 +145,17 @@ echo "Some adapters have special requirements which can be activated by the use echo "For more information take a look at readme.md" echo ' ' -# Checking for and setting up avahi-daemon +# Checking ENV for Adminport +if [ "$adminport" != "8081" ] +then + echo "Adminport is set by ENV." + echo "Setting Adminport to" $adminport"..." + iobroker set admin.0 --port $adminport + echo 'Done.' + echo ' ' +fi + +# Checking for enabled avahi-daemon if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." @@ -151,15 +165,33 @@ then echo ' ' fi +# Checking for enabled zwave-support if [ "$zwave" = "true" ] then - echo "ZWave is activated by ENV." + echo "Z-Wave is activated by ENV." chmod 764 /opt/scripts/setup_zwave.sh sh /opt/scripts/setup_zwave.sh echo "Done." echo ' ' fi +# checking enabled usb-devices + +if [ "$usbdevices" != "none" ] +then + echo "Usb-device-support is activated by ENV." + + IFS=';' read -ra devicearray <<< "$usbdevices" + for i in "${devicearray[@]}" + do + echo "Setting permissions for" $i"..." + chown root:dialout $i + chmod g+rw $i + done + echo "Done." + echo ' ' +fi + sleep 5 # Starting ioBroker diff --git a/aarch64/scripts/setup_avahi.sh b/aarch64/scripts/setup_avahi.sh index 2f64a72..4fd1ab1 100644 --- a/aarch64/scripts/setup_avahi.sh +++ b/aarch64/scripts/setup_avahi.sh @@ -2,7 +2,7 @@ echo "Checking avahi-daemon installation state..." -if [ -f /usr/sbin/avahi-daemon ] +if [ -e /usr/sbin/avahi-daemon ] && [ -e /var/run/dbus ] then echo "Avahi is already installed..." else diff --git a/aarch64/scripts/setup_zwave.sh b/aarch64/scripts/setup_zwave.sh index ff1b82f..e9710d0 100644 --- a/aarch64/scripts/setup_zwave.sh +++ b/aarch64/scripts/setup_zwave.sh @@ -2,7 +2,7 @@ echo "Checking openzwave installation state..." -if [ -f /usr/local/lib64 ] +if [ -e /usr/local/lib64 ] then echo "Openzwave is already installed..." else @@ -16,4 +16,4 @@ else # echo "Openzwave is now installed..." fi -exit 0 \ No newline at end of file +exit 0 diff --git a/amd64/Dockerfile b/amd64/Dockerfile index f36ceb6..8141a3b 100644 --- a/amd64/Dockerfile +++ b/amd64/Dockerfile @@ -6,27 +6,27 @@ ENV DEBIAN_FRONTEND noninteractive # Install prerequisites (as listed in iobroker installer.sh) RUN apt-get update && apt-get upgrade -y && apt-get install -y \ - acl \ - apt-utils \ - build-essential \ - curl \ - git \ - gnupg2 \ + acl \ + apt-utils \ + build-essential \ + curl \ + git \ + gnupg2 \ gosu \ libavahi-compat-libdnssd-dev \ - libcap2-bin \ - libpam0g-dev \ - libudev-dev \ - locales \ + libcap2-bin \ + libpam0g-dev \ + libudev-dev \ + locales \ pkg-config \ procps \ - python \ + python \ python-dev \ sudo \ - unzip \ - wget \ + unzip \ + wget \ && rm -rf /var/lib/apt/lists/* - + # Install node10 RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ && apt-get update && apt-get install -y \ diff --git a/armv7hf/Dockerfile b/armv7hf/Dockerfile index 293db80..120093a 100644 --- a/armv7hf/Dockerfile +++ b/armv7hf/Dockerfile @@ -4,26 +4,30 @@ MAINTAINER Andre Germann ENV DEBIAN_FRONTEND noninteractive -# Install prerequisites +# Install prerequisites (as listed in iobroker installer.sh) RUN apt-get update && apt-get upgrade -y && apt-get install -y \ - acl \ - apt-utils \ - build-essential \ - curl \ - git \ - gnupg2 \ - libcap2-bin \ - libpam0g-dev \ - libudev-dev \ - locales \ - procps \ - python \ - gosu \ - unzip \ - wget \ + acl \ + apt-utils \ + build-essential \ + curl \ + git \ + gnupg2 \ + gosu \ + libavahi-compat-libdnssd-dev \ + libcap2-bin \ + libpam0g-dev \ + libudev-dev \ + locales \ + pkg-config \ + procps \ + python \ + python-dev \ + sudo \ + unzip \ + wget \ && rm -rf /var/lib/apt/lists/* -# Install node8 +# Install node10 RUN curl -sL https://deb.nodesource.com/setup_10.x | bash \ && apt-get update && apt-get install -y \ nodejs \ @@ -56,14 +60,14 @@ RUN apt-get update \ # Install node-gyp WORKDIR /opt/iobroker/ -RUN npm config set unsafe-perm true # To fix "Error: could not get uid/gid" RUN npm install -g node-gyp # Backup initial ioBroker-folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker -# Setting up iobroker-user -RUN chsh -s /bin/bash iobroker +# Setting up iobroker-user (shell and home directory) +RUN chsh -s /bin/bash iobroker \ + && usermod --home /opt/iobroker iobroker # Setting up ENVs ENV DEBIAN_FRONTEND="teletype" \ @@ -71,14 +75,13 @@ ENV DEBIAN_FRONTEND="teletype" \ LANGUAGE="de_DE:de" \ LC_ALL="de_DE.UTF-8" \ TZ="Europe/Berlin" \ - PACKAGES="nano" \ + PACKAGES="vi" \ + ADMINPORT=8081 \ + SETUID=1000 \ + SETGID=1000 \ AVAHI="false" \ - SETUID=1000 \ - SETGID=1000 \ - ZWAVE="false" - -# Setting up EXPOSE for Admin -EXPOSE 8081/tcp + ZWAVE="false" \ + USBDEVICES="none" # Run startup-script ENTRYPOINT ["/opt/scripts/iobroker_startup.sh"] diff --git a/armv7hf/scripts/iobroker_startup.sh b/armv7hf/scripts/iobroker_startup.sh index 68e9537..4e40f6f 100644 --- a/armv7hf/scripts/iobroker_startup.sh +++ b/armv7hf/scripts/iobroker_startup.sh @@ -2,10 +2,12 @@ # Reading ENV packages=$PACKAGES -avahi=$AVAHI +adminport=$ADMINPORT uid=$SETUID gid=$SETGID zwave=$ZWAVE +avahi=$AVAHI +usbdevices=$USBDEVICES # Getting date and time for logging dati=`date '+%Y-%m-%d %H:%M:%S'` @@ -34,8 +36,10 @@ echo -n "----- " && echo -n "$(printf "%-10s %-23s" node: $(node - echo -n "----- " && echo -n "$(printf "%-10s %-23s" npm: $(npm -v))" && echo " -----" echo "----- -----" echo "----- ENV -----" -echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $PACKAGES)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ADMINPORT: $ADMINPORT)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $AVAHI)" && echo " -----" +echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $ZWAVE)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETGID: $SETGID)" && echo " -----" echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETUID: $SETUID)" && echo " -----" echo "$(printf -- '-%.0s' {1..60})" @@ -125,8 +129,8 @@ if [ -f /opt/iobroker/.install_host ] then echo "Looks like this is a new and empty installation of ioBroker." echo "Hostname needs to be updated to " $(hostname)"..." - sh /opt/iobroker/iobroker host $(cat /opt/iobroker/.install_host) - rm -f /opt/iobroker/.install_host + sh /opt/iobroker/iobroker host $(cat /opt/iobroker/.install_host) + rm -f /opt/iobroker/.install_host echo 'Done.' echo ' ' fi @@ -141,7 +145,17 @@ echo "Some adapters have special requirements which can be activated by the use echo "For more information take a look at readme.md" echo ' ' -# Checking for and setting up avahi-daemon +# Checking ENV for Adminport +if [ "$adminport" != "8081" ] +then + echo "Adminport is set by ENV." + echo "Setting Adminport to" $adminport"..." + iobroker set admin.0 --port $adminport + echo 'Done.' + echo ' ' +fi + +# Checking for enabled avahi-daemon if [ "$avahi" = "true" ] then echo "Avahi-daemon is activated by ENV." @@ -151,15 +165,33 @@ then echo ' ' fi +# Checking for enabled zwave-support if [ "$zwave" = "true" ] then - echo "ZWave is activated by ENV." + echo "Z-Wave is activated by ENV." chmod 764 /opt/scripts/setup_zwave.sh sh /opt/scripts/setup_zwave.sh echo "Done." echo ' ' fi +# checking enabled usb-devices + +if [ "$usbdevices" != "none" ] +then + echo "Usb-device-support is activated by ENV." + + IFS=';' read -ra devicearray <<< "$usbdevices" + for i in "${devicearray[@]}" + do + echo "Setting permissions for" $i"..." + chown root:dialout $i + chmod g+rw $i + done + echo "Done." + echo ' ' +fi + sleep 5 # Starting ioBroker diff --git a/armv7hf/scripts/setup_avahi.sh b/armv7hf/scripts/setup_avahi.sh index 2f64a72..4fd1ab1 100644 --- a/armv7hf/scripts/setup_avahi.sh +++ b/armv7hf/scripts/setup_avahi.sh @@ -2,7 +2,7 @@ echo "Checking avahi-daemon installation state..." -if [ -f /usr/sbin/avahi-daemon ] +if [ -e /usr/sbin/avahi-daemon ] && [ -e /var/run/dbus ] then echo "Avahi is already installed..." else diff --git a/armv7hf/scripts/setup_zwave.sh b/armv7hf/scripts/setup_zwave.sh index ff1b82f..e9710d0 100644 --- a/armv7hf/scripts/setup_zwave.sh +++ b/armv7hf/scripts/setup_zwave.sh @@ -2,7 +2,7 @@ echo "Checking openzwave installation state..." -if [ -f /usr/local/lib64 ] +if [ -e /usr/local/lib64 ] then echo "Openzwave is already installed..." else @@ -16,4 +16,4 @@ else # echo "Openzwave is now installed..." fi -exit 0 \ No newline at end of file +exit 0