[3/3] core179: Migrate old ExtraHD entries in /etc/fstab

Message ID 20230815101936.261078-3-michael.tremer@ipfire.org
State Staged
Commit 9f1636bf11968b431d9d484745346fa2b07fc5d7
Headers
Series [1/3] mountfs: Mount ExtraHD filesystems |

Commit Message

Michael Tremer Aug. 15, 2023, 10:19 a.m. UTC
  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@ipfire.org>
---
 config/rootfiles/core/179/update.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
  

Patch

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
 
+migrate_extrahd() {
+	local dev
+	local fs
+	local mp
+	local rest
+
+	while IFS=';' 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=179
 
 # Remove old core updates from pakfire cache to save space...
@@ -61,6 +79,9 @@  ldconfig
 # Filesytem cleanup
 /usr/local/bin/filesystem-cleanup
 
+# Migrate ExtraHD
+migrate_extrahd
+
 # Start services
 /etc/init.d/udev restart
 /etc/init.d/squid restart