Hello,
I've written a shell script which controls the behavior of the rpi LEDs depending on the availability of the configured sources and/or plugged in USB storage(s).
The script is called by a one shot systemd service unit started by a systemd timer unit every 1 minute after the last execution (thanks to philrandal for his advise), you can change this timing to suite your needs. It queries the local SQLITE db to fetch sources settings and tries to remount automatically configured sources if they become unavailable. Works with SMB, NFS, UPnP.
Version 6.5.0 users should turn off LED0 (Activity) and LED1 (Power) directly in the moOde interface (System -> Sytem Modifications) before enabling the systemd service and timer units. I also made some minor modifications to the shell script itself, new version attached here.
Red LED is off by default.
Fixed green LED means all sources configured and/or all plugged in USB storage(s) are available.
Blinking green LED means at least one configured source and/or one plugged in USB storage is unavailable if multiple sources have been configured or if multiple USB storage(s) are plugged in.
Fixed red LED means configured source(s) and/or plugged in USB storage(s) are unavailable.
The only small drawback is when NFS shares are hard mounted (default) ; you may want use soft NFS mounts instead otherwise the script will get stucked waiting for the NFS server to respond (normal behavior).
For NFS soft mounts you should use instead the mount flags:
You can also set these mount flags as default if you edit line 208 (version 6.4.2) or 222 (version 6.5.0) in file /var/www/js/scripts-configs.js in order to obtain:
File checksources.sh should be placed in /usr/local/sbin and made executable:
File checksources.service should be placed in /etc/systemd/system and enabled to launch at startup:
File checksources.timer should be placed in /etc/systemd/system and enabled to execute checksources.service every 1 minute after the last execution of the unit:
Start both systemd units:
or reboot your system:
To check the output of the script, check out syslog:
or use:
I've tested it on pi 3B+ and 4B with moOde versions 6.4.2 and 6.5.0.
Zip file attached, feel free to use and improve if needed.
I've written a shell script which controls the behavior of the rpi LEDs depending on the availability of the configured sources and/or plugged in USB storage(s).
The script is called by a one shot systemd service unit started by a systemd timer unit every 1 minute after the last execution (thanks to philrandal for his advise), you can change this timing to suite your needs. It queries the local SQLITE db to fetch sources settings and tries to remount automatically configured sources if they become unavailable. Works with SMB, NFS, UPnP.
Version 6.5.0 users should turn off LED0 (Activity) and LED1 (Power) directly in the moOde interface (System -> Sytem Modifications) before enabling the systemd service and timer units. I also made some minor modifications to the shell script itself, new version attached here.
Red LED is off by default.
Fixed green LED means all sources configured and/or all plugged in USB storage(s) are available.
Blinking green LED means at least one configured source and/or one plugged in USB storage is unavailable if multiple sources have been configured or if multiple USB storage(s) are plugged in.
Fixed red LED means configured source(s) and/or plugged in USB storage(s) are unavailable.
The only small drawback is when NFS shares are hard mounted (default) ; you may want use soft NFS mounts instead otherwise the script will get stucked waiting for the NFS server to respond (normal behavior).
For NFS soft mounts you should use instead the mount flags:
Code:
soft,timeo=10,retrans=1,ro,nolock
You can also set these mount flags as default if you edit line 208 (version 6.4.2) or 222 (version 6.5.0) in file /var/www/js/scripts-configs.js in order to obtain:
Code:
$('#options').val('soft,timeo=10,retrans=1,ro,nolock');
File checksources.sh should be placed in /usr/local/sbin and made executable:
Code:
sudo chmod +x /usr/local/sbin/checksources.sh
File checksources.service should be placed in /etc/systemd/system and enabled to launch at startup:
Code:
sudo systemctl enable checksources.service
File checksources.timer should be placed in /etc/systemd/system and enabled to execute checksources.service every 1 minute after the last execution of the unit:
Code:
sudo systemctl enable checksources.timer
Start both systemd units:
Code:
sudo systemctl start checksources.service
Code:
sudo systemctl start checksources.timer
Code:
sudo shutdown -r now
To check the output of the script, check out syslog:
Code:
tail -f /var/log/syslog
Code:
journalctl -u checksources.service
I've tested it on pi 3B+ and 4B with moOde versions 6.4.2 and 6.5.0.
Zip file attached, feel free to use and improve if needed.