Distinguish between oneshot and simple services

This commit is contained in:
Santiago Lo Coco 2022-01-05 14:25:32 -03:00
parent 1716c73a53
commit 489adc762e
1 changed files with 13 additions and 7 deletions

View File

@ -376,7 +376,7 @@ updateMirrors() {
countriesFmt=$(echo "$countries" | sed -r 's/" "/,/g') countriesFmt=$(echo "$countries" | sed -r 's/" "/,/g')
reflector --country \"${countriesFmt//\"/}\" --protocol https --sort rate --save /etc/pacman.d/mirrorlist 2>&1 | debug reflector --country \"${countriesFmt//\"/}\" --protocol https --sort rate --save /etc/pacman.d/mirrorlist 2>&1 | debug
else else
checkForSystemdUnit "mirrors update" "reflector.service" checkForSystemdUnit "mirrors update" "reflector.service" "oneshot"
fi fi
} }
@ -454,15 +454,21 @@ getDotfiles() {
checkForSystemdUnit() { checkForSystemdUnit() {
trap 'systemctl stop ${2}; forceExit=true' INT trap 'systemctl stop ${2}; forceExit=true' INT
systemctl is-active --quiet ${2}
[ $? -eq 0 ] && return
forceExit=false forceExit=false
calcWidthAndRun "whiptail --infobox \"Waiting for the ${1} to finish. Please wait.\" 7 WIDTH" calcWidthAndRun "whiptail --infobox \"Waiting for the ${1} to finish. Please wait.\" 7 WIDTH"
systemctl is-active --quiet ${2} if [ "${3}" = "oneshot" ]; then
while [ $? -ne 0 ] && [ $forceExit = false ]; do
sleep 1
systemctl is-active --quiet ${2} systemctl is-active --quiet ${2}
done while [ $? -ne 0 ] && [ $forceExit = false ]; do
sleep 1
systemctl is-active --quiet ${2}
done
else
while [ $forceExit = false ]; do
result=$(systemctl show -p ActiveState --value ${2})
[ "$result" = "activating" ] && break
sleep 1
done
fi
trap - INT trap - INT
} }