From 7f3db064fb5bdb099648791e6794d3f39d34cfcd Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Sep 2022 09:37:47 +0700 Subject: [PATCH 001/237] u --- srv/http/assets/js/networks.js | 21 +++++++++------------ srv/http/assets/js/settings.js | 11 +---------- srv/http/assets/js/system.js | 13 ++++++------- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/srv/http/assets/js/networks.js b/srv/http/assets/js/networks.js index 5c6ee7710..f00375459 100644 --- a/srv/http/assets/js/networks.js +++ b/srv/http/assets/js/networks.js @@ -1,9 +1,7 @@ $( function() { // document ready start >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> var accesspoint = $( '#accesspoint' ).length; -$( '.container' ).click( function( e ) { - if ( $( e.target ).parents( '#listbt, #listlan, #listwl' ).length ) return - +$( 'body' ).click( function() { $( '#menu' ).addClass( 'hide' ); $( 'li' ).removeClass( 'active' ); } ); @@ -58,17 +56,16 @@ $( '#lanadd' ).click( function() { } } ); } ); -$( '#listbt, #listlan, #listwl' ).on( 'click', 'li', function() { +$( '.entries' ).on( 'click', 'li', function( e ) { + e.stopPropagation(); G.li = $( this ); G.liindex = G.li.index(); G.list = G.li.parent().prop( 'id' ); - var active = $( this ).hasClass( 'active' ); $( 'li' ).removeClass( 'active' ); G.li.addClass( 'active' ); - var $menu = $( '#menu' ); - if ( !$menu.hasClass( 'hide' ) ) { - $menu.addClass( 'hide' ); - if ( active ) return + if ( !$( '#menu' ).hasClass( 'hide' ) ) { + $( '#menu' ).addClass( 'hide' ); + return } if ( G.list === 'listbt' ) { @@ -87,11 +84,11 @@ $( '#listbt, #listlan, #listwl' ).on( 'click', 'li', function() { $( '#menu .disconnect' ).toggleClass( 'hide', notconnected ); $( '#menu .info' ).addClass( 'hide' ); } - var menuH = $menu.height(); - $menu + var menuH = $( '#menu' ).height(); + $( '#menu' ) .removeClass( 'hide' ) .css( 'top', G.li.position().top + 48 ); - var targetB = $menu.offset().top + menuH; + var targetB = $( '#menu' ).offset().top + menuH; var wH = window.innerHeight; if ( targetB > wH - 40 + $( window ).scrollTop() ) $( 'html, body' ).animate( { scrollTop: targetB - wH + 42 } ); } ); diff --git a/srv/http/assets/js/settings.js b/srv/http/assets/js/settings.js index 82b17bf93..97f6e0bdc 100644 --- a/srv/http/assets/js/settings.js +++ b/srv/http/assets/js/settings.js @@ -402,16 +402,7 @@ $( document ).keyup( function( e ) { break; } } ); -$( '.container' ).click( function( e ) { - $target = $( e.target ); - if ( $target.hasClass( 'status' ) || $target.parent().hasClass( 'status' ) - || $target.is( 'li' ) || $target.parent().is( 'li' ) - || $target.hasClass( 'setting' ) - || $target.hasClass( 'switch' ) - ) return - - $( 'pre.status' ).addClass( 'hide' ); -} ).on( 'click', '.status', function( e ) { +$( '.container' ).on( 'click', '.status', function( e ) { if ( $( e.target ).is( 'i' ) ) return var $this = $( this ); diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 2e57aacf4..697d6fe2e 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -94,20 +94,19 @@ $( '#list' ).on( 'click', 'li', function() { $( '#codehddinfo' ).addClass( 'hide' ); var mountpoint = $this.find( '.mountpoint' ).text(); $( 'li' ).removeClass( 'active' ); - var $menu = $( '#menu' ); - if ( !$menu.hasClass( 'hide' ) || mountpoint === '/' ) { + if ( !$( '#menu' ).hasClass( 'hide' ) || mountpoint === '/' ) { $( '#menu, #codehddinfo' ).addClass( 'hide' ); return } $this.addClass( 'active' ); - $menu.find( '.info, .spindown' ).toggleClass( 'hide', mountpoint.slice( 9, 12 ) !== 'USB' ); - $menu.find( '.remount' ).toggleClass( 'hide', G.list[ $this.index() ].mounted ); - var menuH = $menu.height(); - $menu + $( '#menu' ).find( '.info, .spindown' ).toggleClass( 'hide', mountpoint.slice( 9, 12 ) !== 'USB' ); + $( '#menu' ).find( '.remount' ).toggleClass( 'hide', G.list[ $this.index() ].mounted ); + var menuH = $( '#menu' ).height(); + $( '#menu' ) .removeClass( 'hide' ) .css( 'top', $this.position().top + 48 ); - var targetB = $menu.offset().top + menuH; + var targetB = $( '#menu' ).offset().top + menuH; var wH = window.innerHeight; if ( targetB > wH - 40 + $( window ).scrollTop() ) $( 'html, body' ).animate( { scrollTop: targetB - wH + 42 } ); } ); From c585d2187716b390d27ae8521caf95e452da441b Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Sep 2022 18:30:37 +0700 Subject: [PATCH 002/237] u --- install.sh | 14 +++++++++ srv/http/assets/js/function.js | 10 ++++++- srv/http/bash/status-dab.sh | 36 +++++++++++++++++++++++ srv/http/bash/status-push.sh | 9 ++++++ srv/http/bash/status-radio.sh | 53 ++++++---------------------------- 5 files changed, 77 insertions(+), 45 deletions(-) create mode 100644 srv/http/bash/status-dab.sh diff --git a/install.sh b/install.sh index 08976472a..ea90ec22d 100644 --- a/install.sh +++ b/install.sh @@ -2,6 +2,20 @@ alias=r1 +# 20220923 +file= +if [[ ! -e $file ]]; then + echo "\ + [Unit] +Description=DAB Radio metadata + +[Service] +Type=simple +ExecStart=/srv/http/bash/status-dab.sh +" > /etc/systemd/system/dab.service + systemctl daemon-reload +fi + # 20220916 dirmpd=/srv/http/data/mpd if (( $( cat $dirmpd/counts | wc -l ) == 1 )); then diff --git a/srv/http/assets/js/function.js b/srv/http/assets/js/function.js index 1a25a5437..f74efc069 100644 --- a/srv/http/assets/js/function.js +++ b/srv/http/assets/js/function.js @@ -1455,7 +1455,15 @@ function setInfo() { $( '#album' ).toggleClass( 'disabled', G.status.Album === '' ); setInfoScroll(); var sampling = G.status.sampling; - if ( G.status.stream ) sampling += ' • '+ ( G.status.Album && G.status.station ? G.status.station : G.status.ext ); + if ( G.status.stream ) { + if ( G.status.icon === 'dabradio' ) { + sampling += ' • DAB'; + } else if ( G.status.Album && G.status.station ) { + sampling += ' • '+ G.status.station; + } else { + sampling += ' • '+ G.status.ext; + } + } $( '#sampling' ).html( sampling ); if ( G.status.icon !== $( '#playericon' ).prop( 'class' ).replace( 'fa fa-', '' ) ) { $( '#playericon' ).removeAttr( 'class' ); diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh new file mode 100644 index 000000000..e710227fe --- /dev/null +++ b/srv/http/bash/status-dab.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +. /srv/http/bash/common.sh + +readarray -t tmpradio < $dirshm/radio +file=${tmpradio[0]} +station=${tmpradio[1]//\"/\\\"} +pos=$( mpc | grep '\[playing' | cut -d' ' -f2 | tr -d '#' ) +song=$(( ${pos/\/*} - 1 )) +filelabel=$dirshm/webradio/DABlabel.txt +touch $filelabel + +while read line; do + title=$( cat $filelabel | tr -d ' \"`?/#&'"'" ) + coverart=/data/shm/webradio/$title.jpg + mv $dirshm/webradio/DABslide{,$title}.jpg + elapsed=$( printf '%.0f' $( { echo status; sleep 0.05; } \ + | telnet 127.0.0.1 6600 2> /dev/null \ + | grep ^elapsed \ + | cut -d' ' -f2 ) ) + data='{ + "Album" : "DAB Radio" +, "Artist" : "'$station'" +, "coverart" : "'$coverart'" +, "elapsed" : '$elapsed' +, "file" : "'$file'" +, "icon" : "dabradio" +, "sampling" : "$pos • 48 kHz 160 kbit/s" +, "state" : "play" +, "song" : '$song' +, "station" : "" +, "Time" : false +, "Title" : "'$title'" +}' + $dirbash/status-push.sh statusradio "$data" & +done < <( inotifywait -mq -e close_write $filelabel ) diff --git a/srv/http/bash/status-push.sh b/srv/http/bash/status-push.sh index 6a2c53d5f..4f00e545b 100644 --- a/srv/http/bash/status-push.sh +++ b/srv/http/bash/status-push.sh @@ -4,6 +4,15 @@ if [[ $1 == statusradio ]]; then # from status-radio.sh state=play + data=$2 + pushstream mpdradio "$data" + cat << EOF > $dirshm/status +$( echo "$data" | sed -e '/^{\|^}/ d' -e 's/^.."//; s/" *: /=/' ) +timestamp=$( date +%s%3N ) +webradio=true +player=mpd +EOF + $dirbash/cmd.sh coverfileslimit else status=$( $dirbash/status.sh ) statusnew=$( echo "$status" \ diff --git a/srv/http/bash/status-radio.sh b/srv/http/bash/status-radio.sh index f7ea7d7e0..ae361b966 100644 --- a/srv/http/bash/status-radio.sh +++ b/srv/http/bash/status-radio.sh @@ -4,8 +4,7 @@ readarray -t tmpradio < $dirshm/radio file=${tmpradio[0]} -station=${tmpradio[1]} -station=${station//\"/\\\"} +station=${tmpradio[1]//\"/\\\"} id=${tmpradio[2]} pos=$( mpc | grep '\[playing' | cut -d' ' -f2 | tr -d '#' ) sampling="$pos • ${tmpradio[3]}" @@ -35,7 +34,6 @@ case $id in lajazz ) id=405;; ocoramonde ) id=404;; opera ) id=409;; - dabradio ) id=500;; esac radiofranceData() { @@ -65,19 +63,9 @@ metadataGet() { if [[ $id < 4 ]]; then icon=radioparadise radioparadiseData - elif [[ $id < 500 ]]; then + else icon=radiofrance radiofranceData - else - icon=dabradio - dablabel=$( cat $dirshm/webradio/DABlabel.txt ) - if [[ $( grep ^Title $dirshm/status | cut -d= -f2- ) == "$dablabel" ]]; then - sleep 15 - metadataGet - return - fi - - metadata=( "$station" "$dablabel" 'DAB Radio' '' 10 ) fi artist=${metadata[0]//\"/\\\"} title=${metadata[1]//\"/\\\"} @@ -96,23 +84,16 @@ metadataGet() { countdown=$(( countdown - ${metadata[5]} )) # radiofrance fi if [[ ! -e $dirsystem/vumeter ]]; then - if [[ $icon == dabradio ]]; then - date=$( date +%s ) - coverart=/data/shm/webradio/DABslide.$date.jpg - rm -f $dirshm/webradio/DABslide.*.jpg - mv $dirshm/webradio/DABslide{,.$date}.jpg + name=$( echo $artist$title | tr -d ' \"`?/#&'"'" ) + if [[ $coverurl ]]; then + coverart=/data/shm/webradio/$name.jpg + curl -s $coverurl -o $dirshm/webradio/$name.jpg else - name=$( echo $artist$title | tr -d ' \"`?/#&'"'" ) - if [[ $coverurl ]]; then - coverart=/data/shm/webradio/$name.jpg - curl -s $coverurl -o $dirshm/webradio/$name.jpg - else - coverart=$( ls $dirshm/webradio/$name* 2> /dev/null | sed 's|/srv/http||' ) - [[ ! $coverart ]] && $dirbash/status-coverartonline.sh "\ + coverart=$( ls $dirshm/webradio/$name* 2> /dev/null | sed 's|/srv/http||' ) + [[ ! $coverart ]] && $dirbash/status-coverartonline.sh "\ $artist title webradio" &> /dev/null & - fi fi fi elapsed=$( printf '%.0f' $( { echo status; sleep 0.05; } \ @@ -133,23 +114,7 @@ webradio" &> /dev/null & , "Time" : false , "Title" : "'$title'" }' - curl -s -X POST http://127.0.0.1/pub?id=mpdradio -d "$data" - cat << EOF > $dirshm/status -Artist="$artist" -Title="$title" -Album="$album" -coverart="$coverart" -station="$station" -file="$file" -state="play" -Time=false -elapsed=$elapsed -timestamp=$( date +%s%3N ) -webradio=true -player="mpd" -EOF - $dirbash/status-push.sh statusradio & # for snapcast ssh - for: mpdoled, lcdchar, vumeter, snapclient(need to run in background) - [[ $icon != dabradio ]] && $dirbash/cmd.sh coverfileslimit + $dirbash/status-push.sh statusradio "$data" & # for snapcast ssh - for: mpdoled, lcdchar, vumeter, snapclient(need to run in background) # next fetch sleep $(( countdown + 5 )) # add 5s delay metadataGet From 66820f0c86cc9cfbad6ef660c3eb5224f937b692 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Sep 2022 18:36:05 +0700 Subject: [PATCH 003/237] Update status.sh --- srv/http/bash/status.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index e8d88c92f..6e32f181d 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -312,11 +312,13 @@ elif [[ $stream ]]; then id=dabradio radiosampling='48 kHz 160 kbit/s' stationname=$station + service=dab else id=$( basename ${file/-*} ) [[ ${id:0:13} == francemusique ]] && id=${id:13} [[ ! $id ]] && id=francemusique stationname=${station/* - } + service=radio fi if [[ ! -e $dirshm/radio ]]; then echo "\ @@ -324,7 +326,7 @@ $file $stationname $id $radiosampling" > $dirshm/radio - systemctl -q is-active radio || systemctl start radio + systemctl -q is-active $service || systemctl start $service else . <( grep -E '^Artist|^Album|^Title|^coverart|^station' $dirshm/status ) [[ ! $displaycover ]] && coverart= From 510377947b2f28b6ddf76dd890fa50a289089a76 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Sep 2022 18:38:34 +0700 Subject: [PATCH 004/237] Update cmd.sh --- srv/http/bash/cmd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index b2561916e..45ebdb49c 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -229,7 +229,7 @@ snapclientStop() { } stopRadio() { if [[ -e $dirshm/radio ]]; then - systemctl stop radio + systemctl stop radio dab rm -f $dirshm/{radio,status} fi } From 873eadcbda04b8204a20aa87691fb9028520f09e Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Sep 2022 18:56:59 +0700 Subject: [PATCH 005/237] Update status-dab.sh --- srv/http/bash/status-dab.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index e710227fe..9b1b9df83 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -13,7 +13,7 @@ touch $filelabel while read line; do title=$( cat $filelabel | tr -d ' \"`?/#&'"'" ) coverart=/data/shm/webradio/$title.jpg - mv $dirshm/webradio/DABslide{,$title}.jpg + mv $dirshm/webradio/DABslide{,$title}.jpg &> /dev/null elapsed=$( printf '%.0f' $( { echo status; sleep 0.05; } \ | telnet 127.0.0.1 6600 2> /dev/null \ | grep ^elapsed \ From a171ef69ab3a7bd3c61cb608dac8318f4b36f57e Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Sep 2022 19:03:51 +0700 Subject: [PATCH 006/237] Update install.sh --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index ea90ec22d..44c0768f2 100644 --- a/install.sh +++ b/install.sh @@ -3,10 +3,10 @@ alias=r1 # 20220923 -file= -if [[ ! -e $file ]]; then +if [[ ! -e /usr/bin/inotifywait ]]; then + pacman -Sy --noconfirm inotify-tools echo "\ - [Unit] +[Unit] Description=DAB Radio metadata [Service] From 242c8664e8097574a51b1ea129a0fa4a7e5def10 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Sep 2022 19:58:51 +0700 Subject: [PATCH 007/237] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 44c0768f2..2a0d938f5 100644 --- a/install.sh +++ b/install.sh @@ -79,7 +79,7 @@ installfinish udevadm control --reload-rules udevadm trigger -if grep -q /srv/http/shareddata /etc/fstab; then +if [[ -e /srv/http/shareddata/webradios ]]; then echo -e "\ $info Shared data: • Disable From 1d1666e5bac46da892316475e3c80df558b43e6f Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 18 Sep 2022 21:59:10 +0700 Subject: [PATCH 008/237] u --- srv/http/assets/js/networks.js | 1 - srv/http/assets/js/system.js | 29 +++++++++++++---------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/srv/http/assets/js/networks.js b/srv/http/assets/js/networks.js index f00375459..e3f0f3ba4 100644 --- a/srv/http/assets/js/networks.js +++ b/srv/http/assets/js/networks.js @@ -1,6 +1,5 @@ $( function() { // document ready start >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -var accesspoint = $( '#accesspoint' ).length; $( 'body' ).click( function() { $( '#menu' ).addClass( 'hide' ); $( 'li' ).removeClass( 'active' ); diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 697d6fe2e..3e90f452b 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -1,5 +1,16 @@ $( function() { // document ready start >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +$( 'body' ).click( function( e ) { + $( '#menu' ).addClass( 'hide' ); + $( 'li' ).removeClass( 'active' ); + if ( !$( e.target ).parents( '#divi2smodule' ).length && $( '#i2smodule' ).val() === 'none' ) { + $( '#divi2smodulesw' ).removeClass( 'hide' ); + $( '#divi2smodule' ).addClass( 'hide' ); + } +} ); +$( '.container' ).on( 'click', '.settings', function() { + location.href = 'settings.php?p='+ $( this ).data( 'setting' ); +} ); var gpiosvg = $( '#gpiosvg' ).html().replace( 'width="380px', 'width="330px' ); var pin2gpio = { 3:2, 5:3, 7:4, 8:14, 10:15, 11:17, 12:18, 13:27, 15:22, 16:23, 18:24, 19:10, 21:9 @@ -40,15 +51,6 @@ ${ gpiosvg }GND:(any black pin) VCC:1 , okno : 1 } ); } ); -$( '.container' ).on( 'click', '.settings', function() { - location.href = 'settings.php?p='+ $( this ).data( 'setting' ); -} ); -$( 'body' ).on( 'click touchstart', function( e ) { - if ( !$( e.target ).parents( '#divi2smodule' ).length && $( '#i2smodule' ).val() === 'none' ) { - $( '#divi2smodulesw' ).removeClass( 'hide' ); - $( '#divi2smodule' ).addClass( 'hide' ); - } -} ); $( '#power' ).click( function() { info( { icon : 'power' @@ -88,7 +90,8 @@ $( '#refresh' ).click( function( e ) { $( '#addnas' ).click( function() { infoMount(); } ); -$( '#list' ).on( 'click', 'li', function() { +$( '#list' ).on( 'click', 'li', function( e ) { + e.stopPropagation(); var $this = $( this ); G.li = $this; $( '#codehddinfo' ).addClass( 'hide' ); @@ -110,12 +113,6 @@ $( '#list' ).on( 'click', 'li', function() { var wH = window.innerHeight; if ( targetB > wH - 40 + $( window ).scrollTop() ) $( 'html, body' ).animate( { scrollTop: targetB - wH + 42 } ); } ); -$( 'body' ).click( function( e ) { - if ( this.id !== 'codehddinfo' && !$( e.target ).parents( '#list' ).length ) { - $( '#menu, #codehddinfo' ).addClass( 'hide' ); - $( 'li' ).removeClass( 'active' ); - } -} ); $( '#menu a' ).click( function() { var $this = $( this ); var cmd = $this.prop( 'class' ); From 55cce0453fa817333278a0b0432132e49944b2fd Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 08:31:01 +0700 Subject: [PATCH 009/237] Update install.sh --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 2a0d938f5..fcb14b8e6 100644 --- a/install.sh +++ b/install.sh @@ -3,8 +3,8 @@ alias=r1 # 20220923 -if [[ ! -e /usr/bin/inotifywait ]]; then - pacman -Sy --noconfirm inotify-tools +file=/etc/systemd/system/dab.service +if [[ ! -e $file ]]; then echo "\ [Unit] Description=DAB Radio metadata @@ -12,7 +12,7 @@ Description=DAB Radio metadata [Service] Type=simple ExecStart=/srv/http/bash/status-dab.sh -" > /etc/systemd/system/dab.service +" > $file systemctl daemon-reload fi From de73018df8b946e4d322f7e1373cbfdf18a7b8fc Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 08:31:34 +0700 Subject: [PATCH 010/237] Update status-dab.sh --- srv/http/bash/status-dab.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index 9b1b9df83..bb35d6ac6 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -10,10 +10,14 @@ song=$(( ${pos/\/*} - 1 )) filelabel=$dirshm/webradio/DABlabel.txt touch $filelabel -while read line; do - title=$( cat $filelabel | tr -d ' \"`?/#&'"'" ) - coverart=/data/shm/webradio/$title.jpg - mv $dirshm/webradio/DABslide{,$title}.jpg &> /dev/null +while true; do + title=$( cat $filelabel ) + name=$( echo $title | tr -d ' \"`?/#&'"'" ) + coverart=/data/shm/webradio/$name.jpg + [[ -e /srv/http/$coverart ]] && continue # not change + + cp $dirshm/webradio/DABslide{,$name}.jpg &> /dev/null + touch $dirshm/webradio/DABslide.text elapsed=$( printf '%.0f' $( { echo status; sleep 0.05; } \ | telnet 127.0.0.1 6600 2> /dev/null \ | grep ^elapsed \ @@ -25,7 +29,7 @@ while read line; do , "elapsed" : '$elapsed' , "file" : "'$file'" , "icon" : "dabradio" -, "sampling" : "$pos • 48 kHz 160 kbit/s" +, "sampling" : "'$pos' • 48 kHz 160 kbit/s" , "state" : "play" , "song" : '$song' , "station" : "" @@ -33,4 +37,5 @@ while read line; do , "Title" : "'$title'" }' $dirbash/status-push.sh statusradio "$data" & -done < <( inotifywait -mq -e close_write $filelabel ) + sleep 10 +done From c3db68fade3f3c2bd1b037e89285e866712a0265 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 08:42:36 +0700 Subject: [PATCH 011/237] Update status-dab.sh --- srv/http/bash/status-dab.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index bb35d6ac6..b30e24aef 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -8,16 +8,18 @@ station=${tmpradio[1]//\"/\\\"} pos=$( mpc | grep '\[playing' | cut -d' ' -f2 | tr -d '#' ) song=$(( ${pos/\/*} - 1 )) filelabel=$dirshm/webradio/DABlabel.txt -touch $filelabel while true; do - title=$( cat $filelabel ) + title=$( cat $filelabel 2> /dev/null ) + [[ ! $title ]] && sleep 5 && continue + name=$( echo $title | tr -d ' \"`?/#&'"'" ) coverart=/data/shm/webradio/$name.jpg - [[ -e /srv/http/$coverart ]] && continue # not change + coverfile=/srv/http/$coverart + [[ -e $coverfile ]] && sleep 10 && continue # not change + touch $coverfile cp $dirshm/webradio/DABslide{,$name}.jpg &> /dev/null - touch $dirshm/webradio/DABslide.text elapsed=$( printf '%.0f' $( { echo status; sleep 0.05; } \ | telnet 127.0.0.1 6600 2> /dev/null \ | grep ^elapsed \ From cdd6d4c1febb36ebbee0524f958932b620f8e36a Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 08:50:28 +0700 Subject: [PATCH 012/237] u --- srv/http/bash/dab-start.sh | 3 +-- srv/http/bash/status-dab.sh | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/srv/http/bash/dab-start.sh b/srv/http/bash/dab-start.sh index f56c7d932..68ab68a08 100644 --- a/srv/http/bash/dab-start.sh +++ b/srv/http/bash/dab-start.sh @@ -3,8 +3,7 @@ killsubs() { kill $DABPID kill $FFMPID - rm $MYPIPE - echo NO INFO > /srv/http/data/shm/webradio/DABlabel.txt + rm $MYPIPE /srv/http/data/shm/webradio/DABlabel.txt } trap killsubs SIGINT diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index b30e24aef..bb90073ba 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -11,8 +11,6 @@ filelabel=$dirshm/webradio/DABlabel.txt while true; do title=$( cat $filelabel 2> /dev/null ) - [[ ! $title ]] && sleep 5 && continue - name=$( echo $title | tr -d ' \"`?/#&'"'" ) coverart=/data/shm/webradio/$name.jpg coverfile=/srv/http/$coverart From 3e9aeda6652c133c8f8ffc82318727e712581b23 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 09:41:43 +0700 Subject: [PATCH 013/237] u --- srv/http/assets/js/passive.js | 9 +++++++++ srv/http/bash/status-dab.sh | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/srv/http/assets/js/passive.js b/srv/http/assets/js/passive.js index cd6f9dcad..1467e95e5 100644 --- a/srv/http/assets/js/passive.js +++ b/srv/http/assets/js/passive.js @@ -225,6 +225,15 @@ function psCoverart( data ) { bookmarkCover( src, path ); getPlaylist( 'refresh' ); break; + case 'coverartplayback': + if ( G.playback ) { + G.status.coverart = src; + $( '#vu' ).addClass( 'hide' ); + $( '#coverart' ) + .attr( 'src', src ) + .removeClass( 'hide' ); + } + break; case 'dabradio': case 'webradio': if ( G.playback ) { diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index bb90073ba..195340f3c 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -14,10 +14,16 @@ while true; do name=$( echo $title | tr -d ' \"`?/#&'"'" ) coverart=/data/shm/webradio/$name.jpg coverfile=/srv/http/$coverart - [[ -e $coverfile ]] && sleep 10 && continue # not change - + [[ -e $coverfile ]] && notchange=1 || notchange= touch $coverfile cp $dirshm/webradio/DABslide{,$name}.jpg &> /dev/null + if [[ $notchange ]]; then # not change + sed -i -E 's/^(coverart=").*/\1'$coverart'"/' $dirshm/status + pushstream coverart '{"type":"coverartplayback","url":"'$coverart'"}' + sleep 10 + continue + fi + elapsed=$( printf '%.0f' $( { echo status; sleep 0.05; } \ | telnet 127.0.0.1 6600 2> /dev/null \ | grep ^elapsed \ From ce6e8dd2e95f47679cfeb483bfce420c9eccf080 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 09:53:38 +0700 Subject: [PATCH 014/237] Update status-dab.sh --- srv/http/bash/status-dab.sh | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index 195340f3c..f6cf88047 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -12,23 +12,19 @@ filelabel=$dirshm/webradio/DABlabel.txt while true; do title=$( cat $filelabel 2> /dev/null ) name=$( echo $title | tr -d ' \"`?/#&'"'" ) - coverart=/data/shm/webradio/$name.jpg - coverfile=/srv/http/$coverart + coverart=/data/shm/webradio/$name.$( date +%s ).jpg + coverfile=/srv/http/data/shm/webradio/$name.jpg [[ -e $coverfile ]] && notchange=1 || notchange= - touch $coverfile cp $dirshm/webradio/DABslide{,$name}.jpg &> /dev/null - if [[ $notchange ]]; then # not change + if [[ $notchange ]]; then # update coverart only sed -i -E 's/^(coverart=").*/\1'$coverart'"/' $dirshm/status pushstream coverart '{"type":"coverartplayback","url":"'$coverart'"}' - sleep 10 - continue - fi - - elapsed=$( printf '%.0f' $( { echo status; sleep 0.05; } \ - | telnet 127.0.0.1 6600 2> /dev/null \ - | grep ^elapsed \ - | cut -d' ' -f2 ) ) - data='{ + else + elapsed=$( printf '%.0f' $( { echo status; sleep 0.05; } \ + | telnet 127.0.0.1 6600 2> /dev/null \ + | grep ^elapsed \ + | cut -d' ' -f2 ) ) + data='{ "Album" : "DAB Radio" , "Artist" : "'$station'" , "coverart" : "'$coverart'" @@ -42,6 +38,7 @@ while true; do , "Time" : false , "Title" : "'$title'" }' - $dirbash/status-push.sh statusradio "$data" & + $dirbash/status-push.sh statusradio "$data" & + fi sleep 10 done From b158591ed7c35c10cc6f3d672a10b278956cbb8f Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 10:05:00 +0700 Subject: [PATCH 015/237] Update status-dab.sh --- srv/http/bash/status-dab.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index f6cf88047..4d8c31cb1 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -16,7 +16,7 @@ while true; do coverfile=/srv/http/data/shm/webradio/$name.jpg [[ -e $coverfile ]] && notchange=1 || notchange= cp $dirshm/webradio/DABslide{,$name}.jpg &> /dev/null - if [[ $notchange ]]; then # update coverart only + if [[ $notchange ]]; then # update coverart only (change later than title or multiple) sed -i -E 's/^(coverart=").*/\1'$coverart'"/' $dirshm/status pushstream coverart '{"type":"coverartplayback","url":"'$coverart'"}' else From c605e8eb9fd54228beab626c7b0a079bbd2b2c7c Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 12:06:07 +0700 Subject: [PATCH 016/237] Update status-dab.sh --- srv/http/bash/status-dab.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index 4d8c31cb1..be287fa46 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -8,18 +8,24 @@ station=${tmpradio[1]//\"/\\\"} pos=$( mpc | grep '\[playing' | cut -d' ' -f2 | tr -d '#' ) song=$(( ${pos/\/*} - 1 )) filelabel=$dirshm/webradio/DABlabel.txt +filecover=$dirshm/webradio/DABslide.jpg while true; do title=$( cat $filelabel 2> /dev/null ) + [[ ! $title ]] && sleep 10 && continue + name=$( echo $title | tr -d ' \"`?/#&'"'" ) coverart=/data/shm/webradio/$name.$( date +%s ).jpg coverfile=/srv/http/data/shm/webradio/$name.jpg - [[ -e $coverfile ]] && notchange=1 || notchange= - cp $dirshm/webradio/DABslide{,$name}.jpg &> /dev/null - if [[ $notchange ]]; then # update coverart only (change later than title or multiple) - sed -i -E 's/^(coverart=").*/\1'$coverart'"/' $dirshm/status - pushstream coverart '{"type":"coverartplayback","url":"'$coverart'"}' + [[ -e $coverfile ]] && changedtitle= || changedtitle=1 + if ! cmp -s $filecover $coverfile; then # change later than title or multiple + changedcover=1 + cp $filecover $coverfile &> /dev/null + sed -i -E 's|^(coverart=").*|\1'$coverart'"|' $dirshm/status else + changedcover= + fi + if [[ $changedtitle ]]; then elapsed=$( printf '%.0f' $( { echo status; sleep 0.05; } \ | telnet 127.0.0.1 6600 2> /dev/null \ | grep ^elapsed \ @@ -39,6 +45,8 @@ while true; do , "Title" : "'$title'" }' $dirbash/status-push.sh statusradio "$data" & + elif [[ $changedcover ]]; then + pushstream coverart '{"type":"coverartplayback","url":"'$coverart'"}' fi sleep 10 done From a0bb0939ceedeaf857d5cf47146b263c647113a0 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 13:34:31 +0700 Subject: [PATCH 017/237] Update main.js --- srv/http/assets/js/main.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/srv/http/assets/js/main.js b/srv/http/assets/js/main.js index bd7e0c608..cf0f6f2e5 100644 --- a/srv/http/assets/js/main.js +++ b/srv/http/assets/js/main.js @@ -106,9 +106,8 @@ if ( navigator.maxTouchPoints ) { // swipeleft / right ///////////////////////// $.getScript( 'assets/js/shortcut.js' ); } -$( '.page' ).click( function( e ) { - if ( ![ 'coverTR', 'timeTR' ].includes( e.target.id ) ) $( '#settings' ).addClass( 'hide' ); -} ).contextmenu( function( e ) { // touch device - on press - disable default context menu +$( 'body' ).click( menuHide ); +$( '.page' ).contextmenu( function( e ) { // touch device - on press - disable default context menu e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); @@ -144,7 +143,8 @@ $( '#logo, #button-library, #button-playlist' ).press( function() { // from info $( '#logo' ).click( function() { if ( !G.localhost ) window.open( 'https://github.com/rern/rAudio-1/discussions' ); } ); -$( '#button-settings' ).click( function() { +$( '#button-settings' ).click( function( e ) { + e.stopPropagation(); if ( $( '#settings' ).hasClass( 'hide' ) ) { menuHide(); $( '#settings' ) @@ -438,7 +438,6 @@ $( '#addons' ).click( function () { loader(); } ); $( '#library, #button-library' ).click( function() { - menuHide(); $( '#lib-path span' ).removeClass( 'hide' ); if ( !$( '#lib-search-input' ).val() ) $( '#lib-search-close' ).empty(); if ( G.library ) { @@ -466,7 +465,6 @@ $( '#playlist, #button-playlist' ).click( function() { if ( !G.local ) G.pladd = {} if ( G.playlist ) { if ( G.savedlist || G.savedplaylist ) getPlaylist(); - menuHide(); } else { switchPage( 'playlist' ); if ( !G.savedlist && !G.savedplaylist ) getPlaylist(); @@ -495,7 +493,6 @@ $( '#settings' ).click( function() { $( this ).addClass( 'hide' ); } ); $( '#page-library, #page-playlist' ).on( 'click', 'p', function() { - menuHide(); if ( G.library ) { $( '.licover .coveredit.cover' ).remove(); $( '.licover img' ).css( 'opacity', '' ); @@ -1281,7 +1278,6 @@ $( '#lib-search-input' ).keyup( function( e ) { if ( e.key === 'Enter' ) $( '#lib-search-btn' ).click(); } ); $( '#button-lib-back' ).click( function() { - menuHide(); var $breadcrumbs = $( '#lib-breadcrumbs a' ); var bL = $breadcrumbs.length var backmode = 'gmode' in G && G.gmode !== G.mode; @@ -1594,9 +1590,9 @@ $( '#page-library' ).press( '.licoverimg', function( e ) { $this.find( 'img' ) .css( 'opacity', '0.33' ) .after( icoveredit ); - menuHide(); } ); $( '#page-library' ).on( 'click', '#lib-list li', function( e ) { + e.stopPropagation(); if ( G.press ) return if ( $( '.licover .coveredit.cover' ).length ) { @@ -1762,11 +1758,7 @@ $( '.page' ).on( 'click', '.index a', function() { $( 'html, body' ).scrollTop( scrollT - ( $( '#bar-top' ).is( ':visible' ) ? 80 : 40 ) ); } ); // PLAYLIST ///////////////////////////////////////////////////////////////////////////////////// -$( '#pl-manage i' ).click( function() { - menuHide(); -} ); $( '#button-pl-back' ).click( function() { - menuHide(); if ( G.savedplaylist ) { $( '#button-pl-playlists' ).click(); } else { @@ -1919,6 +1911,7 @@ new Sortable( document.getElementById( 'pl-savedlist' ), { } } ); $( '#pl-list' ).on( 'click', 'li', function( e ) { + e.stopPropagation(); $target = $( e.target ); if ( $target.hasClass( 'fa-save' ) || $target.hasClass( 'pl-icon' ) || $target.hasClass( 'pl-remove' ) ) return @@ -2005,6 +1998,7 @@ $( '#pl-list' ).on( 'click', 'li', function( e ) { playlistRemove( $( this ).parent() ); } ); $( '#pl-savedlist' ).on( 'click', 'li', function( e ) { + e.stopPropagation(); menuHide(); var $target = $( e.target ); if ( $target.hasClass( 'savewr' ) ) return From 6792c8d21e1904439d8aac454ea0621a04d92c27 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 14:50:02 +0700 Subject: [PATCH 018/237] u --- srv/http/assets/js/function.js | 2 ++ srv/http/assets/js/main.js | 41 +++++++++++----------------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/srv/http/assets/js/function.js b/srv/http/assets/js/function.js index f74efc069..6412f7459 100644 --- a/srv/http/assets/js/function.js +++ b/srv/http/assets/js/function.js @@ -825,6 +825,8 @@ function menuHide() { $( '.menu' ).addClass( 'hide' ); $( '.contextmenu ' ).find( 'a, i' ).removeClass( 'hide' ); $( '.pl-remove' ).remove(); + $( '#lib-list li, #pl-savedlist li' ).removeClass( 'active' ); + $( '#pl-list li' ).removeClass( 'updn' ); } function mpcSeek( elapsed ) { G.status.elapsed = elapsed; diff --git a/srv/http/assets/js/main.js b/srv/http/assets/js/main.js index cf0f6f2e5..e35d01e53 100644 --- a/srv/http/assets/js/main.js +++ b/srv/http/assets/js/main.js @@ -1605,26 +1605,11 @@ $( '#page-library' ).on( 'click', '#lib-list li', function( e ) { if ( $target.hasClass( 'fa-save' ) || $target.hasClass( 'coverart' ) ) return var menushow = $( '.contextmenu:not( .hide )' ).length; - if ( $target.hasClass( 'lib-icon' ) || $target.hasClass( 'licoverimg' ) ) { - if ( $this.hasClass( 'active' ) && menushow ) { - menuHide(); - } else { - $( '#lib-list li' ).removeClass( 'active' ); - contextmenuLibrary( $this, $target ); - } - return - } - + var active = $this.hasClass( 'active' ); menuHide(); - if ( menushow ) return - - $( '#lib-list li' ).removeClass( 'active' ); - if ( $target.hasClass( 'bkedit' ) ) return - - if ( $( '.bkedit' ).length ) { - $( '.bkedit' ).remove(); - $( '.licoverimg img' ).css( 'opacity', '' ); - if ( $( this ).hasClass( 'licover' ) ) return + if ( menushow || $target.hasClass( 'lib-icon' ) || $target.hasClass( 'licoverimg' ) ) { + if ( !active ) contextmenuLibrary( $this, $target ); + return } if ( $this.hasClass( 'licover' ) ) { @@ -1959,14 +1944,11 @@ $( '#pl-list' ).on( 'click', 'li', function( e ) { G.list.name = $thisli.find( '.name' ).text(); G.list.index = $thisli.index(); var $menu = $( '#menu-plaction' ); - $( '#pl-list li' ).removeClass( 'updn' ); + var menushow = !$menu.hasClass( 'hide' ); + var updn = $thisli.hasClass( 'updn' ); + menuHide(); $( '.pl-remove' ).remove(); - $thisli.addClass( 'updn' ); - if ( !$menu.hasClass( 'hide' ) && $menu.css( 'top' ) === ( $thisli.position().top + 48 ) +'px' ) { - $menu.addClass( 'hide' ); - $thisli.removeClass( 'updn' ); - return - } + if ( menushow && updn) return var state = G.status.state; var play = state === 'play'; @@ -1975,6 +1957,7 @@ $( '#pl-list' ).on( 'click', 'li', function( e ) { var notsaved = $thisli.hasClass( 'notsaved' ); var radio = $thisli.hasClass( 'webradio' ); var upnp = $thisli.hasClass( 'upnp' ); + $thisli.addClass( 'updn' ); $( '#menu-plaction a' ).removeClass( 'hide' ); $menu.find( '.current' ).toggleClass( 'hide', active || play ); if ( G.status.player === 'mpd' || G.status.player === 'upnp' ) { @@ -1999,12 +1982,14 @@ $( '#pl-list' ).on( 'click', 'li', function( e ) { } ); $( '#pl-savedlist' ).on( 'click', 'li', function( e ) { e.stopPropagation(); - menuHide(); var $target = $( e.target ); if ( $target.hasClass( 'savewr' ) ) return $this = $( this ); - if ( $this.hasClass( 'active' ) && $( '.contextmenu:not( .hide )' ).length ) return + var menushow = $( '.contextmenu:not( .hide )' ).length; + var active = $this.hasClass( 'active' ); + menuHide(); + if ( menushow && active ) return var pladd = 'file' in G.pladd; var plicon = $target.hasClass( 'pl-icon' ); From ab34b0e68d63b5015a2b2aa2e874bc8a65489d75 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 20:23:15 +0700 Subject: [PATCH 019/237] u --- srv/http/bash/dab-start.sh | 2 +- srv/http/bash/status-dab.sh | 33 ++++++++++++++++----------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/srv/http/bash/dab-start.sh b/srv/http/bash/dab-start.sh index 68ab68a08..d02963297 100644 --- a/srv/http/bash/dab-start.sh +++ b/srv/http/bash/dab-start.sh @@ -3,7 +3,7 @@ killsubs() { kill $DABPID kill $FFMPID - rm $MYPIPE /srv/http/data/shm/webradio/DABlabel.txt + rm $MYPIPE /srv/http/data/shm/webradio/DAB* } trap killsubs SIGINT diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index be287fa46..72322b4bb 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -9,23 +9,14 @@ pos=$( mpc | grep '\[playing' | cut -d' ' -f2 | tr -d '#' ) song=$(( ${pos/\/*} - 1 )) filelabel=$dirshm/webradio/DABlabel.txt filecover=$dirshm/webradio/DABslide.jpg +filetitle=$dirshm/webradio/DABtitle while true; do - title=$( cat $filelabel 2> /dev/null ) - [[ ! $title ]] && sleep 10 && continue + # title + [[ ! -s $filelabel }} && sleep 10 && continue - name=$( echo $title | tr -d ' \"`?/#&'"'" ) - coverart=/data/shm/webradio/$name.$( date +%s ).jpg - coverfile=/srv/http/data/shm/webradio/$name.jpg - [[ -e $coverfile ]] && changedtitle= || changedtitle=1 - if ! cmp -s $filecover $coverfile; then # change later than title or multiple - changedcover=1 - cp $filecover $coverfile &> /dev/null - sed -i -E 's|^(coverart=").*|\1'$coverart'"|' $dirshm/status - else - changedcover= - fi - if [[ $changedtitle ]]; then + if ! cmp -s $filelabel $filetitle; then + cp -f $filelabel $filetitle elapsed=$( printf '%.0f' $( { echo status; sleep 0.05; } \ | telnet 127.0.0.1 6600 2> /dev/null \ | grep ^elapsed \ @@ -33,7 +24,6 @@ while true; do data='{ "Album" : "DAB Radio" , "Artist" : "'$station'" -, "coverart" : "'$coverart'" , "elapsed" : '$elapsed' , "file" : "'$file'" , "icon" : "dabradio" @@ -42,10 +32,19 @@ while true; do , "song" : '$song' , "station" : "" , "Time" : false -, "Title" : "'$title'" +, "Title" : "'$( cat $filetitle )'" }' $dirbash/status-push.sh statusradio "$data" & - elif [[ $changedcover ]]; then + fi + # coverart + [[ ! -s $filecover }} && sleep 10 && continue + + name=$( cat $filetitle | tr -d ' \"`?/#&'"'" ) + coverfile=/srv/http/data/shm/webradio/$name.jpg + if ! cmp -s $filecover $coverfile; then # change later than title or multiple covers + cp -f $filecover $coverfile + coverart=/data/shm/webradio/$name.$( date +%s ).jpg + sed -i -E 's|^(coverart=").*|\1'$coverart'"|' $dirshm/status pushstream coverart '{"type":"coverartplayback","url":"'$coverart'"}' fi sleep 10 From 40708c769bd51d206d4b818a63913c90efc5b60a Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 20:33:07 +0700 Subject: [PATCH 020/237] Update status-dab.sh --- srv/http/bash/status-dab.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index 72322b4bb..f033dfbe3 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -24,6 +24,7 @@ while true; do data='{ "Album" : "DAB Radio" , "Artist" : "'$station'" +, "coverart" : "" , "elapsed" : '$elapsed' , "file" : "'$file'" , "icon" : "dabradio" @@ -44,7 +45,10 @@ while true; do if ! cmp -s $filecover $coverfile; then # change later than title or multiple covers cp -f $filecover $coverfile coverart=/data/shm/webradio/$name.$( date +%s ).jpg - sed -i -E 's|^(coverart=").*|\1'$coverart'"|' $dirshm/status + sed -i -e '/^coverart=/ d +' -e "$ a\ +coverart=$coverart +" $dirshm/status pushstream coverart '{"type":"coverartplayback","url":"'$coverart'"}' fi sleep 10 From 1bec83c2dc6342c4d61c98ba5f6eaa0f507a0945 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 19 Sep 2022 20:59:59 +0700 Subject: [PATCH 021/237] Update status-dab.sh --- srv/http/bash/status-dab.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index f033dfbe3..10c3fae2f 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -13,7 +13,7 @@ filetitle=$dirshm/webradio/DABtitle while true; do # title - [[ ! -s $filelabel }} && sleep 10 && continue + [[ ! -s $filelabel ]] && sleep 10 && continue if ! cmp -s $filelabel $filetitle; then cp -f $filelabel $filetitle @@ -38,7 +38,7 @@ while true; do $dirbash/status-push.sh statusradio "$data" & fi # coverart - [[ ! -s $filecover }} && sleep 10 && continue + [[ ! -s $filecover ]] && sleep 10 && continue name=$( cat $filetitle | tr -d ' \"`?/#&'"'" ) coverfile=/srv/http/data/shm/webradio/$name.jpg From e4fe4cc36cf4498c91d871e391fe5723bec29cc0 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 20 Sep 2022 11:39:02 +0700 Subject: [PATCH 022/237] Update system.js --- srv/http/assets/js/system.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 3e90f452b..0edb06393 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -976,8 +976,8 @@ function renderPage() { .empty() .addClass( 'hide' ); $( '#systemvalue' ).html( - 'rAudio • '+ G.versionui +'' - +'
'+ G.kernel.replace( /-r.*H (.*)/, ' • $1' ) + 'rAudio '+ G.versionui + +'
'+ G.kernel.replace( /-r.*H (.*)/, ' $1' ) +'
'+ G.rpimodel.replace( /(Rev.*)$/, '$1' ) +'
'+ G.soc + ' '+ G.socram +'
'+ G.soccpu From d785d6fc5d4e2dd1d434572d5b14d55b81b46a96 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 20 Sep 2022 12:09:54 +0700 Subject: [PATCH 023/237] u --- srv/http/assets/js/system.js | 6 +++--- srv/http/bash/settings/system-data.sh | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 0edb06393..54b674977 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -977,9 +977,9 @@ function renderPage() { .addClass( 'hide' ); $( '#systemvalue' ).html( 'rAudio '+ G.versionui - +'
'+ G.kernel.replace( /-r.*H (.*)/, ' $1' ) - +'
'+ G.rpimodel.replace( /(Rev.*)$/, '$1' ) - +'
'+ G.soc + ' '+ G.socram + +'
'+ G.kernel + +'
'+ G.rpimodel + +'
'+ G.soc +'
'+ G.soccpu ); renderStatus(); diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 160fd5241..b7e081adf 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -26,7 +26,9 @@ speed=${cpu[2]/.*} (( $speed < 1000 )) && speed+=' MHz' || speed=$( echo "print $speed / 1000" | perl )' GHz' (( $core > 1 )) && soccpu="$core x $cpu" || soccpu=$cpu soccpu+=" @ $speed" -rpimodel=$( cat /proc/device-tree/model | tr -d '\000' | sed 's/ Model //; s/ Plus/+/' ) +rpimodel=$( cat /proc/device-tree/model \ + | tr -d '\000' \ + | sed -E 's/ Model //; s/ Plus/+/; s|( Rev.*)|\1|' ) if [[ $rpimodel == *BeagleBone* ]]; then soc=AM3358 else @@ -43,6 +45,7 @@ else 3 ) soc=BCM2711;; # 4 esac fi +soc+=$( free -h | awk '/^Mem/ {print " "$2}' | sed -E 's|(.i)| \1B|' ) if ifconfig | grep -q eth0; then if [[ -e $dirsystem/soundprofile.conf ]]; then soundprofileconf="[ $( cut -d= -f2 $dirsystem/soundprofile.conf | xargs | tr ' ' , ) ]" @@ -155,7 +158,7 @@ data+=' , "hostapd" : '$( isactive hostapd )' , "hostname" : "'$( hostname )'" , "i2seeprom" : '$( grep -q force_eeprom_read=0 /boot/config.txt && echo true )' -, "kernel" : "'$( uname -rm )'" +, "kernel" : "'$( uname -rm | sed -E 's|-rpi-ARCH (.*)| \1|' )'" , "lcd" : '$lcd' , "lcdchar" : '$( exists $dirsystem/lcdchar )' , "lcdcharaddr" : '$i2caddress' @@ -175,7 +178,6 @@ data+=' , "shareddata" : '$( grep -q /srv/http/shareddata /etc/fstab && echo true )' , "soc" : "'$soc'" , "soccpu" : "'$soccpu'" -, "socram" : "'$( free -h | grep Mem | awk '{print $2}' )'B" , "socspeed" : "'$socspeed'" , "soundprofile" : '$( exists $dirsystem/soundprofile )' , "soundprofileconf" : '$soundprofileconf' From 39988203ac07c4853b59a57a1ab91a945dbbadee Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 20 Sep 2022 12:42:09 +0700 Subject: [PATCH 024/237] u --- srv/http/assets/js/system.js | 8 +------- srv/http/bash/settings/system-data.sh | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 54b674977..5c6ba002d 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -975,13 +975,7 @@ function renderPage() { $( '#codehddinfo' ) .empty() .addClass( 'hide' ); - $( '#systemvalue' ).html( - 'rAudio '+ G.versionui - +'
'+ G.kernel - +'
'+ G.rpimodel - +'
'+ G.soc - +'
'+ G.soccpu - ); + $( '#systemvalue' ).html( G.system ); renderStatus(); var html = ''; $.each( G.list, function( i, val ) { diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index b7e081adf..cee1e3297 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -17,8 +17,6 @@ data=' # for interval refresh [[ $1 == status ]] && echo {$data} && exit -lcdmodel=$( cat $dirsystem/lcdmodel 2> /dev/null || echo tft35a ) -lcd=$( grep -q 'dtoverlay=.*rotate=' /boot/config.txt && echo true ) readarray -t cpu <<< $( lscpu | awk '/Core|Model name|CPU max/ {print $NF}' ) cpu=${cpu[0]} core=${cpu[1]} @@ -46,6 +44,14 @@ else esac fi soc+=$( free -h | awk '/^Mem/ {print " "$2}' | sed -E 's|(.i)| \1B|' ) +version=$( cat $dirsystem/version ) +system="\ +rAudio $( cat $diraddons/r$version 2> /dev/null )
\ +$( uname -rm | sed -E 's|-rpi-ARCH (.*)| \1|' )
\ +$rpimodel
\ +$soc
\ +$soccpu" + if ifconfig | grep -q eth0; then if [[ -e $dirsystem/soundprofile.conf ]]; then soundprofileconf="[ $( cut -d= -f2 $dirsystem/soundprofile.conf | xargs | tr ' ' , ) ]" @@ -57,7 +63,6 @@ $( ifconfig eth0 | awk '/txqueuelen/ {print $4}' ) \ ]" fi fi -version=$( cat $dirsystem/version ) # sd, usb and nas if mount | grep -q 'mmcblk0p2 on /'; then @@ -158,13 +163,12 @@ data+=' , "hostapd" : '$( isactive hostapd )' , "hostname" : "'$( hostname )'" , "i2seeprom" : '$( grep -q force_eeprom_read=0 /boot/config.txt && echo true )' -, "kernel" : "'$( uname -rm | sed -E 's|-rpi-ARCH (.*)| \1|' )'" -, "lcd" : '$lcd' +, "lcd" : '$( grep -q 'dtoverlay=.*rotate=' /boot/config.txt && echo true )' , "lcdchar" : '$( exists $dirsystem/lcdchar )' , "lcdcharaddr" : '$i2caddress' , "lcdcharconf" : '$lcdcharconf' , "list" : '$list' -, "lcdmodel" : "'$lcdmodel'" +, "lcdmodel" : "'$( cat $dirsystem/lcdmodel 2> /dev/null || echo tft35a )'" , "mpdoled" : '$( exists $dirsystem/mpdoled )' , "mpdoledconf" : '$mpdoledconf' , "online" : '$( : >/dev/tcp/8.8.8.8/53 && echo true )' @@ -174,16 +178,11 @@ data+=' , "relays" : '$( exists $dirsystem/relays )' , "rotaryencoder" : '$( isactive rotaryencoder )' , "rotaryencoderconf": '$rotaryencoderconf' -, "rpimodel" : "'$rpimodel'" , "shareddata" : '$( grep -q /srv/http/shareddata /etc/fstab && echo true )' -, "soc" : "'$soc'" -, "soccpu" : "'$soccpu'" -, "socspeed" : "'$socspeed'" , "soundprofile" : '$( exists $dirsystem/soundprofile )' , "soundprofileconf" : '$soundprofileconf' +, "system" : "'$system'" , "usbautoupdate" : '$( exists $dirsystem/usbautoupdate )' -, "version" : "'$version'" -, "versionui" : '$( cat $diraddons/r$version 2> /dev/null )' , "vuled" : '$( exists $dirsystem/vuled )' , "vuledconf" : '$vuledconf if [[ -e $dirshm/onboardwlan ]]; then From 86dee95a20b95323b098a177c2891ec32af2cb33 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 20 Sep 2022 14:57:41 +0700 Subject: [PATCH 025/237] u --- srv/http/assets/js/system.js | 42 +++++---------------------- srv/http/bash/settings/system-data.sh | 25 +++++++--------- 2 files changed, 18 insertions(+), 49 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 5c6ba002d..b787ac1e3 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -77,14 +77,7 @@ $( '#refresh' ).click( function( e ) { $this.removeClass( 'blink' ); } else { $this.addClass( 'blink' ); - G.intCputime = setInterval( function() { - bash( '/srv/http/bash/settings/system-data.sh status', function( status ) { - $.each( status, function( key, val ) { - G[ key ] = val; - } ); - renderStatus(); - }, 'json' ); - }, 10000 ); + G.intCputime = setInterval( getStatus, 10000 ); } } ); $( '#addnas' ).click( function() { @@ -976,7 +969,8 @@ function renderPage() { .empty() .addClass( 'hide' ); $( '#systemvalue' ).html( G.system ); - renderStatus(); + $( '#status' ).html( G.status ); + if ( !G.startup ) setTimeout( getStatus, 10000 ); var html = ''; $.each( G.list, function( i, val ) { if ( val.mounted ) { @@ -1024,30 +1018,8 @@ function renderPage() { $( '#shareddata' ).prop( 'checked', G.shareddata ); showContent(); } -function renderStatus() { - var status = G.cpuload.replace( / /g, ' ' ); - status += + G.cputemp < 80 ? '
'+ G.cputemp +' °C' : '
 '+ G.cputemp +' °C'; - status += '
'+ G.time.replace( ' ', ' ' ) +' '+ G.timezone.replace( '/', ' · ' ) +'' - +'
'+ G.uptime +'since '+ G.uptimesince.replace( ' ', ' • ' ) +'' - +'
'+ ( G.startup ? G.startup.replace( ' ', 's kernel + ' ) +'s userspace' : 'Booting ...' ); - if ( !G.online ) status += '
 No Internet connection.'; - if ( G.throttled !== '0x0' ) { // https://www.raspberrypi.org/documentation/raspbian/applications/vcgencmd.md - var bits = parseInt( G.throttled ).toString( 2 ); // 20 bits ( hex > decimal > binary ) - if ( bits[ 0 ] == 1 ) { // #0 > #18 - status += '
 Voltage under 4.7V - occurred '+ G.throttled +''; - } else if ( bits[ 18 ] == 1 ) { // #18 > #0 - status += '
Voltage under 4.7V - now '+ G.throttled +''; - } - } - $( '#status' ).html( status ); - if ( !G.startup ) { - setTimeout( function() { - bash( "systemd-analyze | grep '^Startup finished' | cut -d' ' -f 4,7 | sed 's/\....s//g'", function( data ) { - if ( data ) { - G.startup = data; - renderStatus(); - } - } ); - }, 10000 ); - } +function getStatus() { + bash( '/srv/http/bash/settings/system-data.sh status', function( status ) { + $( '#status' ).html( status ); + } ); } diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index cee1e3297..1526fb064 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -2,20 +2,15 @@ . /srv/http/bash/common.sh -cputemp=$( /opt/vc/bin/vcgencmd measure_temp | sed 's/[^0-9.]//g' ) -data=' - "page" : "system" -, "cpuload" : "'$( cat /proc/loadavg | cut -d' ' -f1-3 )'" -, "cputemp" : '$( [[ $cputemp ]] && echo $cputemp || echo 0 )' -, "startup" : "'$( systemd-analyze | grep '^Startup finished' | cut -d' ' -f 4,7 | sed 's/\....s//g' )'" -, "throttled" : "'$( /opt/vc/bin/vcgencmd get_throttled | cut -d= -f2 )'" -, "time" : "'$( date +'%T %F' )'" -, "timezone" : "'$( timedatectl | awk '/zone:/ {print $3}' )'" -, "uptime" : "'$( uptime -p | tr -d 's,' | sed 's/up //; s/ day/d/; s/ hour/h/; s/ minute/m/' )'" -, "uptimesince" : "'$( uptime -s | cut -d: -f1-2 )'"' - +startup=$( systemd-analyze | grep '^Startup finished' | cut -d' ' -f 4,7 | sed -e 's/\....s/s/g; s/ / + /' ) +status="\ +$( cat /proc/loadavg | cut -d' ' -f1-3 | sed 's| | |g' )
\ +$( /opt/vc/bin/vcgencmd measure_temp | sed -E 's/temp=(.*).C/\1 °C/' )
\ +$( date +'%F %T' ) • $( timedatectl | awk '/zone:/ {print $3}' )
\ +$( uptime -p | tr -d 's,' | sed 's/up //; s/ day/d/; s/ hour/h/; s/ minute/m/' )'since '$( uptime -s | cut -d: -f1-2 | sed 's/ / • /' )
\ +$( [[ $startup ]] && echo "$startupkernel + usersapce" || echo . . . )" # for interval refresh -[[ $1 == status ]] && echo {$data} && exit +[[ $1 == status ]] && echo $status && exit readarray -t cpu <<< $( lscpu | awk '/Core|Model name|CPU max/ {print $NF}' ) cpu=${cpu[0]} @@ -156,7 +151,7 @@ else fi data+=' -, "audioaplayname" : "'$( cat $dirsystem/audio-aplayname 2> /dev/null )'" + "audioaplayname" : "'$( cat $dirsystem/audio-aplayname 2> /dev/null )'" , "audiooutput" : "'$( cat $dirsystem/audio-output 2> /dev/null )'" , "camilladsp" : '$( exists $dirsystem/camilladsp )' , "hddspindown" : '$( cat $dirsystem/hddspindown 2> /dev/null || echo 0 )' @@ -181,6 +176,8 @@ data+=' , "shareddata" : '$( grep -q /srv/http/shareddata /etc/fstab && echo true )' , "soundprofile" : '$( exists $dirsystem/soundprofile )' , "soundprofileconf" : '$soundprofileconf' +, "status" : "'$status'" +, "startup" : '$( [[ $startup ]] && echo true )' , "system" : "'$system'" , "usbautoupdate" : '$( exists $dirsystem/usbautoupdate )' , "vuled" : '$( exists $dirsystem/vuled )' From 73f8f8c5cea6f2ab627f8c58e222b4d8975c920e Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 20 Sep 2022 14:59:14 +0700 Subject: [PATCH 026/237] Update system-data.sh --- srv/http/bash/settings/system-data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 1526fb064..a76fc41ed 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -7,7 +7,7 @@ status="\ $( cat /proc/loadavg | cut -d' ' -f1-3 | sed 's| | |g' )
\ $( /opt/vc/bin/vcgencmd measure_temp | sed -E 's/temp=(.*).C/\1 °C/' )
\ $( date +'%F %T' ) • $( timedatectl | awk '/zone:/ {print $3}' )
\ -$( uptime -p | tr -d 's,' | sed 's/up //; s/ day/d/; s/ hour/h/; s/ minute/m/' )'since '$( uptime -s | cut -d: -f1-2 | sed 's/ / • /' )
\ +$( uptime -p | tr -d 's,' | sed 's/up //; s/ day/d/; s/ hour/h/; s/ minute/m/' )since $( uptime -s | cut -d: -f1-2 | sed 's/ / • /' )
\ $( [[ $startup ]] && echo "$startupkernel + usersapce" || echo . . . )" # for interval refresh [[ $1 == status ]] && echo $status && exit From aa80ab4704f420d8f85cbea8242805a713671245 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 20 Sep 2022 15:00:28 +0700 Subject: [PATCH 027/237] Update system-data.sh --- srv/http/bash/settings/system-data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index a76fc41ed..324b5c798 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -8,7 +8,7 @@ $( cat /proc/loadavg | cut -d' ' -f1-3 | sed 's| | |g' )
\ $( /opt/vc/bin/vcgencmd measure_temp | sed -E 's/temp=(.*).C/\1 °C/' )
\ $( date +'%F %T' ) • $( timedatectl | awk '/zone:/ {print $3}' )
\ $( uptime -p | tr -d 's,' | sed 's/up //; s/ day/d/; s/ hour/h/; s/ minute/m/' )since $( uptime -s | cut -d: -f1-2 | sed 's/ / • /' )
\ -$( [[ $startup ]] && echo "$startupkernel + usersapce" || echo . . . )" +$( [[ $startup ]] && echo "$startup(kernel + usersapce)" || echo . . . )" # for interval refresh [[ $1 == status ]] && echo $status && exit From ee5bcd33f34bfae8744aca33fee26f2be8f133ce Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 20 Sep 2022 18:01:25 +0700 Subject: [PATCH 028/237] Update system-data.sh --- srv/http/bash/settings/system-data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 324b5c798..50cca01fb 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -8,7 +8,7 @@ $( cat /proc/loadavg | cut -d' ' -f1-3 | sed 's| | |g' )
\ $( /opt/vc/bin/vcgencmd measure_temp | sed -E 's/temp=(.*).C/\1 °C/' )
\ $( date +'%F %T' ) • $( timedatectl | awk '/zone:/ {print $3}' )
\ $( uptime -p | tr -d 's,' | sed 's/up //; s/ day/d/; s/ hour/h/; s/ minute/m/' )since $( uptime -s | cut -d: -f1-2 | sed 's/ / • /' )
\ -$( [[ $startup ]] && echo "$startup(kernel + usersapce)" || echo . . . )" +$( [[ $startup ]] && echo "$startup(kernel + userspace)" || echo . . . )" # for interval refresh [[ $1 == status ]] && echo $status && exit From 1338fd5785bdb3e70027542330dff117e4ba228f Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 20 Sep 2022 21:01:08 +0700 Subject: [PATCH 029/237] u --- srv/http/bash/spotifyd.sh | 2 +- srv/http/bash/status-dab.sh | 2 +- srv/http/bash/status-radio.sh | 2 +- srv/http/bash/status.sh | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/srv/http/bash/spotifyd.sh b/srv/http/bash/spotifyd.sh index 8ded7315e..31f1d896c 100644 --- a/srv/http/bash/spotifyd.sh +++ b/srv/http/bash/spotifyd.sh @@ -58,7 +58,7 @@ cat << EOF > $filestatus , "Artist" : ${status[1]} , "coverart" : ${status[2]} , "file" : "" -, "sampling" : "48 kHz 320 kbit/s • Spotify" +, "sampling" : "48 kHz 320 kbit/s • Spotify" , "state" : "$state" , "Time" : $Time , "Title" : ${status[5]} diff --git a/srv/http/bash/status-dab.sh b/srv/http/bash/status-dab.sh index 10c3fae2f..311ebf2b1 100644 --- a/srv/http/bash/status-dab.sh +++ b/srv/http/bash/status-dab.sh @@ -28,7 +28,7 @@ while true; do , "elapsed" : '$elapsed' , "file" : "'$file'" , "icon" : "dabradio" -, "sampling" : "'$pos' • 48 kHz 160 kbit/s" +, "sampling" : "'$pos' • 48 kHz 160 kbit/s • DAB" , "state" : "play" , "song" : '$song' , "station" : "" diff --git a/srv/http/bash/status-radio.sh b/srv/http/bash/status-radio.sh index ae361b966..358962492 100644 --- a/srv/http/bash/status-radio.sh +++ b/srv/http/bash/status-radio.sh @@ -7,7 +7,7 @@ file=${tmpradio[0]} station=${tmpradio[1]//\"/\\\"} id=${tmpradio[2]} pos=$( mpc | grep '\[playing' | cut -d' ' -f2 | tr -d '#' ) -sampling="$pos • ${tmpradio[3]}" +sampling="$pos • ${tmpradio[3]}" song=$(( ${pos/\/*} - 1 )) case $id in diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index 6e32f181d..2e3fffc59 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -367,7 +367,7 @@ $radiosampling" > $dirshm/radio , "Title" : "'$Title'" , "webradio" : true' if [[ $id ]]; then - sampling="$(( song + 1 ))/$pllength • $radiosampling" + sampling="$(( song + 1 ))/$pllength • $radiosampling" elapsedGet ######## status+=' @@ -436,7 +436,7 @@ samplingLine() { fi if [[ $bitdepth == dsd ]]; then - sampling="${samplerate^^} • $rate" + sampling="${samplerate^^} • $rate" else [[ $bitdepth == 'N/A' && ( $ext == WAV || $ext == AIFF ) ]] && bitdepth=$(( bitrate / samplerate / 2 )) sample="$( awk "BEGIN { printf \"%.1f\n\", $samplerate / 1000 }" ) kHz" @@ -446,11 +446,11 @@ samplingLine() { sampling="$sample $rate" fi fi - [[ $ext != Radio ]] && sampling+=" • $ext" + [[ $ext != Radio ]] && sampling+=" • $ext" } if [[ $ext == CD ]]; then - sampling='16 bit 44.1 kHz 1.41 Mbit/s • CD' + sampling='16 bit 44.1 kHz 1.41 Mbit/s • CD' elif [[ $state != stop ]]; then if [[ $ext == DSF || $ext == DFF ]]; then bitdepth=dsd @@ -481,7 +481,7 @@ else hex=( $( hexdump -x -s$byte -n4 "/mnt/MPD/$file" | head -1 | tr -s ' ' ) ) dsd=$(( ${hex[1]} / 1100 * 64 )) # hex byte#57-58 - @1100:dsd64 bitrate=$( awk "BEGIN { printf \"%.2f\n\", $dsd * 44100 / 1000000 }" ) - sampling="DSD$dsd • $bitrate Mbit/s • $ext" + sampling="DSD$dsd • $bitrate Mbit/s • $ext" else data=( $( ffprobe -v quiet -select_streams a:0 \ -show_entries stream=bits_per_raw_sample,sample_rate \ @@ -500,7 +500,7 @@ fi ######## pos="$(( song + 1 ))/$pllength" -sampling="$pos • $sampling" +sampling="$pos • $sampling" status+=' , "ext" : "'$ext'" , "coverart" : "'$coverart'" From 183b2bae60a8943da19638322ff5f271d2575ad1 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 20 Sep 2022 21:12:56 +0700 Subject: [PATCH 030/237] Update status.sh --- srv/http/bash/status.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index 2e3fffc59..dd355c272 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -281,6 +281,7 @@ elif [[ $stream ]]; then else ext=Radio if [[ $file == *rtsp://*$( hostname -f )* ]]; then + ext=DAB dirradio=$dirdabradio icon=dabradio else @@ -451,20 +452,21 @@ samplingLine() { if [[ $ext == CD ]]; then sampling='16 bit 44.1 kHz 1.41 Mbit/s • CD' +elif [[ $ext == DAB ]]; then + sampling='48 kHz 160 kbit/s • DAB' elif [[ $state != stop ]]; then if [[ $ext == DSF || $ext == DFF ]]; then bitdepth=dsd [[ $state == pause ]] && bitrate=$(( ${samplerate/dsd} * 2 * 44100 )) - fi - if [[ $ext != Radio ]]; then - samplingLine $bitdepth $samplerate $bitrate $ext - else + elif [[ $ext == Radio ]]; then if [[ $bitrate && $bitrate != 0 ]]; then samplingLine $bitdepth $samplerate $bitrate $ext [[ -e $radiofile ]] && sed -i "2 s|.*|$sampling|" $radiofile # update sampling on each play else sampling=$radiosampling fi + else + samplingLine $bitdepth $samplerate $bitrate $ext fi samplingSave & else From c1b93c01a113eec5f4fd72d882f23a02f6f759fa Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 20 Sep 2022 21:18:51 +0700 Subject: [PATCH 031/237] Update main.js --- srv/http/assets/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/assets/js/main.js b/srv/http/assets/js/main.js index e35d01e53..0fe4910fd 100644 --- a/srv/http/assets/js/main.js +++ b/srv/http/assets/js/main.js @@ -418,7 +418,7 @@ $( '#colorreset' ).click( function() { loader(); } ); $( '#colorcancel' ).click( function() { - $( '#colorpicker, .menu' ).addClass( 'hide' ); + $( '#colorpicker' ).addClass( 'hide' ); $( '#bar-top, #playback-controls i, #lib-index, #lib-index a, #bar-bottom i \ , .content-top, #button-library, #mode-title, #button-lib-back \ , #lib-list li, #lib-list li.active, #lib-list i, #lib-list .li2 \ From 7a928a58e922def23ebeb8e3f4fde16f675177f4 Mon Sep 17 00:00:00 2001 From: rern Date: Wed, 21 Sep 2022 10:12:00 +0700 Subject: [PATCH 032/237] u --- install.sh | 10 ++++++++++ srv/http/bash/settings/system-data.sh | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index fcb14b8e6..d29e70eee 100644 --- a/install.sh +++ b/install.sh @@ -3,6 +3,16 @@ alias=r1 # 20220923 +dir=/srv/http/assets/img/guide +if [[ ! -e $dir/1.jpg ]]; then + mkdir -p $dir + if [[ -e /srv/http/assets/img/1.jpg ]]; then + find /srv/http/assets/img -maxdepth 1 -type f -name '[0-9]*' -exec mv {} $dir \; + else + curl -skL https://github.com/rern/_assets/raw/master/guide/guide.tar.xz | bsdtar xf - -C $dir + fi +fi + file=/etc/systemd/system/dab.service if [[ ! -e $file ]]; then echo "\ diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 50cca01fb..1c55a7750 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -61,7 +61,7 @@ fi # sd, usb and nas if mount | grep -q 'mmcblk0p2 on /'; then - used_size=( $( df -lh --output=used,size,target | grep '\/$' ) ) + used_size=( $( df -lh --output=used,size,target | grep '/$' ) ) list+=',{"icon":"microsd","mountpoint":"/","mounted":true,"source":"/dev/mmcblk0p2","size":"'${used_size[0]}'B/'${used_size[1]}'B"}' fi usb=$( mount | grep ^/dev/sd | cut -d' ' -f1 ) From 2f8d867ee44b4fae767085ea2c16a4ff0221179e Mon Sep 17 00:00:00 2001 From: rern Date: Wed, 21 Sep 2022 10:19:49 +0700 Subject: [PATCH 033/237] Update system-data.sh --- srv/http/bash/settings/system-data.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 1c55a7750..b38481156 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -151,7 +151,8 @@ else fi data+=' - "audioaplayname" : "'$( cat $dirsystem/audio-aplayname 2> /dev/null )'" + "page" : "system" +, "audioaplayname" : "'$( cat $dirsystem/audio-aplayname 2> /dev/null )'" , "audiooutput" : "'$( cat $dirsystem/audio-output 2> /dev/null )'" , "camilladsp" : '$( exists $dirsystem/camilladsp )' , "hddspindown" : '$( cat $dirsystem/hddspindown 2> /dev/null || echo 0 )' From 56652b1e1016a8e5682caa5688c8e98de5b6008e Mon Sep 17 00:00:00 2001 From: rern Date: Wed, 21 Sep 2022 11:00:29 +0700 Subject: [PATCH 034/237] Update system-data.sh --- srv/http/bash/settings/system-data.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index b38481156..e0cd7976c 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -9,6 +9,13 @@ $( /opt/vc/bin/vcgencmd measure_temp | sed -E 's/temp=(.*).C/\1 °C/' )
\ $( date +'%F %T' ) • $( timedatectl | awk '/zone:/ {print $3}' )
\ $( uptime -p | tr -d 's,' | sed 's/up //; s/ day/d/; s/ hour/h/; s/ minute/m/' )since $( uptime -s | cut -d: -f1-2 | sed 's/ / • /' )
\ $( [[ $startup ]] && echo "$startup(kernel + userspace)" || echo . . . )" +! : >/dev/tcp/8.8.8.8/53 && status+="
 No Internet connection" +throttled=$( /opt/vc/bin/vcgencmd get_throttled | cut -d= -f2 ) +if [[ $throttled == 0x1 ]]; then # https://www.raspberrypi.org/documentation/raspbian/applications/vcgencmd.md + status+="
 Voltage under 4.7V - now $throttled" +elif [[ $throttled == 0x10000 ]]; then + status+="
 Voltage under 4.7V - occurred $throttled" +fi # for interval refresh [[ $1 == status ]] && echo $status && exit @@ -167,7 +174,6 @@ data+=' , "lcdmodel" : "'$( cat $dirsystem/lcdmodel 2> /dev/null || echo tft35a )'" , "mpdoled" : '$( exists $dirsystem/mpdoled )' , "mpdoledconf" : '$mpdoledconf' -, "online" : '$( : >/dev/tcp/8.8.8.8/53 && echo true )' , "ntp" : "'$( grep '^NTP' /etc/systemd/timesyncd.conf | cut -d= -f2 )'" , "powerbutton" : '$( systemctl -q is-active powerbutton || [[ $audiophonics == true ]] && echo true )' , "powerbuttonconf" : '$powerbuttonconf' From 8ce0ed21e1117a1c7285d5cd1ea039e51e3c429b Mon Sep 17 00:00:00 2001 From: rern Date: Wed, 21 Sep 2022 11:03:00 +0700 Subject: [PATCH 035/237] Update system-data.sh --- srv/http/bash/settings/system-data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index e0cd7976c..f66f784c2 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -12,7 +12,7 @@ $( [[ $startup ]] && echo "$startup(kernel + userspace)/dev/tcp/8.8.8.8/53 && status+="
 No Internet connection" throttled=$( /opt/vc/bin/vcgencmd get_throttled | cut -d= -f2 ) if [[ $throttled == 0x1 ]]; then # https://www.raspberrypi.org/documentation/raspbian/applications/vcgencmd.md - status+="
 Voltage under 4.7V - now $throttled" + status+="
 Voltage under 4.7V - detected now $throttled" elif [[ $throttled == 0x10000 ]]; then status+="
 Voltage under 4.7V - occurred $throttled" fi From ecc6083ca205c9bb28e47fbd9243873ad0a9fbc6 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 23 Sep 2022 10:15:08 +0700 Subject: [PATCH 036/237] u --- srv/http/assets/js/function.js | 5 ++-- srv/http/assets/js/info.js | 1 + srv/http/bash/cmd-list.sh | 9 ++++++-- srv/http/bash/cmd.sh | 15 +++--------- srv/http/bash/startup.sh | 3 ++- srv/http/bash/status.sh | 42 ++++++++++------------------------ 6 files changed, 27 insertions(+), 48 deletions(-) diff --git a/srv/http/assets/js/function.js b/srv/http/assets/js/function.js index 6412f7459..e9cadc3d7 100644 --- a/srv/http/assets/js/function.js +++ b/srv/http/assets/js/function.js @@ -761,8 +761,7 @@ function infoUpdate( path ) { icon : 'refresh-library' , title : 'Library Database' , message : path ? ' '+ path +'' : '' - , radio : path ? '' : { 'Only changed files' : 'update', 'Rebuild entire database': 'rescan' } - , values : path ? '' : 'update' + , radio : path ? '' : { 'Only changed files' : '', 'Rebuild entire database': 'rescan' } , beforeshow : function() { if ( !G.status.counts ) { $( '#infoContent input' ).eq( 0 ).prop( 'disabled', 1 ); @@ -770,7 +769,7 @@ function infoUpdate( path ) { } } , ok : function() { - bash( path ? [ 'mpcupdate', 'path', path ] : [ 'mpcupdate', infoVal() ] ); + bash( [ 'mpcupdate', path || infoVal() ] ); } } ); } diff --git a/srv/http/assets/js/info.js b/srv/http/assets/js/info.js index 24e58f2b4..d9994fbff 100644 --- a/srv/http/assets/js/info.js +++ b/srv/http/assets/js/info.js @@ -422,6 +422,7 @@ function info( json ) { } } } ); + if ( ! O.values ) O.values = [ '' ]; } if ( O.checkbox ) { var line; diff --git a/srv/http/bash/cmd-list.sh b/srv/http/bash/cmd-list.sh index f4c6933a2..8ffd42c5a 100644 --- a/srv/http/bash/cmd-list.sh +++ b/srv/http/bash/cmd-list.sh @@ -73,7 +73,12 @@ fi filealbum=$dirmpd/album filealbumprev=$dirmpd/albumprev -[[ -s $dirmpd/album ]] && cp -f $filealbum{,prev} || > $dirmpd/latest +if [[ -s $dirmpd/album && $( cat $dirmpd/updating ) != rescan ]]; then + cp -f $filealbum{,prev} +else + > $dirmpd/latest + latest=0 +fi for mode in album albumartist artist composer conductor genre date; do filemode=$dirmpd/$mode @@ -104,8 +109,8 @@ if [[ -e $filealbumprev ]]; then # latest mv -f $dirmpd/latest{new,} fi fi + latest=$( cat "$dirmpd/latest" 2> /dev/null | wc -l ) fi -latest=$( cat "$dirmpd/latest" 2> /dev/null | wc -l ) ##### count ############################################# for mode in NAS SD USB; do printf -v $mode '%s' $( mpc ls $mode 2> /dev/null | wc -l ) diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index 45ebdb49c..8308830d2 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -974,18 +974,9 @@ mpcsimilar ) echo $(( $( mpc playlist | wc -l ) - plLprev )) ;; mpcupdate ) - type=${args[1]} - path=${args[2]} - if [[ $type == rescan ]]; then - touch $dirmpd/updating - mpc -q rescan - elif [[ $type == update ]]; then - touch $dirmpd/updating - mpc -q update - elif [[ $type == path ]]; then - echo $path > $dirmpd/updating - mpc -q update "$path" - fi + path=${args[1]} + echo $path > $dirmpd/updating + [[ $path == rescan ]] && mpc -q rescan || mpc -q update "$path" pushstream mpdupdate '{"type":"mpd"}' ;; mpdoledlogo ) diff --git a/srv/http/bash/startup.sh b/srv/http/bash/startup.sh index 27405bb47..e474d6e14 100644 --- a/srv/http/bash/startup.sh +++ b/srv/http/bash/startup.sh @@ -142,7 +142,8 @@ fi if [[ ! $shareddata && ! -e $dirmpd/mpd.db ]]; then $dirbash/cmd.sh$'\n'rescan elif [[ -e $dirmpd/updating ]]; then - $dirbash/cmd.sh$'\n'"$( cat $dirmpd/updating )" + path=$( cat $dirmpd/updating ) + [[ $path == rescan ]] && mpc -q rescan || mpc -q update "$path" elif [[ -e $dirmpd/listing || ! -e $dirmpd/counts ]]; then $dirbash/cmd-list.sh &> dev/null & fi diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index dd355c272..b8ebab189 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -24,25 +24,9 @@ if [[ $1 == snapclient ]]; then # snapclient snapclient=1 player=mpd else - btreceiver=$( exists $dirshm/btreceiver ) - consume=$( mpc | grep -q 'consume: on' && echo true ) - counts=$( cat $dirmpd/counts 2> /dev/null ) - librandom=$( exists $dirsystem/librandom ) player=$( cat $dirshm/player ) [[ ! $player ]] && player=mpd && echo mpd > $dirshm/player [[ $player != mpd ]] && icon=$player - relays=$( exists $dirsystem/relays ) - relayson=$( exists $dirshm/relayson ) - stoptimer=$( exists $dirshm/stoptimer ) - updateaddons=$( exists $diraddons/update ) - if [[ -e $dirmpd/updating ]]; then - updating_db=true - if ! mpc | grep -q ^Updating; then - path=$( cat $dirmpd/updating ) - [[ $path == rescan ]] && mpc -q rescan || mpc -q update "$path" - fi - fi - [[ -e $dirshm/updatingdab ]] && updatingdab=true if [[ -e $dirshm/nosound && ! $btreceiver ]]; then volume=false else @@ -51,30 +35,28 @@ else control=$( echo $ccv | cut -d^ -f2 ) # keep trailing space if any volume=${ccv/*^} fi - scrobble=$( exists $dirsystem/scrobble ) - volumemute=$( cat $dirsystem/volumemute 2> /dev/null || echo 0 ) ######## status=' "player" : "'$player'" -, "btreceiver" : '$btreceiver' +, "btreceiver" : '$( exists $dirshm/btreceiver )' , "card" : '$card' -, "consume" : '$consume' +, "consume" : '$( mpc | grep -q 'consume: on' && echo true )' , "control" : "'$control'" -, "counts" : '$counts' +, "counts" : '$( cat $dirmpd/counts 2> /dev/null )' , "file" : "" , "icon" : "'$icon'" -, "librandom" : '$librandom' -, "relays" : '$relays' -, "relayson" : '$relayson' -, "scrobble" : '$scrobble' -, "stoptimer" : '$stoptimer' +, "librandom" : '$( exists $dirsystem/librandom )' +, "relays" : '$( exists $dirsystem/relays )' +, "relayson" : '$( exists $dirshm/relayson )' +, "scrobble" : '$( exists $dirsystem/scrobble )' +, "stoptimer" : '$( exists $dirshm/stoptimer )' , "stream" : false -, "updateaddons" : '$updateaddons' -, "updating_db" : '$updating_db' -, "updatingdab" : '$updatingdab' +, "updateaddons" : '$( exists $diraddons/update )' +, "updating_db" : '$( exists $dirmpd/updating )' +, "updatingdab" : '$( exists $dirshm/updatingdab )' , "volume" : '$volume' -, "volumemute" : '$volumemute' +, "volumemute" : '$( cat $dirsystem/volumemute 2> /dev/null || echo 0 )' , "webradio" : false' fi if [[ $1 == withdisplay ]]; then From c1a60140b5dd8f6bd1b8c6c4fb0bff535099d461 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 23 Sep 2022 18:57:01 +0700 Subject: [PATCH 037/237] Update system.sh --- srv/http/bash/settings/system.sh | 44 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index d8a7230d2..91a5175b8 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -663,28 +663,6 @@ servers ) fi pushRefresh ;; -shareddatadisable ) - copydata=${args[1]} - mountpoint=/srv/http/shareddata - ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) - sed -i "/$ip/ d" $mountpoint/iplist - [[ ! $( awk NF $mountpoint/iplist ) ]] && rm $mountpoint/iplist - for dir in audiocd bookmarks lyrics mpd playlists webradio; do - rm -rf $dirdata/$dir - [[ $copydata == true ]] && cp -rf $mountpoint/$dir $dirdata || mkdir $dirdata/$dir - done - umount -l $mountpoint - sed -i "\|$mountpoint| d" /etc/fstab - rm -rf $mountpoint - chown -R http:http $dirdata - chown -R mpd:audio $dirmpd - pushRefresh - if [[ $copydata == false ]]; then - rm -f $dirmpd/{updating,listing} - systemctl restart mpd - $dirbash/cmd.sh mpcupdate - fi - ;; shareddata ) protocol=${args[1]} ip=${args[2]} @@ -741,6 +719,28 @@ shareddata ) exit fi ;; +shareddatadisable ) + copydata=${args[1]} + mountpoint=/srv/http/shareddata + ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + sed -i "/$ip/ d" $mountpoint/iplist + [[ ! $( awk NF $mountpoint/iplist ) ]] && rm $mountpoint/iplist + for dir in audiocd bookmarks lyrics mpd playlists webradio; do + rm -rf $dirdata/$dir + [[ $copydata == true ]] && cp -rf $mountpoint/$dir $dirdata || mkdir $dirdata/$dir + done + umount -l $mountpoint + sed -i "\|$mountpoint| d" /etc/fstab + rm -rf $mountpoint + chown -R http:http $dirdata + chown -R mpd:audio $dirmpd + pushRefresh + if [[ $copydata == false ]]; then + rm -f $dirmpd/{updating,listing} + systemctl restart mpd + $dirbash/cmd.sh mpcupdate + fi + ;; soundprofile ) soundProfile ;; From eb0386b3653aeb5df3aea4651d064ea4c4716412 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 23 Sep 2022 18:59:23 +0700 Subject: [PATCH 038/237] Update startup.sh --- srv/http/bash/startup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srv/http/bash/startup.sh b/srv/http/bash/startup.sh index e474d6e14..ee482b9ff 100644 --- a/srv/http/bash/startup.sh +++ b/srv/http/bash/startup.sh @@ -139,8 +139,8 @@ if [[ -e $dirsystem/hddspindown ]]; then fi fi -if [[ ! $shareddata && ! -e $dirmpd/mpd.db ]]; then - $dirbash/cmd.sh$'\n'rescan +if [[ ! -e $dirmpd/mpd.db ]]; then + [[ ! $shareddata ]] && $dirbash/cmd.sh$'\n'rescan elif [[ -e $dirmpd/updating ]]; then path=$( cat $dirmpd/updating ) [[ $path == rescan ]] && mpc -q rescan || mpc -q update "$path" From d0103234944be34c1d59a07ebde474808c043504 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 23 Sep 2022 20:52:12 +0700 Subject: [PATCH 039/237] u --- srv/http/bash/cmd-list.sh | 8 +------- srv/http/bash/cmd.sh | 8 ++++---- srv/http/bash/settings/system.sh | 16 ++++++++++++++++ srv/http/bash/startup.sh | 5 +++-- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/srv/http/bash/cmd-list.sh b/srv/http/bash/cmd-list.sh index 8ffd42c5a..f2e97fb9c 100644 --- a/srv/http/bash/cmd-list.sh +++ b/srv/http/bash/cmd-list.sh @@ -146,13 +146,7 @@ if [[ $toolarge ]]; then pushstreamNotifyBlink 'Library Database' 'Library is too large.
Album list cannot be created.' 'refresh-library' fi -if [[ -e /srv/http/shareddata/iplist ]]; then - ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) - iplist=$( grep -v $ip /srv/http/shareddata/iplist ) - for ip in $iplist; do - sshCommand $ip $dirbash/cmd.sh shareddatareload - done -fi +[[ -e /srv/http/shareddata/iplist ]] && $dirbash/settings/system.sh shareddatalist reload ( nonutf8=$( mpc -f '/mnt/MPD/%file% [• %albumartist% ]• %artist% • %album% • %title%' listall | grep -axv '.*' ) diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index 8308830d2..29335c584 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -1113,6 +1113,10 @@ power ) sshCommand $ip $dirbash/cmd.sh playerstop done fi + if [[ -e /srv/http/shareddata/iplist ]]; then + ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + sed -i "/$ip/ d" /srv/http/shareddata/iplist + fi cdda=$( mpc -f %file%^%position% playlist | grep ^cdda: | cut -d^ -f2 ) [[ $cdda ]] && mpc -q del $cdda if [[ -e $dirshm/relayson ]]; then @@ -1230,10 +1234,6 @@ ${args[1]} ${args[2]} ${args[3]}" &> /dev/null & ;; -shareddatareload ) - systemctl restart mpd - pushstream mpdupdate "$( cat $dirmpd/counts )" - ;; thumbgif ) gifThumbnail "${args[@]:1}" ;; diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 91a5175b8..443de5cd0 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -741,6 +741,22 @@ shareddatadisable ) $dirbash/cmd.sh mpcupdate fi ;; +shareddatalist ) + reload=${args[1]} + list=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + iplist=$( grep -v $list /srv/http/shareddata/iplist ) + for ip in $iplist; do + if ping -4 -c 1 -w 1 $ip &> /dev/null; then + [[ $reload ]] && sshCommand $ip $dirbash/settings/system.sh shareddatarestart & >/dev/null & + list+=$'\n'$ip + fi + done + echo "$list" | sort -u > /srv/http/shareddata/iplist + ;; +shareddatarestart ) + systemctl restart mpd + pushstream mpdupdate "$( cat $dirmpd/counts )" + ;; soundprofile ) soundProfile ;; diff --git a/srv/http/bash/startup.sh b/srv/http/bash/startup.sh index ee482b9ff..ac4f50ba2 100644 --- a/srv/http/bash/startup.sh +++ b/srv/http/bash/startup.sh @@ -82,12 +82,12 @@ if [[ $nas ]]; then done fi if grep -q /srv/http/shareddata /etc/fstab; then - shareddata=1 mount /srv/http/shareddata for i in {1..5}; do sleep 1 [[ -d $dirmpd ]] && break done + $dirbash/settings/system.sh shareddatalist fi [[ -e /boot/startup.sh ]] && . /boot/startup.sh @@ -140,7 +140,8 @@ if [[ -e $dirsystem/hddspindown ]]; then fi if [[ ! -e $dirmpd/mpd.db ]]; then - [[ ! $shareddata ]] && $dirbash/cmd.sh$'\n'rescan + $dirbash/cmd.sh "mpcupdate +rescan" elif [[ -e $dirmpd/updating ]]; then path=$( cat $dirmpd/updating ) [[ $path == rescan ]] && mpc -q rescan || mpc -q update "$path" From f47d44a7dae59c34717fca4ca1afac1906a348cc Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 23 Sep 2022 20:54:04 +0700 Subject: [PATCH 040/237] Update startup.sh --- srv/http/bash/startup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/srv/http/bash/startup.sh b/srv/http/bash/startup.sh index ac4f50ba2..14164b0af 100644 --- a/srv/http/bash/startup.sh +++ b/srv/http/bash/startup.sh @@ -140,8 +140,7 @@ if [[ -e $dirsystem/hddspindown ]]; then fi if [[ ! -e $dirmpd/mpd.db ]]; then - $dirbash/cmd.sh "mpcupdate -rescan" + $dirbash/cmd.sh mpcupdate$'\n'rescan elif [[ -e $dirmpd/updating ]]; then path=$( cat $dirmpd/updating ) [[ $path == rescan ]] && mpc -q rescan || mpc -q update "$path" From 0497e85fde65bbba30860c8eaf8c30452ea49231 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 23 Sep 2022 21:06:21 +0700 Subject: [PATCH 041/237] Update main.js --- srv/http/assets/js/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srv/http/assets/js/main.js b/srv/http/assets/js/main.js index 0fe4910fd..71e7b3038 100644 --- a/srv/http/assets/js/main.js +++ b/srv/http/assets/js/main.js @@ -878,7 +878,8 @@ var btnctrl = { , coverB : 'stop' , coverBR : 'repeat' } -$( '.map' ).click( function() { +$( '.map' ).click( function( e ) { + e.stopPropagation(); if ( G.press ) return if ( $( '#info' ).hasClass( 'hide' ) ) { From 7255866b477db4b83bf7d363c2ca6c2d74e81420 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 24 Sep 2022 19:54:15 +0700 Subject: [PATCH 042/237] u --- etc/udev/rules.d/bluetooth.rules | 9 --------- etc/udev/rules.d/usbbluetooth.rules | 9 --------- etc/udev/rules.d/usbwifi.rules | 9 --------- install.sh | 10 ---------- 4 files changed, 37 deletions(-) delete mode 100644 etc/udev/rules.d/bluetooth.rules delete mode 100644 etc/udev/rules.d/usbbluetooth.rules delete mode 100644 etc/udev/rules.d/usbwifi.rules diff --git a/etc/udev/rules.d/bluetooth.rules b/etc/udev/rules.d/bluetooth.rules deleted file mode 100644 index 9b13bbacd..000000000 --- a/etc/udev/rules.d/bluetooth.rules +++ /dev/null @@ -1,9 +0,0 @@ -ACTION=="add", \ -SUBSYSTEM=="bluetooth", \ -ENV{DEVTYPE}=="link", \ -RUN+="/srv/http/bash/bluetoothcommand.sh connect" - -ACTION=="remove", \ -SUBSYSTEM=="bluetooth", \ -ENV{DEVTYPE}=="link", \ -RUN+="/srv/http/bash/bluetoothcommand.sh disconnect" diff --git a/etc/udev/rules.d/usbbluetooth.rules b/etc/udev/rules.d/usbbluetooth.rules deleted file mode 100644 index 558623caa..000000000 --- a/etc/udev/rules.d/usbbluetooth.rules +++ /dev/null @@ -1,9 +0,0 @@ -ACTION=="add", \ -SUBSYSTEM=="bluetooth", \ -ENV{DEVTYPE}=="host", \ -RUN+="/srv/http/bash/settings/networks.sh usbbluetoothon" - -ACTION=="remove", \ -SUBSYSTEM=="bluetooth", \ -ENV{DEVTYPE}=="host", \ -RUN+="/srv/http/bash/settings/networks.sh usbbluetoothoff" diff --git a/etc/udev/rules.d/usbwifi.rules b/etc/udev/rules.d/usbwifi.rules deleted file mode 100644 index 40d8f6c14..000000000 --- a/etc/udev/rules.d/usbwifi.rules +++ /dev/null @@ -1,9 +0,0 @@ -ACTION=="add", \ -SUBSYSTEMS=="usb", \ -SUBSYSTEM=="net", \ -RUN+="/srv/http/bash/settings/networks.sh usbwifion" - -ACTION=="remove", \ -SUBSYSTEMS=="usb", \ -SUBSYSTEM=="net", \ -RUN+="/srv/http/bash/settings/networks.sh usbwifioff" diff --git a/install.sh b/install.sh index d29e70eee..47d9ab0b6 100644 --- a/install.sh +++ b/install.sh @@ -86,9 +86,6 @@ installfinish #------------------------------------------------------------------------------- # 20220808 -udevadm control --reload-rules -udevadm trigger - if [[ -e /srv/http/shareddata/webradios ]]; then echo -e "\ $info Shared data: @@ -99,10 +96,3 @@ $info Shared data: • Re-enable again. " fi - -if [[ -e /usr/bin/rtsp-simple-server && ! -e $dirdata/dabradio ]]; then - echo -e "\ -$info DAB Radio: - • Rescan for stations again. -" -fi From 48a7d42514a6abb1e7d6dd09164528ffc154c908 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 24 Sep 2022 20:04:48 +0700 Subject: [PATCH 043/237] Update install.sh --- install.sh | 44 +------------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/install.sh b/install.sh index 47d9ab0b6..9241c1124 100644 --- a/install.sh +++ b/install.sh @@ -14,7 +14,7 @@ if [[ ! -e $dir/1.jpg ]]; then fi file=/etc/systemd/system/dab.service -if [[ ! -e $file ]]; then +if [[ -e /usr/bin/rtl_sdr && ! -e $file ]]; then echo "\ [Unit] Description=DAB Radio metadata @@ -41,36 +41,6 @@ fi # 20220826 rm /srv/http/bash/{camilladsp*,features*,networks*,player*,relays*,system*} &> /dev/null -# 20220814 -sed -i '/bluez-utils/ d' /etc/pacman.conf - -# 20220808 -dirdata=/srv/http/data - -dab=$( pacman -Q dab-scanner 2> /dev/null ) -if [[ $dab && $dab != 'dab-scanner 0.8-3' ]]; then - rm -f /etc/rtsp-simple-server.yml $dirdata/webradiosimg/{dablogo*,rtsp*8554*} - rm -rf /srv/http/bash/dab $dirdata/webradios/DAB - pacman -Sy --noconfirm dab-scanner -fi - -if [[ -e $dirdata/webradios ]]; then - mv $dirdata/webradio{s,} - mv $dirdata/{webradiosimg,webradio/img} -fi - -grep -A1 'plugin.*ffmpeg' /etc/mpd.conf | grep -q no && sed -i '/decoder/,+4 d' /etc/mpd.conf - -if [[ $( uname -m ) == armv6l && $( uname -r ) != 5.10.92-2-rpi-legacy-ARCH ]]; then - echo Downgrade kernel to 5.10.92 ... - pkgfile=linux-rpi-legacy-5.10.92-2-armv6h.pkg.tar.xz - curl -skLO https://github.com/rern/_assets/raw/master/$pkgfile - pacman -U --noconfirm $pkgfile - rm $pkgfile -fi - -grep -q gpio-poweroff /boot/config.txt && sed -i '/gpio-poweroff\|gpio-shutdown/ d' /boot/config.txt - #------------------------------------------------------------------------------- . /srv/http/bash/addons.sh @@ -84,15 +54,3 @@ $dirbash/cmd.sh dirpermissions installfinish #------------------------------------------------------------------------------- - -# 20220808 -if [[ -e /srv/http/shareddata/webradios ]]; then - echo -e "\ -$info Shared data: - • Disable - • On server - - Rename: $( tcolor webradios 1 ) > $( tcolor webradio 2 ) - - Move: $( tcolor webradiosimg 1 ) > $( tcolor webradio/img 2 ) - • Re-enable again. -" -fi From bd314970ed4b0fe06073096f7ec9859a99b64914 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 25 Sep 2022 13:22:09 +0700 Subject: [PATCH 044/237] u --- srv/http/assets/js/system.js | 95 ++++++++++++++------------- srv/http/bash/settings/system-data.sh | 2 +- srv/http/settings/system.php | 12 ++-- 3 files changed, 55 insertions(+), 54 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index b787ac1e3..651ca7845 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -680,36 +680,6 @@ $( '#setting-soundprofile' ).click( function() { } } ); } ); -$( '#shareddata' ).click( function() { - if ( G.shareddata ) { - info( { - icon : 'networks' - , title : 'Shared Data' - , radio : { 'Copy shared data to local': true, 'Rebuild entire database': false } - , values : [ true ] - , cancel : function() { - $( '#shareddata' ).prop( 'checked', true ); - } - , okcolor : orange - , oklabel : 'Disable' - , ok : function() { - bash( [ 'shareddatadisable', infoVal() ] ); - notify( 'Shared Data', 'Disable ...', 'networks' ); - } - } ); - } else { - if ( $( '#list .fa-networks' ).length ) { - infoMount( 'shareddata' ); - } else { - info( { - icon : 'networks' - , title : 'Shared Data' - , message : 'Connect music share before enable Shared Data.' - } ); - $( '#shareddata' ).prop( 'checked', false ); - } - } -} ); $( '#backup' ).click( function() { var backuptitle = 'Backup Settings'; var icon = 'sd'; @@ -817,6 +787,36 @@ $( '#restore' ).click( function() { } ); $( '#restore' ).prop( 'checked', 0 ); } ); +$( '#shareddata' ).click( function() { + if ( G.shareddata ) { + info( { + icon : 'networks' + , title : 'Shared Data' + , radio : { 'Copy shared data to local': true, 'Rebuild entire database': false } + , values : [ true ] + , cancel : function() { + $( '#shareddata' ).prop( 'checked', true ); + } + , okcolor : orange + , oklabel : 'Disable' + , ok : function() { + bash( [ 'shareddatadisable', infoVal() ] ); + notify( 'Shared Data', 'Disable ...', 'networks' ); + } + } ); + } else { + if ( $( '#list .fa-networks' ).length ) { + infoMount( 'shareddata' ); + } else { + info( { + icon : 'networks' + , title : 'Shared Data' + , message : 'Connect music share before enable Shared Data.' + } ); + $( '#shareddata' ).prop( 'checked', false ); + } + } +} ); $( '.listtitle' ).click( function( e ) { var $this = $( this ); var $chevron = $this.find( 'i' ); @@ -853,20 +853,18 @@ $( '.listtitle' ).click( function( e ) { function infoMount( values ) { var ip = $( '#list' ).data( 'ip' ); var ipsub = ip.substring( 0, ip.lastIndexOf( '.') + 1 ); - var shareddata = false; - if ( !values || values.length === 8 ) { + if ( values === 'shareddata' ) { + var shareddata = true; + values = [ 'cifs', ipsub, '', '', '', '', false ]; + var htmlname = ''; + var chktext = 'Use data from this rAudio' + } else { + var shareddata = false; var htmlname = `\ -As: NAS/ - +Name + `; var chktext = 'Update Library on mount' - } else { - if ( values === 'shareddata' ) { - var shareddata = true; - values = [ 'cifs', ipsub, '', '', '', '', false ]; - } - var htmlname = ''; - var chktext = 'Use data from this rAudio' } var htmlmount = `\ @@ -904,15 +902,18 @@ ${ htmlname } $( '#infoContent td' ).eq( 1 ).css( 'width', 230 ); var $share = $( '#share' ); function hideOptions( type ) { - $share.val( '' ); if ( type === 'nfs' ) { $( '#sharelabel' ).text( 'Share path' ); $( '.guest' ).addClass( 'hide' ); - $share.attr( 'placeholder', '/path/to/share' ); + var placeholder = '/path/to/share on server'; } else { $( '#sharelabel' ).text( 'Share name' ); $( '.guest' ).removeClass( 'hide' ); - $share.attr( 'placeholder', 'sharename' ); + var placeholder = 'sharename on server'; + } + if ( !values ) { + $( '#mountpoint' ).attr( 'placeholder', 'for Library > NAS > "Name" ' ); + $share.attr( 'placeholder', placeholder ); } } hideOptions( values ? values[ 0 ] : 'cifs' ); @@ -948,7 +949,9 @@ ${ htmlname } , title : shareddata ? 'Shared Data' : 'Mount Share' , message : error , ok : function() { - infoMount( values ); + setTimeout( function() { + infoMount( values ); + }, 0 ); } } ); bannerHide(); @@ -956,7 +959,7 @@ ${ htmlname } refreshData(); } } ); - if ( shareddata ) { + if ( shareddata ) { notify( 'Shared Data', 'Enable ...', 'networks' ); } else { notify( 'Network Mount', 'Mount ...', 'networks' ); diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index f66f784c2..9e5294d70 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -88,7 +88,7 @@ if [[ $usb ]]; then fi done fi -nas=$( awk '/\/mnt\/MPD\/NAS/ {print $1" "$2}' /etc/fstab ) +nas=$( awk '/.mnt.MPD.NAS|.srv.http.shareddata/ {print $1" "$2}' /etc/fstab ) if [[ $nas ]]; then readarray -t nas <<< "$nas" for line in "${nas[@]}"; do diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index d50cb1954..227edaa63 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -87,7 +87,7 @@ • If mount failed, try in SSH terminal:
 mkdir -p "/mnt/MPD/NAS/NAME"
-# CIFS:
+# CIFS: (Remove username=USER,password=PASSWORD, if blank)
 mount -t cifs "//IP/SHARENAME" "/mnt/MPD/NAS/NAME" \
       -o noauto,username=USER,password=PASSWORD,uid=,gid=,iocharset=utf8
 # NFS:
@@ -328,13 +328,11 @@
  • On file server, setup a network share with all permissions
    • NFS: 777 / a+rwx
    • Samba: read only = no
-   • Windows: Everyone - Full Control
+   • Windows: Everyone - Full Control (Sharing and Security tabs)
  • On each rAudio
-    • Storage  Add to connect shared music on the server
-    • Shared Data - Enable to connect the share.
- • Use data from this rAudio:
-   • Check only on rAudio with data to be used or to overwrite existing.
-   • Leave unchecked to use existing data on the server.
+   • Storage  Add to connect shared music on the server
+   • Enable to connect the shared data
+   • Use data from this rAudio: Check only on rAudio with data to be shared or to overwrite existing
 HTML
 	]
 ];

From 59ace436b06356ca9ab3942914fa170121f29f7f Mon Sep 17 00:00:00 2001
From: rern 
Date: Sun, 25 Sep 2022 13:34:28 +0700
Subject: [PATCH 045/237] Update system.php

---
 srv/http/settings/system.php | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php
index 227edaa63..c70cd4654 100644
--- a/srv/http/settings/system.php
+++ b/srv/http/settings/system.php
@@ -330,9 +330,8 @@
    • Samba: read only = no
    • Windows: Everyone - Full Control (Sharing and Security tabs)
  • On each rAudio
-   • Storage  Add to connect shared music on the server
    • Enable to connect the shared data
-   • Use data from this rAudio: Check only on rAudio with data to be shared or to overwrite existing
+   • Check Use data from this rAudio only on rAudio with data to be shared or to overwrite existing
 HTML
 	]
 ];

From 1a9bb5a2140274c6d4b12e63625cd35efe5dd645 Mon Sep 17 00:00:00 2001
From: rern 
Date: Sun, 25 Sep 2022 13:51:03 +0700
Subject: [PATCH 046/237] Update passive.js

---
 srv/http/assets/js/passive.js | 49 +++++++++++++----------------------
 1 file changed, 18 insertions(+), 31 deletions(-)

diff --git a/srv/http/assets/js/passive.js b/srv/http/assets/js/passive.js
index 1467e95e5..788ae6788 100644
--- a/srv/http/assets/js/passive.js
+++ b/srv/http/assets/js/passive.js
@@ -358,44 +358,31 @@ function psMpdUpdate( data ) {
 		G.status.updatingdab = false;
 		renderLibraryCounts();
 		setButtonUpdating();
-		if ( G.librarylist ) {
-			var lipath = $( '#lib-path .lipath' ).text();
-			if ( G.query.length ) {
-				var query = G.query[ G.query.length - 1 ];
-			} else {
-				var query = {
-					  query  : 'ls'
-					, string : lipath
-					, format : [ 'file' ]
-				}
-			}
-			list( query, function( html ) {
-				var data = {
-					  html      : html
-					, modetitle : lipath
-					, path      : lipath
-				}
-				renderLibraryList( data );
-			} );
-		}
 		banner( 'Library Update', 'Done', 'library' );
 		if ( G.library ) {
-			if ( !G.librarylist ) return
+			if ( G.librarylist ) return
 			
 			if ( G.mode === 'webradio' ) {
 				data.webradio ? $( '#mode-webradio' ).click() : $( '#button-library' ).click();
 			} else {
-				var query = G.query[ G.query.length - 1 ];
-				if ( query ) {
-					list( query, function( html ) {
-						var data = {
-							  html      : html
-							, modetitle : query.modetitle
-							, path      : query.path
-						}
-						renderLibraryList( data );
-					} );
+				var lipath = $( '#lib-path .lipath' ).text();
+				if ( G.query.length ) {
+					var query = G.query[ G.query.length - 1 ];
+				} else {
+					var query = {
+						  query  : 'ls'
+						, string : lipath
+						, format : [ 'file' ]
+					}
 				}
+				list( query, function( html ) {
+					var data = {
+						  html      : html
+						, modetitle : lipath
+						, path      : lipath
+					}
+					renderLibraryList( data );
+				} );
 			}
 		} else if ( G.playlist && !G.savedlist ) {
 			$( '#playlist' ).click();

From befcf2c87dec2d113163d1a520ad7f6590923e4a Mon Sep 17 00:00:00 2001
From: rern 
Date: Sun, 25 Sep 2022 15:00:56 +0700
Subject: [PATCH 047/237] Update system.php

---
 srv/http/settings/system.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php
index c70cd4654..6cdb8bdcc 100644
--- a/srv/http/settings/system.php
+++ b/srv/http/settings/system.php
@@ -324,12 +324,13 @@
 		, 'help'    => <<< HTML
 Share data for multiple rAudios: audio CD, bookmarks, lyrics, Library database, saved playlists and Web Radio stations. 
  • SSH passwords must be default.
- • Music files should be on NAS only.
+ • Music files should be on NAS only, no local music files.
  • On file server, setup a network share with all permissions
    • NFS: 777 / a+rwx
    • Samba: read only = no
    • Windows: Everyone - Full Control (Sharing and Security tabs)
  • On each rAudio
+   • Connect shared music files
    • Enable to connect the shared data
    • Check Use data from this rAudio only on rAudio with data to be shared or to overwrite existing
 HTML

From 7c5861e909abf85377e88915714e48262e3119bc Mon Sep 17 00:00:00 2001
From: rern 
Date: Sun, 25 Sep 2022 17:38:16 +0700
Subject: [PATCH 048/237] remove renice

---
 install.sh                            |  8 +++-
 srv/http/bash/cmd.sh                  | 63 ++++++++++++++++-----------
 srv/http/bash/mpdidle.sh              |  5 ---
 srv/http/bash/settings/player-conf.sh |  4 ++
 4 files changed, 47 insertions(+), 33 deletions(-)

diff --git a/install.sh b/install.sh
index 9241c1124..43a3fae89 100644
--- a/install.sh
+++ b/install.sh
@@ -2,7 +2,7 @@
 
 alias=r1
 
-# 20220923
+# 20220926
 dir=/srv/http/assets/img/guide
 if [[ ! -e $dir/1.jpg ]]; then
 	mkdir -p $dir
@@ -23,9 +23,13 @@ Description=DAB Radio metadata
 Type=simple
 ExecStart=/srv/http/bash/status-dab.sh
 " > $file
-	systemctl daemon-reload
 fi
 
+sed -i '/ExecStartPost/ d' /etc/systemd/system/spotifyd.service &> /dev/null
+sed -i '/ExecStartPost/ d' /etc/systemd/system/upmpdcli.service &> /dev/null
+
+systemctl daemon-reload
+
 # 20220916
 dirmpd=/srv/http/data/mpd
 if (( $( cat $dirmpd/counts | wc -l ) == 1 )); then
diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh
index 29335c584..fda76908d 100644
--- a/srv/http/bash/cmd.sh
+++ b/srv/http/bash/cmd.sh
@@ -119,6 +119,18 @@ mpdoledLogo() {
 	type=$( grep mpd_oled /etc/systemd/system/mpd_oled.service | cut -d' ' -f3 )
 	mpd_oled -o $type -L
 }
+reniceProcess() {
+	if [[ $2 == reset ]]; then
+		for pid in $( pgrep $1 ); do
+			renice -n 0 -p $pid &> /dev/null
+		done
+	else
+		for pid in $( pgrep $1 ); do
+			ionice -c 0 -n 0 -p $pid &> /dev/null 
+			renice -n -19 -p $pid &> /dev/null
+		done
+	fi
+}
 plAddPlay() {
 	pushstreamPlaylist add
 	if [[ ${1: -4} == play ]]; then
@@ -982,12 +994,6 @@ mpcupdate )
 mpdoledlogo )
 	mpdoledLogo
 	;;
-nicespotify )
-	for pid in $( pgrep spotifyd ); do
-		ionice -c 0 -n 0 -p $pid &> /dev/null 
-		renice -n -19 -p $pid &> /dev/null
-	done
-	;;
 ordersave )
 	data=$( jq <<< ${args[1]} )
 	pushstream order "$data"
@@ -1022,27 +1028,29 @@ $( cat /etc/dnsmasq.conf )";;
 			catconf="
 # rtl_test -t
 $( script -c "timeout 1 rtl_test -t" | grep -v ^Script )";;
+		nfs-server )
+			pkg=nfs-utils;;
 		smb )
 			fileconf=/etc/samba/smb.conf
 			pkg=samba;;
 		snapclient|snapserver )
 			[[ $id == snapclient ]] && fileconf=/etc/default/snapclient
-			pkg=snapcast
-			service=$id;;
+			pkg=snapcast;;
 		* )
 			fileconf=/etc/$id.conf;;
 	esac
-	[[ -e $fileconf ]] && catconf="
+	conf="$( pacman -Q $pkg )"
+	[[ -e $fileconf ]] && conf+="
 # cat $fileconf
 $( cat $fileconf )"
-	[[ $id != camilladsp ]] && version=$( pacman -Q $pkg ) || version=$( camilladsp -V )
+	status=$( systemctl status $service \
+					| sed -E '1 s|^.* (.*service) |\1|' \
+					| sed -E '/^\s*Active:/ s|( active \(.*\))|\1|; s|( inactive \(.*\))|\1|; s|(failed)|\1|ig' )
+	[[ $pkg == chromium ]] && status=$( echo "$status" | grep -E -v 'Could not resolve keysym|Address family not supported by protocol|ERROR:chrome_browser_main_extra_parts_metrics' )
 	echo "\
-$version$catconf
+$conf
 
-$( systemctl status $service \
-	| sed -E '1 s|^.* (.*service)|\1|' \
-	| sed -E '/^\s*Active:/ s|( active \(.*\))|\1|; s|( inactive \(.*\))|\1|; s|(failed)|\1|ig' \
-	| grep -E -v 'Could not resolve keysym|Address family not supported by protocol|ERROR:chrome_browser_main_extra_parts_metrics' )" # omit warning by xkeyboard | chromium
+$status"
 	;;
 playerstart )
 	newplayer=${args[1]}
@@ -1052,11 +1060,17 @@ playerstart )
 	player=$( cat $dirshm/player )
 	echo $newplayer > $dirshm/player
 	case $player in
-		airplay )   restart=shairport-sync;;
-		mpd|upnp )  restart=mpd;;
-		spotify )   restart=spotifyd;;
+		airplay )     service=shairport-sync;;
+		mpd | upnp )  service=mpd;;
+		spotify )     service=spotifyd;;
 	esac
-	[[ $restart ]] && systemctl restart $restart || snapclientStop
+	if [[ $service ]]; then
+		systemctl restart $service
+		reniceProcess $service
+		[[ $service != mpd ]] && reniceProcess mpd reset
+	else
+		snapclientStop
+	fi
 	pushstream player '{"player":"'$newplayer'","active":true}'
 	;;
 playerstop )
@@ -1093,7 +1107,10 @@ playerstop )
 			$dirbash/status-push.sh
 			;;
 	esac
-	[[ $service && $service != snapclient ]] && systemctl restart $service
+	if [[ $service && $service != snapclient ]]; then
+		systemctl restart $service
+		reniceProcess $service reset
+	fi
 	pushstream player '{"player":"'$player'","active":false}'
 	[[ -e $dirshm/scrobble && $elapsed ]] && scrobbleOnStop $elapsed
 	;;
@@ -1240,12 +1257,6 @@ thumbgif )
 thumbjpg )
 	jpgThumbnail "${args[@]:1}"
 	;;
-upnpnice )
-	for pid in $( pgrep upmpdcli ); do
-		ionice -c 0 -n 0 -p $pid &> /dev/null 
-		renice -n -19 -p $pid &> /dev/null
-	done
-	;;
 volume ) # no args = toggle mute / unmute
 	current=${args[1]}
 	target=${args[2]}
diff --git a/srv/http/bash/mpdidle.sh b/srv/http/bash/mpdidle.sh
index d4a545268..4a7c6180d 100644
--- a/srv/http/bash/mpdidle.sh
+++ b/srv/http/bash/mpdidle.sh
@@ -2,11 +2,6 @@
 
 . /srv/http/bash/common.sh
 
-for pid in $( pgrep mpd ); do
-	ionice -c 0 -n 0 -p $pid &> /dev/null 
-	renice -n -19 -p $pid &> /dev/null
-done
-
 mpc idleloop | while read changed; do
 	case $changed in
 		mixer ) # for upmpdcli
diff --git a/srv/http/bash/settings/player-conf.sh b/srv/http/bash/settings/player-conf.sh
index 0381f797b..5a97b28f9 100644
--- a/srv/http/bash/settings/player-conf.sh
+++ b/srv/http/bash/settings/player-conf.sh
@@ -158,6 +158,10 @@ fi
 
 ### mpd start ##########################################################################
 systemctl restart mpd
+for pid in $( pgrep mpd ); do # set priority
+	ionice -c 0 -n 0 -p $pid &> /dev/null 
+	renice -n -19 -p $pid &> /dev/null
+done
 
 if [[ -e $dirmpd/updating ]]; then
 	path=$( cat $dirmpd/updating )

From b15bcea7bc5b5dfda8547276a73a555b3ded2438 Mon Sep 17 00:00:00 2001
From: rern 
Date: Sun, 25 Sep 2022 21:59:02 +0700
Subject: [PATCH 049/237] u

---
 srv/http/assets/js/features.js        |  4 +--
 srv/http/assets/js/settings.js        |  1 +
 srv/http/assets/js/system.js          | 36 +++++++++++++++++++++--
 srv/http/bash/cmd.sh                  | 38 +++++++++++++++----------
 srv/http/bash/settings/features.sh    |  6 ----
 srv/http/bash/settings/system-data.sh |  5 ++++
 srv/http/bash/settings/system.sh      | 22 ++++++++++++++
 srv/http/settings/system.php          | 41 +++++++++++++++++++--------
 8 files changed, 116 insertions(+), 37 deletions(-)

diff --git a/srv/http/assets/js/features.js b/srv/http/assets/js/features.js
index 24758f848..e5b2ea8e2 100644
--- a/srv/http/assets/js/features.js
+++ b/srv/http/assets/js/features.js
@@ -382,8 +382,6 @@ $( '#setting-login' ).click( function() {
 		}
 	} );
 } );
-
-} );
 $( '#setting-scrobble' ).click( function() {
 	var content = `\
 
@@ -462,6 +460,8 @@ $( '#setting-stoptimer' ).click( function() { } ); } ); +} ); + function passwordWrong() { info( { icon : 'lock' diff --git a/srv/http/assets/js/settings.js b/srv/http/assets/js/settings.js index 97f6e0bdc..8c0d28f3a 100644 --- a/srv/http/assets/js/settings.js +++ b/srv/http/assets/js/settings.js @@ -45,6 +45,7 @@ var services = [ , 'hostapd' , 'localbrowser' , 'mpd' + , 'nfs-server' , 'shairport-sync' , 'smb' , 'snapclient' diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 651ca7845..9e252e07a 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -96,8 +96,9 @@ $( '#list' ).on( 'click', 'li', function( e ) { } $this.addClass( 'active' ); - $( '#menu' ).find( '.info, .spindown' ).toggleClass( 'hide', mountpoint.slice( 9, 12 ) !== 'USB' ); - $( '#menu' ).find( '.remount' ).toggleClass( 'hide', G.list[ $this.index() ].mounted ); + $( '#menu .info, .spindown' ).toggleClass( 'hide', mountpoint.slice( 9, 12 ) !== 'USB' ); + $( '#menu .remount' ).toggleClass( 'hide', G.list[ $this.index() ].mounted ); + $( '#menu .unmount' ).toggleClass( 'hide', !G.list[ $this.index() ].mounted ); var menuH = $( '#menu' ).height(); $( '#menu' ) .removeClass( 'hide' ) @@ -169,6 +170,37 @@ $( '#menu a' ).click( function() { break; } } ); +$( '#setting-nfs' ).click( function() { + info( { + icon : 'networks' + , title : 'NFS Server' + , message : 'Write permission:' + , checkbox : [ '/mnt/MPD/SD', '/mnt/MPD/USB' ] + , values : G.nfsconf + , checkchanged : ( G.nfs ? 1 : 0 ) + , beforeshow : function() { + var $chk = $( '#infoContent input' ); + $chk.eq( 2 ).change( function() { + if ( $( this ).prop( 'checked' ) ) { + $chk.prop( 'checked', 1 ); + } else { + $chk.eq( 0 ).prop( 'checked', G.nfsconf[ 0 ] ); + $chk.eq( 1 ).prop( 'checked', G.nfsconf[ 1 ] ); + } + } ); + } + , cancel : function() { + $( '#nfs-server' ).prop( 'checked', G.nfs ); + } + , ok : function() { + var val = infoVal(); + var permsd = val[ 0 ] ? 777 : 755; + var permusb = val[ 1 ] ? 777 : 755; + bash( [ 'nfsset', permsd, permusb ] ); + notify( 'NFS Server', G.nfs ? 'Change ...' : 'Enable ...', 'networks' ); + } + } ); +} ); $( '#setting-bluetooth' ).click( function() { info( { icon : 'bluetooth' diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index fda76908d..ef129168a 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -1014,22 +1014,13 @@ pkgstatus ) case $id in camilladsp ) fileconf=$dircamilladsp/configs/camilladsp.yml;; - hostapd ) - catconf=" -# cat /etc/hostapd/hostapd.conf -$( cat /etc/hostapd/hostapd.conf ) - -# cat /etc/dnsmasq.conf -$( cat /etc/dnsmasq.conf )";; localbrowser ) fileconf=$dirsystem/localbrowser.conf pkg=chromium;; - rtsp-simple-server ) - catconf=" -# rtl_test -t -$( script -c "timeout 1 rtl_test -t" | grep -v ^Script )";; nfs-server ) - pkg=nfs-utils;; + pkg=nfs-utils + fileconf=/etc/exports + ;; smb ) fileconf=/etc/samba/smb.conf pkg=samba;; @@ -1040,13 +1031,30 @@ $( script -c "timeout 1 rtl_test -t" | grep -v ^Script )";; fileconf=/etc/$id.conf;; esac conf="$( pacman -Q $pkg )" - [[ -e $fileconf ]] && conf+=" + if [[ -e $fileconf ]]; then + conf+=" # cat $fileconf -$( cat $fileconf )" +$( grep -v ^# $fileconf )" + elif [[ $pkg == hostapd ]]; then + conf+=" +# cat /etc/hostapd/hostapd.conf +$( cat /etc/hostapd/hostapd.conf ) + +# cat /etc/dnsmasq.conf +$( cat /etc/dnsmasq.conf )" + elif [[ $pkg == rtsp-simple-server ]]; then + conf+=" +# rtl_test -t +$( script -c "timeout 1 rtl_test -t" | grep -v ^Script )" + fi status=$( systemctl status $service \ | sed -E '1 s|^.* (.*service) |\1|' \ | sed -E '/^\s*Active:/ s|( active \(.*\))|\1|; s|( inactive \(.*\))|\1|; s|(failed)|\1|ig' ) - [[ $pkg == chromium ]] && status=$( echo "$status" | grep -E -v 'Could not resolve keysym|Address family not supported by protocol|ERROR:chrome_browser_main_extra_parts_metrics' ) + if [[ $pkg == chromium ]]; then + status=$( echo "$status" | grep -E -v 'Could not resolve keysym|Address family not supported by protocol|ERROR:chrome_browser_main_extra_parts_metrics' ) + elif [[ $pkg == nfs-utils ]]; then + status=$( echo "$status" | grep -v 'Protocol not supported' ) + fi echo "\ $conf diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index f75c63225..e465c6d15 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -334,12 +334,6 @@ shairport-sync | spotifyd | upmpdcli ) systemctl disable --now $service fi pushRefresh - if [[ $service == shairport-sync ]]; then - for pid in $( pgrep shairport-sync ); do - ionice -c 0 -n 0 -p $pid &> /dev/null - renice -n -19 -p $pid &> /dev/null - done - fi ;; smbdisable ) systemctl disable --now smb diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 9e5294d70..1b88fd203 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -140,6 +140,9 @@ oledchip=$( grep mpd_oled /etc/systemd/system/mpd_oled.service | cut -d' ' -f3 ) baudrate=$( grep baudrate /boot/config.txt | cut -d= -f3 ) [[ ! $baudrate ]] && baudrate=800000 mpdoledconf='[ '$oledchip', '$baudrate' ]' +[[ $( stat -c %a /mnt/MPD/SD ) == 777 ]] && permsd=true +[[ $( stat -c %a /mnt/MPD/USB ) == 777 ]] && permusb=true +grep -q /srv/http/shareddata /etc/exports && nfsshareddata=true [[ -e $dirsystem/audiophonics ]] && audiophonics=true || audiophonics=false if [[ -e $dirsystem/powerbutton.conf ]]; then powerbuttonconf="[ $( cat $dirsystem/powerbutton.conf | cut -d= -f2 | xargs | tr ' ' , ), $audiophonics ]" @@ -174,6 +177,8 @@ data+=' , "lcdmodel" : "'$( cat $dirsystem/lcdmodel 2> /dev/null || echo tft35a )'" , "mpdoled" : '$( exists $dirsystem/mpdoled )' , "mpdoledconf" : '$mpdoledconf' +, "nfs" : '$( isactive nfs-server )' +, "nfsconf" : [ '$permsd', '$permusb', '$nfsshareddata' ] , "ntp" : "'$( grep '^NTP' /etc/systemd/timesyncd.conf | cut -d= -f2 )'" , "powerbutton" : '$( systemctl -q is-active powerbutton || [[ $audiophonics == true ]] && echo true )' , "powerbuttonconf" : '$powerbuttonconf' diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 443de5cd0..05b484520 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -526,6 +526,28 @@ mpdoledset ) pushRefresh fi ;; +nfsdisable ) + systemctl disable --now nfs-server + sed -i '/^.mnt.MPD\|^.srv.http/ d' /etc/exports + chmod 755 /mnt/MPD/{SD,USB} + pushRefresh + ;; +nfsset ) + permsd=${args[1]} + permusb=${args[2]} + chmod $permsd /mnt/MPD/SD + chmod $permusb /mnt/MPD/USB + mkdir -p /srv/http/shareddata + chmod 777 /srv/http/shareddata + routerip=$( ip r get 1 | head -1 | cut -d' ' -f3 ) + ip_options="${routerip%.*}.0/24(rw,sync,no_subtree_check)" + ! grep -q /mnt/MPD/ /etc/exports && echo -n "\ +/mnt/MPD/SD $ip_options +/mnt/MPD/USB $ip_options +/srv/http/shareddata $ip_options" >> /etc/exports + systemctl enable --now nfs-server + pushRefresh + ;; packagelist ) filepackages=$dirtmp/packages if [[ ! -e $filepackages ]]; then diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 6cdb8bdcc..1cf66c2b1 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -97,14 +97,28 @@
 'Auto Update'
-		, 'id'       => 'usbautoupdate'
-		, 'sublabel' => 'USB Drives'
-		, 'icon'     => 'refresh-library'
-		, 'help'     => <<< HTML
+	  'label'    => 'Auto Update'
+	, 'id'       => 'usbautoupdate'
+	, 'sublabel' => 'USB Drives'
+	, 'icon'     => 'refresh-library'
+	, 'help'     => <<< HTML
 Auto update Library database on insert / remove USB drives.
 HTML
-	] );
+] );
+htmlSetting( [
+	  'label'    => 'NFS Server'
+	, 'id'       => 'nfs'
+	, 'sublabel' => 'nfs-server'
+	, 'icon'     => 'networks'
+	, 'setting'  => true
+	, 'status'   => 'nfs-server'
+	, 'help'     => <<< HTML
+Network File System for:
+ • /mnt/MPD/SD
+ • /mnt/MPD/USB
+ • /srv/http/shareddata
+HTML
+] );
 echo '';
 if ( file_exists( '/srv/http/data/shm/onboardwlan' ) ) {
 // ----------------------------------------------------------------------------------
@@ -324,13 +338,16 @@
 		, 'help'    => <<< HTML
 Share data for multiple rAudios: audio CD, bookmarks, lyrics, Library database, saved playlists and Web Radio stations. 
  • SSH passwords must be default.
- • Music files should be on NAS only, no local music files.
- • On file server, setup a network share with all permissions
-   • NFS: 777 / a+rwx
-   • Samba: read only = no
-   • Windows: Everyone - Full Control (Sharing and Security tabs)
+ • Music files should be on NAS only.
+ • On file server:
+   • rAudio as music file server: Enable NFS Server with write permissions
+   • Remote file server: setup a network share with all permissions
+     • NFS: 777 / a+rwx
+     • Samba: read only = no
+     • Windows: Everyone - Full Control (Sharing and Security tabs)
  • On each rAudio
-   • Connect shared music files
+   • Storage  Add shared music
+   • For rAudio as server, also add the share to itself
    • Enable to connect the shared data
    • Check Use data from this rAudio only on rAudio with data to be shared or to overwrite existing
 HTML

From a3c8e26334947fe83a85767ed2588bbea70efc75 Mon Sep 17 00:00:00 2001
From: rern 
Date: Mon, 26 Sep 2022 08:32:45 +0700
Subject: [PATCH 050/237] u

---
 srv/http/assets/css/common.css | 3 +++
 srv/http/assets/js/system.js   | 8 ++------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/srv/http/assets/css/common.css b/srv/http/assets/css/common.css
index c220f29fd..2e4611c53 100644
--- a/srv/http/assets/css/common.css
+++ b/srv/http/assets/css/common.css
@@ -96,6 +96,9 @@ input::-moz-focus-inner {
 .splash svg {
 	animation: none !important;
 }
+::placeholder {
+	color: var( --cg );
+}
 
 .fa {
 	display: inline-block;
diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js
index 9e252e07a..9f87a61a9 100644
--- a/srv/http/assets/js/system.js
+++ b/srv/http/assets/js/system.js
@@ -960,12 +960,8 @@ ${ htmlname }
 			} );
 			$share.on( 'keyup paste', function() {
 				setTimeout( function() {
-					var sharename = $share.val();
-					if ( $( '#infoContent input[type=radio]:checked' ).val() === 'cifs' ) {
-						$share.val( sharename.replace( /[\/\\]/g, '' ) );
-					} else {
-						if ( sharename[ 0 ] !== '/' ) $share.val( '/'+ sharename );
-					}
+					var slash = $( '#infoContent input[type=radio]:checked' ).val() === 'cifs' ? /[\/\\]/g : /\\//g;
+					$share.val( $share.val().replace( slash, '' ) );
 				}, 0 );
 			} );
 		}

From 77cf1c710ebf18e9cbe243bfa5b7ce9c2c009c32 Mon Sep 17 00:00:00 2001
From: rern 
Date: Mon, 26 Sep 2022 10:46:20 +0700
Subject: [PATCH 051/237] Update info.js

---
 srv/http/assets/js/info.js | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srv/http/assets/js/info.js b/srv/http/assets/js/info.js
index d9994fbff..23a5d61b4 100644
--- a/srv/http/assets/js/info.js
+++ b/srv/http/assets/js/info.js
@@ -268,10 +268,9 @@ function info( json ) {
 			htmlbutton += ' class="infobtn extrabtn infobtn-primary">'+ O.buttonlabel[ i ] +'';
 		}
 	}
-	if ( O.cancelshow ) {
+	if ( O.cancelshow || O.cancellabel || O.cancelcolor ) {
 		var color = O.cancelcolor ? ' style="background-color:'+ O.cancelcolor +'"' : '';
-		var hide = O.cancelshow ? '' : ' hide';
-		htmlbutton += ''+ ( O.cancellabel || 'Cancel' ) +'';
+		htmlbutton += ''+ ( O.cancellabel || 'Cancel' ) +'';
 	}
 	if ( !O.okno ) {
 		var color = O.okcolor ? ' style="background-color:'+ O.okcolor +'"' : '';

From a08a8d69f12a0ba8876ea64f95138e4396e90a76 Mon Sep 17 00:00:00 2001
From: rern 
Date: Mon, 26 Sep 2022 12:32:22 +0700
Subject: [PATCH 052/237] Update install.sh

---
 install.sh | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/install.sh b/install.sh
index 43a3fae89..2b246fa8f 100644
--- a/install.sh
+++ b/install.sh
@@ -3,6 +3,14 @@
 alias=r1
 
 # 20220926
+dir=/etc/systemd/system
+for file in $dir/spotifyd.service $dir/upmpdcli.service; do
+	! grep -q CPUAffinity $file && sed -i -e '/ExecStart/ i\CPUAffinity=3' -e 's|/usr/bin/taskset -c 3 ||' $file
+done
+for file in $dir/mpd.service.d/override.conf $dir/shairport-sync.service.d/override.conf; do
+	! grep -q CPUAffinity $file && sed -i -e '/ExecStart/ i\CPUAffinity=3' -e '/ExecStart/ d' $file
+done
+
 dir=/srv/http/assets/img/guide
 if [[ ! -e $dir/1.jpg ]]; then
 	mkdir -p $dir

From 047e0da74968bd02af73df15ee0ed888733974b9 Mon Sep 17 00:00:00 2001
From: rern 
Date: Mon, 26 Sep 2022 12:35:56 +0700
Subject: [PATCH 053/237] Update install.sh

---
 install.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/install.sh b/install.sh
index 2b246fa8f..4820e35e3 100644
--- a/install.sh
+++ b/install.sh
@@ -5,10 +5,10 @@ alias=r1
 # 20220926
 dir=/etc/systemd/system
 for file in $dir/spotifyd.service $dir/upmpdcli.service; do
-	! grep -q CPUAffinity $file && sed -i -e '/ExecStart/ i\CPUAffinity=3' -e 's|/usr/bin/taskset -c 3 ||' $file
+	! grep -q CPUAffinity $file && sed -i -e '/ExecStart=/ i\CPUAffinity=3' -e 's|/usr/bin/taskset -c 3 ||' $file
 done
 for file in $dir/mpd.service.d/override.conf $dir/shairport-sync.service.d/override.conf; do
-	! grep -q CPUAffinity $file && sed -i -e '/ExecStart/ i\CPUAffinity=3' -e '/ExecStart/ d' $file
+	! grep -q CPUAffinity $file && sed -i -e '/ExecStart=/ i\CPUAffinity=3' -e '/ExecStart/ d' $file
 done
 
 dir=/srv/http/assets/img/guide

From 8fb33a46af741151c4ef9fac3ba858411394dfce Mon Sep 17 00:00:00 2001
From: rern 
Date: Mon, 26 Sep 2022 12:39:59 +0700
Subject: [PATCH 054/237] Update install.sh

---
 install.sh | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/install.sh b/install.sh
index 4820e35e3..cd80a7f12 100644
--- a/install.sh
+++ b/install.sh
@@ -5,7 +5,7 @@ alias=r1
 # 20220926
 dir=/etc/systemd/system
 for file in $dir/spotifyd.service $dir/upmpdcli.service; do
-	! grep -q CPUAffinity $file && sed -i -e '/ExecStart=/ i\CPUAffinity=3' -e 's|/usr/bin/taskset -c 3 ||' $file
+	! grep -q CPUAffinity $file && sed -i -e '/ExecStartPost/ d' -e '/ExecStart=/ i\CPUAffinity=3' -e 's|/usr/bin/taskset -c 3 ||' $file
 done
 for file in $dir/mpd.service.d/override.conf $dir/shairport-sync.service.d/override.conf; do
 	! grep -q CPUAffinity $file && sed -i -e '/ExecStart=/ i\CPUAffinity=3' -e '/ExecStart/ d' $file
@@ -33,9 +33,6 @@ ExecStart=/srv/http/bash/status-dab.sh
 " > $file
 fi
 
-sed -i '/ExecStartPost/ d' /etc/systemd/system/spotifyd.service &> /dev/null
-sed -i '/ExecStartPost/ d' /etc/systemd/system/upmpdcli.service &> /dev/null
-
 systemctl daemon-reload
 
 # 20220916

From 6c2839a4e6b671876207cf4c7b8418a34343f064 Mon Sep 17 00:00:00 2001
From: rern 
Date: Mon, 26 Sep 2022 12:42:09 +0700
Subject: [PATCH 055/237] Update install.sh

---
 install.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/install.sh b/install.sh
index cd80a7f12..87342beba 100644
--- a/install.sh
+++ b/install.sh
@@ -5,10 +5,10 @@ alias=r1
 # 20220926
 dir=/etc/systemd/system
 for file in $dir/spotifyd.service $dir/upmpdcli.service; do
-	! grep -q CPUAffinity $file && sed -i -e '/ExecStartPost/ d' -e '/ExecStart=/ i\CPUAffinity=3' -e 's|/usr/bin/taskset -c 3 ||' $file
+	! grep -q CPUAffinity $file && sed -i -e '/ExecStartPost/ d' -e '/Service/ a\CPUAffinity=3' -e 's|/usr/bin/taskset -c 3 ||' $file
 done
 for file in $dir/mpd.service.d/override.conf $dir/shairport-sync.service.d/override.conf; do
-	! grep -q CPUAffinity $file && sed -i -e '/ExecStart=/ i\CPUAffinity=3' -e '/ExecStart/ d' $file
+	! grep -q CPUAffinity $file && sed -i -e '/Service/ a\CPUAffinity=3' -e '/ExecStart/ d' $file
 done
 
 dir=/srv/http/assets/img/guide

From c97494ca48ddedea66e49b8e2dbf2cf23ee17402 Mon Sep 17 00:00:00 2001
From: rern 
Date: Mon, 26 Sep 2022 16:37:20 +0700
Subject: [PATCH 056/237] u

---
 install.sh                            |  4 ++-
 srv/http/assets/js/system.js          | 44 ++++++++++++++++++++++-
 srv/http/bash/cmd.sh                  | 52 +++++++++------------------
 srv/http/bash/dab-start.sh            |  4 +++
 srv/http/bash/settings/system-data.sh |  9 ++---
 srv/http/bash/settings/system.sh      | 35 ++++++++++++------
 srv/http/settings/system.php          | 10 ++----
 7 files changed, 98 insertions(+), 60 deletions(-)

diff --git a/install.sh b/install.sh
index 87342beba..0d1389eab 100644
--- a/install.sh
+++ b/install.sh
@@ -5,11 +5,13 @@ alias=r1
 # 20220926
 dir=/etc/systemd/system
 for file in $dir/spotifyd.service $dir/upmpdcli.service; do
-	! grep -q CPUAffinity $file && sed -i -e '/ExecStartPost/ d' -e '/Service/ a\CPUAffinity=3' -e 's|/usr/bin/taskset -c 3 ||' $file
+	! grep -q CPUAffinity $file && sed -i -e '/Service/ a\CPUAffinity=3' -e '/ExecStartPost/ d' -e 's|/usr/bin/taskset -c 3 ||' $file
 done
 for file in $dir/mpd.service.d/override.conf $dir/shairport-sync.service.d/override.conf; do
 	! grep -q CPUAffinity $file && sed -i -e '/Service/ a\CPUAffinity=3' -e '/ExecStart/ d' $file
 done
+file=$dir/bluetooth.service.d/override.conf
+! grep -q CPUAffinity $file && sed -i -e '/Service/ a\CPUAffinity=3' $file
 
 dir=/srv/http/assets/img/guide
 if [[ ! -e $dir/1.jpg ]]; then
diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js
index 9f87a61a9..1df66591f 100644
--- a/srv/http/assets/js/system.js
+++ b/srv/http/assets/js/system.js
@@ -837,7 +837,49 @@ $( '#shareddata' ).click( function() {
 			}
 		} );
 	} else {
-		if ( $( '#list .fa-networks' ).length ) {
+		if ( G.nfs ) {
+			info( {
+				  icon        : 'networks'
+				, title       : 'Shared Data'
+				, message     : 'NFS Server is enabled.'
+								+'
Use this rAudio as server?' + +'
(Music files and Shared Data)' + , cancellabel : 'No' + , cancel : function() { + $( '#shareddata' ).prop( 'checked', false ); + setTimeout( function() { + infoMount( 'shareddata' ); + }, 0 ); + } + , ok : function() { + setTimeout( function() { + info( { + icon : 'networks' + , title : 'Shared Data' + , message : 'NFS share names:' + , textlabel : [ + '/mnt/MPD/SD as' + , '/mnt/MPD/USB as' + , '/srv/http/shareddata as' + ] + , values : [ 'SD', 'USB', 'shareddata' ] + , footer : '(Clients use as Name on Storage )' + , beforeshow : function() { + $( '#infoContent input' ).on( 'keyup paste', function() { + var $this = $( this ); + setTimeout( function() { + $this.val( $this.val().replace( /\//g, '' ) ); + }, 0 ); + } ); + } + , ok : function() { + bash( [ 'shareddataserver', ...infoVal() ] ); + } + } ); + }, 0 ); + } + } ); + } else if ( $( '#list .fa-networks' ).length ) { infoMount( 'shareddata' ); } else { info( { diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index ef129168a..5677d2511 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -119,18 +119,6 @@ mpdoledLogo() { type=$( grep mpd_oled /etc/systemd/system/mpd_oled.service | cut -d' ' -f3 ) mpd_oled -o $type -L } -reniceProcess() { - if [[ $2 == reset ]]; then - for pid in $( pgrep $1 ); do - renice -n 0 -p $pid &> /dev/null - done - else - for pid in $( pgrep $1 ); do - ionice -c 0 -n 0 -p $pid &> /dev/null - renice -n -19 -p $pid &> /dev/null - done - fi -} plAddPlay() { pushstreamPlaylist add if [[ ${1: -4} == play ]]; then @@ -1019,7 +1007,7 @@ pkgstatus ) pkg=chromium;; nfs-server ) pkg=nfs-utils - fileconf=/etc/exports + grep -q /mnt/MPD /etc/exports && fileconf=/etc/exports ;; smb ) fileconf=/etc/samba/smb.conf @@ -1061,25 +1049,22 @@ $conf $status" ;; playerstart ) - newplayer=${args[1]} - [[ $newplayer == bluetooth ]] && volumeGet save + player=${args[1]} + [[ $player == bluetooth ]] && volumeGet save mpc -q stop stopRadio - player=$( cat $dirshm/player ) - echo $newplayer > $dirshm/player + echo $player > $dirshm/player case $player in - airplay ) service=shairport-sync;; - mpd | upnp ) service=mpd;; - spotify ) service=spotifyd;; + airplay ) service=shairport-sync;; + bluetooth ) service=bluetoothhd;; + spotify ) service=spotifyd;; + upnp ) service=upmpdcli;; esac - if [[ $service ]]; then - systemctl restart $service - reniceProcess $service - [[ $service != mpd ]] && reniceProcess mpd reset - else - snapclientStop - fi - pushstream player '{"player":"'$newplayer'","active":true}' + for pid in $( pgrep $service ); do + ionice -c 0 -n 0 -p $pid &> /dev/null + renice -n -19 -p $pid &> /dev/null + done + pushstream player '{"player":"'$player'","active":true}' ;; playerstop ) elapsed=${args[1]} @@ -1090,35 +1075,30 @@ playerstop ) [[ $player != upnp ]] && $dirbash/status-push.sh case $player in airplay ) - service=shairport-sync systemctl stop shairport-meta rm -f $dirshm/airplay/start + systemctl restart shairport-sync ;; bluetooth ) rm -f $dirshm/bluetoothdest ;; snapcast ) - service=snapclient snapclientStop ;; spotify ) - service=spotifyd rm -f $dirshm/spotify/start + systemctl restart spotifyd ;; upnp ) - service=upmpdcli mpc -q stop tracks=$( mpc -f %file%^%position% playlist | grep 'http://192' | cut -d^ -f2 ) for i in $tracks; do mpc -q del $i done $dirbash/status-push.sh + systemctl restart upmpdcli ;; esac - if [[ $service && $service != snapclient ]]; then - systemctl restart $service - reniceProcess $service reset - fi pushstream player '{"player":"'$player'","active":false}' [[ -e $dirshm/scrobble && $elapsed ]] && scrobbleOnStop $elapsed ;; diff --git a/srv/http/bash/dab-start.sh b/srv/http/bash/dab-start.sh index d02963297..4b8c53811 100644 --- a/srv/http/bash/dab-start.sh +++ b/srv/http/bash/dab-start.sh @@ -33,5 +33,9 @@ ffmpeg \ -f rtsp rtsp://localhost:$3/$4 \ &> /dev/null & FFMPID=$! +for pid in $( pgrep $FFMPID ); do + ionice -c 0 -n 0 -p $pid &> /dev/null + renice -n -19 -p $pid &> /dev/null +done wait $FFMPID diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 1b88fd203..6c1f39500 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -3,10 +3,11 @@ . /srv/http/bash/common.sh startup=$( systemd-analyze | grep '^Startup finished' | cut -d' ' -f 4,7 | sed -e 's/\....s/s/g; s/ / + /' ) +timezone=$( timedatectl | awk '/zone:/ {print $3}' ) status="\ $( cat /proc/loadavg | cut -d' ' -f1-3 | sed 's| | |g' )
\ $( /opt/vc/bin/vcgencmd measure_temp | sed -E 's/temp=(.*).C/\1 °C/' )
\ -$( date +'%F %T' ) • $( timedatectl | awk '/zone:/ {print $3}' )
\ +$( date +'%F %T' ) • $timezone
\ $( uptime -p | tr -d 's,' | sed 's/up //; s/ day/d/; s/ hour/h/; s/ minute/m/' )since $( uptime -s | cut -d: -f1-2 | sed 's/ / • /' )
\ $( [[ $startup ]] && echo "$startup(kernel + userspace)" || echo . . . )" ! : >/dev/tcp/8.8.8.8/53 && status+="
 No Internet connection" @@ -142,7 +143,6 @@ baudrate=$( grep baudrate /boot/config.txt | cut -d= -f3 ) mpdoledconf='[ '$oledchip', '$baudrate' ]' [[ $( stat -c %a /mnt/MPD/SD ) == 777 ]] && permsd=true [[ $( stat -c %a /mnt/MPD/USB ) == 777 ]] && permusb=true -grep -q /srv/http/shareddata /etc/exports && nfsshareddata=true [[ -e $dirsystem/audiophonics ]] && audiophonics=true || audiophonics=false if [[ -e $dirsystem/powerbutton.conf ]]; then powerbuttonconf="[ $( cat $dirsystem/powerbutton.conf | cut -d= -f2 | xargs | tr ' ' , ), $audiophonics ]" @@ -178,19 +178,20 @@ data+=' , "mpdoled" : '$( exists $dirsystem/mpdoled )' , "mpdoledconf" : '$mpdoledconf' , "nfs" : '$( isactive nfs-server )' -, "nfsconf" : [ '$permsd', '$permusb', '$nfsshareddata' ] +, "nfsconf" : [ '$permsd', '$permusb' ] , "ntp" : "'$( grep '^NTP' /etc/systemd/timesyncd.conf | cut -d= -f2 )'" , "powerbutton" : '$( systemctl -q is-active powerbutton || [[ $audiophonics == true ]] && echo true )' , "powerbuttonconf" : '$powerbuttonconf' , "relays" : '$( exists $dirsystem/relays )' , "rotaryencoder" : '$( isactive rotaryencoder )' , "rotaryencoderconf": '$rotaryencoderconf' -, "shareddata" : '$( grep -q /srv/http/shareddata /etc/fstab && echo true )' +, "shareddata" : '$( exists /srv/http/shareddata )' , "soundprofile" : '$( exists $dirsystem/soundprofile )' , "soundprofileconf" : '$soundprofileconf' , "status" : "'$status'" , "startup" : '$( [[ $startup ]] && echo true )' , "system" : "'$system'" +, "timezone" : "'$timezone'" , "usbautoupdate" : '$( exists $dirsystem/usbautoupdate )' , "vuled" : '$( exists $dirsystem/vuled )' , "vuledconf" : '$vuledconf diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 05b484520..a9d8addf6 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -528,7 +528,7 @@ mpdoledset ) ;; nfsdisable ) systemctl disable --now nfs-server - sed -i '/^.mnt.MPD\|^.srv.http/ d' /etc/exports + rm /mnt/MPD/NAS/{SD,USB} chmod 755 /mnt/MPD/{SD,USB} pushRefresh ;; @@ -537,15 +537,13 @@ nfsset ) permusb=${args[2]} chmod $permsd /mnt/MPD/SD chmod $permusb /mnt/MPD/USB - mkdir -p /srv/http/shareddata - chmod 777 /srv/http/shareddata routerip=$( ip r get 1 | head -1 | cut -d' ' -f3 ) ip_options="${routerip%.*}.0/24(rw,sync,no_subtree_check)" ! grep -q /mnt/MPD/ /etc/exports && echo -n "\ /mnt/MPD/SD $ip_options /mnt/MPD/USB $ip_options -/srv/http/shareddata $ip_options" >> /etc/exports - systemctl enable --now nfs-server +" >> /etc/exports + systemctl -q is-active nfs-server && systemctl restart nfs-server || systemctl enable --now nfs-server pushRefresh ;; packagelist ) @@ -744,15 +742,20 @@ shareddata ) shareddatadisable ) copydata=${args[1]} mountpoint=/srv/http/shareddata - ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) - sed -i "/$ip/ d" $mountpoint/iplist - [[ ! $( awk NF $mountpoint/iplist ) ]] && rm $mountpoint/iplist for dir in audiocd bookmarks lyrics mpd playlists webradio; do rm -rf $dirdata/$dir [[ $copydata == true ]] && cp -rf $mountpoint/$dir $dirdata || mkdir $dirdata/$dir done - umount -l $mountpoint - sed -i "\|$mountpoint| d" /etc/fstab + if [[ -L $mountpoint/mpd ]]; then # rAudio is server + sed -i -E '/^.srv.http.shareddata / d' /etc/exports + systemctl restart nfs-server + else + ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + sed -i "/$ip/ d" $mountpoint/iplist + [[ ! $( awk NF $mountpoint/iplist ) ]] && rm $mountpoint/iplist + umount -l $mountpoint + sed -i "\|$mountpoint| d" /etc/fstab + fi rm -rf $mountpoint chown -R http:http $dirdata chown -R mpd:audio $dirmpd @@ -779,6 +782,18 @@ shareddatarestart ) systemctl restart mpd pushstream mpdupdate "$( cat $dirmpd/counts )" ;; +shareddataserver ) + ln -s /mnt/MPD/SD /mnt/MPD/NAS + ln -s /mnt/MPD/USB /mnt/MPD/NAS + mkdir -p /srv/http/shareddata + for dir in audiocd bookmarks lyrics playlists webradio; do + mv -f $dirdata/$dir /srv/http/shareddata + ln -s /srv/http/shareddata/$dir $dirdata/$dir + done + chmod -R 777 /srv/http/shareddata + echo /srv/http/shareddata $ip_options >> /etc/exports + pushRefresh + ;; soundprofile ) soundProfile ;; diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 1cf66c2b1..7ba258742 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -113,10 +113,7 @@ , 'setting' => true , 'status' => 'nfs-server' , 'help' => <<< HTML -Network File System for: - • /mnt/MPD/SD - • /mnt/MPD/USB - • /srv/http/shareddata +Network File System for /mnt/MPD/SD and /mnt/MPD/USB HTML ] ); echo ''; @@ -339,15 +336,12 @@ Share data for multiple rAudios: audio CD, bookmarks, lyrics, Library database, saved playlists and Web Radio stations. • SSH passwords must be default. • Music files should be on NAS only. - • On file server: -   • rAudio as music file server: Enable NFS Server with write permissions -   • Remote file server: setup a network share with all permissions + • On file server: setup a share directory/folder with all permissions     • NFS: 777 / a+rwx     • Samba: read only = no     • Windows: Everyone - Full Control (Sharing and Security tabs) • On each rAudio   • Storage Add shared music -   • For rAudio as server, also add the share to itself   • Enable to connect the shared data   • Check Use data from this rAudio only on rAudio with data to be shared or to overwrite existing HTML From 3991be3579fa4bd85f591ea1b8fb9ed33ca4d315 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 26 Sep 2022 16:51:24 +0700 Subject: [PATCH 057/237] Update system.sh --- srv/http/bash/settings/system.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index a9d8addf6..5019a4fe3 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -236,6 +236,7 @@ datarestore ) chmod 777 $mountpoint std=$( mount $mountpoint ) if [[ $? == 0 ]]; then + systemctl daemon-reload for dir in audiocd bookmarks lyrics mpd playlists webradio; do rm -rf $dirdata/$dir ln -s $mountpoint/$dir $dirdata @@ -487,6 +488,7 @@ mount ) echo "${source// /\\040} ${mountpoint// /\\040} $protocol ${options// /\\040} 0 0" >> /etc/fstab std=$( mount "$mountpoint" 2>&1 ) if [[ $? == 0 ]]; then + systemctl daemon-reload [[ $update == true ]] && $dirbash/cmd.sh mpcupdate$'\n'"${mountpoint:9}" # /mnt/MPD/NAS/... > NAS/... for i in {1..5}; do sleep 1 @@ -634,6 +636,7 @@ remove ) umount -l "$mountpoint" rmdir "$mountpoint" &> /dev/null sed -i "\|${mountpoint// /\\\\040}| d" /etc/fstab + systemctl daemon-reload $dirbash/cmd.sh mpcupdate$'\n'NAS pushRefresh ;; @@ -713,6 +716,7 @@ shareddata ) echo "${source// /\\040} $mountpoint $protocol ${options// /\\040} 0 0" >> /etc/fstab std=$( mount $mountpoint ) if [[ $? == 0 ]]; then + systemctl daemon-reload for i in {1..5}; do sleep 1 mount | grep -q "$mountpoint" && break @@ -755,6 +759,7 @@ shareddatadisable ) [[ ! $( awk NF $mountpoint/iplist ) ]] && rm $mountpoint/iplist umount -l $mountpoint sed -i "\|$mountpoint| d" /etc/fstab + systemctl daemon-reload fi rm -rf $mountpoint chown -R http:http $dirdata From cd09f02fd942fa91257051c300015fae2f10cae2 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 26 Sep 2022 18:26:54 +0700 Subject: [PATCH 058/237] Update system.sh --- srv/http/bash/settings/system.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 5019a4fe3..b9900ebf4 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -746,14 +746,15 @@ shareddata ) shareddatadisable ) copydata=${args[1]} mountpoint=/srv/http/shareddata - for dir in audiocd bookmarks lyrics mpd playlists webradio; do - rm -rf $dirdata/$dir - [[ $copydata == true ]] && cp -rf $mountpoint/$dir $dirdata || mkdir $dirdata/$dir - done if [[ -L $mountpoint/mpd ]]; then # rAudio is server sed -i -E '/^.srv.http.shareddata / d' /etc/exports systemctl restart nfs-server + rm -rf /srv/http/shareddata else + for dir in audiocd bookmarks lyrics mpd playlists webradio; do + rm -rf $dirdata/$dir + [[ $copydata == true ]] && cp -rf $mountpoint/$dir $dirdata || mkdir $dirdata/$dir + done ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) sed -i "/$ip/ d" $mountpoint/iplist [[ ! $( awk NF $mountpoint/iplist ) ]] && rm $mountpoint/iplist @@ -792,8 +793,7 @@ shareddataserver ) ln -s /mnt/MPD/USB /mnt/MPD/NAS mkdir -p /srv/http/shareddata for dir in audiocd bookmarks lyrics playlists webradio; do - mv -f $dirdata/$dir /srv/http/shareddata - ln -s /srv/http/shareddata/$dir $dirdata/$dir + ln -s $dirdata/$dir /srv/http/shareddata done chmod -R 777 /srv/http/shareddata echo /srv/http/shareddata $ip_options >> /etc/exports From 564cbf0410c57eb657565446c64f8fbb87eadb1f Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 26 Sep 2022 18:58:39 +0700 Subject: [PATCH 059/237] u --- srv/http/assets/js/system.js | 20 +++++++++++++------- srv/http/bash/settings/system.sh | 5 +++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 1df66591f..94c3f9749 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -856,15 +856,18 @@ $( '#shareddata' ).click( function() { info( { icon : 'networks' , title : 'Shared Data' - , message : 'NFS share names:' + , message : 'NFS share path : name' , textlabel : [ - '/mnt/MPD/SD as' - , '/mnt/MPD/USB as' - , '/srv/http/shareddata as' + '/mnt/MPD/SD' + , '/mnt/MPD/USB' + , '/srv/http/shareddata' ] - , values : [ 'SD', 'USB', 'shareddata' ] - , footer : '(Clients use as Name on Storage )' + , values : [ 'SD', 'USB', '(for Shared Data)' ] + , footer : '(Storage - settings for clients)' , beforeshow : function() { + $( '#infoContent input' ).eq( 2 ) + .prop( 'disabled', 1 ) + .css( 'color', 'var( --cg60 )' ); $( '#infoContent input' ).on( 'keyup paste', function() { var $this = $( this ); setTimeout( function() { @@ -872,7 +875,10 @@ $( '#shareddata' ).click( function() { }, 0 ); } ); } - , ok : function() { + , cancel : function() { + $( '#shareddata' ).prop( 'checked', false ); + } + , ok : function() { bash( [ 'shareddataserver', ...infoVal() ] ); } } ); diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index b9900ebf4..fdd6016f7 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -789,14 +789,15 @@ shareddatarestart ) pushstream mpdupdate "$( cat $dirmpd/counts )" ;; shareddataserver ) - ln -s /mnt/MPD/SD /mnt/MPD/NAS - ln -s /mnt/MPD/USB /mnt/MPD/NAS + ln -s /mnt/MPD/SD /mnt/MPD/NAS/${args[1]} + ln -s /mnt/MPD/USB /mnt/MPD/NAS/${args[2]} mkdir -p /srv/http/shareddata for dir in audiocd bookmarks lyrics playlists webradio; do ln -s $dirdata/$dir /srv/http/shareddata done chmod -R 777 /srv/http/shareddata echo /srv/http/shareddata $ip_options >> /etc/exports + systemctl restart nfs-server pushRefresh ;; soundprofile ) From 4bea166b923c62ad4ae42ec933af3018952186e5 Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 26 Sep 2022 19:00:01 +0700 Subject: [PATCH 060/237] Update system.sh --- srv/http/bash/settings/system.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index fdd6016f7..c12a578f0 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -792,10 +792,10 @@ shareddataserver ) ln -s /mnt/MPD/SD /mnt/MPD/NAS/${args[1]} ln -s /mnt/MPD/USB /mnt/MPD/NAS/${args[2]} mkdir -p /srv/http/shareddata + chmod 777 /srv/http/shareddata for dir in audiocd bookmarks lyrics playlists webradio; do ln -s $dirdata/$dir /srv/http/shareddata done - chmod -R 777 /srv/http/shareddata echo /srv/http/shareddata $ip_options >> /etc/exports systemctl restart nfs-server pushRefresh From 06fc8197f10bbe80d10dd835a306d0209f419d4b Mon Sep 17 00:00:00 2001 From: rern Date: Mon, 26 Sep 2022 21:50:59 +0700 Subject: [PATCH 061/237] u --- srv/http/assets/js/settings.js | 1 + srv/http/assets/js/system.js | 108 ++++++++++++++++---------- srv/http/bash/settings/system-data.sh | 1 + srv/http/bash/settings/system.sh | 38 +++++++-- srv/http/settings/system.php | 15 ++-- 5 files changed, 106 insertions(+), 57 deletions(-) diff --git a/srv/http/assets/js/settings.js b/srv/http/assets/js/settings.js index 8c0d28f3a..a98841732 100644 --- a/srv/http/assets/js/settings.js +++ b/srv/http/assets/js/settings.js @@ -34,6 +34,7 @@ var cmd = { , mpdignore : playersh +'mpdignorelist' , nonutf8 : playersh +'nonutf8' , rfkill : systemsh +'rfkilllist' + , shareddata : systemsh +'shareddataname' , soundprofile : systemsh +'soundprofileget' , system : systemsh +'systemconfig' , timedatectl : systemsh +'timedate' diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 94c3f9749..ccc9ec1ce 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -820,7 +820,23 @@ $( '#restore' ).click( function() { $( '#restore' ).prop( 'checked', 0 ); } ); $( '#shareddata' ).click( function() { - if ( G.shareddata ) { + if ( G.shareddataserver ) { + info( { + icon : 'networks' + , title : 'Shared Data' + , message : ' All clients will be disconnected.' + +'
Continue?' + , cancel : function() { + $( '#shareddata' ).prop( 'checked', true ); + } + , okcolor : orange + , oklabel : 'Disable' + , ok : function() { + bash( [ 'shareddatadisable' ] ); + notify( 'Shared Data', 'Disable ...', 'networks' ); + } + } ); + } else if ( G.shareddata ) { info( { icon : 'networks' , title : 'Shared Data' @@ -839,50 +855,51 @@ $( '#shareddata' ).click( function() { } else { if ( G.nfs ) { info( { - icon : 'networks' - , title : 'Shared Data' - , message : 'NFS Server is enabled.' - +'
Use this rAudio as server?' - +'
(Music files and Shared Data)' - , cancellabel : 'No' - , cancel : function() { - $( '#shareddata' ).prop( 'checked', false ); - setTimeout( function() { - infoMount( 'shareddata' ); - }, 0 ); - } - , ok : function() { - setTimeout( function() { - info( { - icon : 'networks' - , title : 'Shared Data' - , message : 'NFS share path : name' - , textlabel : [ - '/mnt/MPD/SD' - , '/mnt/MPD/USB' - , '/srv/http/shareddata' - ] - , values : [ 'SD', 'USB', '(for Shared Data)' ] - , footer : '(Storage - settings for clients)' - , beforeshow : function() { - $( '#infoContent input' ).eq( 2 ) - .prop( 'disabled', 1 ) - .css( 'color', 'var( --cg60 )' ); - $( '#infoContent input' ).on( 'keyup paste', function() { - var $this = $( this ); - setTimeout( function() { - $this.val( $this.val().replace( /\//g, '' ) ); - }, 0 ); + icon : 'networks' + , title : 'Shared Data' + , radio : { 'Share with NFS Server on this rAudio': 0, 'Add shares from other server': 1 } + , okno : 1 + , beforeshow : function() { + $( '#infoContent input' ).change( function() { + setTimeout( function() { + if ( $( '#infoContent input:checked' ).val() == 1 ) { + infoMount( 'shareddata' ); + } else { + info( { + icon : 'networks' + , title : 'Shared Data - NFS Server' + , message : 'Share path | Name' + , textlabel : [ + '/mnt/MPD/SD' + , '/mnt/MPD/USB' + , '/srv/http/shareddata' + ] + , values : [ '', 'USB', 'SharedData' ] + , footer : '
• Setting values for clients on Storage )' + +'
• Blank = Disable' + , footeralign : 'left' + , beforeshow : function() { + $( '.infomessage' ).eq( 0 ).css( 'margin-left', '-50px' ); + $( '#infoContent input' ).eq( 2 ) + .prop( 'disabled', 1 ) + .css( 'color', 'var( --cg60 )' ); + $( '#infoContent input' ).on( 'keyup paste', function() { + var $this = $( this ); + setTimeout( function() { + $this.val( $this.val().replace( /\//g, '' ) ); + }, 0 ); + } ); + } + , cancel : function() { + $( '#shareddata' ).prop( 'checked', false ); + } + , ok : function() { + bash( [ 'shareddataserver', ...infoVal() ] ); + } } ); } - , cancel : function() { - $( '#shareddata' ).prop( 'checked', false ); - } - , ok : function() { - bash( [ 'shareddataserver', ...infoVal() ] ); - } - } ); - }, 0 ); + }, 0 ); + } ); } } ); } else if ( $( '#list .fa-networks' ).length ) { @@ -1065,6 +1082,7 @@ function renderPage() { html += val.size ? ' '+ val.size +'' : ''; } ); $( '#list' ).html( html ); + $( '#nfs' ).toggleClass( 'disabled', G.shareddataserver ); if ( 'bluetooth' in G || 'wlan' in G ) { if ( 'bluetooth' in G ) { $( '#bluetooth' ).parent().prev().toggleClass( 'single', !G.bluetoothactive ); @@ -1095,6 +1113,10 @@ function renderPage() { $( '#avahiurl' ).text( G.hostname +'.local' ); $( '#timezone' ).val( G.timezone ); $( '#shareddata' ).prop( 'checked', G.shareddata ); + $( '#divshareddata .col-l' ) + .toggleClass( 'status', G.shareddataserver ) + .toggleClass( 'single', !G.shareddataserver ) + .find( 'gr' ).toggleClass( 'hide', !G.shareddataserver ); showContent(); } function getStatus() { diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 6c1f39500..2fe572ab7 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -186,6 +186,7 @@ data+=' , "rotaryencoder" : '$( isactive rotaryencoder )' , "rotaryencoderconf": '$rotaryencoderconf' , "shareddata" : '$( exists /srv/http/shareddata )' +, "shareddataserver" : '$( [[ -e /srv/http/shareddata && -L /srv/http/shareddata/mpd ]] && echo true )' , "soundprofile" : '$( exists $dirsystem/soundprofile )' , "soundprofileconf" : '$soundprofileconf' , "status" : "'$status'" diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index c12a578f0..51461d428 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -45,6 +45,10 @@ I2Cset() { # i2c-bcm2708 [[ $lcd || $I2Clcdchar ]] && echo i2c-bcm2708 >> $filemodule } +ipOptions() { + routerip=$( ip r get 1 | head -1 | cut -d' ' -f3 ) + ip_options="${routerip%.*}.0/24(rw,sync,no_subtree_check)" +} soundProfile() { if [[ $1 == reset ]]; then swappiness=60 @@ -539,12 +543,13 @@ nfsset ) permusb=${args[2]} chmod $permsd /mnt/MPD/SD chmod $permusb /mnt/MPD/USB - routerip=$( ip r get 1 | head -1 | cut -d' ' -f3 ) - ip_options="${routerip%.*}.0/24(rw,sync,no_subtree_check)" - ! grep -q /mnt/MPD/ /etc/exports && echo -n "\ + if ! grep -q /mnt/MPD/ /etc/exports; then + ipOptions + echo -n "\ /mnt/MPD/SD $ip_options /mnt/MPD/USB $ip_options " >> /etc/exports + fi systemctl -q is-active nfs-server && systemctl restart nfs-server || systemctl enable --now nfs-server pushRefresh ;; @@ -750,9 +755,15 @@ shareddatadisable ) sed -i -E '/^.srv.http.shareddata / d' /etc/exports systemctl restart nfs-server rm -rf /srv/http/shareddata + readarray -t dirs <<< $( ls -1 /mnt/MPD/NAS ) + for dir in "${dirs[@]}"; do + [[ -L "/mnt/MPD/$dir" ]] && rm $dir + done else for dir in audiocd bookmarks lyrics mpd playlists webradio; do - rm -rf $dirdata/$dir + [[ ! -L $dirdata/$dir ]] && continue + + rm $dirdata/$dir [[ $copydata == true ]] && cp -rf $mountpoint/$dir $dirdata || mkdir $dirdata/$dir done ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) @@ -784,19 +795,30 @@ shareddatalist ) done echo "$list" | sort -u > /srv/http/shareddata/iplist ;; +shareddataname ) + echo "\ +# Share path | Name +$( ls -l /mnt/MPD/NAS | grep -v ^total | awk '{print $11" | "$9}' ) +/srv/http/shareddata" + ;; shareddatarestart ) systemctl restart mpd pushstream mpdupdate "$( cat $dirmpd/counts )" ;; shareddataserver ) - ln -s /mnt/MPD/SD /mnt/MPD/NAS/${args[1]} - ln -s /mnt/MPD/USB /mnt/MPD/NAS/${args[2]} + namesd=${args[1]} + nameusb=${args[2]} + [[ $namesd ]] && ln -s /mnt/MPD/SD /mnt/MPD/NAS/$namesd + [[ $nameusb ]] && ln -s /mnt/MPD/USB /mnt/MPD/NAS/$nameusb mkdir -p /srv/http/shareddata chmod 777 /srv/http/shareddata - for dir in audiocd bookmarks lyrics playlists webradio; do + for dir in audiocd bookmarks lyrics mpd playlists webradio; do ln -s $dirdata/$dir /srv/http/shareddata done - echo /srv/http/shareddata $ip_options >> /etc/exports + if ! grep -r /srv/http/shareddata /etc/exports; then + ipOptions + echo /srv/http/shareddata $ip_options >> /etc/exports + fi systemctl restart nfs-server pushRefresh ;; diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 7ba258742..5e977251b 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -110,8 +110,9 @@ , 'id' => 'nfs' , 'sublabel' => 'nfs-server' , 'icon' => 'networks' - , 'setting' => true , 'status' => 'nfs-server' + , 'setting' => true + , 'disabled' => 'Shared Data is currently active on NFS Server.' , 'help' => <<< HTML Network File System for /mnt/MPD/SD and /mnt/MPD/USB HTML @@ -328,11 +329,13 @@ HTML ] , [ - 'label' => 'Shared Data' - , 'id' => 'shareddata' - , 'icon' => 'networks' - , 'setting' => 'none' - , 'help' => <<< HTML + 'label' => 'Shared Data' + , 'id' => 'shareddata' + , 'sublabel' => 'path | name' + , 'icon' => 'networks' + , 'status' => 'shareddata' + , 'setting' => 'none' + , 'help' => <<< HTML Share data for multiple rAudios: audio CD, bookmarks, lyrics, Library database, saved playlists and Web Radio stations. • SSH passwords must be default. • Music files should be on NAS only. From cb412330c2880e323622654d61d05fd545754339 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 08:56:37 +0700 Subject: [PATCH 062/237] Update system-data.sh --- srv/http/bash/settings/system-data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 2fe572ab7..b18fd85cd 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -70,7 +70,7 @@ fi # sd, usb and nas if mount | grep -q 'mmcblk0p2 on /'; then used_size=( $( df -lh --output=used,size,target | grep '/$' ) ) - list+=',{"icon":"microsd","mountpoint":"/","mounted":true,"source":"/dev/mmcblk0p2","size":"'${used_size[0]}'B/'${used_size[1]}'B"}' + list+=',{"icon":"microsd","mountpoint":"/mnt/MPD/SD","mounted":true,"source":"/dev/mmcblk0p2","size":"'${used_size[0]}'B/'${used_size[1]}'B"}' fi usb=$( mount | grep ^/dev/sd | cut -d' ' -f1 ) if [[ $usb ]]; then From 22f1bf260e464dee88ffbeeab5c7731e6c3cca2c Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 16:46:35 +0700 Subject: [PATCH 063/237] u --- srv/http/assets/js/settings.js | 2 +- srv/http/assets/js/system.js | 203 +++++++++++++------------- srv/http/bash/settings/system-data.sh | 4 - srv/http/bash/settings/system.sh | 81 +++++----- srv/http/settings/system.php | 19 +-- 5 files changed, 156 insertions(+), 153 deletions(-) diff --git a/srv/http/assets/js/settings.js b/srv/http/assets/js/settings.js index a98841732..d3bf21283 100644 --- a/srv/http/assets/js/settings.js +++ b/srv/http/assets/js/settings.js @@ -30,7 +30,7 @@ var cmd = { , iw : networkssh +'iwlist' , journalctl : systemsh +'journalctl' , lan : networkssh +'ifconfigeth' - , mount : systemsh +'fstabget' + , mount : systemsh +'storage' , mpdignore : playersh +'mpdignorelist' , nonutf8 : playersh +'nonutf8' , rfkill : systemsh +'rfkilllist' diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index ccc9ec1ce..bd757b030 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -88,17 +88,24 @@ $( '#list' ).on( 'click', 'li', function( e ) { var $this = $( this ); G.li = $this; $( '#codehddinfo' ).addClass( 'hide' ); - var mountpoint = $this.find( '.mountpoint' ).text(); $( 'li' ).removeClass( 'active' ); - if ( !$( '#menu' ).hasClass( 'hide' ) || mountpoint === '/' ) { + if ( !$( '#menu' ).hasClass( 'hide' ) ) { $( '#menu, #codehddinfo' ).addClass( 'hide' ); return } $this.addClass( 'active' ); - $( '#menu .info, .spindown' ).toggleClass( 'hide', mountpoint.slice( 9, 12 ) !== 'USB' ); - $( '#menu .remount' ).toggleClass( 'hide', G.list[ $this.index() ].mounted ); - $( '#menu .unmount' ).toggleClass( 'hide', !G.list[ $this.index() ].mounted ); + $( '#menu a' ).addClass( 'hide' ); + var i = $this.index() + var list = G.list[ i ]; + if ( i === 0 ) { + $( '#menu .share' ).removeClass( 'hide' ); + } else { + var mounted = list.mounted; + $( '#menu .remount' ).toggleClass( 'hide', mounted ); + $( '#menu .unmount' ).toggleClass( 'hide', !mounted ); + $( '#menu .info, .spindown' ).toggleClass( 'hide', list.icon !== 'usbdrive' ); + } var menuH = $( '#menu' ).height(); $( '#menu' ) .removeClass( 'hide' ) @@ -120,14 +127,6 @@ $( '#menu a' ).click( function() { var title = 'Local Mount'; } switch ( cmd ) { - case 'remount': - notify( title, 'Remount ...', icon ); - bash( [ 'remount', mountpoint, source ] ); - break; - case 'unmount': - notify( title, 'Unmount ...', icon ) - bash( [ 'unmount', mountpoint ] ); - break; case 'forget': notify( title, 'Forget ...', icon ); bash( [ 'remove', mountpoint ] ); @@ -144,6 +143,37 @@ $( '#menu a' ).click( function() { $code.addClass( 'hide' ); } break; + case 'remount': + notify( title, 'Remount ...', icon ); + bash( [ 'remount', mountpoint, source ] ); + break; + case 'share': + var path = G.li.find( '.mountpoint' ).text(); + bash( [ 'nfsdata', path ], function( data ) { + info( { + icon : 'networks' + , title : 'NFS Share' + , checkbox : [ 'Share '+ path +'', 'Write permission' ] + , values : data + , checkchanged : 1 + , ok : function() { + var val = infoVal(); + bash( [ 'nfsset', path, ...val ], function( connected ) { + if ( connected ) { + bannerHide(); + info( { + icon : 'networks' + , title : 'NFS Share' + , message : 'NFS Server is currently connected by:
' + + connected + } ); + } + } ); + notify( 'NFS Share', data[ 0 ] ? ( val[ 0 ] ? 'Change ...' : 'Disable ...' ) : 'Enable ...', 'networks' ); + } + } ); + }, 'json' ); + break; case 'spindown': info( { icon : 'usbdrive' @@ -168,39 +198,12 @@ $( '#menu a' ).click( function() { } } ); break; + case 'unmount': + notify( title, 'Unmount ...', icon ) + bash( [ 'unmount', mountpoint ] ); + break; } } ); -$( '#setting-nfs' ).click( function() { - info( { - icon : 'networks' - , title : 'NFS Server' - , message : 'Write permission:' - , checkbox : [ '/mnt/MPD/SD', '/mnt/MPD/USB' ] - , values : G.nfsconf - , checkchanged : ( G.nfs ? 1 : 0 ) - , beforeshow : function() { - var $chk = $( '#infoContent input' ); - $chk.eq( 2 ).change( function() { - if ( $( this ).prop( 'checked' ) ) { - $chk.prop( 'checked', 1 ); - } else { - $chk.eq( 0 ).prop( 'checked', G.nfsconf[ 0 ] ); - $chk.eq( 1 ).prop( 'checked', G.nfsconf[ 1 ] ); - } - } ); - } - , cancel : function() { - $( '#nfs-server' ).prop( 'checked', G.nfs ); - } - , ok : function() { - var val = infoVal(); - var permsd = val[ 0 ] ? 777 : 755; - var permusb = val[ 1 ] ? 777 : 755; - bash( [ 'nfsset', permsd, permusb ] ); - notify( 'NFS Server', G.nfs ? 'Change ...' : 'Enable ...', 'networks' ); - } - } ); -} ); $( '#setting-bluetooth' ).click( function() { info( { icon : 'bluetooth' @@ -853,65 +856,65 @@ $( '#shareddata' ).click( function() { } } ); } else { - if ( G.nfs ) { - info( { - icon : 'networks' - , title : 'Shared Data' - , radio : { 'Share with NFS Server on this rAudio': 0, 'Add shares from other server': 1 } - , okno : 1 - , beforeshow : function() { - $( '#infoContent input' ).change( function() { - setTimeout( function() { - if ( $( '#infoContent input:checked' ).val() == 1 ) { - infoMount( 'shareddata' ); - } else { + info( { + icon : 'networks' + , title : 'Shared Data' + , radio : { 'Share music and data from this rAudio': 0, 'Add shares from other server': 1 } + , okno : 1 + , beforeshow : function() { + $( '#infoContent input' ).change( function() { + setTimeout( function() { + if ( $( '#infoContent input:checked' ).val() == 1 ) { + if ( !$( '#list .fa-networks' ).length ) { info( { - icon : 'networks' - , title : 'Shared Data - NFS Server' - , message : 'Share path | Name' - , textlabel : [ - '/mnt/MPD/SD' - , '/mnt/MPD/USB' - , '/srv/http/shareddata' - ] - , values : [ '', 'USB', 'SharedData' ] - , footer : '
• Setting values for clients on Storage )' - +'
• Blank = Disable' - , footeralign : 'left' - , beforeshow : function() { - $( '.infomessage' ).eq( 0 ).css( 'margin-left', '-50px' ); - $( '#infoContent input' ).eq( 2 ) - .prop( 'disabled', 1 ) - .css( 'color', 'var( --cg60 )' ); - $( '#infoContent input' ).on( 'keyup paste', function() { - var $this = $( this ); - setTimeout( function() { - $this.val( $this.val().replace( /\//g, '' ) ); - }, 0 ); - } ); - } - , cancel : function() { - $( '#shareddata' ).prop( 'checked', false ); - } - , ok : function() { - bash( [ 'shareddataserver', ...infoVal() ] ); - } + icon : 'networks' + , title : 'Shared Data' + , message : 'Connect music share before enable Shared Data.' } ); + $( '#shareddata' ).prop( 'checked', false ); + return } - }, 0 ); - } ); - } - } ); - } else if ( $( '#list .fa-networks' ).length ) { - infoMount( 'shareddata' ); - } else { - info( { - icon : 'networks' - , title : 'Shared Data' - , message : 'Connect music share before enable Shared Data.' - } ); - $( '#shareddata' ).prop( 'checked', false ); - } + + infoMount( 'shareddata' ); + } else { + info( { + icon : 'networks' + , title : 'Shared Data - NFS Server' + , message : 'Share path • Name' + , textlabel : [ + '/mnt/MPD/SD' + , '/mnt/MPD/USB' + , '/srv/http/shareddata' + ] + , checkbox : [ 'Update Library database' ] + , values : [ '', 'Music', 'SharedData', true ] + , footer : '
• Setting values for clients on Storage ' + +'
• Blank = Disable' + , footeralign : 'left' + , beforeshow : function() { + $( '.infomessage' ).eq( 0 ).css( 'margin-left', '-40px' ); + $( '#infoContent input' ).eq( 2 ) + .prop( 'disabled', 1 ) + .css( 'color', 'var( --cg60 )' ); + $( '#infoContent input' ).on( 'keyup paste', function() { + var $this = $( this ); + setTimeout( function() { + $this.val( $this.val().replace( /\//g, '' ) ); + }, 0 ); + } ); + } + , cancel : function() { + $( '#shareddata' ).prop( 'checked', false ); + } + , ok : function() { + bash( [ 'shareddataserver', ...infoVal() ] ); + } + } ); + } + }, 0 ); + } ); + } + } ); } } ); $( '.listtitle' ).click( function( e ) { diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index b18fd85cd..309db0c8e 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -141,8 +141,6 @@ oledchip=$( grep mpd_oled /etc/systemd/system/mpd_oled.service | cut -d' ' -f3 ) baudrate=$( grep baudrate /boot/config.txt | cut -d= -f3 ) [[ ! $baudrate ]] && baudrate=800000 mpdoledconf='[ '$oledchip', '$baudrate' ]' -[[ $( stat -c %a /mnt/MPD/SD ) == 777 ]] && permsd=true -[[ $( stat -c %a /mnt/MPD/USB ) == 777 ]] && permusb=true [[ -e $dirsystem/audiophonics ]] && audiophonics=true || audiophonics=false if [[ -e $dirsystem/powerbutton.conf ]]; then powerbuttonconf="[ $( cat $dirsystem/powerbutton.conf | cut -d= -f2 | xargs | tr ' ' , ), $audiophonics ]" @@ -177,8 +175,6 @@ data+=' , "lcdmodel" : "'$( cat $dirsystem/lcdmodel 2> /dev/null || echo tft35a )'" , "mpdoled" : '$( exists $dirsystem/mpdoled )' , "mpdoledconf" : '$mpdoledconf' -, "nfs" : '$( isactive nfs-server )' -, "nfsconf" : [ '$permsd', '$permusb' ] , "ntp" : "'$( grep '^NTP' /etc/systemd/timesyncd.conf | cut -d= -f2 )'" , "powerbutton" : '$( systemctl -q is-active powerbutton || [[ $audiophonics == true ]] && echo true )' , "powerbuttonconf" : '$powerbuttonconf' diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 51461d428..60082b476 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -45,10 +45,6 @@ I2Cset() { # i2c-bcm2708 [[ $lcd || $I2Clcdchar ]] && echo i2c-bcm2708 >> $filemodule } -ipOptions() { - routerip=$( ip r get 1 | head -1 | cut -d' ' -f3 ) - ip_options="${routerip%.*}.0/24(rw,sync,no_subtree_check)" -} soundProfile() { if [[ $1 == reset ]]; then swappiness=60 @@ -251,14 +247,6 @@ datarestore ) [[ -e $dirsystem/color ]] && $dirbash/cmd.sh color $dirbash/cmd.sh power$'\n'reboot ;; -fstabget ) - echo -e "\ -# cat /etc/fstab -$( cat /etc/fstab ) - -# mount | grep ^/dev -$( mount | grep ^/dev | sort )" - ;; hddspindown ) duration=${args[1]} dev=${args[2]} @@ -532,25 +520,42 @@ mpdoledset ) pushRefresh fi ;; -nfsdisable ) - systemctl disable --now nfs-server - rm /mnt/MPD/NAS/{SD,USB} - chmod 755 /mnt/MPD/{SD,USB} - pushRefresh +nfsdata ) + path=${args[1]} + if systemctl -q is-active nfs-server; then + active=true + grep -q "$path" /etc/exports && shared=true || shared=false + else + active=false + shared=false + fi + [[ $( stat -c %a "$path" ) == 777 ]] && write=true || write=false + echo [ $shared, $write ] ;; nfsset ) - permsd=${args[1]} - permusb=${args[2]} - chmod $permsd /mnt/MPD/SD - chmod $permusb /mnt/MPD/USB - if ! grep -q /mnt/MPD/ /etc/exports; then - ipOptions - echo -n "\ -/mnt/MPD/SD $ip_options -/mnt/MPD/USB $ip_options -" >> /etc/exports + path=${args[1]} + shared=${args[2]} + write=${args[3]} + if [[ $shared == true ]]; then + [[ $write == true ]] && chmod 777 "$path" || chmod 755 "$path" + ! grep -q "^$path " /etc/exports && echo "$path *(rw,sync,no_subtree_check)" >> /etc/exports + systemctl -q is-active nfs-server && exportfs -arv || systemctl enable --now nfs-server + else + #ips=$( netstat -an | awk '/.*:2049.*EST/ {print $5}' | cut -d: -f1 ) + ips=$( grep -shr 'callback address' /proc/fs/nfsd/clients | cut -d: -f2 ) + if [[ $ips ]]; then + for ip in $ips; do + connected+=" +$( getent hosts $ip )" + done + echo "$connected" + exit + fi + + sed -i "\|^$path | d" /etc/exports + grep -qE ^/ /etc/exports && exportfs -arv || systemctl disable --now nfs-server + chmod 755 "$path" fi - systemctl -q is-active nfs-server && systemctl restart nfs-server || systemctl enable --now nfs-server pushRefresh ;; packagelist ) @@ -815,11 +820,8 @@ shareddataserver ) for dir in audiocd bookmarks lyrics mpd playlists webradio; do ln -s $dirdata/$dir /srv/http/shareddata done - if ! grep -r /srv/http/shareddata /etc/exports; then - ipOptions - echo /srv/http/shareddata $ip_options >> /etc/exports - fi - systemctl restart nfs-server + ! grep -r /srv/http/shareddata /etc/exports && echo '/srv/http/shareddata *(rw,sync,no_subtree_check)' >> /etc/exports + systemctl -q is-active nfs-server && exportfs -arv || systemctl enable --now nfs-server pushRefresh ;; soundprofile ) @@ -860,6 +862,19 @@ statusonboard ) bluetoothctl show | sed -E 's/^(Controller.*)/bluetooth: \1/' fi ;; +storage ) + data="\ +# cat /etc/fstab +$( cat /etc/fstab ) + +# mount | grep ^/dev +$( mount | grep ^/dev | sort ) +" + systemctl -q is-active nfs-server && data+=" +# cat /etc/exports # NFS +$( grep ^/mnt/MPD/ /etc/exports )" + echo "$data" + ;; systemconfig ) config="\ # cat /boot/cmdline.txt diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 5e977251b..c5409cc0f 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -79,7 +79,7 @@ ] ); ?>
    -
    Context menu: Unmount / Re-mount / Forget / Info / Spindown +
    Context menu: Unmount / Re-mount / Forget / Info / Share / Spindown Available sources, local USB and NAS mounts, for Library. • USB drives will be found and mounted automatically. @@ -97,24 +97,12 @@
    
      'Auto Update'
    +	  'label'    => 'Update Hotplug'
     	, 'id'       => 'usbautoupdate'
     	, 'sublabel' => 'USB Drives'
     	, 'icon'     => 'refresh-library'
     	, 'help'     => <<< HTML
    -Auto update Library database on insert / remove USB drives.
    -HTML
    -] );
    -htmlSetting( [
    -	  'label'    => 'NFS Server'
    -	, 'id'       => 'nfs'
    -	, 'sublabel' => 'nfs-server'
    -	, 'icon'     => 'networks'
    -	, 'status'   => 'nfs-server'
    -	, 'setting'  => true
    -	, 'disabled' => 'Shared Data is currently active on NFS Server.'
    -	, 'help'     => <<< HTML
    -Network File System for /mnt/MPD/SD and /mnt/MPD/USB
    +Auto update Library database on insert/remove USB drives.
     HTML
     ] );
     echo '
    '; @@ -454,5 +442,6 @@ Re-mount Forget >Info + >Spindown
    From 2b98a9bccecf8ae0b38ed286b7184eca50993522 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 18:27:28 +0700 Subject: [PATCH 064/237] Update system.js --- srv/http/assets/js/system.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index bd757b030..1ba573066 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -87,11 +87,12 @@ $( '#list' ).on( 'click', 'li', function( e ) { e.stopPropagation(); var $this = $( this ); G.li = $this; + var active = $this.hasClass( 'active' ); $( '#codehddinfo' ).addClass( 'hide' ); $( 'li' ).removeClass( 'active' ); if ( !$( '#menu' ).hasClass( 'hide' ) ) { $( '#menu, #codehddinfo' ).addClass( 'hide' ); - return + if ( active ) return } $this.addClass( 'active' ); @@ -104,7 +105,7 @@ $( '#list' ).on( 'click', 'li', function( e ) { var mounted = list.mounted; $( '#menu .remount' ).toggleClass( 'hide', mounted ); $( '#menu .unmount' ).toggleClass( 'hide', !mounted ); - $( '#menu .info, .spindown' ).toggleClass( 'hide', list.icon !== 'usbdrive' ); + $( '#menu' ).find( '.info, .share, .spindown' ).toggleClass( 'hide', list.icon !== 'usbdrive' ); } var menuH = $( '#menu' ).height(); $( '#menu' ) From 86269116557dc37b8849c7d056ae3ad246e23b99 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 19:02:30 +0700 Subject: [PATCH 065/237] u --- srv/http/bash/cmd.sh | 2 +- srv/http/bash/settings/networks-data.sh | 4 ++-- srv/http/bash/settings/system.sh | 12 ++++++++---- srv/http/bash/snapcast.sh | 2 +- srv/http/bash/status-push.sh | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index 5677d2511..1788a40f9 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -223,7 +223,7 @@ $Album" &> /dev/null & snapclientStop() { systemctl stop snapclient $dirbash/settings/player-conf.sh - clientip=$( ifconfig | awk '/inet .*broadcast/ {print $2}' ) + clientip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) sshCommand $( cat $dirshm/serverip ) $dirbash/snapcast.sh remove $clientip rm $dirshm/serverip } diff --git a/srv/http/bash/settings/networks-data.sh b/srv/http/bash/settings/networks-data.sh index 5cbf85ec7..bf7909272 100644 --- a/srv/http/bash/settings/networks-data.sh +++ b/srv/http/bash/settings/networks-data.sh @@ -28,7 +28,7 @@ pushstream bluetooth '{"connected":'$connected',"btreceiver":'$btreceiver'}' [[ $1 == pushbt ]] && pushstream bluetooth "$listbt" && exit -ipeth=$( ifconfig eth0 2> /dev/null | awk '/^\s*inet / {print $2}' ) +ipeth=$( ifconfig eth0 2> /dev/null | awk '/inet.*broadcast/ {print $2}' ) if [[ $ipeth ]]; then ipr=$( ip r | grep ^default.*eth0 ) static=$( [[ $ipr != *"dhcp src $ipeth "* ]] && echo true ) @@ -62,7 +62,7 @@ if [[ -e $dirshm/wlan ]]; then if netctl is-active "$profile" &> /dev/null; then for i in {1..10}; do - ipwlan=$( ifconfig $wlandev | awk '/^\s*inet / {print $2}' ) + ipwlan=$( ifconfig $wlandev | awk '/inet.*broadcast/ {print $2}' ) [[ $ipwlan ]] && break || sleep 1 done gateway=$( ip r | grep "^default.*$wlandev" | cut -d' ' -f3 ) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 60082b476..76c82eec8 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -45,6 +45,12 @@ I2Cset() { # i2c-bcm2708 [[ $lcd || $I2Clcdchar ]] && echo i2c-bcm2708 >> $filemodule } +nfsAdd() { + path=$1 + ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + ! grep -r "^$path" /etc/exports && echo "$path ${ip%.*}.0/24(rw,sync,no_subtree_check)" >> /etc/exports + systemctl -q is-active nfs-server && exportfs -arv || systemctl enable --now nfs-server +} soundProfile() { if [[ $1 == reset ]]; then swappiness=60 @@ -538,8 +544,7 @@ nfsset ) write=${args[3]} if [[ $shared == true ]]; then [[ $write == true ]] && chmod 777 "$path" || chmod 755 "$path" - ! grep -q "^$path " /etc/exports && echo "$path *(rw,sync,no_subtree_check)" >> /etc/exports - systemctl -q is-active nfs-server && exportfs -arv || systemctl enable --now nfs-server + nfsAdd "$path" else #ips=$( netstat -an | awk '/.*:2049.*EST/ {print $5}' | cut -d: -f1 ) ips=$( grep -shr 'callback address' /proc/fs/nfsd/clients | cut -d: -f2 ) @@ -820,8 +825,7 @@ shareddataserver ) for dir in audiocd bookmarks lyrics mpd playlists webradio; do ln -s $dirdata/$dir /srv/http/shareddata done - ! grep -r /srv/http/shareddata /etc/exports && echo '/srv/http/shareddata *(rw,sync,no_subtree_check)' >> /etc/exports - systemctl -q is-active nfs-server && exportfs -arv || systemctl enable --now nfs-server + nfsAdd /srv/http/shareddata pushRefresh ;; soundprofile ) diff --git a/srv/http/bash/snapcast.sh b/srv/http/bash/snapcast.sh index 83e4e1210..9c550a79d 100644 --- a/srv/http/bash/snapcast.sh +++ b/srv/http/bash/snapcast.sh @@ -34,7 +34,7 @@ if [[ $1 == start ]]; then # client start - save server ip echo $serverip > $serverfile $dirbash/cmd.sh playerstart$'\n'snapcast $dirbash/status-push.sh - clientip=$( ifconfig | awk '/inet .*broadcast/ {print $2}' ) + clientip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) sshCommand $serverip $dirbash/snapcast.sh $clientip else systemctl stop snapclient diff --git a/srv/http/bash/status-push.sh b/srv/http/bash/status-push.sh index 4f00e545b..23ddfe7ef 100644 --- a/srv/http/bash/status-push.sh +++ b/srv/http/bash/status-push.sh @@ -75,7 +75,7 @@ if [[ -e $dirsystem/vumeter || -e $dirsystem/vuled ]]; then fi fi if [[ -e $dirshm/clientip ]]; then - serverip=$( ifconfig | awk '/inet .*broadcast/ {print $2}' ) + serverip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) [[ ! $status ]] && status=$( $dirbash/status.sh ) # status-radio.sh status=$( echo "$status" \ | sed -e '1,/^, "single" *:/ d From 7c9e255efc3bd9745539d2207e2f216472774271 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 19:42:17 +0700 Subject: [PATCH 066/237] u --- srv/http/bash/cmd.sh | 6 +++--- srv/http/bash/common.sh | 3 +++ srv/http/bash/settings/features.sh | 2 +- srv/http/bash/settings/system.sh | 8 ++++---- srv/http/bash/snapcast.sh | 2 +- srv/http/bash/status-push.sh | 2 +- srv/http/bash/status.sh | 2 +- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index 1788a40f9..e7f8a466e 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -223,8 +223,8 @@ $Album" &> /dev/null & snapclientStop() { systemctl stop snapclient $dirbash/settings/player-conf.sh - clientip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) - sshCommand $( cat $dirshm/serverip ) $dirbash/snapcast.sh remove $clientip + ip=$( ipGet ) + sshCommand $( cat $dirshm/serverip ) $dirbash/snapcast.sh remove $ip rm $dirshm/serverip } stopRadio() { @@ -1119,7 +1119,7 @@ power ) done fi if [[ -e /srv/http/shareddata/iplist ]]; then - ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + ip=$( ipGet ) sed -i "/$ip/ d" /srv/http/shareddata/iplist fi cdda=$( mpc -f %file%^%position% playlist | grep ^cdda: | cut -d^ -f2 ) diff --git a/srv/http/bash/common.sh b/srv/http/bash/common.sh index ae2c85ad8..6df19af8b 100644 --- a/srv/http/bash/common.sh +++ b/srv/http/bash/common.sh @@ -40,6 +40,9 @@ ${data:1} exists() { [[ -e $1 ]] && echo true || echo false } +ipGet() { + echo $( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) +} isactive() { systemctl -q is-active $1 && echo true || echo false } diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index e465c6d15..cb0f34fba 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -260,7 +260,7 @@ multiraudioset ) if [[ $( echo "$data" | wc -l ) > 2 ]]; then touch $dirsystem/multiraudio echo "$data" > $dirsystem/multiraudio.conf - ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + ip=$( ipGet ) iplist=$( sed -n 'n;p' <<< "$data" | grep -v $ip ) for ip in $iplist; do sshCommand $ip << EOF diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 76c82eec8..f588d7c56 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -47,7 +47,7 @@ I2Cset() { } nfsAdd() { path=$1 - ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + ip=$( ipGet ) ! grep -r "^$path" /etc/exports && echo "$path ${ip%.*}.0/24(rw,sync,no_subtree_check)" >> /etc/exports systemctl -q is-active nfs-server && exportfs -arv || systemctl enable --now nfs-server } @@ -746,7 +746,7 @@ shareddata ) rm -rf $dirdata/$dir ln -s $mountpoint/$dir $dirdata done - ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' >> $mountpoint/iplist + ipGet >> $mountpoint/iplist chown -h http:http $mountpoint/*/ chown -h mpd:audio $mountpoint $mountpoint/{mpd,playlist} pushRefresh @@ -776,7 +776,7 @@ shareddatadisable ) rm $dirdata/$dir [[ $copydata == true ]] && cp -rf $mountpoint/$dir $dirdata || mkdir $dirdata/$dir done - ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + ip=$( ipGet ) sed -i "/$ip/ d" $mountpoint/iplist [[ ! $( awk NF $mountpoint/iplist ) ]] && rm $mountpoint/iplist umount -l $mountpoint @@ -795,7 +795,7 @@ shareddatadisable ) ;; shareddatalist ) reload=${args[1]} - list=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + list=$( ipGet ) iplist=$( grep -v $list /srv/http/shareddata/iplist ) for ip in $iplist; do if ping -4 -c 1 -w 1 $ip &> /dev/null; then diff --git a/srv/http/bash/snapcast.sh b/srv/http/bash/snapcast.sh index 9c550a79d..9cc02537e 100644 --- a/srv/http/bash/snapcast.sh +++ b/srv/http/bash/snapcast.sh @@ -34,7 +34,7 @@ if [[ $1 == start ]]; then # client start - save server ip echo $serverip > $serverfile $dirbash/cmd.sh playerstart$'\n'snapcast $dirbash/status-push.sh - clientip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + clientip=$( ipGet ) sshCommand $serverip $dirbash/snapcast.sh $clientip else systemctl stop snapclient diff --git a/srv/http/bash/status-push.sh b/srv/http/bash/status-push.sh index 23ddfe7ef..b697ee552 100644 --- a/srv/http/bash/status-push.sh +++ b/srv/http/bash/status-push.sh @@ -75,7 +75,7 @@ if [[ -e $dirsystem/vumeter || -e $dirsystem/vuled ]]; then fi fi if [[ -e $dirshm/clientip ]]; then - serverip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + serverip=$( ipGet ) [[ ! $status ]] && status=$( $dirbash/status.sh ) # status-radio.sh status=$( echo "$status" \ | sed -e '1,/^, "single" *:/ d diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index b8ebab189..670cebc39 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -203,7 +203,7 @@ status+=' , "state" : "'$state'" , "timestamp" : '$( date +%s%3N ) if (( $pllength == 0 )); then - ip=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + ip=$( ipGet ) [[ $ip ]] && hostname=$( avahi-resolve -a4 $ip | awk '{print $NF}' ) ######## status+=' From 3e46e88081e8603b7e908950d4b796da34ec9f39 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 19:51:54 +0700 Subject: [PATCH 067/237] Update install.sh --- install.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 0d1389eab..d0e5315e9 100644 --- a/install.sh +++ b/install.sh @@ -2,16 +2,19 @@ alias=r1 -# 20220926 -dir=/etc/systemd/system -for file in $dir/spotifyd.service $dir/upmpdcli.service; do - ! grep -q CPUAffinity $file && sed -i -e '/Service/ a\CPUAffinity=3' -e '/ExecStartPost/ d' -e 's|/usr/bin/taskset -c 3 ||' $file -done -for file in $dir/mpd.service.d/override.conf $dir/shairport-sync.service.d/override.conf; do - ! grep -q CPUAffinity $file && sed -i -e '/Service/ a\CPUAffinity=3' -e '/ExecStart/ d' $file -done -file=$dir/bluetooth.service.d/override.conf -! grep -q CPUAffinity $file && sed -i -e '/Service/ a\CPUAffinity=3' $file +# 20220930 +if [[ ! -e /boot/kernel.img ]]; then + dir=/etc/systemd/system + for file in $dir/spotifyd.service $dir/upmpdcli.service; do + ! grep -q CPUAffinity $file && sed -i -e '/Service/ a\CPUAffinity=3' -e '/ExecStartPost/ d' -e 's|/usr/bin/taskset -c 3 ||' $file + done + for file in $dir/mpd.service.d/override.conf $dir/shairport-sync.service.d/override.conf; do + ! grep -q CPUAffinity $file && sed -i -e '/Service/ a\CPUAffinity=3' -e '/ExecStart/ d' $file + done + for file in $dir/bluealsa.service.d/override.conf $dir/bluetooth.service.d/override.conf; do + ! grep -q CPUAffinity $file && sed -i -e '/Service/ a\CPUAffinity=3' $file + done +fi dir=/srv/http/assets/img/guide if [[ ! -e $dir/1.jpg ]]; then From 5448de1f581e5fec8ab5764eb1e1c834f2decf7a Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 20:19:09 +0700 Subject: [PATCH 068/237] u --- srv/http/assets/js/system.js | 5 ++++- srv/http/bash/settings/system-data.sh | 7 +++++-- srv/http/bash/settings/system.sh | 6 +----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 1ba573066..82fd4e677 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -1083,7 +1083,10 @@ function renderPage() { html += '
  • '+ val.mountpoint +''+ dot html += ''+ val.source +''; - html += val.size ? ' '+ val.size +'
  • ' : ''; + html += val.size ? ' '+ val.size : ''; + html += val.nfs ? ' • NFS' : ''; + html += val.smb ? ' • SMB' : ''; + html += ''; } ); $( '#list' ).html( html ); $( '#nfs' ).toggleClass( 'disabled', G.shareddataserver ); diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 309db0c8e..772523d03 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -68,9 +68,11 @@ $( ifconfig eth0 | awk '/txqueuelen/ {print $4}' ) \ fi # sd, usb and nas +systemctl -q is-active smb && smb=',"smb":true' if mount | grep -q 'mmcblk0p2 on /'; then used_size=( $( df -lh --output=used,size,target | grep '/$' ) ) - list+=',{"icon":"microsd","mountpoint":"/mnt/MPD/SD","mounted":true,"source":"/dev/mmcblk0p2","size":"'${used_size[0]}'B/'${used_size[1]}'B"}' + grep -q /mnt/MPD/SD /etc/exports && nfs=',"nfs":true' + list+=',{"icon":"microsd","mountpoint":"/mnt/MPD/SD","mounted":true,"source":"/dev/mmcblk0p2","size":"'${used_size[0]}'B/'${used_size[1]}'B"'$nfs$smb'}' fi usb=$( mount | grep ^/dev/sd | cut -d' ' -f1 ) if [[ $usb ]]; then @@ -81,7 +83,8 @@ if [[ $usb ]]; then | sed "s| *$source||" ) if [[ $mountpoint ]]; then used_size=( $( df -lh --output=used,size,source | grep "$source" ) ) - list+=',{"icon":"usbdrive","mountpoint":"'$mountpoint'","mounted":true,"source":"'$source'","size":"'${used_size[0]}'B/'${used_size[1]}'B"}' + grep -q /mnt/MPD/SD /etc/exports && nfs=',"nfs":true' || nfs= + list+=',{"icon":"usbdrive","mountpoint":"'$mountpoint'","mounted":true,"source":"'$source'","size":"'${used_size[0]}'B/'${used_size[1]}'B"'$nfs$smb'}' else label=$( e2label $source ) [[ ! $label ]] && label=? diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index f588d7c56..407fe6fe9 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -867,17 +867,13 @@ statusonboard ) fi ;; storage ) - data="\ + echo -n "\ # cat /etc/fstab $( cat /etc/fstab ) # mount | grep ^/dev $( mount | grep ^/dev | sort ) " - systemctl -q is-active nfs-server && data+=" -# cat /etc/exports # NFS -$( grep ^/mnt/MPD/ /etc/exports )" - echo "$data" ;; systemconfig ) config="\ From 691817632a1e2b5edc85f350e92905e3b40b789c Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 20:27:40 +0700 Subject: [PATCH 069/237] Update system.js --- srv/http/assets/js/system.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 82fd4e677..48da49b19 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -160,7 +160,7 @@ $( '#menu a' ).click( function() { , ok : function() { var val = infoVal(); bash( [ 'nfsset', path, ...val ], function( connected ) { - if ( connected ) { + if ( !val[ 0 ] && connected ) { bannerHide(); info( { icon : 'networks' From a6b4825a968e29e23718e2dc0c6816409e2cc1a5 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 20:56:27 +0700 Subject: [PATCH 070/237] u --- srv/http/assets/js/system.js | 14 +++++++++++++- srv/http/bash/settings/system.sh | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 48da49b19..efb193b0c 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -151,12 +151,24 @@ $( '#menu a' ).click( function() { case 'share': var path = G.li.find( '.mountpoint' ).text(); bash( [ 'nfsdata', path ], function( data ) { + var shared = data[ 0 ]; + var write = data[ 1 ]; info( { icon : 'networks' , title : 'NFS Share' , checkbox : [ 'Share '+ path +'', 'Write permission' ] , values : data - , checkchanged : 1 + , checkchanged : shared ? 1 : '' + , beforeshow : function() { + var $chk = $( '#infoContent input' ); + if ( !shared ) $chk.eq( 1 ).prop( 'disabled', 1 ); + $chk.eq( 0 ).change( function() { + var checked = $( this ).prop( 'checked' ); + $chk.eq( 1 ) + .prop( 'checked', checked ? write : 0 ) + .prop( 'disabled', !checked ); + } ); + } , ok : function() { var val = infoVal(); bash( [ 'nfsset', path, ...val ], function( connected ) { diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 407fe6fe9..cf6b82649 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -558,7 +558,7 @@ $( getent hosts $ip )" fi sed -i "\|^$path | d" /etc/exports - grep -qE ^/ /etc/exports && exportfs -arv || systemctl disable --now nfs-server + grep -qE ^/ /etc/exports && exportfs -arv &> /dev/null || systemctl -q disable --now nfs-server chmod 755 "$path" fi pushRefresh From 6c451cd1135bf8f2de9df4ceee87de5a3f26f58b Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 21:04:52 +0700 Subject: [PATCH 071/237] Update system-data.sh --- srv/http/bash/settings/system-data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 772523d03..5718eefa1 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -83,7 +83,7 @@ if [[ $usb ]]; then | sed "s| *$source||" ) if [[ $mountpoint ]]; then used_size=( $( df -lh --output=used,size,source | grep "$source" ) ) - grep -q /mnt/MPD/SD /etc/exports && nfs=',"nfs":true' || nfs= + grep -q "$mountpoint" /etc/exports && nfs=',"nfs":true' || nfs= list+=',{"icon":"usbdrive","mountpoint":"'$mountpoint'","mounted":true,"source":"'$source'","size":"'${used_size[0]}'B/'${used_size[1]}'B"'$nfs$smb'}' else label=$( e2label $source ) From 419630643bf2fd89f2b7ff44fd0c7c03096e5892 Mon Sep 17 00:00:00 2001 From: rern Date: Tue, 27 Sep 2022 23:28:35 +0700 Subject: [PATCH 072/237] u --- srv/http/assets/js/system.js | 60 +++++++++++++++------------ srv/http/bash/settings/features.sh | 1 + srv/http/bash/settings/system-data.sh | 7 +++- srv/http/bash/settings/system.sh | 49 +++++++++++++++------- srv/http/settings/system.php | 10 ++++- 5 files changed, 83 insertions(+), 44 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index efb193b0c..9e49cbd50 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -103,9 +103,10 @@ $( '#list' ).on( 'click', 'li', function( e ) { $( '#menu .share' ).removeClass( 'hide' ); } else { var mounted = list.mounted; + var usb = list.icon === 'usbdrive'; $( '#menu .remount' ).toggleClass( 'hide', mounted ); $( '#menu .unmount' ).toggleClass( 'hide', !mounted ); - $( '#menu' ).find( '.info, .share, .spindown' ).toggleClass( 'hide', list.icon !== 'usbdrive' ); + $( '#menu' ).find( '.info, .share' ).toggleClass( 'hide', !usb ); } var menuH = $( '#menu' ).height(); $( '#menu' ) @@ -135,7 +136,7 @@ $( '#menu a' ).click( function() { case 'info': var $code = $( '#codehddinfo' ); if ( $code.hasClass( 'hide' ) ) { - bash( 'hdparm -I '+ source, function( data ) { + bash( [ 'hddinfo', source ], function( data ) { $code .html( data ) .removeClass( 'hide' ); @@ -187,36 +188,40 @@ $( '#menu a' ).click( function() { } ); }, 'json' ); break; - case 'spindown': - info( { - icon : 'usbdrive' - , title : 'USB Drive' - , message : 'Spindown when idle:' - , radio : { Disable: 0, '2 minutes': 24, '5 minutes': 60, '10 minutes': 120 } - , values : G.hddspindown - , checkchanged : 1 - , ok : function() { - var val = infoVal() - notify( 'USB Drive Spindown', ( val === 0 ? 'Disable ...' : 'Idle: '+ ( val * 5 / 60 ) +'minutes ...' ), 'usbdrive' ) - bash( [ 'hddspindown', val, source ], function( std ) { - if ( std == -1 ) { - info( { - icon : 'usbdrive' - , title : 'USB Drive' - , message : ''+ source +' not support spindown.' - } ); - bannerHide(); - } - } ); - } - } ); - break; case 'unmount': notify( title, 'Unmount ...', icon ) bash( [ 'unmount', mountpoint ] ); break; } } ); +$( '#setting-hddsleep' ).click( function() { + info( { + icon : 'usbdrive' + , title : 'HDD Sleep' + , message : 'Timer:' + , radio : { Disable: 128, '2 minutes': 24, '5 minutes': 60, '10 minutes': 120 } + , values : G.hddsleep || 128 + , checkchanged : 1 + , cancel : function() { + $( '#hddsleep' ).prop( 'checked', G.hddsleep ); + } + , ok : function() { + var val = infoVal() + notify( 'HDD Sleep', ( val === 128 ? 'Disable ...' : 'Timer: '+ ( val * 5 / 60 ) +'minutes ...' ), 'usbdrive' ) + bash( [ 'hddsleep', val ], function( devices ) { + if ( devices ) { + info( { + icon : 'usbdrive' + , title : 'HDD Sleep' + , message : 'Devices not support sleep:
    ' + + devices + } ); + bannerHide(); + } + } ); + } + } ); +} ); $( '#setting-bluetooth' ).click( function() { info( { icon : 'bluetooth' @@ -1101,7 +1106,8 @@ function renderPage() { html += ''; } ); $( '#list' ).html( html ); - $( '#nfs' ).toggleClass( 'disabled', G.shareddataserver ); + $( '#divhddsleep' ).toggleClass( 'hide', $( '#list .fa-usbdrive' ).length === 0 ); + $( '#hddsleep' ).toggleClass( 'disabled', !G.hddapm ); if ( 'bluetooth' in G || 'wlan' in G ) { if ( 'bluetooth' in G ) { $( '#bluetooth' ).parent().prev().toggleClass( 'single', !G.bluetoothactive ); diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index cb0f34fba..5fffec6c7 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -344,6 +344,7 @@ smbset ) sed -i '/read only = no/ d' $smbconf [[ ${args[1]} == true ]] && sed -i '/path = .*SD/ a\ read only = no' $smbconf [[ ${args[2]} == true ]] && sed -i '/path = .*USB/ a\ read only = no' $smbconf + $dirbash/settings/system.sh hddsleepdisable featureSet smb ;; snapclientdisable ) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 5718eefa1..9d5476195 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -108,6 +108,10 @@ if [[ $nas ]]; then fi list="[ ${list:1} ]" +hddapm=$( hdparm -B /dev/sda1 $( mount | grep -m1 .*USB/ | cut -d' ' -f1 ) | grep -m1 APM_level | awk '{print $NF}' ) +if [[ $hddapm ]]; then + [[ $hddapm == 128 ]] && hddsleep=false || hddsleep=$hddapm +fi if grep -q dtparam=i2c_arm=on /boot/config.txt; then dev=$( ls /dev/i2c* 2> /dev/null | cut -d- -f2 ) lines=$( i2cdetect -y $dev 2> /dev/null ) @@ -166,7 +170,8 @@ data+=' , "audioaplayname" : "'$( cat $dirsystem/audio-aplayname 2> /dev/null )'" , "audiooutput" : "'$( cat $dirsystem/audio-output 2> /dev/null )'" , "camilladsp" : '$( exists $dirsystem/camilladsp )' -, "hddspindown" : '$( cat $dirsystem/hddspindown 2> /dev/null || echo 0 )' +, "hddapm" : '$hddapm' +, "hddsleep" : '$hddsleep' , "hostapd" : '$( isactive hostapd )' , "hostname" : "'$( hostname )'" , "i2seeprom" : '$( grep -q force_eeprom_read=0 /boot/config.txt && echo true )' diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index cf6b82649..f3edfd622 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -15,6 +15,15 @@ pushReboot() { pushRefresh() { $dirbash/settings/system-data.sh pushrefresh } +hddSleepDisable() { + devs=$( mount | grep .*USB/ | cut -d' ' -f1 ) + if [[ $devs ]]; then + for dev in $devs; do + hdparm -q -B 128 $dev &> /dev/null + done + pushRefresh + fi +} I2Cset() { # parse finalized settings grep -E -q 'waveshare|tft35a' $fileconfig && lcd=1 @@ -253,20 +262,29 @@ datarestore ) [[ -e $dirsystem/color ]] && $dirbash/cmd.sh color $dirbash/cmd.sh power$'\n'reboot ;; -hddspindown ) - duration=${args[1]} - dev=${args[2]} - grep -q 'APM.*not supported' <<< $( hdparm -B $dev ) && echo -1 && exit - - if [[ $duration == 0 ]]; then - apm=128 - rm -f $dirsystem/hddspindown - else - apm=127 - echo "$duration" > $dirsystem/hddspindown - fi - hdparm -q -B $apm $dev - hdparm -q -S $duration $dev +hddinfo ) + dev=${args[1]} + echo -n "\ +# hdparm -I $dev +$( hdparm -I $dev ) +" + ;; +hddsleepdisable ) + hddSleepDisable + ;; +hddsleep ) + apm=${args[1]} + devs=$( mount | grep .*USB/ | cut -d' ' -f1 ) + for dev in $devs; do + if hdparm -B $dev | grep -q 'APM.*not supported'; then + notsupport+="$dev +" + else + echo hdparm -q -B $apm $dev + hdparm -q -B $apm $dev + fi + done + [[ $notsupport ]] && echo -n "$notsupport" pushRefresh ;; hostname ) @@ -545,6 +563,7 @@ nfsset ) if [[ $shared == true ]]; then [[ $write == true ]] && chmod 777 "$path" || chmod 755 "$path" nfsAdd "$path" + hddSleepDisable # + pushRefresh else #ips=$( netstat -an | awk '/.*:2049.*EST/ {print $5}' | cut -d: -f1 ) ips=$( grep -shr 'callback address' /proc/fs/nfsd/clients | cut -d: -f2 ) @@ -560,8 +579,8 @@ $( getent hosts $ip )" sed -i "\|^$path | d" /etc/exports grep -qE ^/ /etc/exports && exportfs -arv &> /dev/null || systemctl -q disable --now nfs-server chmod 755 "$path" + pushRefresh fi - pushRefresh ;; packagelist ) filepackages=$dirtmp/packages diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index c5409cc0f..965eab148 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -96,6 +96,15 @@
    
      'HDD Sleep'
    +	, 'id'       => 'hddsleep'
    +	, 'icon'     => 'screenoff'
    +	, 'setting'  => true
    +	, 'help'     => <<< HTML
    +Sleep timer for hard drives.
    +HTML
    +] );
     htmlSetting( [
     	  'label'    => 'Update Hotplug'
     	, 'id'       => 'usbautoupdate'
    @@ -443,5 +452,4 @@
     Forget
     >Info
     
    ->Spindown
     
    
    From 434c04c11385c91668995c3a43324a51b5c99efd Mon Sep 17 00:00:00 2001
    From: rern 
    Date: Tue, 27 Sep 2022 23:45:58 +0700
    Subject: [PATCH 073/237] u
    
    ---
     srv/http/bash/settings/features.sh |  1 -
     srv/http/bash/settings/system.sh   | 20 ++++++++------------
     2 files changed, 8 insertions(+), 13 deletions(-)
    
    diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh
    index 5fffec6c7..cb0f34fba 100644
    --- a/srv/http/bash/settings/features.sh
    +++ b/srv/http/bash/settings/features.sh
    @@ -344,7 +344,6 @@ smbset )
     	sed -i '/read only = no/ d' $smbconf
     	[[ ${args[1]} == true ]] && sed -i '/path = .*SD/ a\	read only = no' $smbconf
     	[[ ${args[2]} == true ]] && sed -i '/path = .*USB/ a\	read only = no' $smbconf
    -	$dirbash/settings/system.sh hddsleepdisable
     	featureSet smb
     	;;
     snapclientdisable )
    diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh
    index f3edfd622..38bc9290d 100644
    --- a/srv/http/bash/settings/system.sh
    +++ b/srv/http/bash/settings/system.sh
    @@ -15,15 +15,6 @@ pushReboot() {
     pushRefresh() {
     	$dirbash/settings/system-data.sh pushrefresh
     }
    -hddSleepDisable() {
    -	devs=$( mount | grep .*USB/ | cut -d' ' -f1 )
    -	if [[ $devs ]]; then
    -		for dev in $devs; do
    -			hdparm -q -B 128 $dev &> /dev/null
    -		done
    -		pushRefresh
    -	fi
    -}
     I2Cset() {
     	# parse finalized settings
     	grep -E -q 'waveshare|tft35a' $fileconfig && lcd=1
    @@ -270,7 +261,13 @@ $( hdparm -I $dev )
     "
     	;;
     hddsleepdisable )
    -	hddSleepDisable
    +	devs=$( mount | grep .*USB/ | cut -d' ' -f1 )
    +	if [[ $devs ]]; then
    +		for dev in $devs; do
    +			hdparm -q -B 128 $dev &> /dev/null
    +		done
    +		pushRefresh
    +	fi
     	;;
     hddsleep )
     	apm=${args[1]}
    @@ -563,7 +560,6 @@ nfsset )
     	if [[ $shared == true ]]; then
     		[[ $write == true ]] && chmod 777 "$path" || chmod 755 "$path"
     		nfsAdd "$path"
    -		hddSleepDisable # + pushRefresh
     	else
     		#ips=$( netstat -an | awk '/.*:2049.*EST/ {print $5}' | cut -d: -f1 )
     		ips=$( grep -shr 'callback address' /proc/fs/nfsd/clients | cut -d: -f2 )
    @@ -579,8 +575,8 @@ $( getent hosts $ip )"
     		sed -i "\|^$path | d" /etc/exports
     		grep -qE ^/ /etc/exports && exportfs -arv &> /dev/null || systemctl -q disable --now nfs-server
     		chmod 755 "$path"
    -		pushRefresh
     	fi
    +	pushRefresh
     	;;
     packagelist )
     	filepackages=$dirtmp/packages
    
    From f5bb49fbd2802907880df930d60f8d6a9aa843d3 Mon Sep 17 00:00:00 2001
    From: rern 
    Date: Tue, 27 Sep 2022 23:55:08 +0700
    Subject: [PATCH 074/237] Update system.sh
    
    ---
     srv/http/bash/settings/system.sh | 16 ++++++++--------
     1 file changed, 8 insertions(+), 8 deletions(-)
    
    diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh
    index 38bc9290d..6fd053de0 100644
    --- a/srv/http/bash/settings/system.sh
    +++ b/srv/http/bash/settings/system.sh
    @@ -264,7 +264,10 @@ hddsleepdisable )
     	devs=$( mount | grep .*USB/ | cut -d' ' -f1 )
     	if [[ $devs ]]; then
     		for dev in $devs; do
    +			! hdparm -B $dev | grep -q 'APM_level' && continue
    +			
     			hdparm -q -B 128 $dev &> /dev/null
    +			hdparm -q -S 0 $dev &> /dev/null
     		done
     		pushRefresh
     	fi
    @@ -273,15 +276,12 @@ hddsleep )
     	apm=${args[1]}
     	devs=$( mount | grep .*USB/ | cut -d' ' -f1 )
     	for dev in $devs; do
    -		if hdparm -B $dev | grep -q 'APM.*not supported'; then
    -			notsupport+="$dev
    -"
    -		else
    -			echo hdparm -q -B $apm $dev
    -			hdparm -q -B $apm $dev
    -		fi
    +		! hdparm -B $dev | grep -q 'APM_level' && notsupport+="$dev"$'\n' && continue
    +
    +		hdparm -q -B $apm $dev
    +		hdparm -q -S $apm $dev
     	done
    -	[[ $notsupport ]] && echo -n "$notsupport"
    +	[[ $notsupport ]] && echo -e "$notsupport"
     	pushRefresh
     	;;
     hostname )
    
    From b502acb0211adb53bb018d080fcb16940d1d5137 Mon Sep 17 00:00:00 2001
    From: rern 
    Date: Wed, 28 Sep 2022 11:53:31 +0700
    Subject: [PATCH 075/237] u
    
    ---
     srv/http/assets/js/system.js          | 80 ++++++++++++---------------
     srv/http/bash/settings/system-data.sh | 40 +++++++++++---
     srv/http/bash/settings/system.sh      | 27 +++------
     srv/http/settings/features.php        |  5 +-
     srv/http/settings/system.php          | 30 +++++++---
     5 files changed, 100 insertions(+), 82 deletions(-)
    
    diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js
    index 9e49cbd50..932b87a77 100644
    --- a/srv/http/assets/js/system.js
    +++ b/srv/http/assets/js/system.js
    @@ -2,6 +2,7 @@ $( function() { // document ready start >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
     
     $( 'body' ).click( function( e ) {
     	$( '#menu' ).addClass( 'hide' );
    +	if ( e.target.id !== 'codehddinfo' ) $( '#codehddinfo' ).addClass( 'hide' );
     	$( 'li' ).removeClass( 'active' );
     	if ( !$( e.target ).parents( '#divi2smodule' ).length && $( '#i2smodule' ).val() === 'none' ) {
     		$( '#divi2smodulesw' ).removeClass( 'hide' );
    @@ -95,18 +96,25 @@ $( '#list' ).on( 'click', 'li', function( e ) {
     		if ( active ) return
     	}
     	
    -	$this.addClass( 'active' );
    -	$( '#menu a' ).addClass( 'hide' );
     	var i = $this.index()
     	var list = G.list[ i ];
    -	if ( i === 0 ) {
    -		$( '#menu .share' ).removeClass( 'hide' );
    +	$this.addClass( 'active' );
    +	$( '#menu a' ).addClass( 'hide' );
    +	var write = list.perm.slice( -2, -1 ) === 'w';
    +	$( '#menu .read' ).toggleClass( 'hide', !write );
    +	$( '#menu .write' ).toggleClass( 'hide', write );
    +	if ( list.icon === 'networks' ) {
    +		$( '#menu .share' ).addClass( 'hide' );
     	} else {
    +		var shared = list.nfs || list.smb;
    +		$( '#menu .share' ).toggleClass( 'hide', shared );
    +		$( '#menu .unshare' ).toggleClass( 'hide', !shared );
    +	}
    +	if ( list.icon !== 'microsd' ) {
     		var mounted = list.mounted;
    -		var usb = list.icon === 'usbdrive';
     		$( '#menu .remount' ).toggleClass( 'hide', mounted );
     		$( '#menu .unmount' ).toggleClass( 'hide', !mounted );
    -		$( '#menu' ).find( '.info, .share' ).toggleClass( 'hide', !usb );
    +		$( '#menu .info' ).toggleClass( 'hide', list.icon === 'usbdrive' );
     	}
     	var menuH = $( '#menu' ).height();
     	$( '#menu' )
    @@ -145,48 +153,29 @@ $( '#menu a' ).click( function() {
     				$code.addClass( 'hide' );
     			}
     			break;
    +		case 'read':
    +		case 'write':
    +			bash( [ 'permission', cmd === 'read' ? 755 : 777, mountpoint ] );
    +			notify( 'Permission', 'Change ...', 'edit-circle' )
    +			break;
     		case 'remount':
     			notify( title, 'Remount ...', icon );
     			bash( [ 'remount', mountpoint, source ] );
     			break;
     		case 'share':
    -			var path = G.li.find( '.mountpoint' ).text();
    -			bash( [ 'nfsdata', path ], function( data ) {
    -				var shared = data[ 0 ];
    -				var write = data[ 1 ];
    -				info( {
    -					  icon         : 'networks'
    -					, title        : 'NFS Share'
    -					, checkbox     : [ 'Share '+ path +'', 'Write permission' ]
    -					, values       : data
    -					, checkchanged : shared ? 1 : ''
    -					, beforeshow   : function() {
    -						var $chk = $( '#infoContent input' );
    -						if ( !shared ) $chk.eq( 1 ).prop( 'disabled', 1 );
    -						$chk.eq( 0 ).change( function() {
    -							var checked = $( this ).prop( 'checked' );
    -							$chk.eq( 1 )
    -								.prop( 'checked', checked ? write : 0 )
    -								.prop( 'disabled', !checked );
    -						} );
    -					}
    -					, ok           : function() {
    -						var val = infoVal();
    -						bash( [ 'nfsset', path, ...val ], function( connected ) {
    -							if ( !val[ 0 ] && connected ) {
    -								bannerHide();
    -								info( {
    -									  icon    : 'networks'
    -									, title   : 'NFS Share'
    -									, message : 'NFS Server is currently connected by:
    ' - + connected - } ); - } - } ); - notify( 'NFS Share', data[ 0 ] ? ( val[ 0 ] ? 'Change ...' : 'Disable ...' ) : 'Enable ...', 'networks' ); - } - } ); - }, 'json' ); + case 'unshare': + bash( [ 'nfsset', cmd, mountpoint ], function( connected ) { + if ( cmd === 'unshare' && connected ) { + bannerHide(); + info( { + icon : 'networks' + , title : 'NFS Share' + , message : 'NFS Server is currently connected by:
    ' + + connected + } ); + } + } ); + notify( 'NFS Share', 'Unshare ...', 'networks' ); break; case 'unmount': notify( title, 'Unmount ...', icon ) @@ -1099,8 +1088,9 @@ function renderPage() { } html += '
  • '+ val.mountpoint +''+ dot - html += ''+ val.source +''; - html += val.size ? ' '+ val.size : ''; + html += ''+ val.source +''; + html += val.size ? val.size : ''; + html += val.icon !== 'networks' ? ' • '+ val.perm +'' : ''; html += val.nfs ? ' • NFS' : ''; html += val.smb ? ' • SMB' : ''; html += '
  • '; diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 9d5476195..425f68e5d 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -68,11 +68,19 @@ $( ifconfig eth0 | awk '/txqueuelen/ {print $4}' ) \ fi # sd, usb and nas -systemctl -q is-active smb && smb=',"smb":true' +smb=$( isactive smb ) if mount | grep -q 'mmcblk0p2 on /'; then used_size=( $( df -lh --output=used,size,target | grep '/$' ) ) - grep -q /mnt/MPD/SD /etc/exports && nfs=',"nfs":true' - list+=',{"icon":"microsd","mountpoint":"/mnt/MPD/SD","mounted":true,"source":"/dev/mmcblk0p2","size":"'${used_size[0]}'B/'${used_size[1]}'B"'$nfs$smb'}' + list+=',{ + "icon" : "microsd" +, "mountpoint" : "/mnt/MPD/SD" +, "mounted" : true +, "source" : "/dev/mmcblk0p2" +, "size" : "'${used_size[0]}'B/'${used_size[1]}'B" +, "nfs" : '$( grep -q /mnt/MPD/SD /etc/exports && echo true )' +, "smb" : '$smb' +, "perm" : "'$( stat -c %A /mnt/MPD/SD )'" +}' fi usb=$( mount | grep ^/dev/sd | cut -d' ' -f1 ) if [[ $usb ]]; then @@ -83,8 +91,16 @@ if [[ $usb ]]; then | sed "s| *$source||" ) if [[ $mountpoint ]]; then used_size=( $( df -lh --output=used,size,source | grep "$source" ) ) - grep -q "$mountpoint" /etc/exports && nfs=',"nfs":true' || nfs= - list+=',{"icon":"usbdrive","mountpoint":"'$mountpoint'","mounted":true,"source":"'$source'","size":"'${used_size[0]}'B/'${used_size[1]}'B"'$nfs$smb'}' + list+=',{ + "icon" : "usbdrive" +, "mountpoint" : "'$mountpoint'" +, "mounted" : true +, "source" : "'$source'" +, "size" : "'${used_size[0]}'B/'${used_size[1]}'B" +, "nfs" : '$( grep -q "$mountpoint" /etc/exports && echo true )' +, "smb" : '$smb' +, "perm" : "'$( stat -c %A "$mountpoint" )'" +}' else label=$( e2label $source ) [[ ! $label ]] && label=? @@ -99,10 +115,20 @@ if [[ $nas ]]; then source=$( echo $line | cut -d' ' -f1 | sed 's/\\040/ /g' ) mountpoint=$( echo $line | cut -d' ' -f2 | sed 's/\\040/ /g' ) used_size=( $( timeout 0.1s df -h --output=used,size,source | grep "$source" ) ) + list+=',{ + "icon" : "networks" +, "mountpoint" : "'$mountpoint'"' if [[ $used_size ]]; then - list+=',{"icon":"networks","mountpoint":"'$mountpoint'","mounted":true,"source":"'$source'","size":"'${used_size[0]}'B/'${used_size[1]}'B"}' + list+=' +, "mounted" : true +, "source" : "'$source'" +, "size" : "'${used_size[0]}'B/'${used_size[1]}'B" +}' else - list+=',{"icon":"networks","mountpoint":"'$mountpoint'","mounted":false,"source":"'$source'"}' + list+=' +, "mounted" : false +, "source" : "'$source'" +}' fi done fi diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 6fd053de0..f8475aa43 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -257,7 +257,7 @@ hddinfo ) dev=${args[1]} echo -n "\ # hdparm -I $dev -$( hdparm -I $dev ) +$( hdparm -I $dev | sed '1,3 d' ) " ;; hddsleepdisable ) @@ -541,24 +541,10 @@ mpdoledset ) pushRefresh fi ;; -nfsdata ) - path=${args[1]} - if systemctl -q is-active nfs-server; then - active=true - grep -q "$path" /etc/exports && shared=true || shared=false - else - active=false - shared=false - fi - [[ $( stat -c %a "$path" ) == 777 ]] && write=true || write=false - echo [ $shared, $write ] - ;; nfsset ) - path=${args[1]} - shared=${args[2]} - write=${args[3]} - if [[ $shared == true ]]; then - [[ $write == true ]] && chmod 777 "$path" || chmod 755 "$path" + action=${args[1]} + path=${args[2]} + if [[ $action == share ]]; then nfsAdd "$path" else #ips=$( netstat -an | awk '/.*:2049.*EST/ {print $5}' | cut -d: -f1 ) @@ -574,7 +560,6 @@ $( getent hosts $ip )" sed -i "\|^$path | d" /etc/exports grep -qE ^/ /etc/exports && exportfs -arv &> /dev/null || systemctl -q disable --now nfs-server - chmod 755 "$path" fi pushRefresh ;; @@ -607,6 +592,10 @@ $description fi grep -B1 -A2 --no-group-separator "^${args[1],}" $filepackages ;; +permission ) + chmod ${args[1]} "${args[2]}" + pushRefresh + ;; powerbuttondisable ) if [[ -e $dirsystem/audiophonics ]]; then rm $dirsystem/audiophonics diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index 5dfeefb78..206a1422d 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -209,8 +209,9 @@ , 'setting' => true , 'help' => <<< HTML Samba - Share files on network. - • Set sources permissions for read+write - directory: 0777 file: 0555 - • At address bar of Windows File Explorer: \\\\$ip or \\\\$hostname + • Set sources permissions for read + write - directory: 0777 file: 0555 + • Windows: File Explorer > Address bar - \\\\$ip or \\\\$hostname + • NFS share should yeild better performance. (System > Storage - Context menu) HTML , 'exist' => file_exists( '/usr/bin/smbd' ) ] diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 965eab148..66bf38153 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -1,4 +1,7 @@ '; @@ -79,21 +82,27 @@ ] ); ?>
      -
      Context menu: Unmount / Re-mount / Forget / Info / Share / Spindown +
      Icon context menu: Unmount / Re-mount / Forget / Info / Share + +USB drives: + • Will be found and mounted automatically. -Available sources, local USB and NAS mounts, for Library. - • USB drives will be found and mounted automatically. - • Network shares must be manually configured. +Network shares: + • Must be manually configured. • If mount failed, try in SSH terminal:
       mkdir -p "/mnt/MPD/NAS/NAME"
      -# CIFS: (Remove username=USER,password=PASSWORD, if blank)
      -mount -t cifs "//IP/SHARENAME" "/mnt/MPD/NAS/NAME" \
      +# CIFS: (no user - username=guest, no password - password="")
      +mount -t cifs "//SERVER_IP/SHARENAME" "/mnt/MPD/NAS/NAME" \
             -o noauto,username=USER,password=PASSWORD,uid=,gid=,iocharset=utf8
       # NFS:
      -mount -t nfs "IP:/SHARE/PATH" "/mnt/MPD/NAS/NAME" \
      +mount -t nfs "SERVER_IP:/SHARE/PATH" "/mnt/MPD/NAS/NAME" \
             -o defaults,noauto,bg,soft,timeo=5
      -
      +NFS clients on Windows: + • Windows Features > Services for NFS > Client for NFS - Enable + • File Explorer > Address bar - \\ or \\ + +
      
       Re-mount
       Forget
       >Info
      -
      +
      +Unshare
      +Read + Write
      +Read only
       
      
      From 4ce276c679a1d703598c8e9bdde52ce6a0235df9 Mon Sep 17 00:00:00 2001
      From: rern 
      Date: Wed, 28 Sep 2022 18:08:19 +0700
      Subject: [PATCH 076/237] u
      
      ---
       srv/http/assets/js/features.js          |  3 +-
       srv/http/assets/js/settings.js          |  4 ++-
       srv/http/assets/js/system.js            | 37 +++++++++++++------------
       srv/http/bash/settings/features-data.sh |  1 +
       srv/http/bash/settings/features.sh      |  2 ++
       srv/http/bash/settings/system-data.sh   |  4 +--
       srv/http/bash/settings/system.sh        | 29 +++++++++----------
       srv/http/settings/features.php          |  1 +
       8 files changed, 45 insertions(+), 36 deletions(-)
      
      diff --git a/srv/http/assets/js/features.js b/srv/http/assets/js/features.js
      index e5b2ea8e2..76a1dbbd6 100644
      --- a/srv/http/assets/js/features.js
      +++ b/srv/http/assets/js/features.js
      @@ -263,7 +263,7 @@ $( '#setting-smb' ).click( function() {
       	info( {
       		  icon         : 'networks'
       		, title        : 'Samba File Sharing'
      -		, message      : 'Write permission:'
      +		, message      : 'Write permission:'
       		, checkbox     : [ '/mnt/MPD/SD', '/mnt/MPD/USB' ]
       		, values       : G.smbconf
       		, checkchanged : ( G.smb ? 1 : 0 )
      @@ -480,6 +480,7 @@ function renderPage() {
       	$( '#redirecturi' ).text( G.spotifyredirect );
       	$( '#upmpdcli' ).toggleClass( 'disabled', G.upmpdcliactive );
       	$( '#hostapd' ).toggleClass( 'disabled', G.wlanconnected );
      +	$( '#smb' ).toggleClass( 'disabled', G.nfs );
       	$( '#stoptimer' ).toggleClass( 'disabled', !G.playing );
       	if ( G.nosound ) {
       		$( '#divdsp, #divsnapserver' ).addClass( 'hide' );
      diff --git a/srv/http/assets/js/settings.js b/srv/http/assets/js/settings.js
      index d3bf21283..6b1087dc2 100644
      --- a/srv/http/assets/js/settings.js
      +++ b/srv/http/assets/js/settings.js
      @@ -282,7 +282,9 @@ function psPlayer( data ) {
       }
       function psRefresh( data ) {
       	if ( data.page === page ) {
      -		G = data;
      +		$.each( data, function( k, v ) {
      +			G[ k ] = v;
      +		} );
       		setSwitch();
       		renderPage();
       	}
      diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js
      index 932b87a77..c3e4d19e5 100644
      --- a/srv/http/assets/js/system.js
      +++ b/srv/http/assets/js/system.js
      @@ -106,9 +106,8 @@ $( '#list' ).on( 'click', 'li', function( e ) {
       	if ( list.icon === 'networks' ) {
       		$( '#menu .share' ).addClass( 'hide' );
       	} else {
      -		var shared = list.nfs || list.smb;
      -		$( '#menu .share' ).toggleClass( 'hide', shared );
      -		$( '#menu .unshare' ).toggleClass( 'hide', !shared );
      +		$( '#menu .share' ).toggleClass( 'hide', list.nfs );
      +		$( '#menu .unshare' ).toggleClass( 'hide', !list.nfs );
       	}
       	if ( list.icon !== 'microsd' ) {
       		var mounted = list.mounted;
      @@ -127,8 +126,9 @@ $( '#list' ).on( 'click', 'li', function( e ) {
       $( '#menu a' ).click( function() {
       	var $this = $( this );
       	var cmd = $this.prop( 'class' );
      -	var source = G.li.find( '.source' ).text();
      -	var mountpoint = G.li.find( '.mountpoint' ).text();
      +	var list = G.list[ G.li.index() ];
      +	var mountpoint = list.mountpoint;
      +	var source = list.source;
       	if ( mountpoint.slice( 9, 12 ) === 'NAS' ) {
       		var icon = 'networks';
       		var title = 'Network Mount';
      @@ -164,18 +164,18 @@ $( '#menu a' ).click( function() {
       			break;
       		case 'share':
       		case 'unshare':
      -			bash( [ 'nfsset', cmd, mountpoint ], function( connected ) {
      -				if ( cmd === 'unshare' && connected ) {
      -					bannerHide();
      -					info( {
      -						  icon    : 'networks'
      -						, title   : 'NFS Share'
      -						, message : 'NFS Server is currently connected by:
      ' - + connected - } ); - } - } ); - notify( 'NFS Share', 'Unshare ...', 'networks' ); + if ( list.smb ) { + info( { + icon : 'networks' + , title : 'NFS Share' + , message : 'Samba Server is currently active on:
      ' + + mountpoint + } ); + break; + } + + bash( [ 'nfsset', cmd, mountpoint ] ); + notify( 'NFS Share', ( cmd === 'share' ? 'Share ...' : 'Unshare ...' ), 'networks' ); break; case 'unmount': notify( title, 'Unmount ...', icon ) @@ -1086,8 +1086,9 @@ function renderPage() { var dataunmounted = ' data-unmounted="1"'; var dot = ' • '; } + var mountpoint = val.mountpoint === '/mnt/MPD/SD' ? '/mnt/MPD/SD' : val.mountpoint; html += '
    • '+ val.mountpoint +''+ dot + html += '>'+ mountpoint +''+ dot html += ''+ val.source +''; html += val.size ? val.size : ''; html += val.icon !== 'networks' ? ' • '+ val.perm +'' : ''; diff --git a/srv/http/bash/settings/features-data.sh b/srv/http/bash/settings/features-data.sh index 80fd3e8b1..d00861c3e 100644 --- a/srv/http/bash/settings/features-data.sh +++ b/srv/http/bash/settings/features-data.sh @@ -24,6 +24,7 @@ data+=' , "lyricsembedded" : '$( [[ -e $dirsystem/lyricsembedded ]] && echo true )' , "multiraudio" : '$( exists $dirsystem/multiraudio )' , "multiraudioconf" : [ '$( sed 's/^/"/; s/$/", /' $dirsystem/multiraudio.conf 2> /dev/null | sed '$ s/,//' )' ] +, "nfs" : '$( grep -q -E '/mnt/MPD/SD |/mnt/MPD/USB ' /etc/exports && echo true )' , "nosound" : '$( exists $dirshm/nosound )' , "playing" : '$( mpc | grep -q '\[playing]' && echo true )' , "scrobble" : '$( [[ -e $dirsystem/scrobble ]] && echo true )' diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index cb0f34fba..39ba65d94 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -338,6 +338,7 @@ shairport-sync | spotifyd | upmpdcli ) smbdisable ) systemctl disable --now smb pushRefresh + $dirbash/settings/system-data.sh pushrefresh ;; smbset ) smbconf=/etc/samba/smb.conf @@ -345,6 +346,7 @@ smbset ) [[ ${args[1]} == true ]] && sed -i '/path = .*SD/ a\ read only = no' $smbconf [[ ${args[2]} == true ]] && sed -i '/path = .*USB/ a\ read only = no' $smbconf featureSet smb + $dirbash/settings/system-data.sh pushrefresh ;; snapclientdisable ) rm $dirsystem/snapclient diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 425f68e5d..11ba45c1a 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -73,7 +73,7 @@ if mount | grep -q 'mmcblk0p2 on /'; then used_size=( $( df -lh --output=used,size,target | grep '/$' ) ) list+=',{ "icon" : "microsd" -, "mountpoint" : "/mnt/MPD/SD" +, "mountpoint" : "/mnt/MPD/SD" , "mounted" : true , "source" : "/dev/mmcblk0p2" , "size" : "'${used_size[0]}'B/'${used_size[1]}'B" @@ -98,7 +98,7 @@ if [[ $usb ]]; then , "source" : "'$source'" , "size" : "'${used_size[0]}'B/'${used_size[1]}'B" , "nfs" : '$( grep -q "$mountpoint" /etc/exports && echo true )' -, "smb" : '$smb' +, "smb" : '$( [[ $smb == true && $mountpoint == /mnt/MPD/USB ]] && echo true )' , "perm" : "'$( stat -c %A "$mountpoint" )'" }' else diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index f8475aa43..e649e3b64 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -47,9 +47,11 @@ I2Cset() { } nfsAdd() { path=$1 - ip=$( ipGet ) - ! grep -r "^$path" /etc/exports && echo "$path ${ip%.*}.0/24(rw,sync,no_subtree_check)" >> /etc/exports - systemctl -q is-active nfs-server && exportfs -arv || systemctl enable --now nfs-server + if ! grep -q "^$path" /etc/exports; then + ip=$( ipGet ) + echo "$path ${ip%.*}.0/24(rw,sync,no_subtree_check)" >> /etc/exports + systemctl -q is-active nfs-server && exportfs -arv || systemctl enable --now nfs-server + fi } soundProfile() { if [[ $1 == reset ]]; then @@ -479,7 +481,8 @@ mount ) ! ping -c 1 -w 1 $ip &> /dev/null && echo "IP $ip not found." && exit if [[ -e $mountpoint ]]; then - find "$mountpoint" -mindepth 1 | read && echo "Mount name $mountpoint not empty." && exit + [[ $( ls "$mountpoint" ) ]] && echo "Mount name $mountpoint not empty." && exit + else mkdir "$mountpoint" fi @@ -545,23 +548,21 @@ nfsset ) action=${args[1]} path=${args[2]} if [[ $action == share ]]; then - nfsAdd "$path" - else - #ips=$( netstat -an | awk '/.*:2049.*EST/ {print $5}' | cut -d: -f1 ) - ips=$( grep -shr 'callback address' /proc/fs/nfsd/clients | cut -d: -f2 ) - if [[ $ips ]]; then - for ip in $ips; do - connected+=" -$( getent hosts $ip )" - done - echo "$connected" + if [[ $path == /mnt/MPD/SD || $path == /mnt/MPD/USB ]] && systemctl -q is-active smb; then + echo $path exit fi + nfsAdd "$path" + else + #ips=$( netstat -an | awk '/.*:2049.*EST/ {print $5}' | cut -d: -f1 ) + #ips=$( grep -shr 'callback address' /proc/fs/nfsd/clients | cut -d: -f2 ) sed -i "\|^$path | d" /etc/exports grep -qE ^/ /etc/exports && exportfs -arv &> /dev/null || systemctl -q disable --now nfs-server fi pushRefresh + grep -q -E '/mnt/MPD/SD |/mnt/MPD/USB ' /etc/exports && nfs=true || nfs=false + pushstream refresh '{"page":"features","nfs":'$nfs'}' ;; packagelist ) filepackages=$dirtmp/packages diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index 206a1422d..fc6c6ab67 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -207,6 +207,7 @@ , 'icon' => 'networks' , 'status' => 'smb' , 'setting' => true + , 'disabled' => 'NFS Server is currently active.' , 'help' => <<< HTML Samba - Share files on network. • Set sources permissions for read + write - directory: 0777 file: 0555 From b0c6036d4788bb998c19d27c57b0280c24dc8f4c Mon Sep 17 00:00:00 2001 From: rern Date: Wed, 28 Sep 2022 18:25:37 +0700 Subject: [PATCH 077/237] u --- srv/http/bash/settings/system-data.sh | 7 ++----- srv/http/settings/system.php | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 11ba45c1a..e5ddb8971 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -106,6 +106,7 @@ if [[ $usb ]]; then [[ ! $label ]] && label=? list+=',{"icon":"usbdrive","mountpoint":"/mnt/MPD/USB/'$label'","mounted":false,"source":"'$source'"}' fi + [[ ! $hddapm ]] && hddapm=$( hdparm -B $source | grep -m1 APM_level | awk '{print $NF}' ) done fi nas=$( awk '/.mnt.MPD.NAS|.srv.http.shareddata/ {print $1" "$2}' /etc/fstab ) @@ -134,10 +135,6 @@ if [[ $nas ]]; then fi list="[ ${list:1} ]" -hddapm=$( hdparm -B /dev/sda1 $( mount | grep -m1 .*USB/ | cut -d' ' -f1 ) | grep -m1 APM_level | awk '{print $NF}' ) -if [[ $hddapm ]]; then - [[ $hddapm == 128 ]] && hddsleep=false || hddsleep=$hddapm -fi if grep -q dtparam=i2c_arm=on /boot/config.txt; then dev=$( ls /dev/i2c* 2> /dev/null | cut -d- -f2 ) lines=$( i2cdetect -y $dev 2> /dev/null ) @@ -197,7 +194,7 @@ data+=' , "audiooutput" : "'$( cat $dirsystem/audio-output 2> /dev/null )'" , "camilladsp" : '$( exists $dirsystem/camilladsp )' , "hddapm" : '$hddapm' -, "hddsleep" : '$hddsleep' +, "hddsleep" : '${hddapm/128/false}' , "hostapd" : '$( isactive hostapd )' , "hostname" : "'$( hostname )'" , "i2seeprom" : '$( grep -q force_eeprom_read=0 /boot/config.txt && echo true )' diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 66bf38153..3dcebe7a0 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -110,6 +110,7 @@ , 'id' => 'hddsleep' , 'icon' => 'screenoff' , 'setting' => true + , 'disabled' => 'HDD not support sleep' , 'help' => <<< HTML Sleep timer for hard drives. HTML From 01d3b3894634b78cf7d583775d60fc1ae07df367 Mon Sep 17 00:00:00 2001 From: rern Date: Wed, 28 Sep 2022 18:26:49 +0700 Subject: [PATCH 078/237] Update system.js --- srv/http/assets/js/system.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index c3e4d19e5..b65a4979c 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -188,8 +188,8 @@ $( '#setting-hddsleep' ).click( function() { icon : 'usbdrive' , title : 'HDD Sleep' , message : 'Timer:' - , radio : { Disable: 128, '2 minutes': 24, '5 minutes': 60, '10 minutes': 120 } - , values : G.hddsleep || 128 + , radio : { '2 minutes': 24, '5 minutes': 60, '10 minutes': 120 } + , values : G.hddsleep || 60 , checkchanged : 1 , cancel : function() { $( '#hddsleep' ).prop( 'checked', G.hddsleep ); From 0dd4080e811483849f8a5d725b7f63f8ecbd9538 Mon Sep 17 00:00:00 2001 From: rern Date: Wed, 28 Sep 2022 18:30:19 +0700 Subject: [PATCH 079/237] Update system.php --- srv/http/settings/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 3dcebe7a0..3b0d7857e 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -461,8 +461,8 @@ Re-mount Forget >Info - -Unshare + +NFS Unshare Read + Write Read only From ee45efef44074bd12c61f78302ad16920048962a Mon Sep 17 00:00:00 2001 From: rern Date: Wed, 28 Sep 2022 18:30:47 +0700 Subject: [PATCH 080/237] Update system.php --- srv/http/settings/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 3b0d7857e..a5aff5201 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -461,8 +461,8 @@ Re-mount Forget >Info - -NFS Unshare + +NFS unshare Read + Write Read only From db25eac23aec24c6cbaee8f2a579149a71643ce7 Mon Sep 17 00:00:00 2001 From: rern Date: Thu, 29 Sep 2022 21:41:44 +0700 Subject: [PATCH 081/237] u --- srv/http/assets/js/features.js | 3 +- srv/http/assets/js/system.js | 135 +++--------------------- srv/http/bash/cmd.sh | 58 ++++++---- srv/http/bash/common.sh | 3 +- srv/http/bash/settings/features-data.sh | 2 +- srv/http/bash/settings/features.sh | 25 ++++- srv/http/bash/settings/system-data.sh | 3 +- srv/http/bash/settings/system.sh | 83 ++------------- srv/http/settings/features.php | 13 +++ srv/http/settings/system.php | 29 ++--- 10 files changed, 117 insertions(+), 237 deletions(-) diff --git a/srv/http/assets/js/features.js b/srv/http/assets/js/features.js index 76a1dbbd6..0399f9290 100644 --- a/srv/http/assets/js/features.js +++ b/srv/http/assets/js/features.js @@ -480,7 +480,8 @@ function renderPage() { $( '#redirecturi' ).text( G.spotifyredirect ); $( '#upmpdcli' ).toggleClass( 'disabled', G.upmpdcliactive ); $( '#hostapd' ).toggleClass( 'disabled', G.wlanconnected ); - $( '#smb' ).toggleClass( 'disabled', G.nfs ); + $( '#smb' ).toggleClass( 'disabled', G.nfsserver ); + $( '#nfsserver' ).toggleClass( 'disabled', G.smb ); $( '#stoptimer' ).toggleClass( 'disabled', !G.playing ); if ( G.nosound ) { $( '#divdsp, #divsnapserver' ).addClass( 'hide' ); diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index b65a4979c..d82c9f58a 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -85,6 +85,8 @@ $( '#addnas' ).click( function() { infoMount(); } ); $( '#list' ).on( 'click', 'li', function( e ) { + if ( $( this ).find( '.fa-microsd' ).length ) return + e.stopPropagation(); var $this = $( this ); G.li = $this; @@ -100,21 +102,10 @@ $( '#list' ).on( 'click', 'li', function( e ) { var list = G.list[ i ]; $this.addClass( 'active' ); $( '#menu a' ).addClass( 'hide' ); - var write = list.perm.slice( -2, -1 ) === 'w'; - $( '#menu .read' ).toggleClass( 'hide', !write ); - $( '#menu .write' ).toggleClass( 'hide', write ); - if ( list.icon === 'networks' ) { - $( '#menu .share' ).addClass( 'hide' ); - } else { - $( '#menu .share' ).toggleClass( 'hide', list.nfs ); - $( '#menu .unshare' ).toggleClass( 'hide', !list.nfs ); - } - if ( list.icon !== 'microsd' ) { - var mounted = list.mounted; - $( '#menu .remount' ).toggleClass( 'hide', mounted ); - $( '#menu .unmount' ).toggleClass( 'hide', !mounted ); - $( '#menu .info' ).toggleClass( 'hide', list.icon === 'usbdrive' ); - } + var mounted = list.mounted; + $( '#menu .remount' ).toggleClass( 'hide', mounted ); + $( '#menu .unmount' ).toggleClass( 'hide', !mounted ); + $( '#menu .info' ).toggleClass( 'hide', list.icon !== 'usbdrive' ); var menuH = $( '#menu' ).height(); $( '#menu' ) .removeClass( 'hide' ) @@ -153,30 +144,10 @@ $( '#menu a' ).click( function() { $code.addClass( 'hide' ); } break; - case 'read': - case 'write': - bash( [ 'permission', cmd === 'read' ? 755 : 777, mountpoint ] ); - notify( 'Permission', 'Change ...', 'edit-circle' ) - break; case 'remount': notify( title, 'Remount ...', icon ); bash( [ 'remount', mountpoint, source ] ); break; - case 'share': - case 'unshare': - if ( list.smb ) { - info( { - icon : 'networks' - , title : 'NFS Share' - , message : 'Samba Server is currently active on:
      ' - + mountpoint - } ); - break; - } - - bash( [ 'nfsset', cmd, mountpoint ] ); - notify( 'NFS Share', ( cmd === 'share' ? 'Share ...' : 'Unshare ...' ), 'networks' ); - break; case 'unmount': notify( title, 'Unmount ...', icon ) bash( [ 'unmount', mountpoint ] ); @@ -830,23 +801,9 @@ $( '#restore' ).click( function() { $( '#restore' ).prop( 'checked', 0 ); } ); $( '#shareddata' ).click( function() { - if ( G.shareddataserver ) { - info( { - icon : 'networks' - , title : 'Shared Data' - , message : ' All clients will be disconnected.' - +'
      Continue?' - , cancel : function() { - $( '#shareddata' ).prop( 'checked', true ); - } - , okcolor : orange - , oklabel : 'Disable' - , ok : function() { - bash( [ 'shareddatadisable' ] ); - notify( 'Shared Data', 'Disable ...', 'networks' ); - } - } ); - } else if ( G.shareddata ) { + if ( $( this ).hasClass( 'disabled' ) ) return + + if ( G.shareddata ) { info( { icon : 'networks' , title : 'Shared Data' @@ -863,65 +820,7 @@ $( '#shareddata' ).click( function() { } } ); } else { - info( { - icon : 'networks' - , title : 'Shared Data' - , radio : { 'Share music and data from this rAudio': 0, 'Add shares from other server': 1 } - , okno : 1 - , beforeshow : function() { - $( '#infoContent input' ).change( function() { - setTimeout( function() { - if ( $( '#infoContent input:checked' ).val() == 1 ) { - if ( !$( '#list .fa-networks' ).length ) { - info( { - icon : 'networks' - , title : 'Shared Data' - , message : 'Connect music share before enable Shared Data.' - } ); - $( '#shareddata' ).prop( 'checked', false ); - return - } - - infoMount( 'shareddata' ); - } else { - info( { - icon : 'networks' - , title : 'Shared Data - NFS Server' - , message : 'Share path • Name' - , textlabel : [ - '/mnt/MPD/SD' - , '/mnt/MPD/USB' - , '/srv/http/shareddata' - ] - , checkbox : [ 'Update Library database' ] - , values : [ '', 'Music', 'SharedData', true ] - , footer : '
      • Setting values for clients on Storage ' - +'
      • Blank = Disable' - , footeralign : 'left' - , beforeshow : function() { - $( '.infomessage' ).eq( 0 ).css( 'margin-left', '-40px' ); - $( '#infoContent input' ).eq( 2 ) - .prop( 'disabled', 1 ) - .css( 'color', 'var( --cg60 )' ); - $( '#infoContent input' ).on( 'keyup paste', function() { - var $this = $( this ); - setTimeout( function() { - $this.val( $this.val().replace( /\//g, '' ) ); - }, 0 ); - } ); - } - , cancel : function() { - $( '#shareddata' ).prop( 'checked', false ); - } - , ok : function() { - bash( [ 'shareddataserver', ...infoVal() ] ); - } - } ); - } - }, 0 ); - } ); - } - } ); + infoMount( 'shareddata' ); } } ); $( '.listtitle' ).click( function( e ) { @@ -1089,9 +988,8 @@ function renderPage() { var mountpoint = val.mountpoint === '/mnt/MPD/SD' ? '/mnt/MPD/SD' : val.mountpoint; html += '
    • '+ mountpoint +''+ dot - html += ''+ val.source +''; + html += ''+ val.source +' '; html += val.size ? val.size : ''; - html += val.icon !== 'networks' ? ' • '+ val.perm +'' : ''; html += val.nfs ? ' • NFS' : ''; html += val.smb ? ' • SMB' : ''; html += '
    • '; @@ -1128,11 +1026,12 @@ function renderPage() { $( '#hostname' ).val( G.hostname ); $( '#avahiurl' ).text( G.hostname +'.local' ); $( '#timezone' ).val( G.timezone ); - $( '#shareddata' ).prop( 'checked', G.shareddata ); - $( '#divshareddata .col-l' ) - .toggleClass( 'status', G.shareddataserver ) - .toggleClass( 'single', !G.shareddataserver ) - .find( 'gr' ).toggleClass( 'hide', !G.shareddataserver ); + if ( G.nfs ) { + $( '#divshareddata' ).addClass( 'hide' ); + } else { + $( '#divshareddata' ).removeClass( 'hide' ); + $( '#shareddata' ).toggleClass( 'disabled', $( '#list .fa-networks' ).length === 0 ); + } showContent(); } function getStatus() { diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index e7f8a466e..a8255708b 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -1001,39 +1001,55 @@ pkgstatus ) service=$id case $id in camilladsp ) - fileconf=$dircamilladsp/configs/camilladsp.yml;; + fileconf=$dircamilladsp/configs/camilladsp.yml + ;; + hostapd ) + conf="\ +# cat /etc/hostapd/hostapd.conf +$( cat /etc/hostapd/hostapd.conf ) + +# cat /etc/dnsmasq.conf" + ;; localbrowser ) + pkg=chromium fileconf=$dirsystem/localbrowser.conf - pkg=chromium;; + ;; nfs-server ) pkg=nfs-utils - grep -q /mnt/MPD /etc/exports && fileconf=/etc/exports + if systemctl -q is-active nfs-server; then + conf='# Share path:' + paths=$( grep ^/ /etc/exports | cut -d' ' -f1 ) + for path in $paths; do + [[ $path == /srv/http/shareddata ]] && type='Shared Data' || type=$( echo $path | cut -d/ -f4 ) + conf+=$'\n'$( printf "%-15s %-7s" "$type" ':' $path ) + done + fi + ;; + rtsp-simple-server ) + conf="\ +# rtl_test -t +$( script -c "timeout 1 rtl_test -t" | grep -v ^Script )" ;; smb ) + pkg=samba fileconf=/etc/samba/smb.conf - pkg=samba;; + ;; snapclient|snapserver ) + pkg=snapcast [[ $id == snapclient ]] && fileconf=/etc/default/snapclient - pkg=snapcast;; + ;; * ) - fileconf=/etc/$id.conf;; + fileconf=/etc/$id.conf + ;; esac - conf="$( pacman -Q $pkg )" - if [[ -e $fileconf ]]; then - conf+=" + config="$( pacman -Q $pkg )" + if [[ $conf ]]; then + config+=" +$conf" + elif [[ -e $fileconf ]]; then + config+=" # cat $fileconf $( grep -v ^# $fileconf )" - elif [[ $pkg == hostapd ]]; then - conf+=" -# cat /etc/hostapd/hostapd.conf -$( cat /etc/hostapd/hostapd.conf ) - -# cat /etc/dnsmasq.conf -$( cat /etc/dnsmasq.conf )" - elif [[ $pkg == rtsp-simple-server ]]; then - conf+=" -# rtl_test -t -$( script -c "timeout 1 rtl_test -t" | grep -v ^Script )" fi status=$( systemctl status $service \ | sed -E '1 s|^.* (.*service) |\1|' \ @@ -1044,7 +1060,7 @@ $( script -c "timeout 1 rtl_test -t" | grep -v ^Script )" status=$( echo "$status" | grep -v 'Protocol not supported' ) fi echo "\ -$conf +$config $status" ;; diff --git a/srv/http/bash/common.sh b/srv/http/bash/common.sh index 6df19af8b..c55da688e 100644 --- a/srv/http/bash/common.sh +++ b/srv/http/bash/common.sh @@ -41,7 +41,8 @@ exists() { [[ -e $1 ]] && echo true || echo false } ipGet() { - echo $( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + ipaddress=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) + [[ $1 ]] && echo ${ipaddress%.*}.0/24|| echo $ipaddress } isactive() { systemctl -q is-active $1 && echo true || echo false diff --git a/srv/http/bash/settings/features-data.sh b/srv/http/bash/settings/features-data.sh index d00861c3e..e916ee546 100644 --- a/srv/http/bash/settings/features-data.sh +++ b/srv/http/bash/settings/features-data.sh @@ -24,7 +24,7 @@ data+=' , "lyricsembedded" : '$( [[ -e $dirsystem/lyricsembedded ]] && echo true )' , "multiraudio" : '$( exists $dirsystem/multiraudio )' , "multiraudioconf" : [ '$( sed 's/^/"/; s/$/", /' $dirsystem/multiraudio.conf 2> /dev/null | sed '$ s/,//' )' ] -, "nfs" : '$( grep -q -E '/mnt/MPD/SD |/mnt/MPD/USB ' /etc/exports && echo true )' +, "nfsserver" : '$( [[ -L /srv/http/shareddata ]] && systemctl -q is-active nfs-server && echo true )' , "nosound" : '$( exists $dirshm/nosound )' , "playing" : '$( mpc | grep -q '\[playing]' && echo true )' , "scrobble" : '$( [[ -e $dirsystem/scrobble ]] && echo true )' diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index 39ba65d94..6e64420b2 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -274,6 +274,29 @@ EOF pushRefresh pushSubmenu multiraudio true ;; +nfsserver ) + if [[ ${args[1]} == true ]]; then + options="$( ipGet subnet )(rw,sync,no_subtree_check)" + readarray -t dirs <<< $( { ls -d1 /mnt/MPD/SD/*/; ls -d1 /mnt/MPD/USB/*/; } | sed 's|/$||; s| |\\040|g' ) + for dir in "${dirs[@]}"; do + ! grep -q "^$dir" /etc/exports && list+="$dir $options"$'\n' + [[ -d "$dir" ]] && ln -s "$dir" /mnt/MPD/NAS + done + list+="/srv/http/shareddata $options" + echo "$list" >> /etc/exports + ipGet > /srv/http/data/iplist + chmod 777 /srv/http/data + ln -sf /srv/http/{data,shareddata} + systemctl -q is-active nfs-server && exportfs -ar || systemctl enable --now nfs-server + else + systemctl disable --now nfs-server + rm -f /srv/http/data/iplist /srv/http/shareddata + chmod 755 /srv/http/data + sed -i '/^\// d' /etc/exports + find /mnt/MPD/NAS -maxdepth 1 -type l -exec rm -f {} \; + fi + pushRefresh + ;; screenofftoggle ) # [[ $( /opt/vc/bin/vcgencmd display_power ) == display_power=1 ]] && toggle=0 || toggle=1 # /opt/vc/bin/vcgencmd display_power $toggle # hdmi @@ -338,7 +361,6 @@ shairport-sync | spotifyd | upmpdcli ) smbdisable ) systemctl disable --now smb pushRefresh - $dirbash/settings/system-data.sh pushrefresh ;; smbset ) smbconf=/etc/samba/smb.conf @@ -346,7 +368,6 @@ smbset ) [[ ${args[1]} == true ]] && sed -i '/path = .*SD/ a\ read only = no' $smbconf [[ ${args[2]} == true ]] && sed -i '/path = .*USB/ a\ read only = no' $smbconf featureSet smb - $dirbash/settings/system-data.sh pushrefresh ;; snapclientdisable ) rm $dirsystem/snapclient diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index e5ddb8971..0206044ab 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -79,7 +79,6 @@ if mount | grep -q 'mmcblk0p2 on /'; then , "size" : "'${used_size[0]}'B/'${used_size[1]}'B" , "nfs" : '$( grep -q /mnt/MPD/SD /etc/exports && echo true )' , "smb" : '$smb' -, "perm" : "'$( stat -c %A /mnt/MPD/SD )'" }' fi usb=$( mount | grep ^/dev/sd | cut -d' ' -f1 ) @@ -99,7 +98,6 @@ if [[ $usb ]]; then , "size" : "'${used_size[0]}'B/'${used_size[1]}'B" , "nfs" : '$( grep -q "$mountpoint" /etc/exports && echo true )' , "smb" : '$( [[ $smb == true && $mountpoint == /mnt/MPD/USB ]] && echo true )' -, "perm" : "'$( stat -c %A "$mountpoint" )'" }' else label=$( e2label $source ) @@ -206,6 +204,7 @@ data+=' , "lcdmodel" : "'$( cat $dirsystem/lcdmodel 2> /dev/null || echo tft35a )'" , "mpdoled" : '$( exists $dirsystem/mpdoled )' , "mpdoledconf" : '$mpdoledconf' +, "nfs" : '$( [[ -L /srv/http/shareddata ]] && echo true )' , "ntp" : "'$( grep '^NTP' /etc/systemd/timesyncd.conf | cut -d= -f2 )'" , "powerbutton" : '$( systemctl -q is-active powerbutton || [[ $audiophonics == true ]] && echo true )' , "powerbuttonconf" : '$powerbuttonconf' diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index e649e3b64..9fb4419ee 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -45,14 +45,6 @@ I2Cset() { # i2c-bcm2708 [[ $lcd || $I2Clcdchar ]] && echo i2c-bcm2708 >> $filemodule } -nfsAdd() { - path=$1 - if ! grep -q "^$path" /etc/exports; then - ip=$( ipGet ) - echo "$path ${ip%.*}.0/24(rw,sync,no_subtree_check)" >> /etc/exports - systemctl -q is-active nfs-server && exportfs -arv || systemctl enable --now nfs-server - fi -} soundProfile() { if [[ $1 == reset ]]; then swappiness=60 @@ -544,26 +536,6 @@ mpdoledset ) pushRefresh fi ;; -nfsset ) - action=${args[1]} - path=${args[2]} - if [[ $action == share ]]; then - if [[ $path == /mnt/MPD/SD || $path == /mnt/MPD/USB ]] && systemctl -q is-active smb; then - echo $path - exit - fi - - nfsAdd "$path" - else - #ips=$( netstat -an | awk '/.*:2049.*EST/ {print $5}' | cut -d: -f1 ) - #ips=$( grep -shr 'callback address' /proc/fs/nfsd/clients | cut -d: -f2 ) - sed -i "\|^$path | d" /etc/exports - grep -qE ^/ /etc/exports && exportfs -arv &> /dev/null || systemctl -q disable --now nfs-server - fi - pushRefresh - grep -q -E '/mnt/MPD/SD |/mnt/MPD/USB ' /etc/exports && nfs=true || nfs=false - pushstream refresh '{"page":"features","nfs":'$nfs'}' - ;; packagelist ) filepackages=$dirtmp/packages if [[ ! -e $filepackages ]]; then @@ -593,10 +565,6 @@ $description fi grep -B1 -A2 --no-group-separator "^${args[1],}" $filepackages ;; -permission ) - chmod ${args[1]} "${args[2]}" - pushRefresh - ;; powerbuttondisable ) if [[ -e $dirsystem/audiophonics ]]; then rm $dirsystem/audiophonics @@ -766,28 +734,16 @@ shareddata ) shareddatadisable ) copydata=${args[1]} mountpoint=/srv/http/shareddata - if [[ -L $mountpoint/mpd ]]; then # rAudio is server - sed -i -E '/^.srv.http.shareddata / d' /etc/exports - systemctl restart nfs-server - rm -rf /srv/http/shareddata - readarray -t dirs <<< $( ls -1 /mnt/MPD/NAS ) - for dir in "${dirs[@]}"; do - [[ -L "/mnt/MPD/$dir" ]] && rm $dir - done - else - for dir in audiocd bookmarks lyrics mpd playlists webradio; do - [[ ! -L $dirdata/$dir ]] && continue - - rm $dirdata/$dir - [[ $copydata == true ]] && cp -rf $mountpoint/$dir $dirdata || mkdir $dirdata/$dir - done - ip=$( ipGet ) - sed -i "/$ip/ d" $mountpoint/iplist - [[ ! $( awk NF $mountpoint/iplist ) ]] && rm $mountpoint/iplist - umount -l $mountpoint - sed -i "\|$mountpoint| d" /etc/fstab - systemctl daemon-reload - fi + for dir in audiocd bookmarks lyrics mpd playlists webradio; do + rm $dirdata/$dir + [[ $copydata == true ]] && cp -rf $mountpoint/$dir $dirdata || mkdir $dirdata/$dir + done + ip=$( ipGet ) + sed -i "/$ip/ d" $mountpoint/iplist + [[ ! -s $mountpoint/iplist ]] && rm $mountpoint/iplist + umount -l $mountpoint + sed -i "\|$mountpoint| d" /etc/fstab + systemctl daemon-reload rm -rf $mountpoint chown -R http:http $dirdata chown -R mpd:audio $dirmpd @@ -810,29 +766,10 @@ shareddatalist ) done echo "$list" | sort -u > /srv/http/shareddata/iplist ;; -shareddataname ) - echo "\ -# Share path | Name -$( ls -l /mnt/MPD/NAS | grep -v ^total | awk '{print $11" | "$9}' ) -/srv/http/shareddata" - ;; shareddatarestart ) systemctl restart mpd pushstream mpdupdate "$( cat $dirmpd/counts )" ;; -shareddataserver ) - namesd=${args[1]} - nameusb=${args[2]} - [[ $namesd ]] && ln -s /mnt/MPD/SD /mnt/MPD/NAS/$namesd - [[ $nameusb ]] && ln -s /mnt/MPD/USB /mnt/MPD/NAS/$nameusb - mkdir -p /srv/http/shareddata - chmod 777 /srv/http/shareddata - for dir in audiocd bookmarks lyrics mpd playlists webradio; do - ln -s $dirdata/$dir /srv/http/shareddata - done - nfsAdd /srv/http/shareddata - pushRefresh - ;; soundprofile ) soundProfile ;; diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index fc6c6ab67..a85c786c3 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -236,6 +236,19 @@ Switch between multiple rAudio devices. Switch:  Playlist | • SSH passwords must be default. +HTML + ] + , [ + 'label' => 'NFS Server' + , 'id' => 'nfsserver' + , 'sublabel' => 'nfs-server' + , 'icon' => 'networks' + , 'status' => 'nfs-server' + , 'disabled' => 'File Sharing is currently active.' + , 'help' => <<< HTML +NFS - Network File System - Set rAudio as server, file and Shared Data for rAudio clients. + • Share all subdirectories in SD card and USB drives + • Click label to see all share paths HTML ] , [ diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index a5aff5201..cc3d8e06e 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -338,22 +338,19 @@ , [ 'label' => 'Shared Data' , 'id' => 'shareddata' - , 'sublabel' => 'path | name' , 'icon' => 'networks' - , 'status' => 'shareddata' - , 'setting' => 'none' + , 'setting' => true + , 'disabled' => 'No connected music shares.' , 'help' => <<< HTML -Share data for multiple rAudios: audio CD, bookmarks, lyrics, Library database, saved playlists and Web Radio stations. - • SSH passwords must be default. - • Music files should be on NAS only. - • On file server: setup a share directory/folder with all permissions -     • NFS: 777 / a+rwx -     • Samba: read only = no -     • Windows: Everyone - Full Control (Sharing and Security tabs) - • On each rAudio -   • Storage Add shared music -   • Enable to connect the shared data -   • Check Use data from this rAudio only on rAudio with data to be shared or to overwrite existing +Connect share data as client for Library database, audio CD, bookmarks, lyrics, saved playlists and Web Radio. + • On server: setup a share for data with full permissions. +   - rAudio server: Storage context menu > NFS share - Share data +   - NFS: 777 +   - CIFS: read only = no +   - Windows: Everyone - Full Control (Sharing and Security tabs) + • On clients: +   - Add: Storage with the same music share, name and path/share name. +   - Enable this Shared Data HTML ] ]; @@ -461,8 +458,4 @@ Re-mount Forget >Info - -NFS unshare -Read + Write -Read only From 361dfec61b7248f7f21e1f901d3381aa5ffa7738 Mon Sep 17 00:00:00 2001 From: rern Date: Thu, 29 Sep 2022 22:17:30 +0700 Subject: [PATCH 082/237] u --- srv/http/bash/cmd.sh | 2 +- srv/http/bash/settings/features.sh | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index a8255708b..5d1e31e00 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -1018,7 +1018,7 @@ $( cat /etc/hostapd/hostapd.conf ) pkg=nfs-utils if systemctl -q is-active nfs-server; then conf='# Share path:' - paths=$( grep ^/ /etc/exports | cut -d' ' -f1 ) + paths=$( grep ^/ /etc/exports | sed 's/ .*//; s/\\040/ /g' ) for path in $paths; do [[ $path == /srv/http/shareddata ]] && type='Shared Data' || type=$( echo $path | cut -d/ -f4 ) conf+=$'\n'$( printf "%-15s %-7s" "$type" ':' $path ) diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index 6e64420b2..58016694c 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -277,7 +277,9 @@ EOF nfsserver ) if [[ ${args[1]} == true ]]; then options="$( ipGet subnet )(rw,sync,no_subtree_check)" - readarray -t dirs <<< $( { ls -d1 /mnt/MPD/SD/*/; ls -d1 /mnt/MPD/USB/*/; } | sed 's|/$||; s| |\\040|g' ) + dirs="\ +/mnt/MPD/SD +$( ls -d1 /mnt/MPD/USB/*/ | sed 's|/$||; s| |\\040|g' )" for dir in "${dirs[@]}"; do ! grep -q "^$dir" /etc/exports && list+="$dir $options"$'\n' [[ -d "$dir" ]] && ln -s "$dir" /mnt/MPD/NAS From 9e714c2bd34d0d360df13fba7b6d1ce44046d496 Mon Sep 17 00:00:00 2001 From: rern Date: Thu, 29 Sep 2022 22:28:58 +0700 Subject: [PATCH 083/237] Update features.php --- srv/http/settings/features.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index a85c786c3..0ac39cafa 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -246,9 +246,12 @@ , 'status' => 'nfs-server' , 'disabled' => 'File Sharing is currently active.' , 'help' => <<< HTML -NFS - Network File System - Set rAudio as server, file and Shared Data for rAudio clients. - • Share all subdirectories in SD card and USB drives - • Click label to see all share paths +NFS - Network File System - Set rAudio as a server for music files and Shared Data. + • Shares: +   - SD card +   - directories in USB drives +   - Shared Data directory + • Share paths for Storage - click NFS Share label HTML ] , [ From ea1c0102cb13f24c3d757004c15332949984ce1c Mon Sep 17 00:00:00 2001 From: rern Date: Thu, 29 Sep 2022 22:30:23 +0700 Subject: [PATCH 084/237] Update features.php --- srv/http/settings/features.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index 0ac39cafa..3f6b31b2a 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -247,9 +247,9 @@ , 'disabled' => 'File Sharing is currently active.' , 'help' => <<< HTML NFS - Network File System - Set rAudio as a server for music files and Shared Data. - • Shares: + • Share paths:   - SD card -   - directories in USB drives +   - Each directories in USB drives   - Shared Data directory • Share paths for Storage - click NFS Share label HTML From 39f104530f2d1e46015ea0549584ff93b5922de0 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 11:31:32 +0700 Subject: [PATCH 085/237] Add files via upload --- srv/http/bash/settings/features.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index 58016694c..15bbc416f 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -276,17 +276,19 @@ EOF ;; nfsserver ) if [[ ${args[1]} == true ]]; then - options="$( ipGet subnet )(rw,sync,no_subtree_check)" - dirs="\ + ip=$( ipGet ) + options="${ip%.*}.0/24(rw,sync,no_subtree_check)" + echo $ip >> /srv/http/data/iplist + readarray -t dirs <<< $( echo "\ /mnt/MPD/SD -$( ls -d1 /mnt/MPD/USB/*/ | sed 's|/$||; s| |\\040|g' )" +$( find /mnt/MPD/USB -mindepth 1 -maxdepth 1 -type d ) +/srv/http/shareddata" ) for dir in "${dirs[@]}"; do - ! grep -q "^$dir" /etc/exports && list+="$dir $options"$'\n' - [[ -d "$dir" ]] && ln -s "$dir" /mnt/MPD/NAS + dirname=${dir// /\\040} + ! grep -q "^$dirname" /etc/exports && list+="$dirname $options"$'\n' + [[ ! -d "$dir" ]] && ln -s "$dir" /mnt/MPD/NAS done - list+="/srv/http/shareddata $options" echo "$list" >> /etc/exports - ipGet > /srv/http/data/iplist chmod 777 /srv/http/data ln -sf /srv/http/{data,shareddata} systemctl -q is-active nfs-server && exportfs -ar || systemctl enable --now nfs-server @@ -295,7 +297,7 @@ $( ls -d1 /mnt/MPD/USB/*/ | sed 's|/$||; s| |\\040|g' )" rm -f /srv/http/data/iplist /srv/http/shareddata chmod 755 /srv/http/data sed -i '/^\// d' /etc/exports - find /mnt/MPD/NAS -maxdepth 1 -type l -exec rm -f {} \; + find /mnt/MPD/NAS -mindepth 1 -maxdepth 1 -type l -exec rm -f {} \; fi pushRefresh ;; From b483037b7b427026a35d32068b47183c4634c49d Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 11:32:00 +0700 Subject: [PATCH 086/237] Add files via upload --- srv/http/bash/common.sh | 3 +-- srv/http/bash/startup.sh | 48 ++++++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/srv/http/bash/common.sh b/srv/http/bash/common.sh index c55da688e..25147da67 100644 --- a/srv/http/bash/common.sh +++ b/srv/http/bash/common.sh @@ -41,8 +41,7 @@ exists() { [[ -e $1 ]] && echo true || echo false } ipGet() { - ipaddress=$( ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' ) - [[ $1 ]] && echo ${ipaddress%.*}.0/24|| echo $ipaddress + ifconfig | grep -m1 inet.*broadcast | awk '{print $2}' } isactive() { systemctl -q is-active $1 && echo true || echo false diff --git a/srv/http/bash/startup.sh b/srv/http/bash/startup.sh index 14164b0af..c69512556 100644 --- a/srv/http/bash/startup.sh +++ b/srv/http/bash/startup.sh @@ -65,29 +65,33 @@ $( basename "$devprofile" )" fi fi -[[ $connected ]] && readarray -t nas <<< $( ls -d1 /mnt/MPD/NAS/*/ 2> /dev/null | sed 's/.$//' ) -if [[ $nas ]]; then - for mountpoint in "${nas[@]}"; do # ping target before mount - ip=$( grep "${mountpoint// /\\\\040}" /etc/fstab \ - | cut -d' ' -f1 \ - | sed 's|^//||; s|:*/.*$||' ) - for i in {1..10}; do - if ping -4 -c 1 -w 1 $ip &> /dev/null; then - mount "$mountpoint" && break - else - (( i == 10 )) && pushstreamNotifyBlink NAS "NAS @$ip cannot be reached." nas - sleep 2 - fi +if [[ $connected ]]; then + readarray -t nas <<< $( find /mnt/MPD/NAS -mindepth 1 -maxdepth 1 -type d ) + if [[ $nas ]]; then + for mountpoint in "${nas[@]}"; do # ping target before mount + ip=$( grep "${mountpoint// /\\\\040}" /etc/fstab \ + | cut -d' ' -f1 \ + | sed 's|^//||; s|:*/.*$||' ) + [[ ! $ip ]] && continue + + for i in {1..10}; do + if ping -4 -c 1 -w 1 $ip &> /dev/null; then + mount "$mountpoint" && break + else + (( i == 10 )) && pushstreamNotifyBlink NAS "NAS @$ip cannot be reached." nas + sleep 2 + fi + done done - done -fi -if grep -q /srv/http/shareddata /etc/fstab; then - mount /srv/http/shareddata - for i in {1..5}; do - sleep 1 - [[ -d $dirmpd ]] && break - done - $dirbash/settings/system.sh shareddatalist + fi + if grep -q /srv/http/shareddata /etc/fstab; then + mount /srv/http/shareddata + for i in {1..5}; do + sleep 1 + [[ -d $dirmpd ]] && break + done + $dirbash/settings/system.sh shareddatalist + fi fi [[ -e /boot/startup.sh ]] && . /boot/startup.sh From e785a684bac0ee5ae25f8bc5abee87261de614d6 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 11:36:43 +0700 Subject: [PATCH 087/237] Add files via upload --- srv/http/bash/settings/features.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index 15bbc416f..8bbb2f033 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -294,10 +294,10 @@ $( find /mnt/MPD/USB -mindepth 1 -maxdepth 1 -type d ) systemctl -q is-active nfs-server && exportfs -ar || systemctl enable --now nfs-server else systemctl disable --now nfs-server - rm -f /srv/http/data/iplist /srv/http/shareddata chmod 755 /srv/http/data sed -i '/^\// d' /etc/exports - find /mnt/MPD/NAS -mindepth 1 -maxdepth 1 -type l -exec rm -f {} \; + rm /srv/http/data/iplist /srv/http/shareddata + find /mnt/MPD/NAS -mindepth 1 -maxdepth 1 -type l -exec rm {} \; fi pushRefresh ;; From 36afe8ae7b15468b1094203c11abb42e8fc0d1be Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 12:58:38 +0700 Subject: [PATCH 088/237] u --- srv/http/bash/bluetoothcommand.sh | 2 +- srv/http/bash/cmd.sh | 2 +- srv/http/bash/settings/networks.sh | 2 +- srv/http/bash/status.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/srv/http/bash/bluetoothcommand.sh b/srv/http/bash/bluetoothcommand.sh index 66409e83b..a41192738 100644 --- a/srv/http/bash/bluetoothcommand.sh +++ b/srv/http/bash/bluetoothcommand.sh @@ -83,7 +83,7 @@ if [[ $udev == connect ]]; then # >>>> bluetooth.rules: 1. pair from sender; 2. #----- pushstreamNotifyBlink Bluetooth "$msg" bluetooth - if (( $( bluetoothctl info $mac | grep -E 'Paired: yes|Trusted: yes' | wc -l ) == 2 )); then + if (( $( bluetoothctl info $mac | grep -cE 'Paired: yes|Trusted: yes' ) == 2 )); then action=connect else sleep 2 diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index 5d1e31e00..1fd201bdf 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -143,7 +143,7 @@ plAddRandom() { mpcls=$( mpc ls "$dir" ) cuefile=$( grep -m1 '\.cue$' <<< "$mpcls" ) if [[ $cuefile ]]; then - plL=$(( $( grep '^\s*TRACK' "/mnt/MPD/$cuefile" | wc -l ) - 1 )) + plL=$(( $( grep -c '^\s*TRACK' "/mnt/MPD/$cuefile" ) - 1 )) range=$( shuf -i 0-$plL -n 1 ) file="$range $cuefile" grep -q "$file" $dirsystem/librandom && plAddRandom && return diff --git a/srv/http/bash/settings/networks.sh b/srv/http/bash/settings/networks.sh index 87145902b..b685c986f 100644 --- a/srv/http/bash/settings/networks.sh +++ b/srv/http/bash/settings/networks.sh @@ -67,7 +67,7 @@ bluetoothinfo ) info=$( bluetoothctl info $mac ) echo "$info" | grep -q 'not available' && exit - if (( $( echo "$info" | grep -E 'Connected: yes|UUID: Audio' | wc -l ) == 2 )); then + if (( $( echo "$info" | grep -cE 'Connected: yes|UUID: Audio' ) == 2 )); then data="\ # bluealsa-aplay -L $( bluealsa-aplay -L | grep -A2 $mac ) diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index 670cebc39..60c8f8d5b 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -142,7 +142,7 @@ $( cat $dirshm/spotify/status )" outputStatus fi -(( $( grep -E '"cover".*true|"vumeter".*false' $dirsystem/display | wc -l ) == 2 )) && displaycover=1 +(( $( grep -cE '"cover".*true|"vumeter".*false' $dirsystem/display ) == 2 )) && displaycover=1 filter='^Album|^AlbumArtist|^Artist|^audio|^bitrate|^duration|^file|^Name|^song:|^state|^Time|^Title' [[ ! $snapclient ]] && filter+='|^playlistlength|^random|^repeat|^single' From ff5759e91499901b1ebee90fe752d64a55769c12 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 13:54:52 +0700 Subject: [PATCH 089/237] u --- install.sh | 2 + srv/http/bash/settings/player-asound.sh | 2 +- srv/http/bash/settings/player-conf.sh | 4 +- srv/http/bash/settings/system.sh | 3 + srv/http/bash/startup.sh | 81 ++++++++++++------------- 5 files changed, 47 insertions(+), 45 deletions(-) diff --git a/install.sh b/install.sh index d0e5315e9..3f15842ba 100644 --- a/install.sh +++ b/install.sh @@ -3,6 +3,8 @@ alias=r1 # 20220930 +[[ -e /srv/http/data/system/hddspindown }} && mv /srv/http/data/system/{hddspindown,apm} + if [[ ! -e /boot/kernel.img ]]; then dir=/etc/systemd/system for file in $dir/spotifyd.service $dir/upmpdcli.service; do diff --git a/srv/http/bash/settings/player-asound.sh b/srv/http/bash/settings/player-asound.sh index 3af2fa47c..99b4a4453 100644 --- a/srv/http/bash/settings/player-asound.sh +++ b/srv/http/bash/settings/player-asound.sh @@ -83,7 +83,7 @@ echo "$asound" > /etc/asound.conf alsactl nrestore &> /dev/null # notify changes to running daemons # ---------------------------------------------------------------------------- -wm5102card=$( aplay -l | grep snd_rpi_wsp | cut -c 6 ) +wm5102card=$( aplay -l 2> /dev/null | grep snd_rpi_wsp | cut -c 6 ) if [[ $wm5102card ]]; then output=$( cat $dirsystem/hwmixer-wsp 2> /dev/null || echo HPOUT2 Digital ) $dirbash/settings/player-wm5102.sh $wm5102card $output diff --git a/srv/http/bash/settings/player-conf.sh b/srv/http/bash/settings/player-conf.sh index 5a97b28f9..a33cfa784 100644 --- a/srv/http/bash/settings/player-conf.sh +++ b/srv/http/bash/settings/player-conf.sh @@ -207,11 +207,11 @@ if [[ -e /usr/bin/spotifyd ]]; then elif [[ $btmixer ]]; then device=$( bluealsa-aplay -L | head -1 ) else - cardname=$( aplay -l \ + cardname=$( aplay -l 2> /dev/null \ | grep "^card $i" \ | head -1 \ | cut -d' ' -f3 ) - device=$( aplay -L | grep -m1 "^default.*$cardname" ) + [[ $cardname ]] && device=$( aplay -L | grep -m1 "^default.*$cardname" ) fi ######## conf='[global] diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 9fb4419ee..258f1b991 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -265,6 +265,7 @@ hddsleepdisable ) done pushRefresh fi + rm -f $dirsystem/hddsleep ;; hddsleep ) apm=${args[1]} @@ -274,8 +275,10 @@ hddsleep ) hdparm -q -B $apm $dev hdparm -q -S $apm $dev + support=1 done [[ $notsupport ]] && echo -e "$notsupport" + [[ $support ]] && echo $apm > $dirsystem/apm pushRefresh ;; hostname ) diff --git a/srv/http/bash/startup.sh b/srv/http/bash/startup.sh index 14164b0af..a8607feb7 100644 --- a/srv/http/bash/startup.sh +++ b/srv/http/bash/startup.sh @@ -65,32 +65,38 @@ $( basename "$devprofile" )" fi fi -[[ $connected ]] && readarray -t nas <<< $( ls -d1 /mnt/MPD/NAS/*/ 2> /dev/null | sed 's/.$//' ) -if [[ $nas ]]; then - for mountpoint in "${nas[@]}"; do # ping target before mount - ip=$( grep "${mountpoint// /\\\\040}" /etc/fstab \ - | cut -d' ' -f1 \ - | sed 's|^//||; s|:*/.*$||' ) - for i in {1..10}; do - if ping -4 -c 1 -w 1 $ip &> /dev/null; then - mount "$mountpoint" && break - else - (( i == 10 )) && pushstreamNotifyBlink NAS "NAS @$ip cannot be reached." nas - sleep 2 - fi +if [[ $connected ]]; then + readarray -t nas <<< $( find /mnt/MPD/NAS -mindepth 1 -maxdepth 1 -type d ) + if [[ $nas ]]; then + for mountpoint in "${nas[@]}"; do # ping target before mount + ip=$( grep "${mountpoint// /\\\\040}" /etc/fstab \ + | cut -d' ' -f1 \ + | sed 's|^//||; s|:*/.*$||' ) + [[ ! $ip ]] && continue + + for i in {1..10}; do + if ping -4 -c 1 -w 1 $ip &> /dev/null; then + mount "$mountpoint" && break + else + (( i == 10 )) && pushstreamNotifyBlink NAS "NAS @$ip cannot be reached." nas + sleep 2 + fi + done done - done -fi -if grep -q /srv/http/shareddata /etc/fstab; then - mount /srv/http/shareddata - for i in {1..5}; do - sleep 1 - [[ -d $dirmpd ]] && break - done - $dirbash/settings/system.sh shareddatalist + fi + if grep -q /srv/http/shareddata /etc/fstab; then + mount /srv/http/shareddata + for i in {1..5}; do + sleep 1 + [[ -d $dirmpd ]] && break + done + $dirbash/settings/system.sh shareddatalist + fi fi -[[ -e /boot/startup.sh ]] && . /boot/startup.sh +if [[ -e /boot/startup.sh ]]; then + /boot/startup.sh +fi $dirbash/settings/player-conf.sh # mpd.service started by this script @@ -119,24 +125,8 @@ elif [[ ! -e $dirsystem/wlannoap && $wlandev ]] && ! systemctl -q is-enabled hos systemctl -q disable hostapd fi -lsmod | grep -q brcmfmac && touch $dirshm/onboardwlan -[[ $( rfkill -no type | grep -c wlan ) > 1 ]] && usbwifi=1 -profiles=$( netctl list ) -systemctl -q is-active hostapd && hostapd=1 -[[ $usbwifi || ( ! $profiles && ! $hostapd ) ]] && rmmod brcmfmac &> /dev/null - -if [[ -e $dirsystem/hddspindown ]]; then - usb=$( mount | grep ^/dev/sd | cut -d' ' -f1 ) - if [[ $usb ]]; then - duration=$( cat $dirsystem/hddspindown ) - readarray -t usb <<< "$usb" - for dev in "${usb[@]}"; do - grep -q 'APM.*not supported' <<< $( hdparm -B $dev ) && continue - - hdparm -q -B 127 $dev - hdparm -q -S $duration $dev - done - fi +if [[ -e $dirsystem/hddsleep ]]; then + $dirbash/settings/system.sh hddsleep$'\n'$( cat $dirsystem/apm ) fi if [[ ! -e $dirmpd/mpd.db ]]; then @@ -148,4 +138,11 @@ elif [[ -e $dirmpd/listing || ! -e $dirmpd/counts ]]; then $dirbash/cmd-list.sh &> dev/null & fi -[[ $restorefailed ]] && pushstreamNotify 'Restore Settings' '/boot/backup.gz is not rAudio backup.' restore 10000 +if (( $( grep -c ^w /proc/net/wireless ) > 1 )) || ( ! systemctl -q is-active hostapd && [[ ! $( netctl list ) ]] ); then + rmmod brcmfmac &> /dev/null +fi +lsmod | grep -q brcmfmac && touch $dirshm/onboardwlan + +if [[ $restorefailed ]]; then + pushstreamNotify 'Restore Settings' '/boot/backup.gz is not rAudio backup.' restore 10000 +fi From 79d1d95760c3dbe7d363239aa0fadd090c9e064c Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 14:04:58 +0700 Subject: [PATCH 090/237] Update features-data.sh --- srv/http/bash/settings/features-data.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/srv/http/bash/settings/features-data.sh b/srv/http/bash/settings/features-data.sh index e916ee546..4c32e8470 100644 --- a/srv/http/bash/settings/features-data.sh +++ b/srv/http/bash/settings/features-data.sh @@ -68,6 +68,11 @@ if [[ -e /etc/X11/xinit/xinitrc ]]; then else localbrowserconf='{ "rotate": "NORMAL", "zoom": 100, "screenoff": 0, "playon": false, "cursor": false, "brightness": '$brightness' }' fi + if systemctl -q is-active localbrowser; then + localbrowser=true + else + systemctl -q is-enabled localbrowser && systemctl -q disable --now localbrowser + fi data+=' , "localbrowser" : '$( isactive localbrowser )' , "localbrowserconf" : '$localbrowserconf From 77ea314e85dd9efa5e838e40a58f5a0c6109ab83 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 17:42:01 +0700 Subject: [PATCH 091/237] u --- srv/http/assets/js/system.js | 1 + srv/http/bash/cmd.sh | 9 +-------- srv/http/bash/settings/features-data.sh | 2 +- srv/http/bash/settings/features.sh | 22 ++++++++++------------ srv/http/settings/features.php | 16 +++++++++++----- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index d82c9f58a..8e1b7d2aa 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -103,6 +103,7 @@ $( '#list' ).on( 'click', 'li', function( e ) { $this.addClass( 'active' ); $( '#menu a' ).addClass( 'hide' ); var mounted = list.mounted; + $( '#menu .forget' ).toggleClass( 'hide', mounted ); $( '#menu .remount' ).toggleClass( 'hide', mounted ); $( '#menu .unmount' ).toggleClass( 'hide', !mounted ); $( '#menu .info' ).toggleClass( 'hide', list.icon !== 'usbdrive' ); diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index 1fd201bdf..caaacc051 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -1016,14 +1016,7 @@ $( cat /etc/hostapd/hostapd.conf ) ;; nfs-server ) pkg=nfs-utils - if systemctl -q is-active nfs-server; then - conf='# Share path:' - paths=$( grep ^/ /etc/exports | sed 's/ .*//; s/\\040/ /g' ) - for path in $paths; do - [[ $path == /srv/http/shareddata ]] && type='Shared Data' || type=$( echo $path | cut -d/ -f4 ) - conf+=$'\n'$( printf "%-15s %-7s" "$type" ':' $path ) - done - fi + systemctl -q is-active nfs-server && fileconf=/etc/exports ;; rtsp-simple-server ) conf="\ diff --git a/srv/http/bash/settings/features-data.sh b/srv/http/bash/settings/features-data.sh index 4c32e8470..721b01644 100644 --- a/srv/http/bash/settings/features-data.sh +++ b/srv/http/bash/settings/features-data.sh @@ -24,7 +24,7 @@ data+=' , "lyricsembedded" : '$( [[ -e $dirsystem/lyricsembedded ]] && echo true )' , "multiraudio" : '$( exists $dirsystem/multiraudio )' , "multiraudioconf" : [ '$( sed 's/^/"/; s/$/", /' $dirsystem/multiraudio.conf 2> /dev/null | sed '$ s/,//' )' ] -, "nfsserver" : '$( [[ -L /srv/http/shareddata ]] && systemctl -q is-active nfs-server && echo true )' +, "nfsserver" : '$( isactive nfs-server )' , "nosound" : '$( exists $dirshm/nosound )' , "playing" : '$( mpc | grep -q '\[playing]' && echo true )' , "scrobble" : '$( [[ -e $dirsystem/scrobble ]] && echo true )' diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index 8bbb2f033..143472106 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -279,24 +279,22 @@ nfsserver ) ip=$( ipGet ) options="${ip%.*}.0/24(rw,sync,no_subtree_check)" echo $ip >> /srv/http/data/iplist - readarray -t dirs <<< $( echo "\ -/mnt/MPD/SD -$( find /mnt/MPD/USB -mindepth 1 -maxdepth 1 -type d ) -/srv/http/shareddata" ) + readarray -t dirs <<< $( find /mnt/MPD/USB -mindepth 1 -maxdepth 1 -type d ) + dirs+=( /mnt/MPD/SD ) for dir in "${dirs[@]}"; do - dirname=${dir// /\\040} - ! grep -q "^$dirname" /etc/exports && list+="$dirname $options"$'\n' - [[ ! -d "$dir" ]] && ln -s "$dir" /mnt/MPD/NAS + list+="${dir// /\\040} $options"$'\n' + ln -s "$dir" "/mnt/MPD/NAS/$( basename "$dir" )" done - echo "$list" >> /etc/exports + echo -n "\ +$list +/srv/http/data $options" >> /etc/exports chmod 777 /srv/http/data - ln -sf /srv/http/{data,shareddata} - systemctl -q is-active nfs-server && exportfs -ar || systemctl enable --now nfs-server + systemctl enable --now nfs-server else systemctl disable --now nfs-server chmod 755 /srv/http/data - sed -i '/^\// d' /etc/exports - rm /srv/http/data/iplist /srv/http/shareddata + rm /srv/http/data/iplist + > /etc/exports find /mnt/MPD/NAS -mindepth 1 -maxdepth 1 -type l -exec rm {} \; fi pushRefresh diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index 3f6b31b2a..337b63898 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -1,6 +1,13 @@ '.$dirs[ 0 ].''; +} else { + foreach( $dirs as $dir ) $usbdir.= '
          '.$dir.''; +} if ( !file_exists( '/srv/http/data/shm/nosound' ) || file_exists( '/srv/http/data/shm/btreceiver' ) ) { // ---------------------------------------------------------------------------------- @@ -246,12 +253,11 @@ , 'status' => 'nfs-server' , 'disabled' => 'File Sharing is currently active.' , 'help' => <<< HTML -NFS - Network File System - Set rAudio as a server for music files and Shared Data. +NFS - Network File System - Server for music files and Shared Data. • Share paths: -   - SD card -   - Each directories in USB drives -   - Shared Data directory - • Share paths for Storage - click NFS Share label +   - USB drive: {$usbdir} +   - SD card: /mnt/MPD/SD +   - Shared Data: /srv/http/data HTML ] , [ From b67796075fe8d99b98c22ad091f67fa26bb246e2 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 19:39:42 +0700 Subject: [PATCH 092/237] u --- srv/http/assets/js/system.js | 37 +++++++++++++--- srv/http/bash/settings/system-data.sh | 2 +- srv/http/bash/settings/system.sh | 61 ++++++++++++++++++--------- 3 files changed, 72 insertions(+), 28 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 8e1b7d2aa..5af5f800d 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -897,6 +897,9 @@ ${ htmlname }
      + + +`; htmlmount += '
      '; info( { @@ -908,6 +911,33 @@ ${ htmlname } $( '#infoContent td' ).eq( 0 ).css( 'width', 90 ); $( '#infoContent td' ).eq( 1 ).css( 'width', 230 ); var $share = $( '#share' ); + if ( !shareddata ) { + $( '#infoContent .nfsconnect' ).remove(); + } else { + $( '#infoContent .nfsconnect' ).click( function() { + var ip = $( '#list' ).data( 'ip' ); + info( { + icon : 'networks' + , title : 'Shared Data' + , message : 'Connect rAudio NFS server:' + , textlabel : 'IP' + , values : ip.substring( 0, ip.lastIndexOf( '.') + 1 ) + , ok : function() { + var ip = infoVal(); + bash( [ 'shareddataconnect', ip ], function( std ) { + if ( std == -1 ) { + info( { + icon : 'networks' + , title : 'Shared Data' + , message : 'No NFS shares found on rAudio:' + +'
      '+ ip +'' + } ); + } + } ); + } + } ); + } ); + } function hideOptions( type ) { if ( type === 'nfs' ) { $( '#sharelabel' ).text( 'Share path' ); @@ -1027,12 +1057,7 @@ function renderPage() { $( '#hostname' ).val( G.hostname ); $( '#avahiurl' ).text( G.hostname +'.local' ); $( '#timezone' ).val( G.timezone ); - if ( G.nfs ) { - $( '#divshareddata' ).addClass( 'hide' ); - } else { - $( '#divshareddata' ).removeClass( 'hide' ); - $( '#shareddata' ).toggleClass( 'disabled', $( '#list .fa-networks' ).length === 0 ); - } + $( '#divshareddata' ).toggleClass( 'hide', G.nfsserver ); showContent(); } function getStatus() { diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 0206044ab..65d571bd8 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -204,7 +204,7 @@ data+=' , "lcdmodel" : "'$( cat $dirsystem/lcdmodel 2> /dev/null || echo tft35a )'" , "mpdoled" : '$( exists $dirsystem/mpdoled )' , "mpdoledconf" : '$mpdoledconf' -, "nfs" : '$( [[ -L /srv/http/shareddata ]] && echo true )' +, "nfsserver" : '$( isactive nfs-server )' , "ntp" : "'$( grep '^NTP' /etc/systemd/timesyncd.conf | cut -d= -f2 )'" , "powerbutton" : '$( systemctl -q is-active powerbutton || [[ $audiophonics == true ]] && echo true )' , "powerbuttonconf" : '$powerbuttonconf' diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 258f1b991..150e9beaa 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -702,52 +702,71 @@ shareddata ) options=defaults,noauto,bg,soft,timeo=5 fi [[ $extraoptions ]] && options+=,$extraoptions - mountpoint=/srv/http/shareddata - mkdir -p $mountpoint - echo "${source// /\\040} $mountpoint $protocol ${options// /\\040} 0 0" >> /etc/fstab - std=$( mount $mountpoint ) + dirshared=/srv/http/shareddata + mkdir -p $dirshared + echo "${source// /\\040} $dirshared $protocol ${options// /\\040} 0 0" >> /etc/fstab + std=$( mount $dirshared ) if [[ $? == 0 ]]; then systemctl daemon-reload for i in {1..5}; do sleep 1 - mount | grep -q "$mountpoint" && break + mount | grep -q "$dirshared" && break done for dir in audiocd bookmarks lyrics mpd playlists webradio; do if [[ $copydata == true ]]; then - rm -rf $mountpoint/$dir - cp -rf $dirdata/$dir $mountpoint + rm -rf $dirshared/$dir + cp -rf $dirdata/$dir $dirshared else - mkdir -p $mountpoint/$dir + mkdir -p $dirshared/$dir fi rm -rf $dirdata/$dir - ln -s $mountpoint/$dir $dirdata + ln -s $dirshared/$dir $dirdata done - ipGet >> $mountpoint/iplist - chown -h http:http $mountpoint/*/ - chown -h mpd:audio $mountpoint $mountpoint/{mpd,playlist} + ipGet >> $dirshared/iplist + chown -h http:http $dirshared/*/ + chown -h mpd:audio $dirshared $dirshared/{mpd,playlist} pushRefresh [[ $copydata == false ]] && systemctl restart mpd else echo "Mount $source failed:
      "$( echo "$std" | head -1 | sed 's/.*: //' ) - sed -i "\|$mountpoint| d" /etc/fstab - rm -rf $mountpoint + sed -i "\|$dirshared| d" /etc/fstab + rm -rf $dirshared exit fi ;; +shareddataconnect ) + ip=${args[1]} + readarray -t paths <<< $( timeout 3 showmount --no-headers -e $ip 2> /dev/null | awk 'NF{NF-=1};1' ) + [[ ! $paths ]] && echo -1 && exit + + options=defaults,noauto,bg,soft,timeo=5 + for path in "${paths[@]}"; do + source=${path// /\\040} + [[ $path != /srv/http/data ]] && mountpoint=/mnt/MPD/NAS/$( basename $source ) mountpoint=/srv/http/shareddata + list+="$ip:$source $mountpoint nfs $options 0 0"$'\n' + done + echo -n "$list" >> /etc/fstab + mkdir -p /srv/http/shareddata + mount -a + for dir in audiocd bookmarks lyrics mpd playlists webradio; do + rm -rf /srv/http/data/$dir + ln -s /srv/http/{shareddata,data}/$dir + done + ;; shareddatadisable ) copydata=${args[1]} - mountpoint=/srv/http/shareddata + dirshared=/srv/http/shareddata for dir in audiocd bookmarks lyrics mpd playlists webradio; do rm $dirdata/$dir - [[ $copydata == true ]] && cp -rf $mountpoint/$dir $dirdata || mkdir $dirdata/$dir + [[ $copydata == true ]] && cp -rf $dirshared/$dir $dirdata || mkdir $dirdata/$dir done ip=$( ipGet ) - sed -i "/$ip/ d" $mountpoint/iplist - [[ ! -s $mountpoint/iplist ]] && rm $mountpoint/iplist - umount -l $mountpoint - sed -i "\|$mountpoint| d" /etc/fstab + sed -i "/$ip/ d" $dirshared/iplist + [[ ! -s $dirshared/iplist ]] && rm $dirshared/iplist + umount -l $dirshared + sed -i "\|$dirshared| d" /etc/fstab systemctl daemon-reload - rm -rf $mountpoint + rm -rf $dirshared chown -R http:http $dirdata chown -R mpd:audio $dirmpd pushRefresh From 5ce610c369e27e5c49eca5dff1d8f5c61560ea17 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 19:45:44 +0700 Subject: [PATCH 093/237] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 3f15842ba..16180ea24 100644 --- a/install.sh +++ b/install.sh @@ -3,7 +3,7 @@ alias=r1 # 20220930 -[[ -e /srv/http/data/system/hddspindown }} && mv /srv/http/data/system/{hddspindown,apm} +[[ -e /srv/http/data/system/hddspindown ]] && mv /srv/http/data/system/{hddspindown,apm} if [[ ! -e /boot/kernel.img ]]; then dir=/etc/systemd/system From 9cf7933db1eaf293acceef1820a42538924e0106 Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 21:49:00 +0700 Subject: [PATCH 094/237] u --- srv/http/assets/js/system.js | 8 ++++-- srv/http/bash/cmd-list.sh | 2 +- srv/http/bash/settings/system.sh | 49 +++++++++++++++++++++----------- srv/http/bash/startup.sh | 2 +- srv/http/settings/features.php | 36 +++++++++++------------ srv/http/settings/networks.php | 16 +++++------ srv/http/settings/player.php | 12 ++++---- srv/http/settings/system.php | 28 +++++++++--------- 8 files changed, 87 insertions(+), 66 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 5af5f800d..98e29135d 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -802,8 +802,6 @@ $( '#restore' ).click( function() { $( '#restore' ).prop( 'checked', 0 ); } ); $( '#shareddata' ).click( function() { - if ( $( this ).hasClass( 'disabled' ) ) return - if ( G.shareddata ) { info( { icon : 'networks' @@ -919,9 +917,12 @@ ${ htmlname } info( { icon : 'networks' , title : 'Shared Data' - , message : 'Connect rAudio NFS server:' + , message : 'rAudio NFS server - files and data' , textlabel : 'IP' , values : ip.substring( 0, ip.lastIndexOf( '.') + 1 ) + , cancel : function() { + $( '#shareddata' ).prop( 'checked', false ); + } , ok : function() { var ip = infoVal(); bash( [ 'shareddataconnect', ip ], function( std ) { @@ -1058,6 +1059,7 @@ function renderPage() { $( '#avahiurl' ).text( G.hostname +'.local' ); $( '#timezone' ).val( G.timezone ); $( '#divshareddata' ).toggleClass( 'hide', G.nfsserver ); + $( '#setting-shareddata' ).addClass( 'hide' ); showContent(); } function getStatus() { diff --git a/srv/http/bash/cmd-list.sh b/srv/http/bash/cmd-list.sh index f2e97fb9c..a911720ba 100644 --- a/srv/http/bash/cmd-list.sh +++ b/srv/http/bash/cmd-list.sh @@ -146,7 +146,7 @@ if [[ $toolarge ]]; then pushstreamNotifyBlink 'Library Database' 'Library is too large.
      Album list cannot be created.' 'refresh-library' fi -[[ -e /srv/http/shareddata/iplist ]] && $dirbash/settings/system.sh shareddatalist reload +[[ -e /srv/http/shareddata/iplist ]] && $dirbash/settings/system.sh shareddataiplist$'\n'reload ( nonutf8=$( mpc -f '/mnt/MPD/%file% [• %albumartist% ]• %artist% • %album% • %title%' listall | grep -axv '.*' ) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 150e9beaa..80c1e885a 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -45,6 +45,18 @@ I2Cset() { # i2c-bcm2708 [[ $lcd || $I2Clcdchar ]] && echo i2c-bcm2708 >> $filemodule } +sharedDataIPlist() { + reload=$1 + list=$( ipGet ) + iplist=$( grep -v $list /srv/http/shareddata/iplist ) + for ip in $iplist; do + if ping -4 -c 1 -w 1 $ip &> /dev/null; then + [[ $reload ]] && sshCommand $ip $dirbash/settings/system.sh shareddatarestart & >/dev/null & + list+=$'\n'$ip + fi + done + echo "$list" | sort -u > /srv/http/shareddata/iplist +} soundProfile() { if [[ $1 == reset ]]; then swappiness=60 @@ -742,31 +754,45 @@ shareddataconnect ) options=defaults,noauto,bg,soft,timeo=5 for path in "${paths[@]}"; do source=${path// /\\040} - [[ $path != /srv/http/data ]] && mountpoint=/mnt/MPD/NAS/$( basename $source ) mountpoint=/srv/http/shareddata + if [[ $path == /srv/http/data ]]; then + mkdir -p /srv/http/shareddata + mountpoint=/srv/http/shareddata + else + mkdir "/mnt/MPD/NAS/$( basename $path )" + mountpoint=/mnt/MPD/NAS/$( basename $source ) + fi list+="$ip:$source $mountpoint nfs $options 0 0"$'\n' done echo -n "$list" >> /etc/fstab - mkdir -p /srv/http/shareddata mount -a + systemctl daemon-reload for dir in audiocd bookmarks lyrics mpd playlists webradio; do rm -rf /srv/http/data/$dir ln -s /srv/http/{shareddata,data}/$dir done + sharedDataIPlist + pushRefresh ;; shareddatadisable ) copydata=${args[1]} dirshared=/srv/http/shareddata + ! grep -q $dirshared /etc/fstab && exit + for dir in audiocd bookmarks lyrics mpd playlists webradio; do rm $dirdata/$dir [[ $copydata == true ]] && cp -rf $dirshared/$dir $dirdata || mkdir $dirdata/$dir done + rm $dirshared ip=$( ipGet ) sed -i "/$ip/ d" $dirshared/iplist [[ ! -s $dirshared/iplist ]] && rm $dirshared/iplist - umount -l $dirshared - sed -i "\|$dirshared| d" /etc/fstab + ipserver=$( grep $dirshared /etc/fstab | cut -d: -f1 ) + readarray -t mountpoints <<< $( awk '/^'$ipserver'/ {print $2}' /etc/fstab | sed 's/\\040/ /g' ) + for mountpoint in "${mountpoints[@]}"; do + umount -l "$mountpoint" + done + sed -i "/^$ipserver/ d" /etc/fstab systemctl daemon-reload - rm -rf $dirshared chown -R http:http $dirdata chown -R mpd:audio $dirmpd pushRefresh @@ -776,17 +802,8 @@ shareddatadisable ) $dirbash/cmd.sh mpcupdate fi ;; -shareddatalist ) - reload=${args[1]} - list=$( ipGet ) - iplist=$( grep -v $list /srv/http/shareddata/iplist ) - for ip in $iplist; do - if ping -4 -c 1 -w 1 $ip &> /dev/null; then - [[ $reload ]] && sshCommand $ip $dirbash/settings/system.sh shareddatarestart & >/dev/null & - list+=$'\n'$ip - fi - done - echo "$list" | sort -u > /srv/http/shareddata/iplist +shareddataiplist ) + sharedDataIPlist ${args[1]} ;; shareddatarestart ) systemctl restart mpd diff --git a/srv/http/bash/startup.sh b/srv/http/bash/startup.sh index a8607feb7..855a01d8d 100644 --- a/srv/http/bash/startup.sh +++ b/srv/http/bash/startup.sh @@ -90,7 +90,7 @@ if [[ $connected ]]; then sleep 1 [[ -d $dirmpd ]] && break done - $dirbash/settings/system.sh shareddatalist + $dirbash/settings/system.sh shareddataiplist fi fi diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index 337b63898..aff3cc741 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -65,17 +65,17 @@ Spotifyd - Spotify Connect device. • Require Premium account. (No Spotify password saved on rAudio.) • Get ID and Secret from private app : (Screenshots) -   • Spotify for Developers > LOGIN with normal Spotify account -   • CREATE AN APP -     - App name: (any) -     - App description: (any) -   • EDIT SETTINGS -     - Redirect URIs: -   • USERS AND ACCESS > ADD NEW USER -     - Name: (any) -     - Spotify Account: (login email) -   • rAudio Spotify -     - Paste Client ID and Client Secret from the app + • Spotify for Developers > LOGIN with normal Spotify account + • CREATE AN APP + - App name: (any) + - App description: (any) + • EDIT SETTINGS + - Redirect URIs: + • USERS AND ACCESS > ADD NEW USER + - Name: (any) + - Spotify Account: (login email) + • rAudio Spotify + - Paste Client ID and Client Secret from the app HTML , 'exist' => file_exists( '/usr/bin/spotifyd' ) ] @@ -118,11 +118,11 @@ Snapcast - Multiroom client-server audio player. • SSH passwords must be default. • Set SnapServer as a client to sync: -   • Enable SnapClient -   • Connect:  Networks | + - Enable SnapClient + - Connect:  Networks | • Snapcast control client and player: -   • Snapweb -   • Snapdroid + - Snapweb + - Snapdroid HTML , 'exist' => file_exists( '/usr/bin/snapserver' ) ] @@ -255,9 +255,9 @@ , 'help' => <<< HTML NFS - Network File System - Server for music files and Shared Data. • Share paths: -   - USB drive: {$usbdir} -   - SD card: /mnt/MPD/SD -   - Shared Data: /srv/http/data + - USB drive: {$usbdir} + - SD card: /mnt/MPD/SD + - Shared Data: /srv/http/data HTML ] , [ diff --git a/srv/http/settings/networks.php b/srv/http/settings/networks.php index 79f83b237..bb8a70328 100644 --- a/srv/http/settings/networks.php +++ b/srv/http/settings/networks.php @@ -11,19 +11,19 @@
      
       	
      rAudio as sender:(or pairing non-audio devices) • Pair: -   - On receiver - Turn on discovery / pairing mode -   - On rAudio - Bluetooth  Search > Select to pair + - On receiver - Turn on discovery / pairing mode + - On rAudio - Bluetooth  Search > Select to pair • Connect: -   - On receiver - power on / power off > connect / disconnect -   - Receiver buttons can be used to control playback + - On receiver - power on / power off > connect / disconnect + - Receiver buttons can be used to control playback rAudio as receiver: • Pair: -   - On rAudio - System > Bluetooth setting - enable Discoverable by senders -   - On sender - Search > Select rAudio to pair -   - Forget / Remove should be done on both rAudio and sender + - On rAudio - System > Bluetooth setting - enable Discoverable by senders + - On sender - Search > Select rAudio to pair + - Forget / Remove should be done on both rAudio and sender • Connect: -   - On sender - Select rAudio > connect / disconnect + - On sender - Select rAudio > connect / disconnect
      diff --git a/srv/http/settings/player.php b/srv/http/settings/player.php index acf9a5df9..670f154e3 100644 --- a/srv/http/settings/player.php +++ b/srv/http/settings/player.php @@ -193,12 +193,12 @@ • Stopband Begin - Aliasing/imaging control • Attenuation - Lowers the source to prevent clipping • Flags - Extra settings: -   0 - Rolloff - small (<= 0.01 dB) -   1 - Rolloff - medium (<= 0.35 dB) -   2 - Rolloff - none - For Chebyshev bandwidth -   8 - High precision - Increase irrational ratio accuracy -   16 - Double precision - even if Precision <= 20 -   32 - Variable rate resampling +   0 - Rolloff - small (<= 0.01 dB) +   1 - Rolloff - medium (<= 0.35 dB) +   2 - Rolloff - none - For Chebyshev bandwidth +   8 - High precision - Increase irrational ratio accuracy + 16 - Double precision - even if Precision <= 20 + 32 - Variable rate resampling HTML ] , [ diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index cc3d8e06e..80eec0e86 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -156,8 +156,8 @@ Settings • Auto start Access Point - On failed connection or no router • Country of Wi-Fi regulatory domain: -   - 00 = Least common denominator settings, channels and transmit power are permitted in all countries. -   - The connected router may override it to a certain country. + - 00 = Least common denominator settings, channels and transmit power are permitted in all countries. + - The connected router may override it to a certain country. HTML ] ]; @@ -339,18 +339,20 @@ 'label' => 'Shared Data' , 'id' => 'shareddata' , 'icon' => 'networks' - , 'setting' => true - , 'disabled' => 'No connected music shares.' + , 'setting' => 'self' , 'help' => <<< HTML -Connect share data as client for Library database, audio CD, bookmarks, lyrics, saved playlists and Web Radio. - • On server: setup a share for data with full permissions. -   - rAudio server: Storage context menu > NFS share - Share data -   - NFS: 777 -   - CIFS: read only = no -   - Windows: Everyone - Full Control (Sharing and Security tabs) - • On clients: -   - Add: Storage with the same music share, name and path/share name. -   - Enable this Shared Data +Connect share data as client for Library database, audio CD, bookmarks, lyrics, saved playlists and Web Radio. + • rAudio as server: + - Server: Features > NFS share - Enable + - Clients: Enable Shared Data - Auto connect and setup + + • On server: setup a share for data with full permissions. + - NFS: 777 + - CIFS: read only = no + - Windows: Everyone - Full Control (Sharing and Security tabs) + • On clients: + - Add: System > Storage with the same music share, name and path/share name. + - Enable this Shared Data HTML ] ]; From 65860200abb2d7dd460440ab5310cdcef7d1e8be Mon Sep 17 00:00:00 2001 From: rern Date: Fri, 30 Sep 2022 21:56:54 +0700 Subject: [PATCH 095/237] u --- srv/http/settings/features.php | 12 +----------- srv/http/settings/system.php | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index aff3cc741..29d9c148e 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -1,13 +1,6 @@ '.$dirs[ 0 ].''; -} else { - foreach( $dirs as $dir ) $usbdir.= '
          '.$dir.''; -} if ( !file_exists( '/srv/http/data/shm/nosound' ) || file_exists( '/srv/http/data/shm/btreceiver' ) ) { // ---------------------------------------------------------------------------------- @@ -254,10 +247,7 @@ , 'disabled' => 'File Sharing is currently active.' , 'help' => <<< HTML NFS - Network File System - Server for music files and Shared Data. - • Share paths: - - USB drive: {$usbdir} - - SD card: /mnt/MPD/SD - - Shared Data: /srv/http/data + • rAudio clients: System > Settings and Data > Shared Data HTML ] , [ diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 80eec0e86..e31628596 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -343,7 +343,7 @@ , 'help' => <<< HTML Connect share data as client for Library database, audio CD, bookmarks, lyrics, saved playlists and Web Radio. • rAudio as server: - - Server: Features > NFS share - Enable + - Server: Features > NFS Share - Enable - Clients: Enable Shared Data - Auto connect and setup • On server: setup a share for data with full permissions. From b7015f4ce1f89b47698de445921e5afc30f3e0a3 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 08:59:59 +0700 Subject: [PATCH 096/237] u --- srv/http/assets/js/system.js | 4 ++-- srv/http/bash/settings/features.sh | 19 ++++++++++--------- srv/http/bash/settings/system-data.sh | 3 +-- srv/http/settings/system.php | 4 +++- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 98e29135d..5c36467f3 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -801,7 +801,7 @@ $( '#restore' ).click( function() { } ); $( '#restore' ).prop( 'checked', 0 ); } ); -$( '#shareddata' ).click( function() { +$( '#setting-shareddata' ).click( function() { if ( G.shareddata ) { info( { icon : 'networks' @@ -1058,7 +1058,7 @@ function renderPage() { $( '#hostname' ).val( G.hostname ); $( '#avahiurl' ).text( G.hostname +'.local' ); $( '#timezone' ).val( G.timezone ); - $( '#divshareddata' ).toggleClass( 'hide', G.nfsserver ); + $( '#shareddata' ).toggleClass( 'disabled', G.nfsserver ); $( '#setting-shareddata' ).addClass( 'hide' ); showContent(); } diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index 143472106..fe67eab71 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -278,22 +278,23 @@ nfsserver ) if [[ ${args[1]} == true ]]; then ip=$( ipGet ) options="${ip%.*}.0/24(rw,sync,no_subtree_check)" - echo $ip >> /srv/http/data/iplist - readarray -t dirs <<< $( find /mnt/MPD/USB -mindepth 1 -maxdepth 1 -type d ) - dirs+=( /mnt/MPD/SD ) + dirs="\ +/mnt/MPD/SD +$( find /mnt/MPD/USB -mindepth 1 -maxdepth 1 -type d )" + readarray -t dirs <<< $( echo "$dirs" ) for dir in "${dirs[@]}"; do list+="${dir// /\\040} $options"$'\n' ln -s "$dir" "/mnt/MPD/NAS/$( basename "$dir" )" done - echo -n "\ -$list -/srv/http/data $options" >> /etc/exports - chmod 777 /srv/http/data + list+="$dirdata $options" + echo "$list" | column -t > /etc/exports + echo $ip > $dirdata/iplist + chmod 777 $dirdata systemctl enable --now nfs-server else systemctl disable --now nfs-server - chmod 755 /srv/http/data - rm /srv/http/data/iplist + chmod 755 $dirdata + rm $dirdata/iplist > /etc/exports find /mnt/MPD/NAS -mindepth 1 -maxdepth 1 -type l -exec rm {} \; fi diff --git a/srv/http/bash/settings/system-data.sh b/srv/http/bash/settings/system-data.sh index 65d571bd8..78d53034b 100644 --- a/srv/http/bash/settings/system-data.sh +++ b/srv/http/bash/settings/system-data.sh @@ -211,8 +211,7 @@ data+=' , "relays" : '$( exists $dirsystem/relays )' , "rotaryencoder" : '$( isactive rotaryencoder )' , "rotaryencoderconf": '$rotaryencoderconf' -, "shareddata" : '$( exists /srv/http/shareddata )' -, "shareddataserver" : '$( [[ -e /srv/http/shareddata && -L /srv/http/shareddata/mpd ]] && echo true )' +, "shareddata" : '$( [[ -L $dirmpd ]] && echo true )' , "soundprofile" : '$( exists $dirsystem/soundprofile )' , "soundprofileconf" : '$soundprofileconf' , "status" : "'$status'" diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index e31628596..1348c1c13 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -338,8 +338,10 @@ , [ 'label' => 'Shared Data' , 'id' => 'shareddata' + , 'sublabel' => 'client' , 'icon' => 'networks' - , 'setting' => 'self' + , 'setting' => true + , 'disabled' => 'This rAudio is NFS Server' , 'help' => <<< HTML Connect share data as client for Library database, audio CD, bookmarks, lyrics, saved playlists and Web Radio. • rAudio as server: From ca71d0dc1f02e8c9672d83adcd1447c4debca3b9 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 09:01:23 +0700 Subject: [PATCH 097/237] Update system.sh --- srv/http/bash/settings/system.sh | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 80c1e885a..9496b9c8d 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -751,38 +751,38 @@ shareddataconnect ) readarray -t paths <<< $( timeout 3 showmount --no-headers -e $ip 2> /dev/null | awk 'NF{NF-=1};1' ) [[ ! $paths ]] && echo -1 && exit - options=defaults,noauto,bg,soft,timeo=5 + options="nfs defaults,noauto,bg,hard,intr,timeo=5 0 0" + list=$( cat /etc/fstab ) for path in "${paths[@]}"; do + mkdir "/mnt/MPD/NAS/$( basename $path )" source=${path// /\\040} - if [[ $path == /srv/http/data ]]; then - mkdir -p /srv/http/shareddata - mountpoint=/srv/http/shareddata - else - mkdir "/mnt/MPD/NAS/$( basename $path )" - mountpoint=/mnt/MPD/NAS/$( basename $source ) - fi - list+="$ip:$source $mountpoint nfs $options 0 0"$'\n' + mountpoint=/mnt/MPD/NAS/$( basename $source ) + list+="$ip:$source $mountpoint $options"$'\n' + mountpoints+=( "$mountpoint" ) + done + echo "$list" | column -t > /etc/fstab + for mountpoint in "${mountpoints[@]}"; do + mount "$mountpoint" done - echo -n "$list" >> /etc/fstab - mount -a systemctl daemon-reload for dir in audiocd bookmarks lyrics mpd playlists webradio; do - rm -rf /srv/http/data/$dir - ln -s /srv/http/{shareddata,data}/$dir + rm -rf $dirdata/$dir + ln -s /mnt/MPD/NAS/data/$dir $dirdata done + echo data > /mnt/MPD/NAS/.mpdignore sharedDataIPlist pushRefresh ;; shareddatadisable ) - copydata=${args[1]} - dirshared=/srv/http/shareddata - ! grep -q $dirshared /etc/fstab && exit +# ! grep -q $dirdata /etc/fstab && echo -1 && exit + copydata=${args[1]} + [[ -e /mnt/MPD/NAS/data ]] && dirshared=/mnt/MPD/NAS/data || dirshared=/srv/http/shareddata for dir in audiocd bookmarks lyrics mpd playlists webradio; do rm $dirdata/$dir [[ $copydata == true ]] && cp -rf $dirshared/$dir $dirdata || mkdir $dirdata/$dir done - rm $dirshared + rm -f $dirshared /mnt/MPD/NAS/.mpdignore ip=$( ipGet ) sed -i "/$ip/ d" $dirshared/iplist [[ ! -s $dirshared/iplist ]] && rm $dirshared/iplist From 68cc90d2913f2c23d2faa44466e54e75ae5869a8 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 09:10:52 +0700 Subject: [PATCH 098/237] Update system.sh --- srv/http/bash/settings/system.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 9496b9c8d..e449c2dcc 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -761,10 +761,10 @@ shareddataconnect ) mountpoints+=( "$mountpoint" ) done echo "$list" | column -t > /etc/fstab + systemctl daemon-reload for mountpoint in "${mountpoints[@]}"; do mount "$mountpoint" done - systemctl daemon-reload for dir in audiocd bookmarks lyrics mpd playlists webradio; do rm -rf $dirdata/$dir ln -s /mnt/MPD/NAS/data/$dir $dirdata From a215929d9fd6372962c4b69fa8e7341a53423068 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 14:48:13 +0700 Subject: [PATCH 099/237] Update system.js --- srv/http/assets/js/system.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 5c36467f3..c94f1de72 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -102,11 +102,13 @@ $( '#list' ).on( 'click', 'li', function( e ) { var list = G.list[ i ]; $this.addClass( 'active' ); $( '#menu a' ).addClass( 'hide' ); + if ( list.icon === 'microsd' ) return + var mounted = list.mounted; - $( '#menu .forget' ).toggleClass( 'hide', mounted ); + $( '#menu .info' ).toggleClass( 'hide', list.icon !== 'usbdrive' ); + $( '#menu .forget' ).removeClass( 'hide' ); $( '#menu .remount' ).toggleClass( 'hide', mounted ); $( '#menu .unmount' ).toggleClass( 'hide', !mounted ); - $( '#menu .info' ).toggleClass( 'hide', list.icon !== 'usbdrive' ); var menuH = $( '#menu' ).height(); $( '#menu' ) .removeClass( 'hide' ) From 20d6d0f3318550cb6e85b7eecda228fab7aba056 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 14:48:32 +0700 Subject: [PATCH 100/237] Update system.php --- srv/http/settings/system.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 1348c1c13..cb148b8b3 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -458,8 +458,8 @@
      From d80249282b6279ece63b6c6d6dfe8782cdb5116a Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 16:49:32 +0700 Subject: [PATCH 101/237] u --- srv/http/assets/js/features.js | 2 +- srv/http/bash/settings/features-data.sh | 1 + srv/http/bash/settings/features.sh | 4 +++- srv/http/bash/settings/system.sh | 27 +++++++++++++++++-------- srv/http/settings/features.php | 2 +- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/srv/http/assets/js/features.js b/srv/http/assets/js/features.js index 0399f9290..e9dfcdcde 100644 --- a/srv/http/assets/js/features.js +++ b/srv/http/assets/js/features.js @@ -481,7 +481,7 @@ function renderPage() { $( '#upmpdcli' ).toggleClass( 'disabled', G.upmpdcliactive ); $( '#hostapd' ).toggleClass( 'disabled', G.wlanconnected ); $( '#smb' ).toggleClass( 'disabled', G.nfsserver ); - $( '#nfsserver' ).toggleClass( 'disabled', G.smb ); + $( '#nfsserver' ).toggleClass( 'disabled', G.smb || G.shareddata ); $( '#stoptimer' ).toggleClass( 'disabled', !G.playing ); if ( G.nosound ) { $( '#divdsp, #divsnapserver' ).addClass( 'hide' ); diff --git a/srv/http/bash/settings/features-data.sh b/srv/http/bash/settings/features-data.sh index 721b01644..21bbdcdc7 100644 --- a/srv/http/bash/settings/features-data.sh +++ b/srv/http/bash/settings/features-data.sh @@ -30,6 +30,7 @@ data+=' , "scrobble" : '$( [[ -e $dirsystem/scrobble ]] && echo true )' , "scrobbleconf" : ['$scrobbleconf'] , "scrobblekey" : '$( [[ -e $dirsystem/scrobble.conf/key ]] && echo true )' +, "shareddata" : '$( [[ -L $dirmpd ]] && echo true )' , "stoptimer" : '$( [[ -e $dirshm/stoptimer ]] && echo true )' , "stoptimerconf" : '$( cat $dirshm/stoptimer 2> /dev/null || echo [ false, false ] )' , "streaming" : '$( grep -q 'type.*"httpd"' /etc/mpd.conf && echo true ) diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index fe67eab71..4bccf0f77 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -275,7 +275,8 @@ EOF pushSubmenu multiraudio true ;; nfsserver ) - if [[ ${args[1]} == true ]]; then + active=${args[1]} + if [[ $active == true ]]; then ip=$( ipGet ) options="${ip%.*}.0/24(rw,sync,no_subtree_check)" dirs="\ @@ -299,6 +300,7 @@ $( find /mnt/MPD/USB -mindepth 1 -maxdepth 1 -type d )" find /mnt/MPD/NAS -mindepth 1 -maxdepth 1 -type l -exec rm {} \; fi pushRefresh + pushstream refresh '{"page":"system","nfsserver":'$active'}' ;; screenofftoggle ) # [[ $( /opt/vc/bin/vcgencmd display_power ) == display_power=1 ]] && toggle=0 || toggle=1 diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index e449c2dcc..a733a3d1b 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -508,7 +508,10 @@ mount ) options=defaults,noauto,bg,soft,timeo=5 fi [[ $extraoptions ]] && options+=,$extraoptions - echo "${source// /\\040} ${mountpoint// /\\040} $protocol ${options// /\\040} 0 0" >> /etc/fstab + fstab="\ +$( cat /etc/fstab ) +${source// /\\040} ${mountpoint// /\\040} $protocol ${options// /\\040} 0 0" + echo "$fstab" | column -t > /etc/fstab std=$( mount "$mountpoint" 2>&1 ) if [[ $? == 0 ]]; then systemctl daemon-reload @@ -738,6 +741,8 @@ shareddata ) chown -h http:http $dirshared/*/ chown -h mpd:audio $dirshared $dirshared/{mpd,playlist} pushRefresh + pusrstream refresh '{"page":"features","shareddata":true}' + mpc -q clear [[ $copydata == false ]] && systemctl restart mpd else echo "Mount $source failed:
      "$( echo "$std" | head -1 | sed 's/.*: //' ) @@ -754,11 +759,11 @@ shareddataconnect ) options="nfs defaults,noauto,bg,hard,intr,timeo=5 0 0" list=$( cat /etc/fstab ) for path in "${paths[@]}"; do - mkdir "/mnt/MPD/NAS/$( basename $path )" + mkdir "/mnt/MPD/NAS/$( basename "$path" )" source=${path// /\\040} mountpoint=/mnt/MPD/NAS/$( basename $source ) - list+="$ip:$source $mountpoint $options"$'\n' - mountpoints+=( "$mountpoint" ) + list+=$'\n'"$ip:$source $mountpoint $options" + mountpoints+=( "$path" ) done echo "$list" | column -t > /etc/fstab systemctl daemon-reload @@ -770,32 +775,38 @@ shareddataconnect ) ln -s /mnt/MPD/NAS/data/$dir $dirdata done echo data > /mnt/MPD/NAS/.mpdignore + mpc -q clear sharedDataIPlist pushRefresh + pusrstream refresh '{"page":"features","shareddata":true}' ;; shareddatadisable ) -# ! grep -q $dirdata /etc/fstab && echo -1 && exit - copydata=${args[1]} [[ -e /mnt/MPD/NAS/data ]] && dirshared=/mnt/MPD/NAS/data || dirshared=/srv/http/shareddata + ! grep -q $dirshared /etc/fstab && echo -1 && exit + for dir in audiocd bookmarks lyrics mpd playlists webradio; do - rm $dirdata/$dir + [[ -L $dirdata/$dir ]] && rm $dirdata/$dir [[ $copydata == true ]] && cp -rf $dirshared/$dir $dirdata || mkdir $dirdata/$dir done rm -f $dirshared /mnt/MPD/NAS/.mpdignore ip=$( ipGet ) sed -i "/$ip/ d" $dirshared/iplist [[ ! -s $dirshared/iplist ]] && rm $dirshared/iplist + mpc -q clear ipserver=$( grep $dirshared /etc/fstab | cut -d: -f1 ) readarray -t mountpoints <<< $( awk '/^'$ipserver'/ {print $2}' /etc/fstab | sed 's/\\040/ /g' ) for mountpoint in "${mountpoints[@]}"; do umount -l "$mountpoint" + rm "$mountpoint" done - sed -i "/^$ipserver/ d" /etc/fstab + fstab=$( sed "/^$ipserver/ d" /etc/fstab ) + echo "$fstab" | column -t > /etc/fstab systemctl daemon-reload chown -R http:http $dirdata chown -R mpd:audio $dirmpd pushRefresh + pusrstream refresh '{"page":"features","shareddata":false}' if [[ $copydata == false ]]; then rm -f $dirmpd/{updating,listing} systemctl restart mpd diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index 29d9c148e..e5fd641a6 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -244,7 +244,7 @@ , 'sublabel' => 'nfs-server' , 'icon' => 'networks' , 'status' => 'nfs-server' - , 'disabled' => 'File Sharing is currently active.' + , 'disabled' => is_link( '/srv/http/data/mpd' ) ? 'Shared Data is currently enabled.' : 'File Sharing is currently active.' , 'help' => <<< HTML NFS - Network File System - Server for music files and Shared Data. • rAudio clients: System > Settings and Data > Shared Data From 04e988ad3933e4c7b37e357d3720b9e4e8e0ce9b Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 19:00:05 +0700 Subject: [PATCH 102/237] u --- srv/http/assets/js/system.js | 50 +++++++++++++++++--------------- srv/http/bash/settings/system.sh | 39 +++++++++++++++++++------ 2 files changed, 56 insertions(+), 33 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index c94f1de72..392a6aa41 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -915,30 +915,7 @@ ${ htmlname } $( '#infoContent .nfsconnect' ).remove(); } else { $( '#infoContent .nfsconnect' ).click( function() { - var ip = $( '#list' ).data( 'ip' ); - info( { - icon : 'networks' - , title : 'Shared Data' - , message : 'rAudio NFS server - files and data' - , textlabel : 'IP' - , values : ip.substring( 0, ip.lastIndexOf( '.') + 1 ) - , cancel : function() { - $( '#shareddata' ).prop( 'checked', false ); - } - , ok : function() { - var ip = infoVal(); - bash( [ 'shareddataconnect', ip ], function( std ) { - if ( std == -1 ) { - info( { - icon : 'networks' - , title : 'Shared Data' - , message : 'No NFS shares found on rAudio:' - +'
      '+ ip +'' - } ); - } - } ); - } - } ); + infoNFSconnect( $( '#list' ).data( 'ip' ) ); } ); } function hideOptions( type ) { @@ -1003,6 +980,31 @@ ${ htmlname } } } ); } +function infoNFSconnect( ip ) { + info( { + icon : 'networks' + , title : 'Shared Data' + , message : 'rAudio NFS server - files and data' + , textlabel : 'IP' + , values : ip.substring( 0, ip.lastIndexOf( '.') + 1 ) + , cancel : function() { + $( '#shareddata' ).prop( 'checked', false ); + } + , ok : function() { + var ip = infoVal(); + bash( [ 'shareddataconnect', ip ], function( std ) { + if ( std ) { + info( { + icon : 'networks' + , title : 'Shared Data' + , message : std + } ); + bannerHide(); + } + } ); + } + } ); +} function renderPage() { $( '#codehddinfo' ) .empty() diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index a733a3d1b..a27e94433 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -485,7 +485,7 @@ mount ) extraoptions=${args[7]} update=${args[8]} - ! ping -c 1 -w 1 $ip &> /dev/null && echo "IP $ip not found." && exit + ! ping -c 1 -w 1 $ip &> /dev/null && echo "IP not found: $ip" && exit if [[ -e $mountpoint ]]; then [[ $( ls "$mountpoint" ) ]] && echo "Mount name $mountpoint not empty." && exit @@ -523,7 +523,8 @@ ${source// /\\040} ${mountpoint// /\\040} $protocol ${options// /\\040} 0 0 pushRefresh else echo "Mount $source failed:
      "$( echo "$std" | head -1 | sed 's/.*: //' ) - sed -i "\|${mountpoint// /\\040}| d" /etc/fstab + fstab=$( grep -v "${mountpoint// /\\040}" /etc/fstab ) + echo "$fstab" | column -t > /etc/fstab rmdir "$mountpoint" fi ;; @@ -753,23 +754,44 @@ shareddata ) ;; shareddataconnect ) ip=${args[1]} + ! ping -c 1 -w 1 $ip &> /dev/null && echo "IP not found: $ip" && exit + readarray -t paths <<< $( timeout 3 showmount --no-headers -e $ip 2> /dev/null | awk 'NF{NF-=1};1' ) - [[ ! $paths ]] && echo -1 && exit + [[ ! $paths ]] && echo "No NFS shares found @$ip" && exit + + for path in "${paths[@]}"; do + dir="/mnt/MPD/NAS/$( basename "$path" )" + [[ -e "$dir" ]] && echo "Directory exists: $dir" && exit + done options="nfs defaults,noauto,bg,hard,intr,timeo=5 0 0" list=$( cat /etc/fstab ) for path in "${paths[@]}"; do - mkdir "/mnt/MPD/NAS/$( basename "$path" )" + dir="/mnt/MPD/NAS/$( basename "$path" )" + mkdir "$dir" + mountpoints+=( "$dir" ) source=${path// /\\040} mountpoint=/mnt/MPD/NAS/$( basename $source ) list+=$'\n'"$ip:$source $mountpoint $options" - mountpoints+=( "$path" ) done echo "$list" | column -t > /etc/fstab systemctl daemon-reload - for mountpoint in "${mountpoints[@]}"; do - mount "$mountpoint" + for dir in "${mountpoints[@]}"; do + std=$( mount "$dir" 2>&1 ) + [[ $? != 0 ]] && failed=$std && break done + if [[ $failed ]]; then + for dir in "${mountpoints[@]}"; do + umount -l "$dir" &> /dev/null + rm -rf "$dir" + done + fstab=$( grep ^PART /etc/fstab ) + echo "$fstab" | column -t > /etc/fstab + systemctl daemon-reload + echo "Mount $failed failed:
      "$( echo "$std" | head -1 | sed 's/.*: //' ) + exit + fi + for dir in audiocd bookmarks lyrics mpd playlists webradio; do rm -rf $dirdata/$dir ln -s /mnt/MPD/NAS/data/$dir $dirdata @@ -777,7 +799,6 @@ shareddataconnect ) echo data > /mnt/MPD/NAS/.mpdignore mpc -q clear sharedDataIPlist - pushRefresh pusrstream refresh '{"page":"features","shareddata":true}' ;; shareddatadisable ) @@ -864,7 +885,7 @@ storage ) $( cat /etc/fstab ) # mount | grep ^/dev -$( mount | grep ^/dev | sort ) +$( mount | grep ^/dev | sort | column -t ) " ;; systemconfig ) From eee0f1ce919d72f1f81e3ba60bb98ea21c280363 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 19:10:10 +0700 Subject: [PATCH 103/237] Update system.php --- srv/http/settings/system.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index cb148b8b3..257f9e76b 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -347,14 +347,13 @@ • rAudio as server: - Server: Features > NFS Share - Enable - Clients: Enable Shared Data - Auto connect and setup - - • On server: setup a share for data with full permissions. - - NFS: 777 - - CIFS: read only = no - - Windows: Everyone - Full Control (Sharing and Security tabs) - • On clients: - - Add: System > Storage with the same music share, name and path/share name. - - Enable this Shared Data + • Other servers: + - Server: Create a share for data with full permissions + - Linux: NFS 777, CIFS read only = no + - Windows: Everyone - Full Control (Sharing + Security) + - Clients: + - Add: System > Storage with the same music share, name and path/share name. + - Enable Shared Data - Add shared data from the server HTML ] ]; From d9cb6cefd67e7155f8b0c77edd07d34339e52c96 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 19:38:46 +0700 Subject: [PATCH 104/237] Update system.php --- srv/http/settings/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 257f9e76b..c40351ae6 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -346,7 +346,7 @@ Connect share data as client for Library database, audio CD, bookmarks, lyrics, saved playlists and Web Radio. • rAudio as server: - Server: Features > NFS Share - Enable - - Clients: Enable Shared Data - Auto connect and setup + - Clients: Enable Shared Data > Connect rAudio server with IP address • Other servers: - Server: Create a share for data with full permissions - Linux: NFS 777, CIFS read only = no From bacbf57c8b0cedeacf4205ef03a69bf64ca9b88c Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 21:00:47 +0700 Subject: [PATCH 105/237] u --- srv/http/assets/js/system.js | 45 +++++++++++++++++++++++--------- srv/http/bash/settings/system.sh | 26 +++++++++++++----- srv/http/settings/system.php | 8 +++--- 3 files changed, 56 insertions(+), 23 deletions(-) diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 392a6aa41..69a161ac2 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -803,7 +803,7 @@ $( '#restore' ).click( function() { } ); $( '#restore' ).prop( 'checked', 0 ); } ); -$( '#setting-shareddata' ).click( function() { +$( '#shareddata' ).click( function() { if ( G.shareddata ) { info( { icon : 'networks' @@ -816,7 +816,7 @@ $( '#setting-shareddata' ).click( function() { , okcolor : orange , oklabel : 'Disable' , ok : function() { - bash( [ 'shareddatadisable', infoVal() ] ); + bash( [ 'shareddatadisconnect', infoVal() ] ); notify( 'Shared Data', 'Disable ...', 'networks' ); } } ); @@ -992,15 +992,32 @@ function infoNFSconnect( ip ) { } , ok : function() { var ip = infoVal(); - bash( [ 'shareddataconnect', ip ], function( std ) { - if ( std ) { - info( { - icon : 'networks' - , title : 'Shared Data' - , message : std - } ); - bannerHide(); - } + bash( [ 'sharelist', ip ], function( list ) { + info( { + icon : 'networks' + , title : 'Shared Data' + , message : list + , cancel : function() { + $( '#shareddata' ).prop( 'checked', false ); + } + , ok : function() { + if ( list.slice( 0, 6 ) === 'Shares' ) { + bash( [ 'shareddataconnect', ip ], function( std ) { + if ( std ) { + info( { + icon : 'networks' + , title : 'Shared Data' + , message : std + } ); + bannerHide(); + } + } ); + notify( 'Shared Data', 'Connect rAudio server ...', 'networks' ); + } else { + $( '#infoX' ).click(); + } + } + } ); } ); } } ); @@ -1062,8 +1079,10 @@ function renderPage() { $( '#hostname' ).val( G.hostname ); $( '#avahiurl' ).text( G.hostname +'.local' ); $( '#timezone' ).val( G.timezone ); - $( '#shareddata' ).toggleClass( 'disabled', G.nfsserver ); - $( '#setting-shareddata' ).addClass( 'hide' ); + $( '#shareddata' ) + .toggleClass( 'disabled', G.nfsserver ) + .prop( 'checked', G.shareddata ); + $( '#setting-shareddata' ).remove(); showContent(); } function getStatus() { diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index a27e94433..3ef322151 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -754,8 +754,6 @@ shareddata ) ;; shareddataconnect ) ip=${args[1]} - ! ping -c 1 -w 1 $ip &> /dev/null && echo "IP not found: $ip" && exit - readarray -t paths <<< $( timeout 3 showmount --no-headers -e $ip 2> /dev/null | awk 'NF{NF-=1};1' ) [[ ! $paths ]] && echo "No NFS shares found @$ip" && exit @@ -799,9 +797,10 @@ shareddataconnect ) echo data > /mnt/MPD/NAS/.mpdignore mpc -q clear sharedDataIPlist + pushRefresh pusrstream refresh '{"page":"features","shareddata":true}' ;; -shareddatadisable ) +shareddatadisconnect ) copydata=${args[1]} [[ -e /mnt/MPD/NAS/data ]] && dirshared=/mnt/MPD/NAS/data || dirshared=/srv/http/shareddata ! grep -q $dirshared /etc/fstab && echo -1 && exit @@ -817,9 +816,9 @@ shareddatadisable ) mpc -q clear ipserver=$( grep $dirshared /etc/fstab | cut -d: -f1 ) readarray -t mountpoints <<< $( awk '/^'$ipserver'/ {print $2}' /etc/fstab | sed 's/\\040/ /g' ) - for mountpoint in "${mountpoints[@]}"; do - umount -l "$mountpoint" - rm "$mountpoint" + for dir in "${mountpoints[@]}"; do + umount -l "$dir" + rmdir "$dir" &> /dev/null done fstab=$( sed "/^$ipserver/ d" /etc/fstab ) echo "$fstab" | column -t > /etc/fstab @@ -841,6 +840,21 @@ shareddatarestart ) systemctl restart mpd pushstream mpdupdate "$( cat $dirmpd/counts )" ;; +sharelist ) + ip=${args[1]} + ! ping -c 1 -w 1 $ip &> /dev/null && echo "IP not found: $ip" && exit + + paths=$( timeout 3 showmount --no-headers -e $ip 2> /dev/null | awk 'NF{NF-=1};1' ) + if [[ $paths ]]; then + echo "\ +Shares @$ip: + +
      $paths
      +Connect all shares?" + else + echo "No NFS shares found @$ip" + fi + ;; soundprofile ) soundProfile ;; diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index c40351ae6..6bbdb5487 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -340,20 +340,20 @@ , 'id' => 'shareddata' , 'sublabel' => 'client' , 'icon' => 'networks' - , 'setting' => true + , 'setting' => 'self' , 'disabled' => 'This rAudio is NFS Server' , 'help' => <<< HTML Connect share data as client for Library database, audio CD, bookmarks, lyrics, saved playlists and Web Radio. • rAudio as server: - Server: Features > NFS Share - Enable - - Clients: Enable Shared Data > Connect rAudio server with IP address + - Clients: Shared Data > Connect rAudio server with IP address • Other servers: - Server: Create a share for data with full permissions - Linux: NFS 777, CIFS read only = no - Windows: Everyone - Full Control (Sharing + Security) - Clients: - - Add: System > Storage with the same music share, name and path/share name. - - Enable Shared Data - Add shared data from the server + - System > Storage with the same music share, name and path/share name. + - Shared Data - Add the created share on server HTML ] ]; From 2dc7d87148886b5a0179bf1ca5f22c4f3e1e0b36 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 21:03:46 +0700 Subject: [PATCH 106/237] Update settings.php --- srv/http/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srv/http/settings.php b/srv/http/settings.php index bb081fa08..01aaaa47b 100644 --- a/srv/http/settings.php +++ b/srv/http/settings.php @@ -53,7 +53,7 @@ , 'status' => 'COMMAND' // include status icon and status box , 'input' => 'HTML' // alternative - if not switch , 'setting' => true // true = common - setting before enable - // 'self' = self trigger setting + // 'self' = self trigger setting - must toggle check manually // 'none' = no setting - self trigger script , 'settingicon' => 'ICON' , 'disable' => 'MESSAGE' // set data-diabled From 63e06323cbc5fcf07dd59e13dfbd4dcd2a0c96aa Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 21:16:54 +0700 Subject: [PATCH 107/237] Update features.php --- srv/http/settings/features.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index e5fd641a6..883b19f88 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -247,7 +247,9 @@ , 'disabled' => is_link( '/srv/http/data/mpd' ) ? 'Shared Data is currently enabled.' : 'File Sharing is currently active.' , 'help' => <<< HTML NFS - Network File System - Server for music files and Shared Data. - • rAudio clients: System > Settings and Data > Shared Data + • rAudio clients: + - System > Settings and Data > Shared Data + - With only IP address of the server, discover and connect all available file and data shares automatically. HTML ] , [ From 0a13df1144739ff747f6a2d783ccd52b117835e7 Mon Sep 17 00:00:00 2001 From: rern Date: Sat, 1 Oct 2022 21:20:46 +0700 Subject: [PATCH 108/237] Update cmd.sh --- srv/http/bash/cmd.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index caaacc051..33383bffa 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -1016,7 +1016,9 @@ $( cat /etc/hostapd/hostapd.conf ) ;; nfs-server ) pkg=nfs-utils - systemctl -q is-active nfs-server && fileconf=/etc/exports + systemctl -q is-active nfs-server && conf="\ +# showmount -e localhost +$( timeout 3 showmount -e localhost 2> /dev/null )" ;; rtsp-simple-server ) conf="\ From 11c48d38ca9bbc95f321e5dea5753451612962d1 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 2 Oct 2022 08:35:37 +0700 Subject: [PATCH 109/237] Update features.sh --- srv/http/bash/settings/features.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index 4bccf0f77..1d4eb008f 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -292,6 +292,7 @@ $( find /mnt/MPD/USB -mindepth 1 -maxdepth 1 -type d )" echo $ip > $dirdata/iplist chmod 777 $dirdata systemctl enable --now nfs-server + $dirbash/cmd.sh mpcupdate$'\n'rescan else systemctl disable --now nfs-server chmod 755 $dirdata From 9e51d990f00494f5dc4f52af29ec75bd2759b12e Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 2 Oct 2022 11:19:38 +0700 Subject: [PATCH 110/237] u --- srv/http/assets/js/features.js | 19 ++++++++++++++ srv/http/assets/js/settings.js | 4 +-- srv/http/assets/js/system.js | 6 ++--- srv/http/bash/cmd.sh | 2 +- srv/http/bash/settings/features.sh | 10 ++++++++ srv/http/bash/settings/system.sh | 2 +- srv/http/settings.php | 13 +++++----- srv/http/settings/features.php | 18 +++++-------- srv/http/settings/player.php | 41 +++++++++++++++--------------- srv/http/settings/system.php | 31 ++++++++-------------- 10 files changed, 80 insertions(+), 66 deletions(-) diff --git a/srv/http/assets/js/features.js b/srv/http/assets/js/features.js index e9dfcdcde..6c5472553 100644 --- a/srv/http/assets/js/features.js +++ b/srv/http/assets/js/features.js @@ -333,6 +333,25 @@ $( '#setting-multiraudio' ).click( function() { } } ); } ); +$( '#nfsserver' ).click( function() { + bash( [ 'nfssharelist', G.nfsserver ], function( list ) { + info( { + icon : 'networks' + , title : 'NFS Server' + , message : ( G.nfsserver ? 'Shared directories:' : 'Directories to share:' ) + +'
      '+ list +'

      ' + + ( G.nfsserver ? 'Disable all shares?' : 'Share all directories?' ) + , cancel : function() { + $( '#nfsserver' ).prop( 'checked', G.nfsserver ); + } + , okcolor : G.nfsserver ? orange : '' + , ok : function() { + bash( [ 'nfsserver', !G.nfsserver ] ); + notify( 'NFS Server', G.nfsserver ? 'Disable ...' : 'Enable ...', 'networks' ); + } + } ); + } ); +} ); $( '#login' ).click( function() { if ( $( this ).prop( 'checked' ) ) { $( '#setting-login' ).click(); diff --git a/srv/http/assets/js/settings.js b/srv/http/assets/js/settings.js index 6b1087dc2..39079c5e1 100644 --- a/srv/http/assets/js/settings.js +++ b/srv/http/assets/js/settings.js @@ -487,10 +487,8 @@ $( '.help' ).click( function() { $( this ).parents( '.section' ).find( '.help-block' ).toggleClass( 'hide' ); $( '#help' ).toggleClass( 'bl', $( '.help-block:not( .hide ), .help-sub:not( .hide )' ).length > 0 ); } ); -$( '.switch' ).click( function() { +$( '.switch:not( .self )' ).click( function() { var id = this.id; - if ( id === 'novolume' ) return - var $this = $( this ); var checked = $this.prop( 'checked' ); var label = $this.data( 'label' ); diff --git a/srv/http/assets/js/system.js b/srv/http/assets/js/system.js index 69a161ac2..51a2fc7b8 100644 --- a/srv/http/assets/js/system.js +++ b/srv/http/assets/js/system.js @@ -804,6 +804,8 @@ $( '#restore' ).click( function() { $( '#restore' ).prop( 'checked', 0 ); } ); $( '#shareddata' ).click( function() { + if ( $( this ).hasClass( 'disabled' ) ) return + if ( G.shareddata ) { info( { icon : 'networks' @@ -1079,9 +1081,7 @@ function renderPage() { $( '#hostname' ).val( G.hostname ); $( '#avahiurl' ).text( G.hostname +'.local' ); $( '#timezone' ).val( G.timezone ); - $( '#shareddata' ) - .toggleClass( 'disabled', G.nfsserver ) - .prop( 'checked', G.shareddata ); + $( '#shareddata' ).toggleClass( 'disabled', G.nfsserver ); $( '#setting-shareddata' ).remove(); showContent(); } diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index 33383bffa..cf42d1014 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -1018,7 +1018,7 @@ $( cat /etc/hostapd/hostapd.conf ) pkg=nfs-utils systemctl -q is-active nfs-server && conf="\ # showmount -e localhost -$( timeout 3 showmount -e localhost 2> /dev/null )" +$( timeout 3 showmount --no-headers -e localhost 2> /dev/null | sort )" ;; rtsp-simple-server ) conf="\ diff --git a/srv/http/bash/settings/features.sh b/srv/http/bash/settings/features.sh index 1d4eb008f..277865c68 100644 --- a/srv/http/bash/settings/features.sh +++ b/srv/http/bash/settings/features.sh @@ -303,6 +303,16 @@ $( find /mnt/MPD/USB -mindepth 1 -maxdepth 1 -type d )" pushRefresh pushstream refresh '{"page":"system","nfsserver":'$active'}' ;; +nfssharelist ) + if systemctl -q is-active nfs-server; then + timeout 3 showmount --no-headers -e localhost 2> /dev/null | awk 'NF{NF-=1};1' | sort + else + echo "\ +/mnt/MPD/SD +$( find /mnt/MPD/USB -mindepth 1 -maxdepth 1 -type d ) +/srv/http/data" + fi + ;; screenofftoggle ) # [[ $( /opt/vc/bin/vcgencmd display_power ) == display_power=1 ]] && toggle=0 || toggle=1 # /opt/vc/bin/vcgencmd display_power $toggle # hdmi diff --git a/srv/http/bash/settings/system.sh b/srv/http/bash/settings/system.sh index 3ef322151..c244ea660 100644 --- a/srv/http/bash/settings/system.sh +++ b/srv/http/bash/settings/system.sh @@ -844,7 +844,7 @@ sharelist ) ip=${args[1]} ! ping -c 1 -w 1 $ip &> /dev/null && echo "IP not found: $ip" && exit - paths=$( timeout 3 showmount --no-headers -e $ip 2> /dev/null | awk 'NF{NF-=1};1' ) + paths=$( timeout 3 showmount --no-headers -e $ip 2> /dev/null | awk 'NF{NF-=1};1' | sort ) if [[ $paths ]]; then echo "\ Shares @$ip: diff --git a/srv/http/settings.php b/srv/http/settings.php index 01aaaa47b..60d8d0f73 100644 --- a/srv/http/settings.php +++ b/srv/http/settings.php @@ -52,9 +52,9 @@ , 'icon' => 'ICON' , 'status' => 'COMMAND' // include status icon and status box , 'input' => 'HTML' // alternative - if not switch - , 'setting' => true // true = common - setting before enable - // 'self' = self trigger setting - must toggle check manually - // 'none' = no setting - self trigger script + , 'setting' => (none) // default = '.common' - setup before enable > $( '.switch' ).click( ... [id/iddisable] (like click setting) + // false = no icon, no setting > $( '.switch' ).click( ... [id, true/false] + // 'self' = custom event script > $( '#id' ).click( ... , 'settingicon' => 'ICON' , 'disable' => 'MESSAGE' // set data-diabled , 'help' => <<
      '; } else { $html.= $input; } - $html.= $setting && $setting !== 'none' ? '' : ''; + $html.= $setting ? '' : ''; $html.= $help ? ''.$help.'' : ''; $html.= '
      diff --git a/srv/http/settings/features.php b/srv/http/settings/features.php index 883b19f88..46d90e578 100644 --- a/srv/http/settings/features.php +++ b/srv/http/settings/features.php @@ -11,6 +11,7 @@ , 'id' => 'shairport-sync' , 'sublabel' => 'shairport-sync' , 'icon' => 'airplay' + , 'setting' => false , 'status' => 'shairport-sync' , 'disabled' => 'AirPlay is currently active.' , 'help' => <<< HTML @@ -23,6 +24,7 @@ , 'id' => 'dabradio' , 'sublabel' => 'rtsp-server' , 'icon' => 'dabradio' + , 'setting' => false , 'status' => 'rtsp-simple-server' , 'disabled' => 'No DAB devices found.' , 'help' => <<< HTML @@ -36,7 +38,6 @@ , 'id' => 'snapclient' , 'icon' => 'snapcast' , 'status' => 'snapclient' - , 'setting' => true , 'disabled' => 'SnapClient is currently active.' , 'help' => <<< HTML Snapcast - Multiroom client-server audio player. @@ -52,7 +53,6 @@ , 'sublabel' => 'spotifyd' , 'icon' => 'spotify' , 'status' => 'spotifyd' - , 'setting' => true , 'disabled' => 'Spotify is currently active.' , 'help' => <<< HTML Spotifyd - Spotify Connect device. @@ -78,7 +78,6 @@ , 'sublabel' => 'upmpdcli' , 'icon' => 'upnp' , 'status' => 'upmpdcli' - , 'setting' => true , 'disabled' => 'UPnP is currently active.' , 'help' => <<< HTML upmpdcli - UPnP / DLNA rendering device. @@ -96,6 +95,7 @@ , 'id' => 'streaming' , 'sublabel' => 'MPD httpd' , 'icon' => 'webradio' + , 'setting' => false , 'help' => <<< HTML HTTP streaming - Asynchronous streaming for browsers via http://$ip:8000 (Latency - several seconds) HTML @@ -105,6 +105,7 @@ , 'id' => 'snapserver' , 'sublabel' => 'snapserver' , 'icon' => 'snapcast' + , 'setting' => false , 'status' => 'snapserver' , 'disabled' => 'SnapClient is currently connected.' , 'help' => <<< HTML @@ -129,7 +130,6 @@ , 'sublabel' => 'camilladsp' , 'icon' => 'camilladsp' , 'status' => 'camilladsp' - , 'setting' => true , 'disabled' => ( exec( 'systemctl -q is-active bluetooth && echo true' ) ? 'Bluetooth' : 'Equalizer' ).' is currently enabled.' , 'help' => <<< HTML CamillaDSP - A flexible cross-platform IIR and FIR engine for crossovers, room correction etc. @@ -142,6 +142,7 @@ , 'sublabel' => 'alsaequal' , 'id' => 'equalizer' , 'icon' => 'equalizer' + , 'setting' => false , 'disabled' => 'DSP is currently enabled.' , 'help' => <<< HTML Alsaequal - 10 band graphic equalizer with user presets. @@ -165,7 +166,6 @@ , 'sublabel' => 'hostapd' , 'icon' => 'accesspoint' , 'status' => 'hostapd' - , 'setting' => true , 'disabled' => 'Wi-Fi is currently connected.' , 'help' => <<< HTML hostapd - Connect with rAudio hotspot directly when no routers available. @@ -177,7 +177,6 @@ 'label' => 'AutoPlay' , 'id' => 'autoplay' , 'icon' => 'play' - , 'setting' => true , 'help' => <<< HTML Start playing automatically on: • Bluetooth connected @@ -191,7 +190,6 @@ , 'sublabel' => 'chromium' , 'icon' => 'chromium' , 'status' => 'localbrowser' - , 'setting' => true , 'help' => <<< HTML Chromium - Browser on RPi connected screen. • TFT 3.5" LCD: Rotate needs reboot. @@ -206,7 +204,6 @@ , 'sublabel' => 'smb' , 'icon' => 'networks' , 'status' => 'smb' - , 'setting' => true , 'disabled' => 'NFS Server is currently active.' , 'help' => <<< HTML Samba - Share files on network. @@ -220,6 +217,7 @@ 'label' => 'Lyrics in File' , 'id' => 'lyricsembedded' , 'icon' => 'lyrics' + , 'setting' => false , 'help' => <<< HTML • Get embedded lyrics from local files. • Search online if not available. @@ -231,7 +229,6 @@ 'label' => 'Multiple rAudios' , 'id' => 'multiraudio' , 'icon' => 'raudiobox' - , 'setting' => true , 'help' => <<< HTML Switch between multiple rAudio devices. Switch:  Playlist | @@ -243,6 +240,7 @@ , 'id' => 'nfsserver' , 'sublabel' => 'nfs-server' , 'icon' => 'networks' + , 'setting' => 'self' , 'status' => 'nfs-server' , 'disabled' => is_link( '/srv/http/data/mpd' ) ? 'Shared Data is currently enabled.' : 'File Sharing is currently active.' , 'help' => <<< HTML @@ -268,7 +266,6 @@ , 'id' => 'scrobble' , 'sublabel' => 'Last.fm' , 'icon' => 'lastfm' - , 'setting' => true , 'help' => <<< HTML • Send artist, title and album of played tracks to Last.fm to save in user's database. • Require Last.fm account. @@ -282,7 +279,6 @@ 'label' => 'Stop Timer' , 'id' => 'stoptimer' , 'icon' => 'stopwatch' - , 'setting' => true , 'disabled' => 'Player is not playing.' , 'help' => <<< HTML Stop timer: diff --git a/srv/http/settings/player.php b/srv/http/settings/player.php index 670f154e3..7c79882c6 100644 --- a/srv/http/settings/player.php +++ b/srv/http/settings/player.php @@ -44,10 +44,11 @@ HTML ] , [ - 'label' => 'Device' - , 'id' => 'audiooutput' - , 'input' => '' - , 'help' => <<< HTML + 'label' => 'Device' + , 'id' => 'audiooutput' + , 'input' => '' + , 'setting' => false + , 'help' => <<< HTML HDMI device available only when connected before boot. HTML ] @@ -63,10 +64,11 @@ HTML ] , [ - 'label' => 'Volume Control' - , 'id' => 'mixertype' - , 'input' => '' - , 'help' => <<< HTML + 'label' => 'Volume Control' + , 'id' => 'mixertype' + , 'input' => '' + , 'setting' => false + , 'help' => <<< HTML Volume control for each device. • None / 0dB Best sound quality. (Use amplifier volume) • Mixer device Good and convenient. (Device hardware volume) @@ -78,9 +80,10 @@ $head = [ 'title' => 'Bit-Perfect' ]; ////////////////////////////////// $body = [ [ - 'label' => 'No Volume' - , 'id' => 'novolume' - , 'help' => <<< HTML + 'label' => 'No Volume' + , 'id' => 'novolume' + , 'setting' => 'self' + , 'help' => <<< HTML Disable all manipulations for bit-perfect stream from MPD to DAC output. • No changes in data stream until it reaches amplifier volume control. • Mixer device volume: 0dB (No amplitude manipulations) @@ -90,9 +93,10 @@ HTML ] , [ - 'label' => 'DSD over PCM' - , 'id' => 'dop' - , 'help' => <<< HTML + 'label' => 'DSD over PCM' + , 'id' => 'dop' + , 'setting' => false + , 'help' => <<< HTML For DSD-capable devices without drivers dedicated for native DSD. • Enable if there's static/no sound from the DAC which means not support as native DSD. • DoP will repack 16bit DSD stream into 24bit PCM frames and transmit to the DAC. @@ -106,7 +110,6 @@ $body = [ [ 'label' => 'Crossfade' , 'id' => 'crossfade' - , 'setting' => true , 'help' => <<< HTML mpc crossfade N Fade-out to fade-in between songs. @@ -115,6 +118,7 @@ , [ 'label' => 'Normalization' , 'id' => 'normalization' + , 'setting' => false , 'help' => <<< HTML volume_normalization "yes" Normalize the volume level of songs as they play. @@ -123,7 +127,6 @@ , [ 'label' => 'Replay Gain' , 'id' => 'replaygain' - , 'setting' => true , 'help' => <<< HTML replaygain "N" Set gain control to setting in replaygain tag. @@ -140,7 +143,6 @@ 'label' => 'Buffer - Audio' , 'id' => 'buffer' , 'sublabel' => 'custom size' - , 'setting' => true , 'help' => <<< HTML audio_buffer_size "kB" Default buffer size: 4096 kB (24 seconds of CD-quality audio) @@ -151,7 +153,6 @@ 'label' => 'Buffer - Output' , 'id' => 'bufferoutput' , 'sublabel' => 'custom size' - , 'setting' => true , 'help' => <<< HTML max_output_buffer_size "kB" Default buffer size: 8192 kB @@ -162,6 +163,7 @@ 'label' => 'FFmpeg' , 'id' => 'ffmpeg' , 'sublabel' => 'decoder plugin' + , 'setting' => false , 'disabled' => 'DAB Radio is currently enabled.' , 'help' => <<< HTML enable "yes" @@ -173,6 +175,7 @@ , [ 'label' => 'Library Auto Update' , 'id' => 'autoupdate' + , 'setting' => false , 'help' => <<< HTML auto_update "yes" Automatic update MPD database when files changed. @@ -182,7 +185,6 @@ 'label' => 'SoXR Resampler' , 'id' => 'soxr' , 'sublabel' => 'custom settings' - , 'setting' => true , 'help' => <<< HTML quality "custom" Default quality: very high @@ -204,7 +206,6 @@ , [ 'label' => "User's Configurations" , 'id' => 'custom' - , 'setting' => true , 'help' => <<< HTML Insert custom configurations into /etc/mpd.conf. HTML diff --git a/srv/http/settings/system.php b/srv/http/settings/system.php index 6bbdb5487..923fa54ae 100644 --- a/srv/http/settings/system.php +++ b/srv/http/settings/system.php @@ -109,7 +109,6 @@ 'label' => 'HDD Sleep' , 'id' => 'hddsleep' , 'icon' => 'screenoff' - , 'setting' => true , 'disabled' => 'HDD not support sleep' , 'help' => <<< HTML Sleep timer for hard drives. @@ -120,6 +119,7 @@ , 'id' => 'usbautoupdate' , 'sublabel' => 'USB Drives' , 'icon' => 'refresh-library' + , 'setting' => false , 'help' => <<< HTML Auto update Library database on insert/remove USB drives. HTML @@ -138,7 +138,6 @@ , 'sublabel' => 'bluetoothctl' , 'icon' => 'bluetooth' , 'status' => 'bluetooth' - , 'setting' => true , 'disabled' => ( file_exists( '/srv/http/data/system/camilladsp' ) ? 'DSP is currently active.' : 'Bluetooth is currently connected.' ) , 'help' => <<< HTML Sampling 16bit - Only for Bluetooth receivers with fixed sampling @@ -150,7 +149,6 @@ , 'sublabel' => 'iw' , 'icon' => 'wifi' , 'status' => 'iw' - , 'setting' => true , 'disabled' => 'Wi-Fi is currently connected.' , 'help' => <<< HTML Settings @@ -192,7 +190,6 @@ , 'id' => 'lcdchar' , 'sublabel' => 'HD44780' , 'icon' => 'lcdchar' - , 'setting' => true , 'help' => <<< HTML LCD module - display playback data • Support 16x2 and 20x4 LCD modules. @@ -204,7 +201,6 @@ , 'id' => 'powerbutton' , 'sublabel' => 'Power LED' , 'icon' => 'power' - , 'setting' => true , 'help' => <<< HTML Power button and LED - power on/off rAudio • On - Fixed to pin 5 @@ -218,7 +214,6 @@ 'label' => 'Relay Module' , 'id' => 'relays' , 'icon' => 'relays' - , 'setting' => true , 'help' => <<< HTML Relay module - power on/off peripheral equipments On/Off:  System | @@ -230,7 +225,6 @@ 'label' => 'Rotary Encoder' , 'id' => 'rotaryencoder' , 'icon' => 'volume' - , 'setting' => true , 'help' => <<< HTML Rotary encoder for: • Turn volume up/down @@ -241,7 +235,6 @@ 'label' => 'Spectrum OLED' , 'id' => 'mpdoled' , 'icon' => 'mpdoled' - , 'setting' => true , 'help' => <<< HTML OLED module - display audio level spectrum HTML @@ -250,7 +243,6 @@ 'label' => 'TFT 3.5" LCD' , 'id' => 'lcd' , 'icon' => 'lcd' - , 'setting' => true , 'help' => <<< HTML TFT LCD module with resistive touchscreen - local display HTML @@ -260,7 +252,6 @@ 'label' => 'VU LED' , 'id' => 'vuled' , 'icon' => 'led' - , 'setting' => true , 'help' => <<< HTML 7 LEDs - display audio level • LED resister calculator @@ -271,11 +262,12 @@ $head = [ 'title' => 'Environment' ]; ////////////////////////////////// $body = [ [ - 'label' => 'Host Name' - , 'id' => 'hostname' - , 'icon' => 'plus-r' - , 'input' => '' - , 'help' => <<< HTML + 'label' => 'Host Name' + , 'id' => 'hostname' + , 'icon' => 'plus-r' + , 'input' => '' + , 'setting' => false + , 'help' => <<< HTML For: • Access point, AirPlay, Bluetooth, SnapCast, Spotify, UPnP • Web Interface URL: @@ -302,7 +294,6 @@ , 'sublabel' => 'sysctl' , 'icon' => 'soundprofile' , 'status' => 'soundprofile' - , 'setting' => true , 'help' => <<< HTML Tweak kernel parameters for sound profiles. HTML @@ -315,7 +306,7 @@ 'label' => 'Backup' , 'id' => 'backup' , 'icon' => 'sd' - , 'setting' => 'none' + , 'setting' => false , 'help' => <<< HTML Backup all settings and Library database: • Settings @@ -330,7 +321,7 @@ 'label' => 'Restore' , 'id' => 'restore' , 'icon' => 'restore' - , 'setting' => 'none' + , 'setting' => 'self' , 'help' => <<< HTML Restore all settings and Library database from a backup file. The system will reboot after finished. HTML @@ -340,8 +331,8 @@ , 'id' => 'shareddata' , 'sublabel' => 'client' , 'icon' => 'networks' - , 'setting' => 'self' - , 'disabled' => 'This rAudio is NFS Server' + , 'setting' => false + , 'disabled' => 'This rAudio is NFS Server.' , 'help' => <<< HTML Connect share data as client for Library database, audio CD, bookmarks, lyrics, saved playlists and Web Radio. • rAudio as server: From bc74c8082c1b263dd7747a454534ca0bb786282a Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 2 Oct 2022 11:42:22 +0700 Subject: [PATCH 111/237] u --- srv/http/assets/css/info.css | 3 +++ srv/http/assets/js/features.js | 12 +++++++++++- srv/http/bash/cmd.sh | 4 +--- srv/http/bash/settings/features-data.sh | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/srv/http/assets/css/info.css b/srv/http/assets/css/info.css index 0c224ef00..dc2c73e8a 100644 --- a/srv/http/assets/css/info.css +++ b/srv/http/assets/css/info.css @@ -391,6 +391,9 @@ hr { color: var( --cg60 ); background: none; } +.infomessage pre { + font-size: 16px; +} .infomessage, .infofooter { width: fit-content; diff --git a/srv/http/assets/js/features.js b/srv/http/assets/js/features.js index 6c5472553..b2cbe9935 100644 --- a/srv/http/assets/js/features.js +++ b/srv/http/assets/js/features.js @@ -334,7 +334,7 @@ $( '#setting-multiraudio' ).click( function() { } ); } ); $( '#nfsserver' ).click( function() { - bash( [ 'nfssharelist', G.nfsserver ], function( list ) { + bash( [ 'nfssharelist' ], function( list ) { info( { icon : 'networks' , title : 'NFS Server' @@ -352,6 +352,16 @@ $( '#nfsserver' ).click( function() { } ); } ); } ); +$( '#setting-nfsserver' ).click( function() { + bash( [ 'nfssharelist' ], function( list ) { + info( { + icon : 'networks' + , title : 'NFS Server' + , message : '@'+ G.ip +' Share paths:' + +'

      '+ list +'
      ' + } ); + } ); +} ); $( '#login' ).click( function() { if ( $( this ).prop( 'checked' ) ) { $( '#setting-login' ).click(); diff --git a/srv/http/bash/cmd.sh b/srv/http/bash/cmd.sh index cf42d1014..caaacc051 100644 --- a/srv/http/bash/cmd.sh +++ b/srv/http/bash/cmd.sh @@ -1016,9 +1016,7 @@ $( cat /etc/hostapd/hostapd.conf ) ;; nfs-server ) pkg=nfs-utils - systemctl -q is-active nfs-server && conf="\ -# showmount -e localhost -$( timeout 3 showmount --no-headers -e localhost 2> /dev/null | sort )" + systemctl -q is-active nfs-server && fileconf=/etc/exports ;; rtsp-simple-server ) conf="\ diff --git a/srv/http/bash/settings/features-data.sh b/srv/http/bash/settings/features-data.sh index 21bbdcdc7..0b2cf040f 100644 --- a/srv/http/bash/settings/features-data.sh +++ b/srv/http/bash/settings/features-data.sh @@ -18,6 +18,7 @@ data+=' , "camillarefresh" : '$( grep 'status_update_interval' /srv/http/settings/camillagui/config/gui-config.yml | cut -d' ' -f2 )' , "equalizer" : '$( exists $dirsystem/equalizer )' , "hostname" : "'$( hostname )'" +, "ip" : "'$( ipGet )'" , "latest" : '$( exists $dirsystem/latest )' , "lcd" : '$( grep -E -q 'waveshare|tft35a' /boot/config.txt 2> /dev/null && echo true )' , "login" : '$( exists $dirsystem/login )' From f56fe2c660f4206393708f3f5236c80bbcb3cbd0 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 2 Oct 2022 13:17:39 +0700 Subject: [PATCH 112/237] u --- srv/http/assets/js/settings.js | 2 +- srv/http/settings.php | 12 +++++++----- srv/http/settings/features.php | 4 ++-- srv/http/settings/player.php | 13 +++++++------ srv/http/settings/system.php | 4 ++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/srv/http/assets/js/settings.js b/srv/http/assets/js/settings.js index 39079c5e1..6aead0adf 100644 --- a/srv/http/assets/js/settings.js +++ b/srv/http/assets/js/settings.js @@ -487,7 +487,7 @@ $( '.help' ).click( function() { $( this ).parents( '.section' ).find( '.help-block' ).toggleClass( 'hide' ); $( '#help' ).toggleClass( 'bl', $( '.help-block:not( .hide ), .help-sub:not( .hide )' ).length > 0 ); } ); -$( '.switch:not( .self )' ).click( function() { +$( '.switch:not( .custom )' ).click( function() { var id = this.id; var $this = $( this ); var checked = $this.prop( 'checked' ); diff --git a/srv/http/settings.php b/srv/http/settings.php index 60d8d0f73..2f6860e65 100644 --- a/srv/http/settings.php +++ b/srv/http/settings.php @@ -52,10 +52,12 @@ , 'icon' => 'ICON' , 'status' => 'COMMAND' // include status icon and status box , 'input' => 'HTML' // alternative - if not switch - , 'setting' => (none) // default = '.common' - setup before enable > $( '.switch' ).click( ... [id/iddisable] (like click setting) - // false = no icon, no setting > $( '.switch' ).click( ... [id, true/false] - // 'self' = custom event script > $( '#id' ).click( ... - , 'settingicon' => 'ICON' + , 'setting' => (none) // default = '.common' > $( '.switch' ).click( ... > $( '#setting-'+ id ).click() before enable > [ id/iddisable ] + // false = no icon, no setting > $( '.switch' ).click( ... > [ id, true/false ] + // 'custom' = custom script > $( '#id' ).click( ... > [ command ] + , 'settingicon' => (none) // default = 'gear' + // false = omit + // 'icon' = 'fa-icon' , 'disable' => 'MESSAGE' // set data-diabled , 'help' => <<