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]+ ]]
66 reply=( `$mpccmd volume`)
67 currvolume=`echo ${reply[1]} | sed 's/%//'`
70 if [ "$arg" -gt "$currvolume" ]
72 delta=$(( $arg - $currvolume ))
73 $mpccmd volume +$delta
75 if [ "$arg" -lt "$currvolume" ]
77 delta=$(( $currvolume - $arg ))
78 $mpccmd volume -$delta
97 repeat|random|single|consume)
101 echo "Неизвестная команда $cmd"
108 echo "Недопустимый аргумент $arg"