Revamp services management

Put update requests in a job queue and replace the job queue when new update requests are presented within the scheduled wait time
This approach makes only the last update request running
New log entries are provided to follow execution of the jobs
This commit is contained in:
bergware
2025-02-16 21:33:00 +01:00
parent 927d01a4ad
commit 01e4027460
3 changed files with 23 additions and 7 deletions
+12 -2
View File
@@ -1,8 +1,18 @@
#!/bin/bash
SERVICES="rpc nfsd ntpd nginx sshd avahidaemon samba"
if [[ -n $1 ]]; then
[[ ! -e $1 ]] && touch $1 || exit 0
# delayed execution
sleep ${1:-1}
# run & log functions
. /etc/rc.d/rc.runlog
JOB=$(atq | grep -Pom1 '^\d+')
if [[ -n $JOB ]]; then
atrm $JOB 2>/dev/null
log "execute queued job $JOB"
else
exit 0
fi
for cmd in $SERVICES; do
+10 -4
View File
@@ -1,10 +1,16 @@
#!/bin/bash
lock=/tmp/atlock.tmp
# run & log functions
. /etc/rc.d/rc.runlog
log "delay = ${1:-1}s"
rm -f $lock
echo "sleep ${1:-1};/usr/local/emhttp/webGui/scripts/reload_services $lock"|at -M now &>/dev/null
JOB=$(atq | grep -Pom1 '^\d+')
if [[ -n $JOB ]]; then
atrm $JOB 2>/dev/null
log "remove queued job $JOB"
else
log "no queued job present"
fi
echo "/usr/local/emhttp/webGui/scripts/reload_services ${1:-1}" | at -M now 2>/dev/null
log "queue new job $(atq | grep -Pom1 '^\d+'), wait for ${1:-1}s"
exit 0
+1 -1
View File
@@ -27,7 +27,7 @@ if ($arg == 'yes') {
exec("/etc/rc.d/rc.wireless start &>/dev/null &");
} elseif ($arg == 'no') {
exec("/etc/rc.d/rc.wireless stop");
exec("$docroot/webGui/scripts/update_services 5");
exec("$docroot/webGui/scripts/update_services");
} elseif (($wifi['wlan0']['WIFI']??'') == 'yes') {
foreach ($wifi as $network => $block) {
if ($network == $port) continue;