summaryrefslogtreecommitdiff
path: root/shutdownasap.in
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-05-10 13:10:23 +0200
committerErich Eckner <git@eckner.net>2020-05-10 13:10:23 +0200
commit4d4a228fb3bc21b0015981d99ed8d708a3c533db (patch)
tree01509053aa9235e5183aca9723e3fbbcb3ccd42e /shutdownasap.in
parentab20110df8c5f3e05c87e9b8b64360e3326ad99f (diff)
downloadshutdownasap-4d4a228fb3bc21b0015981d99ed8d708a3c533db.tar.xz
shutdownasap: sudo is optional if called as root
Diffstat (limited to 'shutdownasap.in')
-rwxr-xr-xshutdownasap.in11
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