small changes

This commit is contained in:
buanet
2021-08-30 23:13:35 +02:00
parent cf4fb97696
commit 5d3d75292c
3 changed files with 83 additions and 64 deletions

View File

@@ -8,7 +8,7 @@ on:
- dev - dev
jobs: jobs:
bulid-dev-image: bulid-dev-node14-image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repo (dev) - name: Checkout repo (dev)

View File

@@ -24,54 +24,54 @@ dati=`date '+%Y-%m-%d %H:%M:%S'`
# Logging header # Logging header
echo ' ' echo ' '
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo -n "$(printf -- '-%.0s' {1..15})" && echo -n " "$dati" " && echo "$(printf -- '-%.0s' {1..15})" echo -n "$(printf -- '-%.0s' {1..25})" && echo -n " "$dati" " && echo "$(printf -- '-%.0s' {1..25})"
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo ' ' echo ' '
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo "----- Welcome to your ioBroker-container! -----" echo "----- Welcome to your ioBroker-container! -----"
echo "----- Startupscript is now running. -----" echo "----- Startupscript is now running. -----"
echo "----- Please be patient! -----" echo "----- Please be patient! -----"
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo ' ' echo ' '
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo "----- Debugging information -----" echo "----- Debugging information -----"
echo "----- -----" echo "----- -----"
echo "----- System -----" echo "----- System -----"
echo -n "----- " && echo -n "$(printf "%-10s %-23s" arch: $(uname -m))" && echo " -----" echo -n "----- " && echo -n "$(printf "%-20s %-28s" arch: $(uname -m))" && echo " -----"
echo "----- -----" echo "----- -----"
echo "----- Docker-Image -----" echo "----- Docker-Image -----"
echo -n "----- " && echo -n "$(printf "%-10s %-23s" image: ${VERSION})" && echo " -----" echo -n "----- " && echo -n "$(printf "%-20s %-28s" image: ${VERSION})" && echo " -----"
echo -n "----- " && echo -n "$(printf "%-10s %-23s" build: ${BUILD})" && echo " -----" echo -n "----- " && echo -n "$(printf "%-20s %-28s" build: ${BUILD})" && echo " -----"
echo "----- -----" echo "----- -----"
echo "----- Versions -----" echo "----- Versions -----"
echo -n "----- " && echo -n "$(printf "%-10s %-23s" node: $(node -v))" && echo " -----" echo -n "----- " && echo -n "$(printf "%-20s %-28s" node: $(node -v))" && echo " -----"
echo -n "----- " && echo -n "$(printf "%-10s %-23s" npm: $(npm -v))" && echo " -----" echo -n "----- " && echo -n "$(printf "%-20s %-28s" npm: $(npm -v))" && echo " -----"
echo "----- -----" echo "----- -----"
echo "----- ENV -----" echo "----- ENV -----"
if [ "$adminport" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" IOB_ADMINPORT: $adminport)" && echo " -----"; fi if [ "$adminport" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_ADMINPORT: $adminport)" && echo " -----"; fi
if [ "$avahi" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" AVAHI: $avahi)" && echo " -----"; fi if [ "$avahi" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" AVAHI: $avahi)" && echo " -----"; fi
if [ "$multihost" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" IOB_MULTIHOST: $multihost)" && echo " -----"; fi if [ "$multihost" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_MULTIHOST: $multihost)" && echo " -----"; fi
if [ "$objectsdbhost" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" IOB_OBJECTSDB_HOST: $objectsdbhost)" && echo " -----"; fi if [ "$objectsdbhost" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_OBJECTSDB_HOST: $objectsdbhost)" && echo " -----"; fi
if [ "$objectsdbport" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" IOB_OBJECTSDB_PORT: $objectsdbport)" && echo " -----"; fi if [ "$objectsdbport" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_OBJECTSDB_PORT: $objectsdbport)" && echo " -----"; fi
if [ "$objectsdbtype" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" IOB_OBJECTSDB_TYPE: $objectsdbtype)" && echo " -----"; fi if [ "$objectsdbtype" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_OBJECTSDB_TYPE: $objectsdbtype)" && echo " -----"; fi
if [ "$packages" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" PACKAGES: $packages)" && echo " -----"; fi if [ "$packages" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" PACKAGES: $packages)" && echo " -----"; fi
if [ "$setgid" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETGID: $setgid)" && echo " -----"; fi if [ "$setgid" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" SETGID: $setgid)" && echo " -----"; fi
if [ "$setuid" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" SETUID: $setuid)" && echo " -----"; fi if [ "$setuid" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" SETUID: $setuid)" && echo " -----"; fi
if [ "$statesdbhost" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" IOB_STATESDB_HOST: $statesdbhost)" && echo " -----"; fi if [ "$statesdbhost" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_STATESDB_HOST: $statesdbhost)" && echo " -----"; fi
if [ "$statesdbport" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" IOB_STATESDB_PORT: $statesdbport)" && echo " -----"; fi if [ "$statesdbport" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_STATESDB_PORT: $statesdbport)" && echo " -----"; fi
if [ "$statesdbtype" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" IOB_STATESDB_TYPE: $statesdbtype)" && echo " -----"; fi if [ "$statesdbtype" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" IOB_STATESDB_TYPE: $statesdbtype)" && echo " -----"; fi
if [ "$usbdevices" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" USBDEVICES: $usbdevices)" && echo " -----"; fi if [ "$usbdevices" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" USBDEVICES: $usbdevices)" && echo " -----"; fi
if [ "$zwave" != "" ]; then echo -n "----- " && echo -n "$(printf "%-10s %-23s" ZWAVE: $zwave)" && echo " -----"; fi if [ "$zwave" != "" ]; then echo -n "----- " && echo -n "$(printf "%-20s %-28s" ZWAVE: $zwave)" && echo " -----"; fi
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo ' ' echo ' '
##### #####
# STEP 1 - Preparing container # STEP 1 - Preparing container
##### #####
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo "----- Step 1 of 5: Preparing container -----" echo "----- Step 1 of 5: Preparing container -----"
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo ' ' echo ' '
# Adding ckeck file for easy docker detection by ioBroker # Adding ckeck file for easy docker detection by ioBroker
@@ -122,9 +122,9 @@ cd /opt/iobroker
##### #####
# Detecting ioBroker-Installation # Detecting ioBroker-Installation
##### #####
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo "----- Step 2 of 5: Detecting ioBroker installation -----" echo "----- Step 2 of 5: Detecting ioBroker installation -----"
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo ' ' echo ' '
if [ `find /opt/iobroker -type f | wc -l` -lt 1 ] if [ `find /opt/iobroker -type f | wc -l` -lt 1 ]
@@ -176,9 +176,9 @@ echo ' '
##### #####
# Checking ioBroker-Installation # Checking ioBroker-Installation
##### #####
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo "----- Step 3 of 5: Checking ioBroker installation -----" echo "----- Step 3 of 5: Checking ioBroker installation -----"
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo ' ' echo ' '
# (Re)Setting permissions to "/opt/iobroker" and "/opt/scripts" # (Re)Setting permissions to "/opt/iobroker" and "/opt/scripts"
@@ -218,9 +218,9 @@ fi
##### #####
# Setting up prerequisites for some ioBroker-adapters # Setting up prerequisites for some ioBroker-adapters
##### #####
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo "----- Step 4 of 5: Applying special settings -----" echo "----- Step 4 of 5: Applying special settings -----"
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo ' ' echo ' '
echo "Some adapters have special requirements/ settings which can be activated by the use of environment variables." echo "Some adapters have special requirements/ settings which can be activated by the use of environment variables."
@@ -487,9 +487,9 @@ fi
##### #####
# Starting ioBroker # Starting ioBroker
##### #####
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo "----- Step 5 of 5: ioBroker startup -----" echo "----- Step 5 of 5: ioBroker startup -----"
echo "$(printf -- '-%.0s' {1..60})" echo "$(printf -- '-%.0s' {1..80})"
echo ' ' echo ' '
echo "Starting ioBroker..." echo "Starting ioBroker..."
echo ' ' echo ' '

View File

@@ -4,9 +4,7 @@
##### default settings ##### ##### default settings #####
############################ ############################
autoconfirm=no # yould be set to true by commandline option autoconfirm=no # could be set to true by commandline option
switch=none
#################################### ####################################
##### declaration of functions ##### ##### declaration of functions #####
@@ -86,6 +84,8 @@ switch_on() {
# turn maintenance mode OFF # turn maintenance mode OFF
switch_off() { switch_off() {
if [ $(cat /opt/scripts/.docker_config/.healthcheck) == 'maintenance' ] && [ "$autoconfirm" == "no" ] # maintenance mode ON / autoconfirm = no
then
echo 'You are now going to deactivate maintenance mode for this container.' echo 'You are now going to deactivate maintenance mode for this container.'
echo 'Depending on the restart policy, your container will be stopped/ restarted immediately.' echo 'Depending on the restart policy, your container will be stopped/ restarted immediately.'
read -p 'Do you want to continue [yes/no]? ' A read -p 'Do you want to continue [yes/no]? ' A
@@ -94,10 +94,24 @@ switch_off() {
echo 'Deactivating maintenance mode and forcing container to stop/ restart...' echo 'Deactivating maintenance mode and forcing container to stop/ restart...'
echo "stopping" > /opt/scripts/.docker_config/.healthcheck echo "stopping" > /opt/scripts/.docker_config/.healthcheck
pkill -u root pkill -u root
echo 'Done.'
exit 0 exit 0
else else
exit 0 exit 0
fi fi
elif [ $(cat /opt/scripts/.docker_config/.healthcheck) == 'maintenance' ] && [ "$autoconfirm" == "yes" ] # maintenance mode ON / autoconfirm = yes
then
echo 'You are now going to deactivate maintenance mode for this container.'
echo 'Depending on the restart policy, your container will be stopped/ restarted immediately.'
echo 'This command was already confirmed by -y or --yes option.'
echo 'Deactivating maintenance mode and forcing container to stop/ restart...'
echo "stopping" > /opt/scripts/.docker_config/.healthcheck
pkill -u root
echo 'Done.'
exit 0
else
echo 'Maintenance mode is already turned OFF.'
fi
} }
# upgrade js-controller # upgrade js-controller
@@ -147,22 +161,27 @@ for i in $reverse; do
case $i in case $i in
help|-h|--help) help|-h|--help)
display_help # calling function to display help text display_help # calling function to display help text
exit break
;; ;;
status) status)
check_status # calling function to check maintenance mode status check_status # calling function to check maintenance mode status
break
;; ;;
on) on)
switch_on # calling function to switch maintenance mode on switch_on # calling function to switch maintenance mode on
break
;; ;;
off) off)
switch_off # calling function to switch maintenance mode off switch_off # calling function to switch maintenance mode off
break
;; ;;
upgrade) upgrade)
upgrade # calling function to upgrade js-controller upgrade # calling function to upgrade js-controller
break
;; ;;
-y|--yes) -y|--yes)
autoconfirm=yes # setting autoconfrm option to "yes" autoconfirm=yes # setting autoconfrm option to "yes"
shift
;; ;;
-a=*|--argument=*) # dummy exaple for parsing option with value -a=*|--argument=*) # dummy exaple for parsing option with value
ARGUMENT="${i#*=}" ARGUMENT="${i#*=}"