From 5fec9f90d6ede751f2c6099eba2a4b9b345b6f17 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 19 Aug 2020 21:26:59 +0200 Subject: update-me: command_needs_root() new --- update-me.in | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/update-me.in b/update-me.in index f5e08cb..cbd6fd9 100644 --- a/update-me.in +++ b/update-me.in @@ -66,6 +66,20 @@ if command -v check-kernel >/dev/null; then postCmds+=('check-kernel -r') fi +command_needs_root() { + local cmd + cmd="$1" + cmd="${cmd%% *}" + cmd="${cmd##*/}" + if [ "${cmd}" = 'mount' ] \ + || [ "${cmd}" = 'checkservices' ] \ + || [ "${cmd}" = 'check-kernel' ]; then + return 0 + else + return 1 + fi +} + opportunity_for_rescue_shell() { if "${play_it_safe}"; then printf '%s' "$$" >"${safety_file}" @@ -161,16 +175,14 @@ fi for cmd in "${preCmds[@]}" do - if [ -z "${cmd%%check-kernel*}" ] \ - || [ -z "${cmd%%mount*}" ]; then + if command_needs_root "${cmd}"; then eval ${pre} ${cmd} else eval ${cmd} fi err=$? while [ ${err} -ne 0 ] && nochmal_versuchen; do - if [ -z "${cmd%%check-kernel*}" ] \ - || [ -z "${cmd%%mount*}" ]; then + if command_needs_root "${cmd}"; then eval ${pre} ${cmd} else eval ${cmd} @@ -200,16 +212,14 @@ opportunity_for_rescue_shell for cmd in "${postCmds[@]}" do - if [ -z "${cmd%%check-kernel*}" ] \ - || [ -z "${cmd%%mount*}" ]; then + if command_needs_root "${cmd}"; then eval ${pre} ${cmd} else eval ${cmd} fi err=$? while [ ${err} -ne 0 ] && nochmal_versuchen; do - if [ -z "${cmd%%check-kernel*}" ] \ - || [ -z "${cmd%%mount*}" ]; then + if command_needs_root "${cmd}"; then eval ${pre} ${cmd} else eval ${cmd} -- cgit v1.2.3-70-g09d2