diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-11-18 20:30:27 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-11-18 20:30:27 +0100 |
commit | 67e50a419b7bc0f694e11b95c82a083608299d67 (patch) | |
tree | d2992d3a5812a6507b84fabc7cec21e0912ea2a6 /etc | |
parent | 5b04152cceaf7c30f1aa437dd025977d70021650 (diff) |
off: Added -n / -r (simulate / reboot)
Diffstat (limited to 'etc')
-rw-r--r-- | etc/functions/off | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/etc/functions/off b/etc/functions/off index 8369de9..3e65aef 100644 --- a/etc/functions/off +++ b/etc/functions/off @@ -2,7 +2,21 @@ typeset filesystem line IFS=$'\n' typeset -a filesystems typeset tune2fs -uinit stop-all +typeset reboot simulate + +function execute { + (( simulate )) || $* +} + +while [[ $1 == -* ]] { + case $1 in + -n) simulate=1 ;; + -r) reboot=1 ;; + esac + shift +} + +execute uinit stop-all for line in $(cat /etc/fstab); { if [[ $line == *[12] ]] { filesystems+=${${(s: :)line}[1]} @@ -14,4 +28,8 @@ for filesystem in $filesystems; { echo "notice: filesystem $filesystem due to check at next boot" } } -sudo halt +if (( reboot )) { + execute sudo reboot +} else { + execute sudo halt +} |