diff options
author | Erich Eckner <git@eckner.net> | 2020-05-10 13:10:23 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-05-10 13:10:23 +0200 |
commit | 4d4a228fb3bc21b0015981d99ed8d708a3c533db (patch) | |
tree | 01509053aa9235e5183aca9723e3fbbcb3ccd42e /shutdownasap.in | |
parent | ab20110df8c5f3e05c87e9b8b64360e3326ad99f (diff) | |
download | shutdownasap-4d4a228fb3bc21b0015981d99ed8d708a3c533db.tar.xz |
shutdownasap: sudo is optional if called as root
Diffstat (limited to 'shutdownasap.in')
-rwxr-xr-x | shutdownasap.in | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/shutdownasap.in b/shutdownasap.in index 4bcd2e8..4314ed0 100755 --- a/shutdownasap.in +++ b/shutdownasap.in @@ -119,8 +119,15 @@ done beforeShutDownHook +if command -v sudo >/dev/null \ +&& [ "$(whoami)" != 'root' ]; then + pre='sudo' +else + pre='' +fi + if ${reboot}; then - sudo /sbin/reboot + ${pre} /sbin/reboot else - sudo /sbin/poweroff + ${pre} /sbin/poweroff fi |