package/mender: adding a writable location
authorAngelo Compagnucci <angelo@amarulasolutions.com>
Tue, 5 Feb 2019 10:49:55 +0000 (11:49 +0100)
committerPeter Korsgaard <peter@korsgaard.com>
Tue, 5 Feb 2019 12:40:10 +0000 (13:40 +0100)
Mender needs /var/lib/mender to be writable at the service start, the
path is hardcoded and thus we cannot change it.
This patch solves the problem using the same approach we have for
dropbear.

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Acked-by: <aduskett@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
package/mender/mender.mk
package/mender/mender.service

index a5cece70447b3c0b00c367f8a473807ad9353c84..3203df8a47a56e5ee1fc1e89ad36853c8225b730 100644 (file)
@@ -49,6 +49,8 @@ define MENDER_INSTALL_CONFIG_FILES
                $(INSTALL) -D -m 0755 $(@D)/support/mender-inventory-$(f) \
                        $(TARGET_DIR)/usr/share/mender/inventory/mender-inventory-$(f)
        )
+
+       ln -snf /var/run/mender $(TARGET_DIR)/var/lib/mender
 endef
 
 MENDER_POST_INSTALL_TARGET_HOOKS += MENDER_INSTALL_CONFIG_FILES
index 9ede55acb5e692887becf4d84805c329ac84466d..8b60a4f1aad0ebaad1dfad72dad65ecd3523fb63 100644 (file)
@@ -6,7 +6,17 @@ After=systemd-resolved.service
 Type=idle
 User=root
 Group=root
-ExecStartPre=/bin/mkdir -p -m 0700 /data/mender
+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