diff options
Diffstat (limited to 'update-me.in')
-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 |