From eea1c61ac53b7330c9d1efad63d8199d52fff15d Mon Sep 17 00:00:00 2001 From: buanet Date: Mon, 28 Jan 2019 13:57:27 +0100 Subject: [PATCH] moving avahi to script --- Dockerfile | 12 +++++------- scripts/avahi_startup.sh | 21 +++++++++++++++++---- scripts/iobroker_startup.sh | 15 +++++++++++---- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 37c7821..8e43097 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,6 @@ RUN apt-get update && apt-get install -y \ android-tools-adb \ android-tools-fastboot \ apt-utils \ - avahi-daemon \ build-essential \ curl \ ffmpeg \ @@ -35,7 +34,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Configure avahi-daemon -RUN sed -i '/^rlimit-nproc/s/^\(.*\)/#\1/g' /etc/avahi/avahi-daemon.conf +# RUN sed -i '/^rlimit-nproc/s/^\(.*\)/#\1/g' /etc/avahi/avahi-daemon.conf # Configure locales/ language/ timezone RUN sed -i -e 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/' /etc/locale.gen \ @@ -49,11 +48,10 @@ ENV TZ Europe/Berlin RUN mkdir -p /opt/scripts/ \ && chmod 777 /opt/scripts/ WORKDIR /opt/scripts/ -ADD scripts/avahi_startup.sh avahi_startup.sh -ADD scripts/iobroker_startup.sh iobroker_startup.sh +COPY scripts/avahi_startup.sh avahi_startup.sh +COPY scripts/iobroker_startup.sh iobroker_startup.sh RUN chmod +x avahi_startup.sh \ - && chmod +x iobroker_startup.sh \ - && mkdir /var/run/dbus/ + && chmod +x iobroker_startup.sh # Install ioBroker WORKDIR / @@ -69,7 +67,7 @@ RUN npm install node-gyp -g # Backup initial ioBroker-folder RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker -# Some Testing +# Giving iobroker-user sudo rights RUN echo 'iobroker ALL=(ALL) NOPASSWD: ALL' | EDITOR='tee -a' visudo \ && echo "iobroker:iobroker" | chpasswd \ && adduser iobroker sudo diff --git a/scripts/avahi_startup.sh b/scripts/avahi_startup.sh index 00ce579..53e304b 100644 --- a/scripts/avahi_startup.sh +++ b/scripts/avahi_startup.sh @@ -1,17 +1,30 @@ #!/bin/sh +echo 'Checking avahi-daemon installation state...' + +if [ -f /usr/sbin/avahi-daemon ] +then + echo "Avahi already installed..." +else + echo "Installing avahi-daemon..." + apt-get update && apt-get install -y avahi-daemon && rm -rf /var/lib/apt/lists/* + echo "Configuring avahi-daemon..." + sed -i '/^rlimit-nproc/s/^\(.*\)/#\1/g' /etc/avahi/avahi-daemon.conf + echo "Configuring dbus..." + mkdir /var/run/dbus/ +fi + if [ -f /var/run/dbus/pid ]; then rm -f /var/run/dbus/pid fi -echo 'Preparing...' -rm /var/run/dbus/pid +echo 'Starting dbus...' dbus-daemon --system -echo 'Restarting...' +echo 'Restarting avahi-daemon...' /etc/init.d/avahi-daemon stop -sleep 5 +sleep 1 /etc/init.d/avahi-daemon start exit 0 diff --git a/scripts/iobroker_startup.sh b/scripts/iobroker_startup.sh index e9ff3f4..b609143 100644 --- a/scripts/iobroker_startup.sh +++ b/scripts/iobroker_startup.sh @@ -1,7 +1,11 @@ #!/bin/sh +# Checking env-variables packages=$PACKAGES -echo 'Additional packages:' $packages +avahi=$AVAHI + +echo 'ENV packages:' $packages +echo 'ENV avahi:' $avahi cd /opt/iobroker @@ -24,9 +28,12 @@ then echo 'First run preparation done...' fi -echo 'Initializing Avahi-Daemon...' -sudo sh /opt/scripts/avahi_startup.sh -echo 'Initializing Avahi-Daemon done...' +if [ "$avahi" == "true"]; +then + echo 'Initializing Avahi-Daemon...' + sudo sh /opt/scripts/avahi_startup.sh + echo 'Initializing Avahi-Daemon done...' +fi sleep 5