From 67e50a419b7bc0f694e11b95c82a083608299d67 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 18 Nov 2008 20:30:27 +0100 Subject: off: Added -n / -r (simulate / reboot) --- etc/functions/off | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'etc/functions') 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 +} -- cgit v1.2.3