Added read config
This commit is contained in:
parent
c4cd7c80cd
commit
fabd452de9
37
SendUpdateCommand.sh
Normal file → Executable file
37
SendUpdateCommand.sh
Normal file → Executable 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
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$1" ]]; then
|
||||
echo "$1" >$pipe
|
||||
else
|
||||
echo "Hello from $$" >$pipe
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user