mirror of
https://github.com/buanet/ioBroker.docker.git
synced 2025-12-18 02:49: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|
|
|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|
|
|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"|
|
|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|
|
|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|
|
|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|
|
|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 \
|
&& sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \
|
||||||
&& locale-gen
|
&& locale-gen
|
||||||
|
|
||||||
# Create scripts directory and copy scripts
|
# Create scripts directorys and copy scripts
|
||||||
RUN mkdir -p /opt/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/
|
WORKDIR /opt/scripts/
|
||||||
COPY scripts/iobroker_startup.sh iobroker_startup.sh
|
COPY scripts/iobroker_startup.sh iobroker_startup.sh
|
||||||
COPY scripts/setup_avahi.sh setup_avahi.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
|
COPY scripts/setup_zwave.sh setup_zwave.sh
|
||||||
RUN chmod +x iobroker_startup.sh \
|
RUN chmod +x iobroker_startup.sh \
|
||||||
&& chmod +x setup_avahi.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
|
# Install ioBroker
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
@@ -63,8 +69,9 @@ RUN apt-get update \
|
|||||||
WORKDIR /opt/iobroker/
|
WORKDIR /opt/iobroker/
|
||||||
RUN npm install -g node-gyp
|
RUN npm install -g node-gyp
|
||||||
|
|
||||||
# Backup initial ioBroker-folder
|
# Backup initial ioBroker and userscript folder
|
||||||
RUN tar -cf /opt/initial_iobroker.tar /opt/iobroker
|
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)
|
# Setting up iobroker-user (shell and home directory)
|
||||||
RUN chsh -s /bin/bash iobroker \
|
RUN chsh -s /bin/bash iobroker \
|
||||||
|
|||||||
@@ -49,11 +49,6 @@ echo "$(printf -- '-%.0s' {1..60})"
|
|||||||
echo ' '
|
echo ' '
|
||||||
|
|
||||||
|
|
||||||
# Not in use
|
|
||||||
# if [ -f /opt/.firstrun ]
|
|
||||||
# rm -f /opt/.firstrun
|
|
||||||
|
|
||||||
|
|
||||||
#####
|
#####
|
||||||
# STEP 1 - Preparing container
|
# STEP 1 - Preparing container
|
||||||
#####
|
#####
|
||||||
@@ -68,7 +63,7 @@ then
|
|||||||
echo "Installing additional packages is set by ENV."
|
echo "Installing additional packages is set by ENV."
|
||||||
echo "The following packages will be installed:" $packages"..."
|
echo "The following packages will be installed:" $packages"..."
|
||||||
echo $packages > /opt/scripts/.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."
|
echo "Done."
|
||||||
else
|
else
|
||||||
echo "There are no additional packages defined."
|
echo "There are no additional packages defined."
|
||||||
@@ -162,15 +157,15 @@ if [ -f /opt/iobroker/.install_host ]
|
|||||||
then
|
then
|
||||||
echo "Looks like this is a new and empty installation of ioBroker."
|
echo "Looks like this is a new and empty installation of ioBroker."
|
||||||
echo "Hostname needs to be updated to " $(hostname)"..."
|
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
|
rm -f /opt/iobroker/.install_host
|
||||||
echo 'Done.'
|
echo 'Done.'
|
||||||
echo ' '
|
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
|
then
|
||||||
echo "Hostname in ioBroker does not match the hostname of this container."
|
echo "Hostname in ioBroker does not match the hostname of this container."
|
||||||
echo "Updating hostname to " $(hostname)"..."
|
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 'Done.'
|
||||||
echo ' '
|
echo ' '
|
||||||
fi
|
fi
|
||||||
@@ -189,11 +184,11 @@ echo "For more information take a look at readme.md on Github!"
|
|||||||
echo ' '
|
echo ' '
|
||||||
|
|
||||||
# Checking ENV for Adminport
|
# 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
|
then
|
||||||
echo "Adminport set by ENV does not match port configured in ioBroker installation."
|
echo "Adminport set by ENV does not match port configured in ioBroker installation."
|
||||||
echo "Setting Adminport to" $adminport"..."
|
echo "Setting Adminport to" $adminport"..."
|
||||||
iobroker set admin.0 --port $adminport
|
bash iobroker set admin.0 --port $adminport
|
||||||
echo 'Done.'
|
echo 'Done.'
|
||||||
echo ' '
|
echo ' '
|
||||||
fi
|
fi
|
||||||
@@ -202,8 +197,8 @@ fi
|
|||||||
if [ "$avahi" = "true" ]
|
if [ "$avahi" = "true" ]
|
||||||
then
|
then
|
||||||
echo "Avahi-daemon is activated by ENV."
|
echo "Avahi-daemon is activated by ENV."
|
||||||
chmod 764 /opt/scripts/setup_avahi.sh
|
chmod 755 /opt/scripts/setup_avahi.sh
|
||||||
sh /opt/scripts/setup_avahi.sh
|
bash /opt/scripts/setup_avahi.sh
|
||||||
echo "Done."
|
echo "Done."
|
||||||
echo ' '
|
echo ' '
|
||||||
fi
|
fi
|
||||||
@@ -212,8 +207,8 @@ fi
|
|||||||
if [ "$zwave" = "true" ]
|
if [ "$zwave" = "true" ]
|
||||||
then
|
then
|
||||||
echo "Z-Wave is activated by ENV."
|
echo "Z-Wave is activated by ENV."
|
||||||
chmod 764 /opt/scripts/setup_zwave.sh
|
chmod 755 /opt/scripts/setup_zwave.sh
|
||||||
sh /opt/scripts/setup_zwave.sh
|
bash /opt/scripts/setup_zwave.sh
|
||||||
echo "Done."
|
echo "Done."
|
||||||
echo ' '
|
echo ' '
|
||||||
fi
|
fi
|
||||||
@@ -250,6 +245,38 @@ then
|
|||||||
echo ' '
|
echo ' '
|
||||||
fi
|
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
|
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