diff options
-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 |