The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide LED control on rpi 3B+ and 4B (moOde 6.4.2+)
#1
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:
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
or reboot your system:
Code:
sudo shutdown -r now

To check the output of the script, check out syslog:
Code:
tail -f /var/log/syslog
or use:
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.


Attached Files
.zip   checksources.zip (Size: 2.32 KB / Downloads: 23)
Reply


Messages In This Thread
LED control on rpi 3B+ and 4B (moOde 6.4.2+) - by romain - 04-07-2020, 01:01 PM

Forum Jump: