about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypt.awk2
-rw-r--r--functions4
-rw-r--r--halt.84
-rw-r--r--modules-load.84
-rw-r--r--pause.14
-rwxr-xr-xshutdown35
-rw-r--r--shutdown.84
-rwxr-xr-xzzz2
-rw-r--r--zzz.84
9 files changed, 32 insertions, 31 deletions
diff --git a/crypt.awk b/crypt.awk
index d533ab8..2d2c965 100644
--- a/crypt.awk
+++ b/crypt.awk
@@ -3,7 +3,7 @@ NF>4 { print "a valid crypttab has max 4 cols not " NF >"/dev/stderr"; next }
 {
     # decode the src variants
     split($2, o_src, "=")
-    if (o_src[1] == "UUID") "blkid -t " $2 " -l -o device" |& getline src;
+    if (o_src[1] == "UUID") ("blkid -l -o device -t " $2) | getline src;
     else src=o_src[1];
 
     # no password or none is given, ask fo it
diff --git a/functions b/functions
index d1cd318..7f2e38c 100644
--- a/functions
+++ b/functions
@@ -49,7 +49,9 @@ deactivate_vgs() {
 deactivate_crypt() {
    if [ -x /sbin/dmsetup -o -x /bin/dmsetup ]; then
        msg "Deactivating Crypt Volumes"
-       dmsetup ls --target crypt --exec 'cryptsetup close'
+       for v in $(dmsetup ls --target crypt --exec "dmsetup info -c --noheadings -o open,name"); do
+           [ ${v%%:*} -eq 0 ] && cryptsetup close ${v##*:}
+       done
        deactivate_vgs "Crypt"
    fi
 }
diff --git a/halt.8 b/halt.8
index f6fad42..8930ad3 100644
--- a/halt.8
+++ b/halt.8
@@ -63,5 +63,5 @@ to shut down network interfaces.
 .Xr init 8 ,
 .Xr shutdown 8
 .Sh AUTHOR
-.An Christian Neukirchen ,
-.Mt chneukirchen@gmail.com .
+.An Leah Neukirchen ,
+.Mt leah@vuxu.org .
diff --git a/modules-load.8 b/modules-load.8
index 31441ec..40e2c9c 100644
--- a/modules-load.8
+++ b/modules-load.8
@@ -45,8 +45,8 @@ This program is a replacement for the
 utility provided by
 .Nm systemd .
 .Sh AUTHOR
-.An Christian Neukirchen ,
-.Mt chneukirchen@gmail.com .
+.An Leah Neukirchen ,
+.Mt leah@vuxu.org .
 .Sh LICENSE
 .Nm
 is in the public domain.
diff --git a/pause.1 b/pause.1
index e4f9997..1e56f20 100644
--- a/pause.1
+++ b/pause.1
@@ -35,5 +35,5 @@ ip link set eth0 down
 .Xr sleep 1 ,
 .Xr pause 2
 .Sh AUTHOR
-.An Christian Neukirchen ,
-.Mt chneukirchen@gmail.com .
+.An Leah Neukirchen ,
+.Mt leah@vuxu.org .
diff --git a/shutdown b/shutdown
index b456647..9b6bba4 100755
--- a/shutdown
+++ b/shutdown
@@ -6,7 +6,7 @@ single() {
 }
 
 abort() {
-  echo "$@" >&2
+  printf '%s\n' "$1" >&2
   exit 1
 }
 
@@ -37,7 +37,10 @@ time=$1; shift
 message="${*:-system is going down}"
 
 if [ "$action" = "cancel" ]; then
-  kill $(cat /run/runit/shutdown.pid)
+  kill "$(cat /run/runit/shutdown.pid)"
+  if [ -e /etc/nologin ] && ! [ -s /etc/nologin ]; then
+    rm /etc/nologin
+  fi
   echo "${*:-shutdown cancelled}" | wall
   exit
 fi
@@ -52,23 +55,19 @@ case "$time" in
   *) abort "invalid time";;
 esac
 
-if [ "$time" -gt 5 ]; then
-  echo "$message in $time minutes" | wall
-  printf "shutdown: sleeping for $time minutes... "
-  sleep $(((time - 5) * 60))
-  printf "\n"
-  time=5
-fi
+for break in 5 0; do
+  [ "$time" -gt "$break" ] || continue
+  [ "$break" = 0 ] && touch /etc/nologin
 
-if [ "$time" -gt 0 ]; then
-  echo "$message in $time minutes" | wall
-  touch /etc/nologin
-  printf "shutdown: sleeping for $time minutes... "
-  sleep $((time * 60))
-  printf "\n"
-  rm /etc/nologin
-fi
+  printf '%s in %s minutes\n' "$message" "$time" | wall
+  printf 'shutdown: sleeping for %s minutes... ' "$(( time - break ))"
+  sleep $(( (time - break) * 60 ))
+  time="$break"
+  printf '\n'
+
+  [ "$break" = 0 ] && rm /etc/nologin
+done
 
-echo "$message NOW" | wall
+printf '%s NOW\n' "$message" | wall
 
 $action
diff --git a/shutdown.8 b/shutdown.8
index 021cd62..4547e5b 100644
--- a/shutdown.8
+++ b/shutdown.8
@@ -86,5 +86,5 @@ Turn off the system:
 .Xr runit 8 ,
 .Xr runsvchdir 8
 .Sh AUTHOR
-.An Christian Neukirchen ,
-.Mt chneukirchen@gmail.com .
+.An Leah Neukirchen ,
+.Mt leah@vuxu.org .
diff --git a/zzz b/zzz
index 7d422a1..6dd903c 100755
--- a/zzz
+++ b/zzz
@@ -18,7 +18,7 @@ case "$0" in
   *ZZZ) ZZZ_MODE=hibernate;;
 esac
 
-while getopts hnSzHRZ: opt; do
+while getopts hnSzHRZ opt; do
   case "$opt" in
     n) ZZZ_MODE=noop;;
     S) ZZZ_MODE=standby;;
diff --git a/zzz.8 b/zzz.8
index 41ed105..27c9032 100644
--- a/zzz.8
+++ b/zzz.8
@@ -87,8 +87,8 @@ command appeared in
 and
 .Ox 1.2 .
 .Sh AUTHOR
-.An Christian Neukirchen ,
-.Mt chneukirchen@gmail.com .
+.An Leah Neukirchen ,
+.Mt leah@vuxu.org .
 .Sh LICENSE
 .Nm
 is in the public domain.