diff options
author | Erich Eckner <git@eckner.net> | 2019-08-18 12:07:18 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-08-18 12:07:18 +0200 |
commit | 72ac75c3322b07e1893246b8928d96a3411aee21 (patch) | |
tree | 9debb3def95c958764ca3c5fb2aa99d1d3502c3f | |
parent | 6b6ac582561156d192f6be7e522c8c584a694b13 (diff) | |
download | update-all-72ac75c3322b07e1893246b8928d96a3411aee21.tar.xz |
update-me: "mount -o remount,rw /boot" if necessarry (and as root)
-rw-r--r-- | update-me.in | 19 |
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 |