UpdateController/SendUpdateCommand.sh

34 lines
592 B
Bash
Executable File

#!/bin/bash
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"
return 0
}
if [ $# -ne 1 ] ; then
echo "Usage: $0 filename"
exit 1
else
if read_config "$1" ; then
if [[ ! -p $fifo ]]; then
echo "Reader not running on $fifo"
exit 1
fi
echo "Reader running on $fifo: update"
echo "update" >$fifo
exit 0
fi
fi