aboutsummaryrefslogtreecommitdiff
path: root/net/wifi-presence/files
diff options
context:
space:
mode:
authorAdam Williams <pwnfactory@gmail.com>2022-03-19 22:38:24 -0600
committerJonathan McCrohan <jmccrohan@gmail.com>2022-04-05 13:37:55 +0100
commitaabd0da680f8bb20550801d1f53f47e97749e593 (patch)
tree4b9a2f124f26d72579e96a1c5c134371e014eef8 /net/wifi-presence/files
parenta39470c44d2023f87299b41235db113cfa03692f (diff)
wifi-presence: add new package
See https://github.com/awilliams/wifi-presence for details. Signed-off-by: Adam Williams <pwnfactory@gmail.com>
Diffstat (limited to 'net/wifi-presence/files')
-rw-r--r--net/wifi-presence/files/wifi-presence.conf46
-rw-r--r--net/wifi-presence/files/wifi-presence.init66
2 files changed, 112 insertions, 0 deletions
diff --git a/net/wifi-presence/files/wifi-presence.conf b/net/wifi-presence/files/wifi-presence.conf
new file mode 100644
index 000000000..61529e89c
--- /dev/null
+++ b/net/wifi-presence/files/wifi-presence.conf
@@ -0,0 +1,46 @@
+config wifi-presence main
+ ## MQTT broker address. Ex: 'tcp://192.168.1.2:1883'
+ ## Required.
+ option mqttAddr ''
+
+ ## MQTT client ID.
+ ## Defaults to 'wifi-presence.<hostname>'
+ # option mqttID ''
+
+ ## MQTT topic prefix.
+ ## Defaults to 'wifi-presence'
+ # option mqttPrefix 'wifi-presence'
+
+ ## MQTT username and password (optional).
+ # option mqttUsername ''
+ # option mqttPassword ''
+
+ ## Verbose logging output if true.
+ ## Defaults to false.
+ # option verbose 1
+
+ ## Debounce duration (using Go duration syntax). Ex: '5s', '10m', '1s', '0'
+ ## Time until a client is considered disconnected and MQTT disconnect message
+ ## is published.
+ ## Defaults to 10s.
+ # option debounce '10s'
+
+ ## Access Point (AP) name. Included in MQTT topic and message payload.
+ ## Defaults to hostname.
+ # option apName 'my-ap-name'
+
+ ## hostapd control interface sockets.
+ ## Separate multiple sockets using ':'. Ex: '/var/run/hostapd/wlan0:/var/run/hostapd/wlan1'.
+ ## The hostadp configuration file contains the location where these sockets
+ ## will be created.
+ ## Defaults to any Unix socket(s) found in /var/run/hostapd, which is
+ ## the default hostapd directory.
+ # option hostapdSocks ''
+
+ ## Home Assistant options:
+ ## Publish MQTT auto discovery messages for each configured device.
+ ## Default is true.
+ # option hassAutodiscovery 1
+ ## Set the MQTT topic prefix used by Home Assistant.
+ ## Default is 'homeassistant' (also Home Assistant's default value).
+ # option hassPrefix 'homeassistant'
diff --git a/net/wifi-presence/files/wifi-presence.init b/net/wifi-presence/files/wifi-presence.init
new file mode 100644
index 000000000..7e8d26e8a
--- /dev/null
+++ b/net/wifi-presence/files/wifi-presence.init
@@ -0,0 +1,66 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+
+START=95
+# stops before networking stops
+STOP=89
+
+PROG=/usr/bin/wifi-presence
+CONF=wifi-presence
+
+start_service() {
+ # Load config.
+ config_load "${CONF}"
+
+ local apName
+ local debounce
+ local hassAutodiscovery
+ local hassPrefix
+ local hostapdSocks
+ local mqttAddr
+ local mqttID
+ local mqttUsername
+ local mqttPassword
+ local mqttPrefix
+ local sockDir
+ local verbose
+
+ config_get apName main apName
+ config_get debounce main debounce
+ config_get hassAutodiscovery main hassAutodiscovery
+ config_get hassPrefix main hassPrefix
+ config_get hostapdSocks main hostapdSocks
+ config_get mqttAddr main mqttAddr
+ config_get mqttID main mqttId
+ config_get mqttUsername main mqttUsername
+ config_get mqttPassword main mqttPassword
+ config_get mqttPrefix main mqttPrefix
+ config_get sockDir main sockDir
+ config_get_bool verbose main verbose
+
+ procd_open_instance
+
+ procd_set_param command ${PROG}
+ [ -n "${apName}" ] && procd_append_param command "-apName=${apName}"
+ [ -n "${debounce}" ] && procd_append_param command "-debounce=${debounce}"
+ [ -n "${hassAutodiscovery}" ] && procd_append_param command "-hass.autodiscovery=${hassAutodiscovery}"
+ [ -n "${hassPrefix}" ] && procd_append_param command "-hass.prefix=${hassPrefix}"
+ [ -n "${hostapdSocks}" ] && procd_append_param command "-hostapd.socks=${hostapdSocks}"
+ [ -n "${mqttAddr}" ] && procd_append_param command "-mqtt.addr=${mqttAddr}"
+ [ -n "${mqttID}" ] && procd_append_param command "-mqtt.id=${mqttID}"
+ [ -n "${mqttUsername}" ] && procd_append_param command "-mqtt.username=${mqttUsername}"
+ [ -n "${mqttPassword}" ] && procd_append_param command "-mqtt.password=${mqttPassword}"
+ [ -n "${mqttPrefix}" ] && procd_append_param command "-mqtt.prefix=${mqttPrefix}"
+ [ -n "${sockDir}" ] && procd_append_param command "-sockDir=${sockDir}"
+ [ -n "${verbose}" ] && procd_append_param command "-verbose=${verbose}"
+
+ procd_set_param file "/etc/config/${CONF}"
+ procd_set_param stdout 1
+ procd_set_param stderr 1
+
+ # Restart every 5 seconds, indefinitely.
+ procd_set_param respawn 0 5 0
+
+ procd_close_instance
+}