bundles/apt: introduce restart_triggers (restart services if another service has been upgraded)
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit

This commit is contained in:
Franzi 2021-04-02 08:12:51 +02:00
parent 7ca24d27d3
commit a24fb12c21
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 16 additions and 0 deletions

View file

@ -74,4 +74,19 @@ then
date | mail -s "SYSREBOOTNOW ${node.name}" ${data['mail']} date | mail -s "SYSREBOOTNOW ${node.name}" ${data['mail']}
% endif % endif
systemctl reboot systemctl reboot
% if restart_triggers
else
% for affected, restarts in sorted(restart_triggers.items()):
up_since=$(systemctl show "${affected}" | sed -n 's/^ActiveEnterTimestamp=//p' || echo 0)
up_since_ts=$(date -d "$up_since" +%s || echo 0)
now=$(date +%s)
if [ $((now - up_since_ts)) -lt 3600 ]
then
% for restart in sorted(restarts):
systemctl restart "${restart}" || true
% endfor
fi
% endfor
% endif
fi fi

View file

@ -33,6 +33,7 @@ files = {
'context': { 'context': {
'clean_old_kernels': node.metadata.get('apt/clean_old_kernels', True), 'clean_old_kernels': node.metadata.get('apt/clean_old_kernels', True),
'data': node.metadata.get('apt/unattended-upgrades', {}), 'data': node.metadata.get('apt/unattended-upgrades', {}),
'restart_triggers': node.metadata.get('apt/restart_triggers', {}),
} }
}, },
'/etc/cloud': { '/etc/cloud': {