diff --git a/src/modules/openmower/filesystem/root/boot/openmower/mqtt/_configuration.example b/src/modules/openmower/filesystem/root/boot/openmower/mqtt/_configuration.example new file mode 100644 index 0000000..1e3eb5a --- /dev/null +++ b/src/modules/openmower/filesystem/root/boot/openmower/mqtt/_configuration.example @@ -0,0 +1,22 @@ +##################################################### +### example config to forward mqtt to another broker +##################################################### +### +### copy this file to another one ending with .conf +### +### to enable/disable the service execute: +### sudo systemctl enable --now openmower-mqtt-bridge +### sudo systemctl disable --now openmower-mqtt-bridge +### + +connection bridge-to-external-broker + +try_private true +cleansession true +topic # out 0 "" openmower/ +topic openmower/# in 0 + +address 192.168.XXX.XXX + +#remote_username user +#remote_password pass diff --git a/src/modules/openmower/filesystem/root/boot/openmower/mqtt/mqtt-bridge.conf b/src/modules/openmower/filesystem/root/boot/openmower/mqtt/mqtt-bridge.conf new file mode 100644 index 0000000..aa8d752 --- /dev/null +++ b/src/modules/openmower/filesystem/root/boot/openmower/mqtt/mqtt-bridge.conf @@ -0,0 +1,11 @@ +connection bridge-to-external-broker + +try_private true +cleansession true +topic # out 0 "" openmower/ +topic # in 0 "" openmower/ + +address 192.168.XXX.XXX + +#remote_username user +#remote_password pass diff --git a/src/modules/openmower/filesystem/root/etc/mosquitto/mosquitto.conf b/src/modules/openmower/filesystem/root/etc/mosquitto/mosquitto.conf new file mode 100644 index 0000000..bb5fc2e --- /dev/null +++ b/src/modules/openmower/filesystem/root/etc/mosquitto/mosquitto.conf @@ -0,0 +1,21 @@ +# A full description of the configuration file is at +# /usr/share/doc/mosquitto/examples/mosquitto.conf.example + +pid_file /run/mosquitto/openmower-mqtt-bridge.pid +log_type notice + +#some random port +listener 18838 + + +#the bridge to the openmower container +connection bridge-to-openmower + +try_private true +cleansession true +topic # out 0 +topic # in 0 +address localhost + +#include the config for the external bridge +include_dir /boot/openmower/mqtt diff --git a/src/modules/openmower/filesystem/root/etc/systemd/system/openmower-mqtt-bridge.service b/src/modules/openmower/filesystem/root/etc/systemd/system/openmower-mqtt-bridge.service new file mode 100644 index 0000000..f9ce029 --- /dev/null +++ b/src/modules/openmower/filesystem/root/etc/systemd/system/openmower-mqtt-bridge.service @@ -0,0 +1,21 @@ +[Unit] +Description=OpenMower MQTT Bridge +Documentation=man:mosquitto.conf(5) man:mosquitto(8) +After=network.target openmower.service openmower-debug.service +Wants=network.target +StartLimitBurst=0 + +[Service] +Type=notify +NotifyAccess=main +ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-failure +RestartSec=10s +ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto +ExecStartPre=/bin/chown mosquitto /var/log/mosquitto +ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto +ExecStartPre=/bin/chown mosquitto /run/mosquitto + +[Install] +WantedBy=multi-user.target diff --git a/src/modules/openmower/start_chroot_script b/src/modules/openmower/start_chroot_script index 356da4f..1096c2c 100644 --- a/src/modules/openmower/start_chroot_script +++ b/src/modules/openmower/start_chroot_script @@ -45,6 +45,10 @@ systemctl disable podman.socket echo_green "Disabling podman auto update..." systemctl disable podman-auto-update.timer podman-auto-update.service +echo_green "Installing mosquitto and masking the normal mosquitto.service..." +apt-get install -y mosquitto +systemctl_if_exists mask mosquitto.service +systemctl disable openmower-mqtt-bridge.service #cleanup