summaryrefslogtreecommitdiff
path: root/etc/functions
diff options
context:
space:
mode:
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
+}