From mboxrd@z Thu Jan  1 00:00:00 1970
From: Michael Tremer <michael.tremer@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH 3/3] core179: Migrate old ExtraHD entries in /etc/fstab
Date: Tue, 15 Aug 2023 10:19:36 +0000
Message-ID: <20230815101936.261078-3-michael.tremer@ipfire.org>
In-Reply-To: <20230815101936.261078-1-michael.tremer@ipfire.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============6366872524249391408=="
List-Id: <development.lists.ipfire.org>

--===============6366872524249391408==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

The rewritten version of ExtraHD no longer stores entries in /etc/fstab
which is why they have to be removed during the update.

Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
---
 config/rootfiles/core/179/update.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/config/rootfiles/core/179/update.sh b/config/rootfiles/core/179/=
update.sh
index bc8fa28cd..110335d13 100644
--- a/config/rootfiles/core/179/update.sh
+++ b/config/rootfiles/core/179/update.sh
@@ -24,6 +24,24 @@
 . /opt/pakfire/lib/functions.sh
 /usr/local/bin/backupctrl exclude >/dev/null 2>&1
=20
+migrate_extrahd() {
+	local dev
+	local fs
+	local mp
+	local rest
+
+	while IFS=3D';' read -r dev fs mp rest; do
+		# Make sure mountpoint it set (so that we won't delete
+		# everything in /etc/fstab if there was an empty line).
+		if [ -z "${mp}" ]; then
+			continue
+		fi
+
+		# Remove the mountpoint from /etc/fstab
+		sed "/[[:blank:]]${mp//\//\\\/}[[:blank:]]/d" -i /etc/fstab
+	done < /var/ipfire/extrahd/devices
+}
+
 core=3D179
=20
 # Remove old core updates from pakfire cache to save space...
@@ -61,6 +79,9 @@ ldconfig
 # Filesytem cleanup
 /usr/local/bin/filesystem-cleanup
=20
+# Migrate ExtraHD
+migrate_extrahd
+
 # Start services
 /etc/init.d/udev restart
 /etc/init.d/squid restart
--=20
2.39.2


--===============6366872524249391408==--