mirror of
https://github.com/buanet/ioBroker.docker.git
synced 2025-12-17 18:39:01 +02:00
testing for advanced userscripts
This commit is contained in:
@@ -70,7 +70,7 @@ To configure the ioBroker container on startup it is possible to set some enviro
|
||||
|LANGUAGE|de_DE:de|The following locales are pre-generated: de_DE:de, en_US:en|
|
||||
|LC_ALL|de_DE.UTF-8|The following locales are pre-generated: de_DE.UTF-8, en_US.UTF-8|
|
||||
|PACKAGES|vi|Installs additional packages to your container needed by some adapters, packages should be seperated by whitespace like "package1 package2 package3"|
|
||||
|REDIS|false|Activates the uses of redis as states-db on startup, fill with "hostname:port" to set redis connection, redis db has to be set up seperately (e.g. in another container)|
|
||||
|REDIS|false|Activates the use of redis as states-db on startup, fill with "hostname:port" to set redis connection, redis db has to be set up seperately (e.g. in another container)|
|
||||
|SETGID|1000|For security reasons it might be useful to specify the gid of the containers iobroker user to match an existing group on the docker host|
|
||||
|SETUID|1000|For security reasons it might be useful to specify the uid of the containers iobroker user to match an existing user on the docker host|
|
||||
|TZ|Europe/Berlin|All valid Linux-timezones|
|
||||
|
||||
@@ -39,9 +39,11 @@ RUN sed -i 's/^# *\(de_DE.UTF-8\)/\1/' /etc/locale.gen \
|
||||
&& sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \
|
||||
&& locale-gen
|
||||
|
||||
# Create scripts directory and copy scripts
|
||||
# Create scripts directorys and copy scripts
|
||||
RUN mkdir -p /opt/scripts/ \
|
||||
&& chmod 777 /opt/scripts/
|
||||
&& mkdir -p /opt/userscripts/ \
|
||||
&& chmod 777 /opt/scripts/ \
|
||||
&& chmod 777 /opt/userscripts/
|
||||
WORKDIR /opt/scripts/
|
||||
COPY scripts/iobroker_startup.sh iobroker_startup.sh
|
||||
COPY scripts/setup_avahi.sh setup_avahi.sh
|
||||
@@ -49,7 +51,11 @@ COPY scripts/setup_packages.sh setup_packages.sh
|
||||
COPY scripts/setup_zwave.sh setup_zwave.sh
|
||||
RUN chmod +x iobroker_startup.sh \
|
||||
&& chmod +x setup_avahi.sh \
|
||||
&& chmod +x setup_packages.sh
|
||||
&& chmod +x setup_packages.sh \
|
||||
&& chmod +x setup_zwave.sh
|
||||
WORKDIR /opt/userscripts/
|
||||
COPY userscripts/userscript_firststart_example.sh userscript_firststart_example.sh
|
||||
COPY userscripts/userscript_everystart_example.sh userscript_everystart_example.sh
|
||||
|
||||
# Install ioBroker
|
||||
WORKDIR /
|
||||
@@ -63,8 +69,9 @@ RUN apt-get update \
|
||||
WORKDIR /opt/iobroker/
|
||||
RUN npm install -g node-gyp
|
||||
|
||||
# Backup initial ioBroker-folder
|
||||
RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker
|
||||
# Backup initial ioBroker and userscript folder
|
||||
RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker \
|
||||
&& tar -cf /opt/initial_userscripts.tar /opt/userscripts
|
||||
|
||||
# Setting up iobroker-user (shell and home directory)
|
||||
RUN chsh -s /bin/bash iobroker \
|
||||
|
||||
@@ -49,11 +49,6 @@ echo "$(printf -- '-%.0s' {1..60})"
|
||||
echo ' '
|
||||
|
||||
|
||||
# Not in use
|
||||
# if [ -f /opt/.firstrun ]
|
||||
# rm -f /opt/.firstrun
|
||||
|
||||
|
||||
#####
|
||||
# STEP 1 - Preparing container
|
||||
#####
|
||||
@@ -68,7 +63,7 @@ then
|
||||
echo "Installing additional packages is set by ENV."
|
||||
echo "The following packages will be installed:" $packages"..."
|
||||
echo $packages > /opt/scripts/.packages
|
||||
sh /opt/scripts/setup_packages.sh > /opt/scripts/setup_packages.log 2>&1
|
||||
bash /opt/scripts/setup_packages.sh > /opt/scripts/setup_packages.log 2>&1
|
||||
echo "Done."
|
||||
else
|
||||
echo "There are no additional packages defined."
|
||||
@@ -162,15 +157,15 @@ 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)
|
||||
bash iobroker host $(cat /opt/iobroker/.install_host)
|
||||
rm -f /opt/iobroker/.install_host
|
||||
echo 'Done.'
|
||||
echo ' '
|
||||
elif [ $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') != $(hostname) ]
|
||||
elif [ $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*') != $(hostname) ]
|
||||
then
|
||||
echo "Hostname in ioBroker does not match the hostname of this container."
|
||||
echo "Updating hostname to " $(hostname)"..."
|
||||
sh /opt/iobroker/iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*')
|
||||
bash iobroker host $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="host": ")[^"]*')
|
||||
echo 'Done.'
|
||||
echo ' '
|
||||
fi
|
||||
@@ -189,11 +184,11 @@ echo "For more information take a look at readme.md on Github!"
|
||||
echo ' '
|
||||
|
||||
# Checking ENV for Adminport
|
||||
if [ "$adminport" != $(iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="port": )[^,]*') ]
|
||||
if [ "$adminport" != $(bash iobroker object get system.adapter.admin.0 --pretty | grep -oP '(?<="port": )[^,]*') ]
|
||||
then
|
||||
echo "Adminport set by ENV does not match port configured in ioBroker installation."
|
||||
echo "Setting Adminport to" $adminport"..."
|
||||
iobroker set admin.0 --port $adminport
|
||||
bash iobroker set admin.0 --port $adminport
|
||||
echo 'Done.'
|
||||
echo ' '
|
||||
fi
|
||||
@@ -202,8 +197,8 @@ fi
|
||||
if [ "$avahi" = "true" ]
|
||||
then
|
||||
echo "Avahi-daemon is activated by ENV."
|
||||
chmod 764 /opt/scripts/setup_avahi.sh
|
||||
sh /opt/scripts/setup_avahi.sh
|
||||
chmod 755 /opt/scripts/setup_avahi.sh
|
||||
bash /opt/scripts/setup_avahi.sh
|
||||
echo "Done."
|
||||
echo ' '
|
||||
fi
|
||||
@@ -212,8 +207,8 @@ fi
|
||||
if [ "$zwave" = "true" ]
|
||||
then
|
||||
echo "Z-Wave is activated by ENV."
|
||||
chmod 764 /opt/scripts/setup_zwave.sh
|
||||
sh /opt/scripts/setup_zwave.sh
|
||||
chmod 755 /opt/scripts/setup_zwave.sh
|
||||
bash /opt/scripts/setup_zwave.sh
|
||||
echo "Done."
|
||||
echo ' '
|
||||
fi
|
||||
@@ -250,6 +245,38 @@ then
|
||||
echo ' '
|
||||
fi
|
||||
|
||||
# Checking for Userscripts in /opt/userscripts
|
||||
if [ `find /opt/userscripts -type f | wc -l` -lt 1 ]
|
||||
then
|
||||
echo "There is no data detected in /opt/userscripts. Restoring exapmple userscripts..."
|
||||
tar -xf /opt/initial_userscripts.tar -C /
|
||||
chmod 755 userscript_firststart_example.sh
|
||||
chmod 755 userscript_everystart_example.sh
|
||||
echo "Done."
|
||||
echo ' '
|
||||
elif [ -f /opt/userscripts/userscript_firststart.sh ] || [ -f /opt/userscripts/userscript_everystart.sh ]
|
||||
then
|
||||
if [ -f /opt/userscripts/userscript_firststart.sh ] && [ -f /opt/.firstrun ]
|
||||
then
|
||||
echo "Userscript for first start detected and this is the first start of a new container."
|
||||
echo "Running userscript_firststart.sh..."
|
||||
chmod 755 userscript_firststart.sh
|
||||
bash /opt/userscripts/userscript_firststart.sh
|
||||
rm -f /opt/.firstrun
|
||||
echo "Done."
|
||||
echo ' '
|
||||
fi
|
||||
if [ -f /opt/userscripts/userscript_everystart.sh ]
|
||||
then
|
||||
echo "Userscript for every start detected. Running userscript_everystart.sh..."
|
||||
chmod 755 userscript_everystart.sh
|
||||
bash /opt/userscripts/userscript_everystart.sh
|
||||
echo "Done."
|
||||
echo ' '
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
sleep 5
|
||||
|
||||
|
||||
|
||||
8
amd64/scripts/userscript_everystart_example.sh
Normal file
8
amd64/scripts/userscript_everystart_example.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is an example script file.
|
||||
# To run the Script on every start of the container you have to rename it to userscript_everystart.sh.
|
||||
|
||||
# You can add your advanced script code here!
|
||||
|
||||
exit 0
|
||||
8
amd64/scripts/userscript_firststart_example.sh
Normal file
8
amd64/scripts/userscript_firststart_example.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is an example script file.
|
||||
# To run the Script on the first start of a new container you have to rename it to userscript_firststart.sh.
|
||||
|
||||
# You can add your advanced script code here!
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user