summaryrefslogtreecommitdiff
path: root/update-me.in
diff options
context:
space:
mode:
Diffstat (limited to 'update-me.in')
-rw-r--r--update-me.in19
1 files changed, 17 insertions, 2 deletions
diff --git a/update-me.in b/update-me.in
index 449d7b9..0b4c48d 100644
--- a/update-me.in
+++ b/update-me.in
@@ -4,6 +4,15 @@ preCmds=('hostname')
cmds=()
postCmds=('sync')
+if mountpoint -q /boot \
+&& mount \
+ | grep -wF '/boot' \
+ | cut -d' ' -f6 \
+ | grep -qwF 'ro'; then
+ preCmds+=('mount -o remount,rw /boot')
+ postCmds+=('mount -o remount,ro /boot')
+fi
+
if command -v check-kernel >/dev/null; then
postCmds+=('check-kernel -r')
fi
@@ -12,9 +21,15 @@ fi
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' ]; then
- postCmds[${i}]='sudo check-kernel -r';
+ if [ "${postCmds[${i}]}" = 'check-kernel -r' ] \
+ || [ -z "${postCmds[${i}]%%mount*}" ]; then
+ postCmds[${i}]='sudo '"${postCmds[${i}]}";
fi
done
fi