When there are a bunch of updates to be done, as soon as the kernel update is done Webmin alerts that System requires Reboot though there may still be a lot of updates still happening.
This can either fool the Admin into rebooting, and does fool the Reboot Required system monitor into rebooting.
End result corruption due to half installed update - in my case systemd had to be forced re-installed.
Suggest don’t set Reboot Required until after all current (security) updates are finished.
We don’t set reboot required, so we can’t control when it gets set. That’s handled by the OS package manager.
I don’t know how best to handle that race risk, but I do know it’s almost never urgent that you reboot as soon as it is set. It is only set when a kernel update is installed, and it’s only actually a necessary reboot if there is a security issue that effects your system. In all other cases, a reboot can happen whenever is convenient/safe. I wouldn’t automate it, personally, but you could make your monitor wait an hour or whatever before rebooting to avoid the race.
No, though you could create one (you can create your own monitors to do literally anything), but that would be subject to a race, too.
I don’t know any way to completely avoid a race here. You could check to see if apt/dpkg or dnf/rpm are running, and if so, wait a few minutes and try again.
if you really want to do it here’s a starting point
bash
OUTPUT="$(apt-get --assume-no upgrade | tail -n 1)"
if [[ $OUTPUT == 0* ]] ;
then
echo All upgraded
# reboot here perhaps
exit 1
fi
# at this point there are still upgrades
echo There are upgrades to do
php
<?php
$cmd = "apt-get --assume-no upgrade";
exec($cmd,$output,$ret);
$last = end($output);
if( str_starts_with($last, "0 ")){
echo "ALL upgraded\n";
//
}
else {
// there are upgrades to do
}
note this applies if your using apt but could be changed to other package managers, and it really is just an example
as I said this is a starter & not fully polished scripts
bash
if [[ $(ps -e | grep apt-get) ]]; then
echo "apt-get is running"
exit 0
fi
OUTPUT="$(apt-get --assume-no upgrade | tail -n 1)"
prefix="0 "
if [[ $OUTPUT == "$prefix"* ]] ;
then
echo All upgraded
# reboot here perhaps
exit 1
fi
# at this point there are still upgrades
echo There are upgrades to do
php
<?php
$check = trim(shell_exec("ps -e | grep apt-get"));
if (!empty($check)){
echo "apt-get is running\n";
exit;
}
$cmd = "apt-get --assume-no upgrade";
exec($cmd,$output,$ret);
$last = end($output);
if( str_starts_with($last, "0 ")){
echo "ALL upgraded\n";
//
}
else {
// there are upgrades to do
}
as I said in my previous post, these are starter scripts for someone else to improve on