diff options
author | Erich Eckner <git@eckner.net> | 2020-02-21 09:39:33 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-02-21 09:39:33 +0100 |
commit | 9e18b08b629c69e49417fd778fafc3f0217b4cc9 (patch) | |
tree | 52d2b0e51a2f40ae1f88addde68491a751d3baa4 | |
parent | 0724b47df2dcf95c1e701c77834cb24dcd88cda4 (diff) | |
download | update-all-9e18b08b629c69e49417fd778fafc3f0217b4cc9.tar.xz |
update-me: -c and -s new
-rw-r--r-- | update-me.in | 47 |
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 |