summaryrefslogtreecommitdiff
path: root/setup-apklbu.in
diff options
context:
space:
mode:
authorJeff Bilyk <jbilyk@gmail.com>2011-06-08 22:31:20 +0000
committerJeff Bilyk <jbilyk@gmail.com>2011-06-08 22:31:20 +0000
commite13d4b56eabe125b9a4a73a25f04060518e82048 (patch)
tree6c9526779343cb406e12683f1a91c6050d0b4d51 /setup-apklbu.in
parent5ac7203533034845fed9ea4b7718e91ab58b2a7f (diff)
downloadalpine-conf-e13d4b56eabe125b9a4a73a25f04060518e82048.zip
setup-apklbu: handle ro media for apk and lbu
Diffstat (limited to 'setup-apklbu.in')
-rwxr-xr-xsetup-apklbu.in20
1 files changed, 20 insertions, 0 deletions
diff --git a/setup-apklbu.in b/setup-apklbu.in
index 91aac54..7e548a2 100755
--- a/setup-apklbu.in
+++ b/setup-apklbu.in
@@ -18,6 +18,23 @@ fi
mountpoint="usb"
echo "Please enter mountpoint directory under /media for lbu ($mountpoint):"
default_read mountpoint "$mountpoint"
+
+mountstatus="`mount | grep /media/${mountpoint}`"
+
+if [ -z $mountstatus ]; then
+ echo "$mountpoint is not mounted" && exit 1
+fi
+
+readwritestatus="`echo $mountstatus | awk -F '(' '{print $2}' | awk -F ',' '{print $1}'`"
+
+if [ "$readwritestatus" == "ro" ]; then
+ rewrite=1
+fi
+
+if [ "$rewrite" == 1 ]; then
+ mount -o remount,rw /media/${mountpoint} || die "Failed to remount media rw"
+}
+
mkdir -p /media/${mountpoint}/cache || die "Failed to create /media/${mountpoint}/cache"
ln -s /media/${mountpoint}/cache /etc/apk/cache || die "Failed to create apk cache softlink"
cat > /etc/lbu/lbu.conf <<EOF
@@ -36,3 +53,6 @@ LBU_MEDIA=$mountpoint
EOF
lbu package /media/"$mountpoint" || die "Failed to lbu apkovl on /media/${mountpoint}"
sync
+if [ "$rewrite" == 1 ]; then
+ mount -o remount,ro /media/${mountpoint} || die "Failed to remount media ro"
+}