Last active
March 5, 2016 15:02
-
-
Save saez0pub/e1169b3688744b9a843b to your computer and use it in GitHub Desktop.
detect and restart systemctl units after a full upgrade Oo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: restart systemctl units with deleted files when upgraded | |
shell: find /proc/*/fd/ -xtype f ! -exec file {} \; | grep -P '^/proc/[0-9]+/fd/[0-9]+{{ ":" }} broken symbolic link to /.*(deleted)' | sed -e 's/^\/proc\/\([0-9][0-9]*\)\/fd\/[0-9][0-9]*{{ ":" }} broken symbolic link to \(\/.*\) (deleted)/\1 \2/' | grep -v -e ' /tmp/' -e '(deleted)' |cut -d ' ' -f1 | sort -u | while read pid; do systemctl status $pid --no-pager -n0 --no-legend | grep '^ *Loaded\{{ ":" }} loaded (/usr/lib/systemd/' | sed -e 's/^ *Loaded\{{ ":" }} loaded (//' -e 's/;.*//' -e 's/.*\///'; done | sort -u | |
register: restartUnits | |
failed_when: restartUnits.stderr | |
when: "systemUpgraded | changed" |
Author
saez0pub
commented
Mar 5, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment