Skip to content

Commit

Permalink
Merge pull request #1067 from rern/UPDATE
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
rern authored Oct 14, 2022
2 parents d3fc7bc + 9562183 commit feab76d
Show file tree
Hide file tree
Showing 30 changed files with 145 additions and 137 deletions.
2 changes: 1 addition & 1 deletion srv/http/bash/addons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ installfinish() {
path=$( cat $dirmpd/updating )
[[ $path == rescan ]] && mpc -q rescan || mpc -q update "$path"
elif [[ -e $dirmpd/listing || ! -e $dirmpd/counts ]]; then
cmd-list.sh &> /dev/null &
$dirbash/cmd-list.sh &> /dev/null &
fi
}
uninstallstart() {
Expand Down
8 changes: 4 additions & 4 deletions srv/http/bash/audiocd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ input {\
}\
' /etc/mpd.conf
systemctl restart mpd
player-data.sh pushrefresh
$dirsettings/player-data.sh pushrefresh
exit

elif [[ $1 == eject || $1 == off || $1 == ejectwithicon ]]; then # eject/off : remove tracks from playlist
Expand All @@ -38,7 +38,7 @@ elif [[ $1 == eject || $1 == off || $1 == ejectwithicon ]]; then # eject/off : r
linecdio=$( sed -n '/cdio_paranoia/ =' /etc/mpd.conf )
sed -i "$(( linecdio - 1 )),/^$/ d" /etc/mpd.conf
systemctl restart mpd
player-data.sh pushrefresh
$dirsettings/player-data.sh pushrefresh
elif [[ $1 == ejectwithicon ]]; then
eject
fi
Expand Down Expand Up @@ -108,7 +108,7 @@ eject -x 4

if [[ $autoplaycd ]]; then
cdtrack1=$(( $( mpc playlist | wc -l ) - $trackL + 1 ))
cmd.sh "mpcplayback
$dirbash/cmd.sh "mpcplayback
play
$cdtrack1"
fi
Expand All @@ -126,4 +126,4 @@ $artist
$album
audiocd
$discid"
status-coverartonline.sh "$args" &> /dev/null &
$dirbash/status-coverartonline.sh "$args" &> /dev/null &
14 changes: 7 additions & 7 deletions srv/http/bash/bluetoothcommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ disconnectRemove() {
touch $dirshm/$type-$mac
if [[ $type == Source ]]; then
icon=btsender
cmd.sh playerstop
$dirbash/cmd.sh playerstop
elif [[ $type == Sink ]]; then
rm $dirshm/btreceiver
pushstream btreceiver false
cmd.sh mpcplayback$'\n'stop
player-conf.sh
$dirbash/cmd.sh mpcplayback$'\n'stop
$dirsettings/player-conf.sh
fi
pushstreamNotify "$name" $msg $icon
pushstreamList
}
pushstreamList() {
features-data.sh pushrefresh
networks-data.sh pushbt
$dirsettings/features-data.sh pushrefresh
$dirsettings/networks-data.sh pushbt
exit
}
#-------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -144,8 +144,8 @@ if [[ $action == connect || $action == pair ]]; then
echo $btmixer > $dirshm/btreceiver
echo $mac Sink $name >> $dirshm/btconnected
pushstream btreceiver true
cmd.sh playerstop
player-conf.sh
$dirbash/cmd.sh playerstop
$dirsettings/player-conf.sh
fi
pushstreamList
elif [[ $action == disconnect || $action == remove ]]; then # from rAudio only
Expand Down
4 changes: 2 additions & 2 deletions srv/http/bash/cmd-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ for mode in album albumartist artist composer conductor genre date; do
else
printf -v $mode '%s' $( mpc list $mode | awk NF | awk '{$1=$1};1' | tee $filemode | wc -l )
fi
(( $mode > 0 )) && php /srv/http/bash/cmd-listsort.php $filemode
(( $mode > 0 )) && php $dirbash/cmd-listsort.php $filemode
done

##### latest album #############################################
Expand Down Expand Up @@ -146,7 +146,7 @@ if [[ $toolarge ]]; then
pushstreamNotifyBlink 'Library Database' 'Library is too large.<br>Album list cannot be created.' 'refresh-library'
fi

[[ -e $filesharedip ]] && system.sh shareddataiplist$'\n'reload
[[ -e $filesharedip ]] && $dirsettings/system.sh shareddataiplist$'\n'reload

(
nonutf8=$( mpc -f '/mnt/MPD/%file% [• %albumartist% ]• %artist% • %album% • %title%' listall | grep -axv '.*' )
Expand Down
50 changes: 28 additions & 22 deletions srv/http/bash/cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ plAddPlay() {
if [[ ${1: -4} == play ]]; then
sleep $2
mpc -q play $pos
status-push.sh
$dirbash/status-push.sh
fi
}
plAddPosition() {
Expand Down Expand Up @@ -209,7 +209,7 @@ scrobbleOnStop() {
. $dirshm/scrobble
elapsed=$1
if (( $Time > 30 && ( $elapsed > 240 || $elapsed > $Time / 2 ) )) && [[ $Artist && $Title ]]; then
scrobble.sh "\
$dirbash/scrobble.sh "\
$Artist
$Title
$Album" &> /dev/null &
Expand All @@ -218,9 +218,9 @@ $Album" &> /dev/null &
}
snapclientStop() {
systemctl stop snapclient
player-conf.sh
$dirsettings/player-conf.sh
ip=$( ipGet )
sshCommand $( cat $dirshm/serverip ) snapcast.sh remove $ip
sshCommand $( cat $dirshm/serverip ) $dirbash/snapcast.sh remove $ip
rm $dirshm/serverip
}
stopRadio() {
Expand Down Expand Up @@ -545,7 +545,7 @@ coverartreset )
filename=$( basename "$coverfile" )
id=${filename/.*}
rm -f "$coverfile"
status-coverartonline.sh "\
$dirbash/status-coverartonline.sh "\
$artist
$album
audiocd
Expand All @@ -571,7 +571,7 @@ $id" &> /dev/null &
gifsicle -O3 --resize-fit 80x80 "$restorefile" > "$dir/thumb.gif"
fi
fi
url=$( status-coverart.sh "\
url=$( $dirbash/status-coverart.sh "\
$artist
$album
$mpdpath" )
Expand All @@ -597,7 +597,7 @@ coverfileslimit )
;;
dabscan )
touch $dirshm/updatingdab
dab-scan.sh &> /dev/null &
$dirbash/dab-scan.sh &> /dev/null &
pushstream mpdupdate '{"type":"dabradio"}'
;;
displaysave )
Expand All @@ -609,15 +609,15 @@ displaysave )
[[ $prevvumeter == $vumeter ]] && exit

