summaryrefslogtreecommitdiff
path: root/etc/functions
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2008-11-18 21:15:21 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2008-11-18 21:15:21 +0100
commit910756e86426e90b9e48a52c4f619ae3556f3b55 (patch)
tree8154f0a9ee3adeaa2458b794bb528cf79bd6eeb5 /etc/functions
parent67e50a419b7bc0f694e11b95c82a083608299d67 (diff)
Use the hosts array to associate some information with each host
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] ]] {