diff mbox series

[2/6] package/mender: remove /var/lib/mender symlinking

Message ID 20241014102123.3727883-3-adam.duskett@amarulasolutions.com
State New
Headers show
Series mender cleanup and intermittent update | expand

Commit Message

Adam Duskett Oct. 14, 2024, 10:21 a.m. UTC
The logic behind making /var/lib/mender a symlink to itself is to
detect if a filesystem is read-only. However, this creates a few problems:

  1) The logic confusing.

  2) The official mender documentation suggests four partitions minimum:
     - boot
     - rootfs A
     - rootfs B
     - data

     If a user is to follow the official documentation, which they should,
     then there is no need for any additional logic for a system setup with
     a read-only filesystem, as the data partition is always read-write.

  3) The post-build.sh script in the board/mender/x86_64 directory removes
     the symlink.

  - Remove symlinking /var/lib/mender to itself

  - Remove the difficult to understand logic dealing with the symlinks
    in S42mender, mender-client.service.

  - Remove the logic dealing with the symlink in
    board/mender/x86_64/post-build.sh

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
 board/mender/x86_64/post-build.sh    |  5 -----
 package/mender/S42mender             | 16 ----------------
 package/mender/mender-client.service | 11 -----------
 package/mender/mender.mk             |  3 +--
 4 files changed, 1 insertion(+), 34 deletions(-)
diff mbox series

Patch

diff --git a/board/mender/x86_64/post-build.sh b/board/mender/x86_64/post-build.sh
index bc4f4b8f11..0c52eb7be5 100755
--- a/board/mender/x86_64/post-build.sh
+++ b/board/mender/x86_64/post-build.sh
@@ -31,11 +31,6 @@  parse_args() {
 # Create a persistent directory to mount the data partition at.
 mender_fixup() {
     pushd "${TARGET_DIR}"
-    if [[ -L var/lib/mender ]]; then
-        rm var/lib/mender
-        mkdir -p var/lib/mender
-    fi
-
     # The common paradigm is to have the persistent data volume at /data for mender.
     if [[ ! -L data ]]; then
         ln -s var/lib/mender data
diff --git a/package/mender/S42mender b/package/mender/S42mender
index 0f2077d089..70116ed4eb 100644
--- a/package/mender/S42mender
+++ b/package/mender/S42mender
@@ -8,22 +8,6 @@  PIDFILE="/var/run/${DAEMON}.pid"
 DAEMON_ARGS="daemon"
 
 start() {
-	# If /var/lib/mender is a symlink to /var/run/mender, and
-	#   - the filesystem is RO (i.e. we can not rm the symlink),
-	#     create the directory pointed to by the symlink.
-	#   - the filesystem is RW (i.e. we can rm the symlink),
-	#     replace the symlink with an actual directory
-	if [ -L /var/lib/mender ] && [ "$(readlink /var/lib/mender)" = "/var/run/mender" ]
-	then
-		if rm -f /var/lib/mender >/dev/null 2>&1; then
-			mkdir -p /var/lib/mender
-		else
-			echo "No persistent location to store mender data. Data will be lost"
-			echo "at reboot. Are you sure this is what you want to do?"
-			mkdir -p "$(readlink /var/lib/mender)"
-		fi
-	fi
-
 	printf "Starting mender service: "
 	umask 077
 	start-stop-daemon -bmSqp "$PIDFILE" -x ${DAEMON_PATH} -- ${DAEMON_ARGS}
diff --git a/package/mender/mender-client.service b/package/mender/mender-client.service
index 5539a56fd6..47e439993c 100644
--- a/package/mender/mender-client.service
+++ b/package/mender/mender-client.service
@@ -6,17 +6,6 @@  After=systemd-resolved.service
 Type=idle
 User=root
 Group=root
-ExecStartPre=/bin/sh -c '\
-if [ -L /var/lib/mender \
-     -a "$(readlink /var/lib/mender)" = "/var/run/mender" ]; then \
-    if rm -f /var/lib/mender >/dev/null 2>&1; then \
-        mkdir -p /var/lib/mender; \
-    else \
-        echo "No persistent location to store mender data. Data will be lost" \
-        echo "at reboot. Are you sure this is what you want to do?"; \
-        mkdir -p "$(readlink /var/lib/mender)"; \
-    fi; \
-fi'
 ExecStart=/usr/bin/mender daemon
 Restart=on-abort
 
diff --git a/package/mender/mender.mk b/package/mender/mender.mk
index ee1398244b..e6a2740e80 100644
--- a/package/mender/mender.mk
+++ b/package/mender/mender.mk
@@ -72,8 +72,7 @@  define MENDER_INSTALL_CONFIG_FILES
 	$(INSTALL) -D -m 0755 $(MENDER_PKGDIR)/device_type \
 			$(TARGET_DIR)/etc/mender/device_type
 
-	mkdir -p $(TARGET_DIR)/var/lib
-	ln -snf /var/run/mender $(TARGET_DIR)/var/lib/mender
+	mkdir -p $(TARGET_DIR)/var/lib/mender
 	$(foreach f,$(MENDER_UPDATE_MODULES_FILES), \
 		$(INSTALL) -D -m 0755 $(@D)/support/modules/$(notdir $(f)) \
 			$(TARGET_DIR)/usr/share/mender/modules/v3/$(notdir $(f))