mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-20 23:03:55 +08:00
Add a launcher script to use a config file from a user writeable
area in the home directory. It will also copy the example config in to the same location so that people can use it as a reference.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
port 1883
|
||||
persistence false
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# Wrapper to check for custom config in $SNAP_USER_COMMON and use it
|
||||
# otherwise fall back to the included basic config which will at least
|
||||
# allow mosquitto to run and do something.
|
||||
# This script will also copy the full example config in to SNAP_USER_COMMON
|
||||
# so that people can refer to it.
|
||||
|
||||
CONFIG_FILE="$SNAP/default_config.conf"
|
||||
CUSTOM_CONFIG="$SNAP_USER_COMMON/mosquitto.conf"
|
||||
|
||||
|
||||
# Copy the example config if it doesn't exist
|
||||
if [ ! -e "$SNAP_USER_COMMON/mosquitto_example.conf" ]
|
||||
then
|
||||
echo "Copying example config to $SNAP_USER_COMMON/mosquitto_example.conf"
|
||||
echo "You can create a custom config by creating a file called $CUSTOM_CONFIG"
|
||||
cp $SNAP/mosquitto.conf $SNAP_USER_COMMON/mosquitto_example.conf
|
||||
fi
|
||||
|
||||
|
||||
# Does the custom config exist? If so use it.
|
||||
if [ -e "$CUSTOM_CONFIG" ]
|
||||
then
|
||||
echo "Found config in $CUSTOM_CONFIG"
|
||||
CONFIG_FILE=$CUSTOM_CONFIG
|
||||
else
|
||||
echo "Using default config from $CONFIG_FILE"
|
||||
fi
|
||||
|
||||
# Launch the snap
|
||||
$SNAP/usr/local/sbin/mosquitto -c $CONFIG_FILE $@
|
||||
@@ -1,3 +0,0 @@
|
||||
port 1883
|
||||
persistence true
|
||||
user root
|
||||
+14
-7
@@ -9,10 +9,11 @@ description: This is a message broker that supports version 3.1 and 3.1.1 of the
|
||||
where a sensor or other simple device may be implemented using an arduino for
|
||||
example.
|
||||
confinement: strict
|
||||
grade: stable
|
||||
|
||||
apps:
|
||||
mosquitto:
|
||||
command: usr/local/sbin/mosquitto -c $SNAP/mosquitto.conf
|
||||
command: launcher.sh
|
||||
daemon: simple
|
||||
restart-condition: always
|
||||
plugs: [network, network-bind]
|
||||
@@ -23,7 +24,14 @@ parts:
|
||||
plugin: dump
|
||||
source: snap/
|
||||
prime:
|
||||
- mosquitto.conf
|
||||
- default_config.conf
|
||||
- launcher.sh
|
||||
config:
|
||||
plugin: dump
|
||||
source: .
|
||||
prime:
|
||||
- mosquitto.conf
|
||||
|
||||
|
||||
|
||||
mosquitto:
|
||||
@@ -42,8 +50,7 @@ parts:
|
||||
- libuuid1
|
||||
- libc-ares2
|
||||
prime:
|
||||
- usr/local/sbin/mosquitto
|
||||
- lib/*-linux-gnu/libcrypto.so*
|
||||
- lib/*-linux-gnu/libssl.so*
|
||||
- lib/*-linux-gnu/libuuid.so*
|
||||
|
||||
- usr/local/sbin/mosquitto
|
||||
- lib/*-linux-gnu/libcrypto.so*
|
||||
- lib/*-linux-gnu/libssl.so*
|
||||
- lib/*-linux-gnu/libuuid.so*
|
||||
|
||||
Reference in New Issue
Block a user