From 66c165e3796da61fa00f833b49208cd70993c4d4 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 24 Jan 2023 16:44:18 +0100 Subject: [PATCH] Added pipe. Started wait_for_trigger --- UpdateController.sh | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/UpdateController.sh b/UpdateController.sh index c2a37c4..ab659a4 100755 --- a/UpdateController.sh +++ b/UpdateController.sh @@ -1,11 +1,32 @@ #!/bin/bash +update_controller_pipe="/tmp/update_controller_pipe" + +init () { + trap "rm -f $update_controller_pipe" EXIT + + if [[ ! -p $update_controller_pipe ]]; then + mkfifo $update_controller_pipe + fi +} + read_config() { + # name der fifo laesst sich ueberschreiben return 0 } wait_for_trigger() { - return 0 + if [[ "$1" -eq -1 ]]; then + # wait for external impulse + if read line <$update_controller_pipe; then + if [ "$line" == "quit" ] || [ "$line" == "update" ]; then + echo "$line" + fi + fi + else + sleep ${1} + echo "sleep" + fi } check_for_apism() { @@ -78,7 +99,15 @@ UpdateController() { # By default (trigger_timeout==-1), UpdateController can only be triggered # from some external source to perform an update. - while wait_for_trigger $trigger_timeout; do + while : + do + request=$(wait_for_trigger $trigger_timeout) + if [ ${request} = "quit" ]; then + $trigger_reboot = true + elif [ ${request} != "update" ]; then + continue + fi + if $trigger_reboot; then echo "CRITICAL send message to reboot the PSA" send_reboot_message_to_system_controller