Intel NUC unattended-upgrades battery power error
I have an Intel NUC running Ubuntu 21.10 server. When testing my unattended-upgrades setup (via
sudo unattended-upgrades --dry-run --debug) I am receiving the following error:
System is on battery power, stopping
The NUC doesn’t have a battery so there appears to be a system configuration error. After repeated searches I haven’t found any reports of similar problems. Does anyone have an idea of what the issue is and how to fix it?
EDIT: Here is the output of the
on_ac_power script referenced below. I was unable to determine what is causing it to return false when the NUC is certainly on AC power:
deploy@deploy-nuc:~▶ ./on_ac_power.sh + OFF_LINE_P=no + [ -d /sys/class/power_supply/ ] + test -d /sys/class/power_supply/ucsi-source-psy-USBC000:001 + test -r /sys/class/power_supply/ucsi-source-psy-USBC000:001/type + cat /sys/class/power_supply/ucsi-source-psy-USBC000:001/type + type=USB + [ -r /sys/class/power_supply/ucsi-source-psy-USBC000:001/online ] + cat /sys/class/power_supply/ucsi-source-psy-USBC000:001/online + online=0 + [ 0 = 1 ] + [ 0 = 0 ] + OFF_LINE_P=yes + test -d /sys/class/power_supply/ucsi-source-psy-USBC000:002 + test -r /sys/class/power_supply/ucsi-source-psy-USBC000:002/type + cat /sys/class/power_supply/ucsi-source-psy-USBC000:002/type + type=USB + [ -r /sys/class/power_supply/ucsi-source-psy-USBC000:002/online ] + cat /sys/class/power_supply/ucsi-source-psy-USBC000:002/online + online=0 + [ 0 = 1 ] + [ 0 = 0 ] + OFF_LINE_P=yes + [ yes = yes ] + exit 1
I don’t know why your system believes it is on battery, but it looks like
unattended-upgrades calls the external command
on_ac_power to determine if on battery.
on_ac_power is just a fairly basic shell script, so you might be able to walk through it and figure out why it is returning the wrong value.
As a workaround, you can add to your apt configuration this setting that will tell
unattended-upgrades to continue when on battery.