Added read config

This commit is contained in:
Gerhard Hoffmann 2023-01-25 11:10:26 +01:00
parent c4cd7c80cd
commit fabd452de9

37
SendUpdateCommand.sh Normal file → Executable file
View File

@ -1,17 +1,32 @@
#!/bin/bash
pipe=/tmp/testpipe
fifo=""
if [[ ! -p $pipe ]]; then
echo "Reader not running"
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
if [[ "$1" ]]; then
echo "$1" >$pipe
else
echo "Hello from $$" >$pipe
echo "update" >$fifo
exit 0
fi
fi