about summary refs log tree commit diff
path: root/shutdown
diff options
context:
space:
mode:
authorMatthew Martin <phy1729@gmail.com>2017-07-25 20:44:10 -0500
committerLeаh Neukirchen <chneukirchen@gmail.com>2017-07-26 13:36:59 +0200
commit121baec9946541c80028f55894dcd3dd293599c4 (patch)
treeb117d2d7b2a97bb61565d9801763c1c4679fdd0d /shutdown
parentc7b381a1fe9bf431c5fe47d93ba1ff1051500f9b (diff)
downloadrunit-void-121baec9946541c80028f55894dcd3dd293599c4.tar.gz
runit-void-121baec9946541c80028f55894dcd3dd293599c4.tar.xz
runit-void-121baec9946541c80028f55894dcd3dd293599c4.zip
shutdown: Combine sleeping blocks
Diffstat (limited to 'shutdown')
-rwxr-xr-xshutdown22
1 files changed, 9 insertions, 13 deletions
diff --git a/shutdown b/shutdown
index 9d51d54..edb67af 100755
--- a/shutdown
+++ b/shutdown
@@ -55,22 +55,18 @@ 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 "shutdown: sleeping for $(( time - break )) minutes... "
+  sleep $(( (time - break) * 60 ))
+  time="$break"
   printf "\n"
-  rm /etc/nologin
-fi
+
+  [ "$break" = 0 ] && rm /etc/nologin
+done
 
 echo "$message NOW" | wall