summaryrefslogtreecommitdiff
path: root/etc/functions
diff options
context:
space:
mode:
Diffstat (limited to 'etc/functions')
-rw-r--r--etc/functions/off11
1 files changed, 10 insertions, 1 deletions
diff --git a/etc/functions/off b/etc/functions/off
index 3e65aef..7ecaec9 100644
--- a/etc/functions/off
+++ b/etc/functions/off
@@ -1,8 +1,9 @@
## vim:ft=zsh
+autoload warn
typeset filesystem line IFS=$'\n'
typeset -a filesystems
typeset tune2fs
-typeset reboot simulate
+typeset -i force reboot simulate
function execute {
(( simulate )) || $*
@@ -12,10 +13,18 @@ while [[ $1 == -* ]] {
case $1 in
-n) simulate=1 ;;
-r) reboot=1 ;;
+ --force) force=1 ;;
esac
shift
}
+# Don't shut down a server too easily
+if [[ $force != 1 && $hosts[$HOST] == *:server:* ]] {
+ warn "This seems to be a server... not shutting down"
+ echo "Use 'off --force' if you really mean it"
+ return 1
+}
+
execute uinit stop-all
for line in $(cat /etc/fstab); {
if [[ $line == *[12] ]] {