From 65813a73568016081733bc88bf9f6790988a6e44 Mon Sep 17 00:00:00 2001 From: Ryan Sawhill Aroha Date: Sat, 8 Apr 2017 01:13:43 -0400 Subject: [PATCH] v1.0.0: implement #1 and #2 and update README --- README.md | 9 ++++----- rguard | 8 ++++---- rguard.service | 5 +++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 75cc795..0e9d523 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ Block systemd-initiated poweroff/reboot/halt until configurable condition checks WARNING: ☹ Blocked poweroff.target WARNING: ☹ Blocked reboot.target WARNING: ☹ Blocked halt.target - WARNING: Exiting due to -1 or -0 option [root]# ``` @@ -50,7 +49,6 @@ Block systemd-initiated poweroff/reboot/halt until configurable condition checks WARNING: ☻ Unblocked poweroff.target WARNING: ☻ Unblocked reboot.target WARNING: ☻ Unblocked halt.target - WARNING: Exiting due to -1 or -0 option [root]# ``` @@ -86,14 +84,15 @@ Block systemd-initiated poweroff/reboot/halt until configurable condition checks ``` -### Instructions +### Instructions for daemon service 1. Install the rpm - `yum install http://people.redhat.com/rsawhill/rpms/latest-rsawaroha-release.rpm` - `yum install reboot-guard` +1. If you want the service to always block reboot/shutdown, requiring the service to be manually stopped or killed, simply run `systemctl daemon-reload; systemctl enable rguard --now` and you are done; otherwise, continue to next step 1. Play with the options until you get them how you want them (see help page: `rguard --help`) -1. Copy `/usr/lib/systemd/system/rguard.service` to `/etc/systemd/system` and modify set an `ExecStart=` directive -1. Run: `systemctl daemon-reload; systemctl enable rguard; systemctl start rguard` +1. Copy `/usr/lib/systemd/system/rguard.service` to `/etc/systemd/system` and set the `ExecStart=` directive to your liking +1. Run: `systemctl daemon-reload; systemctl enable rguard --now` 1. Check `systemctl status rguard -n50` or use `journalctl -fu rguard` to keep an eye on logs (turn up the `--loglevel` if necesary) 1. Tweak `rguard.service` as required, and then re-run `systemctl daemon-reload; systemctl restart rguard` 1. Give feedback by posting to the [Issue Tracker](https://github.com/ryran/reboot-guard/issues) diff --git a/rguard b/rguard index b09afb8..031a384 100755 --- a/rguard +++ b/rguard @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2015 Ryan Sawhill Aroha +# Copyright 2015, 2017 Ryan Sawhill Aroha # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,8 +26,8 @@ from stat import S_IWRITE prog = 'rguard' vers = {} -vers['version'] = '0.2.2' -vers['date'] = '2015/09/02' +vers['version'] = '1.0.0' +vers['date'] = '2017/04/08' def ret(returnCode): @@ -454,7 +454,7 @@ def main(): r.guard(enforce=True) else: r.guard(enforce=False) - logging.warning("Exiting due to -1 or -0 option") + logging.info("Exiting due to -1 or -0 option") exit() c = ConditionChecker( forbidFiles=opts.forbid_file, diff --git a/rguard.service b/rguard.service index 6531efe..cf8ed3d 100644 --- a/rguard.service +++ b/rguard.service @@ -2,6 +2,11 @@ Description=Reboot Guard [Service] +# With the following default example, shutdown will ALWAYS be blocked +# This is because the "false" command will never succeed +# In this case, shutdown can only be unblocked by manually stopping/killing rguard.service +ExecStart=/usr/sbin/rguard --run false --interval 86400 +# # NOTE: The following ExecStart lines are EXAMPLES only; modify to suit your needs # There should be only ONE uncommented ExecStart line #