From 4d4a228fb3bc21b0015981d99ed8d708a3c533db Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sun, 10 May 2020 13:10:23 +0200 Subject: shutdownasap: sudo is optional if called as root --- shutdownasap.in | 11 +++++++++-- 1 file 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 -- cgit v1.2.3-70-g09d2