Added pipe. Started wait_for_trigger

This commit is contained in:
Gerhard Hoffmann 2023-01-24 16:44:18 +01:00
parent c3275ad756
commit 66c165e379

View File

@ -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