6 for i in `pgrep -f "/bin/bash /opt/mqtt-mpd/mqmpdj"`
15 . /opt/mqtt-mpd/mqmpd.cfg
17 # запускаем процессы, мониторящие состояние
20 while [ "x${hosts[i]}" != "x" ]
23 /opt/mqtt-mpd/mqmpdj ${hosts[i]} ${passwd[i]} &
29 # сами остаемся слушать команды
31 mosquitto_sub -v -h $mqhost -p $mqport -t "$mqcmd/#" -u $mquser -P $mqpassword | while read line
34 template="s!$mqcmd/!!"
35 addr=`echo $line | cut -f 1 -d " " | sed $template`
36 arg=`echo $line | cut -f 2 -d " "`
39 host=`echo $addr | cut -f 1 -d "/"`
40 cmd=`echo $addr | cut -f 2 -d "/"`
43 while [ "x${hosts[i]}" != "x" ]
45 if [ "${hosts[i]}" = "$host" ]
48 if [ "$mpdpass" = "-" ]
52 mpccmd="mpc -h $host -P $mpdpass"
59 arg=`printf "%q" $arg`
60 if [[ "$arg" =~ [A-Za-z0-9]+ ]]
68 if [ "$arg" = "INCREASE" ]
72 if [ "$arg" = "DECREASE" ]
76 if [[ "$arg" =~ [0-9]+ ]]
78 reply=( `$mpccmd volume`)
79 currvolume=`echo ${reply[1]} | sed 's/%//'`
82 if [ "$arg" -gt "$currvolume" ]
84 delta=$(( $arg - $currvolume ))
85 $mpccmd volume +$delta
87 if [ "$arg" -lt "$currvolume" ]
89 delta=$(( $currvolume - $arg ))
90 $mpccmd volume -$delta
92 if [ "$arg" -eq "$currvolume" ]
119 repeat|random|single|consume)
123 echo "Неизвестная команда $cmd"
130 echo "Недопустимый аргумент $arg"