summaryrefslogtreecommitdiff
path: root/update-me.in
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-02-21 09:39:33 +0100
committerErich Eckner <git@eckner.net>2020-02-21 09:39:33 +0100
commit9e18b08b629c69e49417fd778fafc3f0217b4cc9 (patch)
tree52d2b0e51a2f40ae1f88addde68491a751d3baa4 /update-me.in
parent0724b47df2dcf95c1e701c77834cb24dcd88cda4 (diff)
downloadupdate-all-9e18b08b629c69e49417fd778fafc3f0217b4cc9.tar.xz
update-me: -c and -s new
Diffstat (limited to 'update-me.in')
-rw-r--r--update-me.in47
1 files changed, 47 insertions, 0 deletions
diff --git a/update-me.in b/update-me.in
index 46db7f7..903c30d 100644
--- a/update-me.in
+++ b/update-me.in
@@ -1,5 +1,40 @@
#!/bin/bash
+usage() {
+ >&2 echo 'usage: update-me [-s|-c]'
+ >&2 echo ' -s: play it save'
+ >&2 echo ' -c: clear for exit'
+ exit $1
+}
+
+play_it_safe=false
+safety_file='/tmp/update-me.do-not-exit'
+
+case $# in
+ 0)
+ ;;
+ 1)
+ case "x$1" in
+ 'x-s')
+ play_it_safe=true
+ ;;
+ 'x-c')
+ if [ -f "${safety_file}" ] && kill -0 $(cat "${safety_file}"); then
+ rm "${safety_file}"
+ exit 0
+ fi
+ exit 1
+ ;;
+ *)
+ usage
+ ;;
+ esac
+ ;;
+ *)
+ usage 1
+ ;;
+esac
+
preCmds=('hostname')
cmds=()
postCmds=('sync')
@@ -21,6 +56,18 @@ if command -v check-kernel >/dev/null; then
fi
exit_or_rescue_shell() {
+ if "${play_it_safe}"; then
+ printf '%s' "$$" >"${safety_file}"
+ >&2 printf '%s: waiting for clearance ...' "$(hostname)"
+ while [ -f "${safety_file}" ] && [ "$(cat "${safety_file}")" = "$$" ]; do
+ if read -t 1; then
+ >&2 printf ' rescue shell!\n'
+ bash
+ break
+ fi
+ done
+ >&2 printf ' clear.\n'
+ fi
if [ "$1" -eq 0 ]; then
>&2 printf '%s: Erfolg\n' "$(hostname)"
else