summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-08-22 13:56:39 +0200
committerErich Eckner <git@eckner.net>2019-08-22 13:56:39 +0200
commit54f4f5902c282696eef9df8d36baaa5f869df5eb (patch)
treed02f88b68fc963b00ec9c6b56bf36d6f739629e8
parentd08f3409df1f066808f12f7711100a7119609c3b (diff)
downloadupdate-all-54f4f5902c282696eef9df8d36baaa5f869df5eb.tar.xz
update-me: add ${pre} before sudo-needing $preCmds and $postCmds instead of patching the respective commands themselfv0.5.6
-rw-r--r--update-me.in29
1 files changed, 14 insertions, 15 deletions
diff --git a/update-me.in b/update-me.in
index 00864ee..f3854fb 100644
--- a/update-me.in
+++ b/update-me.in
@@ -22,19 +22,8 @@ fi
. #ETCDIR#/update-me.conf
-if "${hasSudo}" && \
- command -v sudo >/dev/null; then
- for ((i=0; i<${#preCmds[@]}; i++)); do
- if [ -z "${preCmds[${i}]%%mount*}" ]; then
- preCmds[${i}]='sudo '"${preCmds[${i}]}";
- fi
- done
- for ((i=0; i<${#postCmds[@]}; i++)); do
- if [ "${postCmds[${i}]}" = 'check-kernel -r' ] \
- || [ -z "${postCmds[${i}]%%mount*}" ]; then
- postCmds[${i}]='sudo '"${postCmds[${i}]}";
- fi
- done
+if ! command -v sudo >/dev/null; then
+ hasSudo=false
fi
if [ ! "$(whoami)" == "root" ]; then
@@ -74,7 +63,12 @@ fi
for cmd in "${preCmds[@]}"
do
- ${cmd}
+ if [ -z "${cmd%%check-kernel*}" ] \
+ || [ -z "${cmd%%mount*}" ]; then
+ ${pre} ${cmd}
+ else
+ ${cmd}
+ fi
err=$?
if [ ${err} -ne 0 ]
then
@@ -98,7 +92,12 @@ done
for cmd in "${postCmds[@]}"
do
- ${cmd}
+ if [ -z "${cmd%%check-kernel*}" ] \
+ || [ -z "${cmd%%mount*}" ]; then
+ ${pre} ${cmd}
+ else
+ ${cmd}
+ fi
err=$?
if [ ${err} -ne 0 ]
then