From f9cc9c0b639e066e7778ac2543b13a7c5b733d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Marthinsen=20Gi=C3=A6ver?= Date: Tue, 26 Nov 2024 05:54:03 +0100 Subject: [PATCH 1/2] Update launcher.sh Change hard-coded instance name to variable --- snap/local/launcher.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/local/launcher.sh b/snap/local/launcher.sh index bedd7cdf95..9701796432 100755 --- a/snap/local/launcher.sh +++ b/snap/local/launcher.sh @@ -11,7 +11,7 @@ # If a non-root user runs the command, then SNAP_USER_COMMON will be used. case "$SNAP_USER_COMMON" in - */root/snap/mosquitto/common*) COMMON=$SNAP_COMMON ;; + */root/snap/$SNAP_INSTANCE_NAME/common*) COMMON=$SNAP_COMMON ;; *) COMMON=$SNAP_USER_COMMON ;; esac From 04f82b2685bb96db3bb1b8ea94ae898e92bc6c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Marthinsen=20Gi=C3=A6ver?= Date: Tue, 26 Nov 2024 07:32:00 +0100 Subject: [PATCH 2/2] Update launcher.sh More general fix, taking the user into account. --- snap/local/launcher.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snap/local/launcher.sh b/snap/local/launcher.sh index 9701796432..5cc93fd3d5 100755 --- a/snap/local/launcher.sh +++ b/snap/local/launcher.sh @@ -10,9 +10,9 @@ # that mosquitto is being run as a system daemon, and SNAP_COMMON will be used. # If a non-root user runs the command, then SNAP_USER_COMMON will be used. -case "$SNAP_USER_COMMON" in - */root/snap/$SNAP_INSTANCE_NAME/common*) COMMON=$SNAP_COMMON ;; - *) COMMON=$SNAP_USER_COMMON ;; +case "$SNAP_UID" in + 0) COMMON="$(sed -E "s#/$SNAP_NAME/#/${SNAP_INSTANCE_NAME}/#" <<< $SNAP_COMMON)";; + *) COMMON="$(sed -E "s#/$SNAP_NAME/#/${SNAP_INSTANCE_NAME}/#" <<< $SNAP_USER_COMMON)";; esac CONFIG_FILE="$SNAP/default_config.conf"