diff options
author | Matthew Vernon <mvernon@wikimedia.org> | 2022-09-29 15:16:43 +0100 |
---|---|---|
committer | Matthew Vernon <mvernon@wikimedia.org> | 2022-09-30 09:47:24 +0100 |
commit | e838d8a9475242c6e8e47f1229cabecce0fc3281 (patch) | |
tree | c998c311eae07dd2d92b4b2fceb7f4aef030f858 /bin | |
parent | 99b0b3d1ec15e93a98dd7ddd1c24e1da9650f64b (diff) | |
download | swift-e838d8a9475242c6e8e47f1229cabecce0fc3281.tar.gz |
swift-drive-audit: reload systemd after editing fstab
Systemd does not monitor /etc/fstab for changes; so a filesystem
unmounted and commented-out in fstab will be re-mounted by systemd
after some time.
This change means that swift-drive-audit will call systemcl
daemon-reload (which causes systemd to reload its configuration
including /etc/fstab) after editing /etc/fstab on systems where
systemd is the running init. Check for that case by looking for the
existence of the directory /run/systemd/system, as documented in
sd_booted(3).
Signed-off-by: Matthew Vernon <mvernon@wikimedia.org>
Change-Id: I8830e3da9b6b085224511ac351f2d2860119c432
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/swift-drive-audit | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/bin/swift-drive-audit b/bin/swift-drive-audit index b77167042..03662bc25 100755 --- a/bin/swift-drive-audit +++ b/bin/swift-drive-audit @@ -18,6 +18,7 @@ import datetime import glob import locale import os +import os.path import re import subprocess import sys @@ -222,3 +223,6 @@ if __name__ == '__main__': if unmounts == 0: logger.info("No drives were unmounted") + elif os.path.isdir("/run/systemd/system"): + logger.debug("fstab updated, calling systemctl daemon-reload") + subprocess.call(["/usr/bin/systemctl", "daemon-reload"]) |