docker-apps/mosquitto/mosquitto_jm.txt

87 lines
2.9 KiB
Plaintext

# https://cedalo.com/blog/mosquitto-docker-configuration-ultimate-guide/
Create user and group
---------------------
Credentials -> Local Users -> Add
Full Name: mosquitto
Username: mosquitt
Disable Password: <select>
Email: stuurmcp@telkomsa.net
UID: (note)
Create New Primary Group: <unselect>
Primary Group: mosquitt
Create Home Directory: <uncheck>
Samba Authentication: <uncheck>
Save
mosquitt UID: 3047
mosquitt GID: 3046
Create datasets
---------------
# In Truenas shell:
# list datasets
zfs list | grep -i "docker.*mosquitto"
# create following datasets if not present
zfs create SSD1/docker/data/mosquitto
zfs create SSD1/docker/data/mosquitto/appdata
zfs create SSD1/docker/data/mosquitto/config
zfs create SSD1/docker/data/mosquitto/logs
# create the following dataset if you want the default folder for password.txt to be mapped outside the container
zfs create SSD1/docker/data/mosquitto/configinc
chown -R mosquitt:mosquitt /mnt/SSD1/docker/data/mosquitto
Create folder
-------------
# In Truenas shell:
mkdir -p /mnt/SSD1/docker/stacks/mosquitto
Copy folder to docker stacks
----------------------------
# In Windows cmd shell in mosquitto folder, enter:
./cp2nas
# or
pscp -P 22 -r stacks/*.* root@192.168.2.2:/mnt/SSD1/docker/stacks/mosquitto/
# This should copy mosquitto stacks folder to /mnt/SSD1/docker/stacks/mosquitto
Migrating data
--------------
# example mosquitto.conf:
# https://github.com/eclipse/mosquitto/blob/master/mosquitto.conf
# since config file was not persisted outside container, we will have to copy it from the container
# get fullname of pod:
k3s kubectl get pods -n ix-mosquitto
# select and copy the pod name to clipboard to use it in copy command hereafter
# copy the the config file from the container
k3s kubectl cp -c mosquitto ix-mosquitto/<podname>:/mosquitto/config/mosquitto.conf /mnt/SSD1/docker/data/mosquitto/config/config/mosquitto.conf
# now for the rest of the files:
# Stop mosquitto on truenas, in truenas shell
heavyscript app --stop mosquitto
cp -pr /mnt/stpool1/appdata/mosquitto/* /mnt/SSD1/docker/data/mosquitto/config/data
# if you have mapped the default folder for password.txt to be outside the container
cp -pr /mnt/stpool1/apps/mosquitto/* /mnt/SSD1/docker/data/mosquitto/config/configinc
chown -R mosquitt:mosquitt /mnt/SSD1/docker/data/mosquitto/
chmod -R 700 /mnt/SSD1/docker/data/mosquitto/
Creating mosquitto user
-----------------------
# start mosquitto app with Dockge or issuing "docker compose up -d" in stacks/mosquitto folder
# open shell on mosquitto
docker exec -it mosquitto-mosquitto-1 sh
# enter following line in mosquitto app shell, replacing <username> with the appropriate mosquitto username
mosquitto_passwd -c /mosquitto/config/password.txt <username>
# enter and confirm the password
# exit mosquitto shell
Test mosquitto
--------------
# TODO
Setting up certbot to renew certificate
---------------------------------------
# TODO