summaryrefslogtreecommitdiff
path: root/setup-apkcache.in
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2022-05-07 19:18:00 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2022-05-07 19:18:00 +0000
commitda8e4b50ee627d042059ec8617305be51ca3c6b2 (patch)
tree2ea165ee882edb12f7c4b8769dda818abe98f6c8 /setup-apkcache.in
parent5427c716f6bee896942219cc7cee76eb07288e16 (diff)
downloadalpine-conf-da8e4b50ee627d042059ec8617305be51ca3c6b2.zip
setup-apkcache: remove noauto mount option
setup-lbu will add noauto, which makes sense when there is no apk cache. But when we have apk cache enabled, we want the media where it is stored to be mounted during boot so the apk cache works. So we strip the noauto mount option.
Diffstat (limited to 'setup-apkcache.in')
-rw-r--r--setup-apkcache.in37
1 files changed, 31 insertions, 6 deletions
diff --git a/setup-apkcache.in b/setup-apkcache.in
index ce7a30a..fbe8541 100644
--- a/setup-apkcache.in
+++ b/setup-apkcache.in
@@ -60,23 +60,37 @@ find_mount_point() {
echo $dir
}
-get_mount_opts() {
+# get device for a given mount point
+get_dev_from_mountpoint() {
local mnt="$1"
- awk "\$2 == \"$mnt\" {gsub(/,/, \" \", \$4); print \$4}" /proc/mounts
+ local fstab="$2"
+ awk "\$2 == \"$mnt\" {print \$1}" "$fstab"
}
-is_mounted_ro() {
+get_mount_opts_from_mountpoint() {
local mnt="$1"
- local opts=$(get_mount_opts $mnt)
+ local fstab="$2"
+ awk "\$2 == \"$mnt\" {gsub(/,/, \" \", \$4); print \$4}" "$fstab"
+}
+
+has_mount_opt() {
+ local searchfor="$1"
+ local mnt="$2"
+ local fstab="$3"
+ local opts=$(get_mount_opts_from_mountpoint $mnt $fstab)
local opt=
for opt in $opts; do
- if [ "$opt" = "ro" ]; then
+ if [ "$opt" = "$searchfor" ]; then
return 0
fi
done
return 1
}
+is_mounted_ro() {
+ has_mount_opt ro "$1" /proc/mounts
+}
+
# get the fstype of the given mount point
mount_fstype() {
# we only want the last mount in case there are several
@@ -147,8 +161,19 @@ mount=$(find_mount_point $cachedir)
cleanup=
if ! is_mounted $mount; then
+ # remove noauto that setup-lbu might have added
+ if has_mount_opt noauto "$mount" /etc/fstab; then
+ fstabtmp=$(mktemp)
+ awk -v mnt="$mount" \
+ '$2 != mnt {print $0}
+ $2 == mnt {
+ sub(/noauto,|,noauto/, "", $4);
+ sub(/^noauto$/, "defaults", $4);
+ print $0
+ }' /etc/fstab > "$fstabtmp"
+ mv "$fstabtmp" /etc/fstab
+ fi
mount $mount || exit 1
- cleanup="umount"
elif is_mounted_ro $mount; then
mount -o remount,rw $mount || exit 1
cleanup="remount"