Commit 92210657 authored by Natanael Copa's avatar Natanael Copa

setup-bootable: remount as read/write if needed

parent aa172c5a
......@@ -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-)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment