diff options
| author | Jon duSaint | 2026-02-23 21:50:04 -0800 |
|---|---|---|
| committer | Jon duSaint | 2026-02-23 21:50:04 -0800 |
| commit | ddd36cb3ae690a0b37e2653bac2acaf8b53af336 (patch) | |
| tree | e0997a8c1c86ede26231c34c063df21fc0dc4c4e | |
| parent | deff9f834414a25b01159420587c8731efe1b203 (diff) | |
mqtt-esp5100: service files
| -rw-r--r-- | Makefile | 20 | ||||
| -rw-r--r-- | mqtt-esp5100-conf.d | 5 | ||||
| -rwxr-xr-x | mqtt-esp5100-init.d | 19 |
3 files changed, 40 insertions, 4 deletions
@@ -1,8 +1,13 @@ CFLAGS = -Wall -.PHONY: all install-mqtt-publish clean -all: mqtt-publish -install: install-mqtt-publish +.PHONY: help install-mqtt-publish clean +help: + @echo valid targets are + @echo " mqtt-publish" + @echo " mqtt-esp5100" + +#all: mqtt-publish +#install: install-mqtt-publish mqtt-publish: mqtt-publish.c $(CC) $(CFLAGS) -o $@ $^ -lmosquitto -li2c @@ -11,5 +16,12 @@ install-mqtt-publish: mqtt-publish mqtt-publish-init.d mqtt-publish-conf.d install -D -m 0755 mqtt-publish-init.d /etc/init.d/mqtt-publish install -D -m 0644 mqtt-publish-conf.d /etc/conf.d/mqtt-publish +mqtt-esp5100: mqtt-esp5100.c + $(CC) $(CFLAGS) -o $@ $^ -lmosquitto +install-mqtt-esp5100: mqtt-esp5100 mqtt-esp5100-init.d mqtt-esp5100-conf.d + install -D -m 0755 mqtt-esp5100 /usr/local/bin/mqtt-esp5100 + install -D -m 0755 mqtt-esp5100-init.d /etc/init.d/mqtt-esp5100 + install -D -m 0644 mqtt-esp5100-conf.d /etc/conf.d/mqtt-esp5100 + clean: - rm -f mqtt-publish + rm -f mqtt-publish mqtt-esp5100 diff --git a/mqtt-esp5100-conf.d b/mqtt-esp5100-conf.d new file mode 100644 index 0000000..c806bb8 --- /dev/null +++ b/mqtt-esp5100-conf.d @@ -0,0 +1,5 @@ +PIDFILE=/var/run/mqtt-esp5100.pid +SECRET_FILE=/etc/mqtt-esp5100.secret +HOSTNAME=192.168.1.15 + +ARGS="--pidfile $PIDFILE --secret $SECRET_FILE --hostname $HOSTNAME" diff --git a/mqtt-esp5100-init.d b/mqtt-esp5100-init.d new file mode 100755 index 0000000..ea3804a --- /dev/null +++ b/mqtt-esp5100-init.d @@ -0,0 +1,19 @@ +#!/sbin/openrc-run + +name="MQTT for ESP-5100" +command="/usr/local/bin/${RC_SVCNAME}" +description="MQTT for ESP-5100" +pidfile="/var/run/${RC_SVCNAME}.pid" +command_args="$ARGS" + +depend() { + use logger dns + need net +} + +start_pre() { + if ! ip link show can0 | grep -q UP; then + ip link set can0 up type can bitrate 250000 + ifconfig can0 up + fi +} |
