UpdateController/SendUpdateCommand.sh

33 lines
545 B
Bash
Raw Normal View History

#!/bin/bash
2023-01-25 11:10:26 +01:00
fifo=""
2023-01-25 11:10:26 +01:00
read_config() {
fifo_dir=$(cat "$1" | jq -r .fifo_dir)
if [ -z "$fifo_dir" ]; then
return 1
fi
2023-01-25 11:10:26 +01:00
fifo=$(cat "$1" | jq -r .fifo)
if [ -z "$fifo" ]; then
return 1
fi
fifo="${fifo_dir}/$fifo"
return 0
}
2023-01-25 11:10:26 +01:00
if [ $# -ne 1 ] ; then
echo "Usage: $0 filename"
exit 1
else
2023-01-25 11:10:26 +01:00
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