if [[ $vumeter ]]; then
mpc | grep -q '\[playing' && cava -p /etc/cava.conf | vu.sh &> /dev/null &
mpc | grep -q '\[playing' && cava -p /etc/cava.conf | $dirbash/vu.sh &> /dev/null &
touch $dirsystem/vumeter
else
killall cava &> /dev/null
rm -f $dirsystem/vumeter
pushstreamNotifyBlink 'Playback' 'VU meter disable...' 'playback'
fi
player-conf.sh
status=$( status.sh )
$dirsettings/player-conf.sh
status=$( $dirbash/status.sh )
pushstream mpdplayer "$status"
;;
equalizer )
Expand Down Expand Up @@ -776,7 +776,7 @@ mpccrop )
mpc -q stop
fi
[[ -e $dirsystem/librandom ]] && plAddRandom
status-push.sh
$dirbash/status-push.sh
pushstreamPlaylist
;;
mpcfindadd )
Expand Down Expand Up @@ -836,7 +836,7 @@ mpcplayback )
if [[ ! $command ]]; then
player=$( cat $dirshm/player )
if [[ $( cat $dirshm/player ) != mpd ]]; then
cmd.sh playerstop
$dirbash/cmd.sh playerstop
exit
fi

Expand Down Expand Up @@ -868,7 +868,7 @@ mpcprevnext )
state=${args[4]}
elapsed=${args[5]}
else
status=( $( status.sh | jq -r .song,.pllength,.state,.elapsed ) )
status=( $( $dirbash/status.sh | jq -r .song,.pllength,.state,.elapsed ) )
current=${status[0]}
length=${status[1]}
state=${status[2]}
Expand Down Expand Up @@ -912,7 +912,7 @@ mpcremove )
else
mpc -q clear
fi
status-push.sh
$dirbash/status-push.sh
pushstreamPlaylist
;;
mpcseek )
Expand All @@ -931,7 +931,7 @@ mpcseek )
mpcsetcurrent )
mpc -q play ${args[1]}
mpc -q stop
status-push.sh
$dirbash/status-push.sh
;;
mpcshuffle )
mpc -q shuffle
Expand Down Expand Up @@ -991,7 +991,7 @@ playerstop )
[[ -e $dirsystem/scrobble && -e $dirsystem/scrobble.conf/$player ]] && cp -f $dirshm/{status,scrobble}
killall cava &> /dev/null
echo mpd > $dirshm/player
[[ $player != upnp ]] && status-push.sh
[[ $player != upnp ]] && $dirbash/status-push.sh
case $player in
airplay )
systemctl stop shairport-meta
Expand All @@ -1014,7 +1014,7 @@ playerstop )
for i in $tracks; do
mpc -q del $i
done
status-push.sh
$dirbash/status-push.sh
systemctl restart upmpdcli
;;
esac
Expand All @@ -1031,7 +1031,7 @@ power )
ips=$( grep -v $( ipGet ) $filesharedip )
if [[ $ips ]]; then
for ip in $ips; do
sshCommand $ip system.sh shareddatadisconnect
sshCommand $ip $dirsettings/system.sh shareddatadisconnect
done
fi
elif [[ -e $filesharedip ]]; then # rclient
Expand All @@ -1049,13 +1049,13 @@ power )
if [[ -e $dirshm/clientip ]]; then
clientip=$( cat $dirshm/clientip )
for ip in $clientip; do
sshCommand $ip cmd.sh playerstop
sshCommand $ip $dirbash/cmd.sh playerstop
done
fi
cdda=$( mpc -f %file%^%position% playlist | grep ^cdda: | cut -d^ -f2 )
[[ $cdda ]] && mpc -q del $cdda
if [[ -e $dirshm/relayson ]]; then
relays.sh
$dirsettings/relays.sh
sleep 2
fi
systemctl -q is-active camilladsp && camilladsp-gain.py
Expand All @@ -1078,7 +1078,7 @@ radiorestart )
;;
relaystimerreset )
killall relays-timer.sh &> /dev/null
relays-timer.sh &> /dev/null &
$dirsettings/relays-timer.sh &> /dev/null &
pushstream relays '{"state":"RESET"}'
;;
rotatesplash )
Expand Down Expand Up @@ -1155,7 +1155,7 @@ screenoff )
DISPLAY=:0 xset ${args[1]}
;;
scrobble )
scrobble.sh "\
$dirbash/scrobble.sh "\
${args[1]}
${args[2]}
${args[3]}" &> /dev/null &
Expand Down Expand Up @@ -1258,6 +1258,12 @@ $charset" > "$file"
webradioCount
webRadioSampling $url "$file" &
;;
webradiocopybackup )
if [[ -e $filesharedip ]]; then
rm -rf $dirbackup/webradio
cp -r $dirwebradio $dirbackup
fi
;;
webradiocoverreset )
coverart=${args[1]}
type=${args[2]}
Expand Down
7 changes: 4 additions & 3 deletions srv/http/bash/common.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

