Posts: 47
Threads: 8
Joined: Jan 2020
Reputation:
3
(04-07-2020, 01:01 PM)romain Wrote: 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.
Wonder if you can help.
Just found your post and thought if would be a good fix for my NAS becoming unmounted randomly or after the router resets.
Implemented as you have it described and it worked great - only thing I noticed is it really bogged the system down and made the webinterface almost unusable - on a Pi3B+ also running an OLED using pydPiper
Rob
Posts: 159
Threads: 19
Joined: Mar 2020
Reputation:
3
04-19-2021, 08:29 AM
(This post was last modified: 04-20-2021, 09:52 AM by romain.
Edit Reason: previous solution not working
)
(04-19-2021, 03:26 AM)Britracer Wrote: (04-07-2020, 01:01 PM)romain Wrote: 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.
Wonder if you can help.
Just found your post and thought if would be a good fix for my NAS becoming unmounted randomly or after the router resets.
Implemented as you have it described and it worked great - only thing I noticed is it really bogged the system down and made the webinterface almost unusable - on a Pi3B+ also running an OLED using pydPiper
Rob
Hello Rob,
I hadn't retried my script with the latest version of moOde. I've just noticed that mountpoint now behaves differently and gets indefinitely stuck if a mountpoint becomes unavailable.
To fix this, in function called checkMount of /usr/local/sbin/checksources.sh, replace
Code: /bin/mountpoint -q "${1}"
with
Code: timeout 1 /bin/mountpoint -q "${1}"
Code: timeout 1 stat -t "${1}" > /dev/null 2>&1
It's on line 17 in my version of the script.
Let me know if it helps.
Posts: 159
Threads: 19
Joined: Mar 2020
Reputation:
3
04-20-2021, 09:53 AM
(This post was last modified: 04-20-2021, 09:55 AM by romain.
Edit Reason: previous solution not working
)
(04-19-2021, 08:29 AM)romain Wrote: (04-19-2021, 03:26 AM)Britracer Wrote: (04-07-2020, 01:01 PM)romain Wrote: 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.
Wonder if you can help.
Just found your post and thought if would be a good fix for my NAS becoming unmounted randomly or after the router resets.
Implemented as you have it described and it worked great - only thing I noticed is it really bogged the system down and made the webinterface almost unusable - on a Pi3B+ also running an OLED using pydPiper
Rob
Hello Rob,
I hadn't retried my script with the latest version of moOde. I've just noticed that mountpoint now behaves differently and gets indefinitely stuck if a mountpoint becomes unavailable.
To fix this, in function called checkMount of /usr/local/sbin/checksources.sh, replace
Code: /bin/mountpoint -q "${1}"
with
Code: timeout 1 /bin/mountpoint -q "${1}"
It's on line 17 in my version of the script. Edit reason is that previous solution was not working
Let me know if it helps.
Posts: 47
Threads: 8
Joined: Jan 2020
Reputation:
3
(04-19-2021, 08:29 AM)romain Wrote: (04-19-2021, 03:26 AM)Britracer Wrote: (04-07-2020, 01:01 PM)romain Wrote: 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.
Wonder if you can help.
Just found your post and thought if would be a good fix for my NAS becoming unmounted randomly or after the router resets.
Implemented as you have it described and it worked great - only thing I noticed is it really bogged the system down and made the webinterface almost unusable - on a Pi3B+ also running an OLED using pydPiper
Rob
Hello Rob,
I hadn't retried my script with the latest version of moOde. I've just noticed that mountpoint now behaves differently and gets indefinitely stuck if a mountpoint becomes unavailable.
To fix this, in function called checkMount of /usr/local/sbin/checksources.sh, replace
Code: /bin/mountpoint -q "${1}"
with
Code: timeout 1 /bin/mountpoint -q "${1}"
Code: timeout 1 stat -t "${1}" > /dev/null 2>&1
It's on line 17 in my version of the script.
Let me know if it helps.
Thank you I will give it a go.
Appreciate you looking into this for me.
Posts: 159
Threads: 19
Joined: Mar 2020
Reputation:
3
(04-20-2021, 12:30 PM)Britracer Wrote: (04-19-2021, 08:29 AM)romain Wrote: (04-19-2021, 03:26 AM)Britracer Wrote: (04-07-2020, 01:01 PM)romain Wrote: 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.
Wonder if you can help.
Just found your post and thought if would be a good fix for my NAS becoming unmounted randomly or after the router resets.
Implemented as you have it described and it worked great - only thing I noticed is it really bogged the system down and made the webinterface almost unusable - on a Pi3B+ also running an OLED using pydPiper
Rob
Hello Rob,
I hadn't retried my script with the latest version of moOde. I've just noticed that mountpoint now behaves differently and gets indefinitely stuck if a mountpoint becomes unavailable.
To fix this, in function called checkMount of /usr/local/sbin/checksources.sh, replace
Code: /bin/mountpoint -q "${1}"
with
Code: timeout 1 /bin/mountpoint -q "${1}"
Code: timeout 1 stat -t "${1}" > /dev/null 2>&1
It's on line 17 in my version of the script.
Let me know if it helps.
Thank you I will give it a go.
Appreciate you looking into this for me.
OK, disregard the line with
Code: timeout 1 stat -t "${1}" > /dev/null 2>&1
it should be
Code: timeout 1 /bin/mountpoint -q "${1}"
instead
Posts: 47
Threads: 8
Joined: Jan 2020
Reputation:
3
Romain,
thank you seems to have solved the issue
Posts: 159
Threads: 19
Joined: Mar 2020
Reputation:
3
It's my pleasure Rob
Posts: 22
Threads: 2
Joined: Apr 2020
Reputation:
1
Hello Romain,
Hope this message will find you well.
I used you little utility with the previous moOde versions successfully until I recently updated to the latest 8 version.
Maybe I am wrong or I made mistake, but it seems not to work anymore with the latest version.
Anyone got it to work with moOde 8?
Posts: 1,278
Threads: 24
Joined: Jun 2022
Reputation:
42
05-28-2023, 02:24 PM
(This post was last modified: 05-28-2023, 03:31 PM by Nutul.)
(05-28-2023, 12:36 PM)zazouboy Wrote: Hello Romain,
Hope this message will find you well.
I used you little utility with the previous moOde versions successfully until I recently updated to the latest 8 version.
Maybe I am wrong or I made mistake, but it seems not to work anymore with the latest version.
Anyone got it to work with moOde 8?
In recent Raspbian OS versions the names of the leds have changed from "led0" and "led1" to "ACT" and "PWR" respectively, so I believe the checksources.sh file needs to be modified, at the lines 10 and 11, replacing the LED=0 with LED="ACT" and LED=1- with LED="PWR" respectively.
In line 13, also, the "led" text just before "${LED}" should be removed for this change to work.
Posts: 22
Threads: 2
Joined: Apr 2020
Reputation:
1
05-28-2023, 02:49 PM
(This post was last modified: 05-28-2023, 02:49 PM by zazouboy.
Edit Reason: Punctuation
)
Thanks for the feedback!
As soon as I can, I will try as you suggest and will report back.
Kind regards,
Renaud
|