Skip to content

Commit 293f035

Browse files
committed
Mosquitto service definition - 1 of 2 - master branch
Changes `service.yml` to coalesce **file** volume references to `mosquitto.conf` and `filter.acl` into a single **directory** volume reference to the `services` directory, and to flag the access as read-only. See also extended discussion at [Issue 269](#269). Changes `mosquitto.conf` to: 1. Improve layout, including grouping like controls. 2. Extend comments on password handling. 3. Fix small typo/bug by removing trailing "/" from `persistence_location` path (this was showing up in the Mosquitto log as "//"). Adds checking preamble to `directoryfix.sh` to mitigate two common mistakes: 1. Prevents invocation from `sudo`; and 2. Warns if the working directory does not appear to be called "IOTstack".
1 parent 00f2dd9 commit 293f035

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

.templates/mosquitto/directoryfix.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/bash
22

3+
# should not run as root
4+
[ "$EUID" -eq 0 ] && echo "This script should NOT be run using sudo" && exit -1
5+
6+
# expects to run from IOTstack
7+
[ $(basename "$PWD") = "IOTstack" ] || echo -e \
8+
"Warning: This script expects to be run from ~/IOTstack.\n" \
9+
" The script will continue but may produce unexpected results."
10+
311
[ -d ./volumes/mosquitto ] || sudo mkdir -p ./volumes/mosquitto
412

513
#check user 1883

.templates/mosquitto/mosquitto.conf

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
# required by https://mosquitto.org/documentation/migrating-to-2-0/
2+
#
23
listener 1883
34

5+
# persistence enabled for remembering retain flag across restarts
6+
#
47
persistence true
5-
persistence_location /mosquitto/data/
8+
persistence_location /mosquitto/data
9+
10+
# logging options:
11+
# enable one of the following (stdout = less wear on SD cards but
12+
# logs do not persist across restarts)
613
#log_dest file /mosquitto/log/mosquitto.log
7-
# To avoid flash wearing
814
log_dest stdout
15+
log_timestamp_format %Y-%m-%dT%H:%M:%S
916

10-
# To enable passwords:
11-
# 1. Uncomment "password_file"; and
12-
# 2. Change "allow_anonymous" to "false"
17+
# password handling:
18+
# password_file commented-out allow_anonymous true =
19+
# open access
20+
# password_file commented-out allow_anonymous false =
21+
# no access
22+
# password_file activated allow_anonymous true =
23+
# passwords omitted is permitted but
24+
# passwords provided must match pwfile
25+
# password_file activated allow_anonymous false =
26+
# no access without passwords
27+
# passwords provided must match pwfile
28+
#
1329
#password_file /mosquitto/pwfile/pwfile
1430
allow_anonymous true
1531

16-
#Uncomment to enable filters
32+
# Uncomment to enable filters
1733
#acl_file /mosquitto/config/filter.acl
18-
19-
log_timestamp_format %Y-%m-%dT%H:%M:%S

.templates/mosquitto/service.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ mosquitto:
99
- ./volumes/mosquitto/data:/mosquitto/data
1010
- ./volumes/mosquitto/log:/mosquitto/log
1111
- ./volumes/mosquitto/pwfile:/mosquitto/pwfile
12-
- ./services/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf
13-
- ./services/mosquitto/filter.acl:/mosquitto/config/filter.acl
12+
- ./services/mosquitto:/mosquitto/config:ro
1413
networks:
1514
- iotstack_nw

0 commit comments

Comments
 (0)