export PATH=$PATH:/srv/http/bash:/srv/http/bash/settings

dirbash=/srv/http/bash
dirsettings=$dirbash/settings
dirdata=/srv/http/data
dirbackup=$dirdata/backup
dirnas=/mnt/MPD/NAS
Expand Down Expand Up @@ -57,7 +57,7 @@ pushRefresh() {
[[ $1 ]] && page=$1 || page=$( basename $0 .sh )
[[ $2 ]] && push=$2 || push=push
[[ $page == networks ]] && sleep 2
$page-data.sh $push
$dirsettings/$page-data.sh $push
}
pushstream() {
channel=$1
Expand All @@ -79,6 +79,7 @@ pushstream() {
ips=$( grep -v $( ipGet ) $filesharedip )
for ip in $ips; do
curl -s -X POST http://$ip/pub?id=$channel -d "$data"
[[ $channel == radiolist ]] && sshCommand $ip $dirbash/cmd.sh webradiocopybackup & >/dev/null &
done
fi
}
Expand Down
6 changes: 3 additions & 3 deletions srv/http/bash/mpdidle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mpc idleloop | while read changed; do
echo $s > $dirshm/vol
else
rm -f $dirshm/vol
pushstream volume '{"val":'$( cmd.sh volumeget )'}'
pushstream volume '{"val":'$( $dirbash/cmd.sh volumeget )'}'
fi
done ) &> /dev/null &
fi
Expand All @@ -31,12 +31,12 @@ mpc idleloop | while read changed; do
player )
if [[ ! -e $dirshm/radio && ! -e $dirshm/prevnextseek ]]; then
killall status-push.sh &> /dev/null
status-push.sh & # need to run in background for snapcast ssh
$dirbash/status-push.sh & # need to run in background for snapcast ssh
fi
;;
update )
sleep 1
! mpc | grep -q '^Updating' && cmd-list.sh
! mpc | grep -q '^Updating' && $dirbash/cmd-list.sh
;;
esac
done
2 changes: 1 addition & 1 deletion srv/http/bash/settings/features-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ data+='
, "streaming" : '$( grep -q 'type.*"httpd"' /etc/mpd.conf && echo true )
[[ -e /usr/bin/hostapd ]] && data+='
, "hostapd" : '$( isactive hostapd )'
, "hostapdconf" : '$( features.sh hostapdget )'
, "hostapdconf" : '$( $dirsettings/features.sh hostapdget )'
, "ssid" : "'$( awk -F'=' '/^ssid/ {print $2}' /etc/hostapd/hostapd.conf | sed 's/"/\\"/g' )'"
, "wlanconnected" : '$( ip r | grep -q "^default.*wlan0" && echo true )
[[ -e /usr/bin/shairport-sync ]] && data+='
Expand Down
10 changes: 5 additions & 5 deletions srv/http/bash/settings/features-stoptimer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ sleep $(( min * 60 ))

rm -f $dirshm/stoptimer

cmd.sh volume # mute
[[ $( cat $dirshm/player ) == mpd ]] && cmd.sh mpcplayback$'\n'stop || cmd.sh playerstop
cmd.sh volume # unmute
$dirbash/cmd.sh volume # mute
[[ $( cat $dirshm/player ) == mpd ]] && $dirbash/cmd.sh mpcplayback$'\n'stop || $dirbash/cmd.sh playerstop
$dirbash/cmd.sh volume # unmute

if [[ $poweroff ]]; then
cmd.sh power$'\n'off
$dirbash/cmd.sh power$'\n'off
elif [[ -e $dirshm/relayson ]]; then
relays.sh off
$dirsettings/relays.sh off
fi
Loading

0 comments on commit feab76d

Please sign in to comment.