From 910756e86426e90b9e48a52c4f619ae3556f3b55 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 18 Nov 2008 21:15:21 +0100 Subject: Use the hosts array to associate some information with each host --- etc/functions/off | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'etc/functions') 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] ]] { -- cgit v1.2.3