summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2020-08-19 21:26:59 +0200
committerErich Eckner <git@eckner.net>2020-08-19 21:26:59 +0200
commit5fec9f90d6ede751f2c6099eba2a4b9b345b6f17 (patch)
tree191094b34bdeba95d41da995a751124c6b0d8fb3
parent282c2e9fed356015ab401a518b9311c89ca62d13 (diff)
downloadupdate-all-5fec9f90d6ede751f2c6099eba2a4b9b345b6f17.tar.xz
update-me: command_needs_root() new
-rw-r--r--update-me.in26
1 files 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}