8 for i in `pgrep -f "/bin/bash /opt/mqtt-mpd/mqmpdj"`
17 . /opt/mqtt-mpd/mqmpd.cfg
19 # запускаем процессы, мониторящие состояние
22 while [ "x${hosts[i]}" != "x" ]
25 /opt/mqtt-mpd/mqmpdj ${hosts[i]} ${passwd[i]} &
31 # сами остаемся слушать команды
33 mosquitto_sub -i mqtt-mpd-$id -v -h $mqhost -p $mqport -t "$mqcmd/#" -u $mquser -P $mqpassword | while read line
36 template="s!$mqcmd/!!"
37 addr=`echo $line | cut -f 1 -d " " | sed $template`
38 arg=`echo $line | cut -f 2 -d " "`
41 host=`echo $addr | cut -f 1 -d "/"`
42 cmd=`echo $addr | cut -f 2 -d "/"`
45 while [ "x${hosts[i]}" != "x" ]
47 if [ "${hosts[i]}" = "$host" ]
50 if [ "$mpdpass" = "-" ]
54 mpccmd="mpc -h $host -P $mpdpass"
61 arg=`printf "%q" $arg`
62 if [[ "$arg" =~ [A-Za-z0-9]+ ]]
70 if [ "$arg" = "INCREASE" ]
74 if [ "$arg" = "DECREASE" ]
78 if [[ "$arg" =~ [0-9]+ ]]
80 reply=( `$mpccmd volume`)
81 currvolume=`echo ${reply[1]} | sed 's/%//'`
84 if [ "$arg" -gt "$currvolume" ]
86 delta=$(( $arg - $currvolume ))
87 $mpccmd volume +$delta
89 if [ "$arg" -lt "$currvolume" ]
91 delta=$(( $currvolume - $arg ))
92 $mpccmd volume -$delta
94 if [ "$arg" -eq "$currvolume" ]
120 repeat|random|single|consume)
124 echo "Неизвестная команда $cmd"
131 echo "Недопустимый аргумент $arg"