Compare commits
No commits in common. "cf118ee75d179967b1d3bd4ed6ae532883522c59" and "c4cd7c80cd094dd05a1619e551ef2138a086d088" have entirely different histories.
cf118ee75d
...
c4cd7c80cd
39
SendUpdateCommand.sh
Executable file → Normal file
39
SendUpdateCommand.sh
Executable file → Normal file
@ -1,32 +1,17 @@
|
||||
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
fifo=""
|
||||
pipe=/tmp/testpipe
|
||||
|
||||
read_config() {
|
||||
fifo_dir=$(cat "$1" | jq -r .fifo_dir)
|
||||
if [ -z "$fifo_dir" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
fifo=$(cat "$1" | jq -r .fifo)
|
||||
if [ -z "$fifo" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
fifo="${fifo_dir}/$fifo"
|
||||
return 0
|
||||
}
|
||||
|
||||
if [ $# -ne 1 ] ; then
|
||||
echo "Usage: $0 filename"
|
||||
if [[ ! -p $pipe ]]; then
|
||||
echo "Reader not running"
|
||||
exit 1
|
||||
else
|
||||
if read_config "$1" ; then
|
||||
if [[ ! -p $fifo ]]; then
|
||||
echo "Reader not running on $fifo"
|
||||
exit 1
|
||||
fi
|
||||
echo "update" >$fifo
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$1" ]]; then
|
||||
echo "$1" >$pipe
|
||||
else
|
||||
echo "Hello from $$" >$pipe
|
||||
fi
|
||||
|
@ -1,19 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
fifo=""
|
||||
|
||||
GIT_SSL_NO_VERIFY=true
|
||||
|
||||
init_fifo () {
|
||||
trap "rm -f $fifo" EXIT
|
||||
trap rm -f ${fifo} EXIT
|
||||
if [ $? -eq 0 ]; then
|
||||
# set trap
|
||||
if [[ ! -p "$fifo" ]]; then
|
||||
mkfifo "$fifo"
|
||||
if [[ ! -p ${fifo} ]]; then
|
||||
mkfifo ${fifo}
|
||||
if [ $? -eq 0 ]; then
|
||||
# fifo created
|
||||
echo "created fifo=$fifo"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
@ -22,30 +20,26 @@ init_fifo () {
|
||||
}
|
||||
|
||||
read_config() {
|
||||
fifo_dir=$(cat "$1" | jq -r .fifo_dir)
|
||||
if [ -z "$fifo_dir" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
fifo=$(cat "$1" | jq -r .fifo)
|
||||
if [ -z "$fifo" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
fifo="${fifo_dir}/$fifo"
|
||||
fifo_dir=$(cat ${1} | jq -r .fifo_dir)
|
||||
fifo="${fifo_dir}/$(cat ${1} | jq -r .fifo)"
|
||||
return 0
|
||||
}
|
||||
|
||||
if read_config UpdateController.conf; then
|
||||
echo "fifo=$fifo"
|
||||
#init_fifo "$fifo"
|
||||
fi
|
||||
|
||||
wait_for_trigger() {
|
||||
if [[ "$1" -eq -1 ]]; then
|
||||
# wait for external impulse
|
||||
if read line <$fifo; then
|
||||
if [ "$line" = "quit" ] || [ "$line" = "update" ]; then
|
||||
if [ "$line" == "quit" ] || [ "$line" == "update" ]; then
|
||||
echo "$line"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
sleep $1
|
||||
sleep ${1}
|
||||
echo "sleep"
|
||||
fi
|
||||
}
|
||||
@ -122,18 +116,16 @@ UpdateController() {
|
||||
# from some external source to perform an update.
|
||||
while :
|
||||
do
|
||||
trigger=$(wait_for_trigger $trigger_timeout)
|
||||
echo "trigger=$trigger"
|
||||
if [ "$trigger" = "quit" ]; then
|
||||
request=$(wait_for_trigger $trigger_timeout)
|
||||
if [ ${request} = "quit" ]; then
|
||||
$trigger_reboot = true
|
||||
elif [ "$trigger" != "update" ]; then
|
||||
elif [ ${request} != "update" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if $trigger_reboot; then
|
||||
echo "CRITICAL send message to reboot the PSA"
|
||||
send_reboot_message_to_system_controller
|
||||
continue
|
||||
fi
|
||||
|
||||
# Is APISM running, listening on the correct ports etc. ?
|
||||
@ -144,11 +136,9 @@ UpdateController() {
|
||||
check_apism_count=$((check_apism_count+1))
|
||||
if [[ "$check_apism_count" -eq 5 ]]; then
|
||||
trigger_reboot=true
|
||||
check_apism_count=0
|
||||
echo "ERROR APISM not working"
|
||||
continue 2
|
||||
fi
|
||||
echo "[$check_apism_count]: $(date +'%Y-%m-%d %T') check APISM"
|
||||
sleep 60s
|
||||
else
|
||||
# APISM up and working
|
||||
@ -157,9 +147,6 @@ UpdateController() {
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$(date +'%Y-%m-%d %T') checking for updates..."
|
||||
exit 1
|
||||
|
||||
# Are there new updates available ?
|
||||
if ! check_for_updates; then
|
||||
echo "DEBUG no updates available"
|
||||
@ -269,15 +256,7 @@ UpdateController() {
|
||||
|
||||
###############################################################################
|
||||
|
||||
if [ $# -ne 1 ] ; then
|
||||
echo "Usage: $0 filename"
|
||||
exit 1
|
||||
else
|
||||
if read_config "$1" ; then
|
||||
init_fifo
|
||||
UpdateController
|
||||
fi
|
||||
fi
|
||||
|
||||
# start the UpdateController
|
||||
# UpdateController
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user