summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-05-04 07:15:45 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-05-04 07:18:12 +0000
commit9221065710635d8a5436807c23a6e201cd583cea (patch)
tree5eb9d908a7ddb52a384310b4e9ab992322a6abbb
parentaa172c5a08d6bf9cac0e4e0e1dc3f0f5b455d328 (diff)
downloadalpine-conf-9221065710635d8a5436807c23a6e201cd583cea.tar.bz2
alpine-conf-9221065710635d8a5436807c23a6e201cd583cea.tar.xz
setup-bootable: remount as read/write if needed
-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-)