aboutsummaryrefslogtreecommitdiffstats
path: root/setup-bootable.in
diff options
context:
space:
mode:
Diffstat (limited to 'setup-bootable.in')
-rw-r--r--setup-bootable.in19
1 files changed, 19 insertions, 0 deletions
diff --git a/setup-bootable.in b/setup-bootable.in
index a841ddc..503a47b 100644
--- a/setup-bootable.in
+++ b/setup-bootable.in
@@ -4,10 +4,14 @@ prog=${0##*/}
version=@VERSION@
cleanup() {
+ local i=
cd /
if [ -n "$uninstalls" ]; then
apk del -q syslinux
fi
+ for i in $read_only_mounts; do
+ mount -o remount,ro "$i"
+ done
if [ -n "$umounts" ]; then
umount $umounts
fi
@@ -50,6 +54,14 @@ vecho() {
echo "$@"
}
+# check if given dir is read-only
+is_read_only() {
+ local tmpfile=$(mktemp -p "$1" 2>/dev/null)
+ [ -z "$tmpfile" ] && return 0
+ rm -f "$tmpfile"
+ return 1
+}
+
usage() {
cat <<__EOF__
$prog $version
@@ -123,6 +135,13 @@ elif [ -b "$dest" ]; then
umounts="$umounts $destdir"
fi
+# remount as rw if needed
+if is_read_only "$destdir"; then
+ vecho "Remounting $destdir as read/write"
+ mount -o remount,rw "$dest" || die "Failed to remount $destdir as rw"
+ read_only_mounts="$read_only_mounts $destdir"
+fi
+
# fish out label, uuid and type
eval $(blkid $dest | cut -d: -f2-)