summaryrefslogtreecommitdiff
path: root/etc/functions
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2008-11-18 20:30:27 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2008-11-18 20:30:27 +0100
commit67e50a419b7bc0f694e11b95c82a083608299d67 (patch)
treed2992d3a5812a6507b84fabc7cec21e0912ea2a6 /etc/functions
parent5b04152cceaf7c30f1aa437dd025977d70021650 (diff)
off: Added -n / -r (simulate / reboot)
Diffstat (limited to 'etc/functions')
-rw-r--r--etc/functions/off22
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
+}