aboutsummaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2022-03-24 13:10:09 +0100
committerAleksander Morgado <aleksander@aleksander.es>2022-04-05 08:14:53 +0000
commit7960b365d50c2a9e687a75b46f044e8e52b72b65 (patch)
treefe50e2c04423cfd4eda3518f2cc6dfd5b0b95f25 /data
parent99232154b34e0b8034e84678959454fd9763336e (diff)
data: add example connection dispatcher
Just a minimal example that prints the events in syslog
Diffstat (limited to 'data')
-rw-r--r--data/Makefile.am2
-rw-r--r--data/dispatcher-connection/99-log-event22
-rw-r--r--data/dispatcher-connection/Makefile.am21
-rw-r--r--data/dispatcher-connection/meson.build25
4 files changed, 69 insertions, 1 deletions
diff --git a/data/Makefile.am b/data/Makefile.am
index d7ede2de..12330e27 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,5 @@
-SUBDIRS = . dispatcher-fcc-unlock tests
+SUBDIRS = . dispatcher-connection dispatcher-fcc-unlock tests
edit = @sed \
-e 's|@sbindir[@]|$(sbindir)|g' \
diff --git a/data/dispatcher-connection/99-log-event b/data/dispatcher-connection/99-log-event
new file mode 100644
index 00000000..31188efa
--- /dev/null
+++ b/data/dispatcher-connection/99-log-event
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# SPDX-License-Identifier: CC0-1.0
+# 2022 Aleksander Morgado <aleksander@aleksander.es>
+#
+# Example connection info dispatcher script
+#
+
+# require program name and at least 4 arguments
+[ $# -lt 4 ] && exit 1
+
+MODEM_PATH="$1"
+BEARER_PATH="$2"
+INTERFACE="$3"
+STATE="$4"
+
+MODEM_ID=$(basename ${MODEM_PATH})
+BEARER_ID=$(basename ${BEARER_PATH})
+
+# report in syslog the event
+logger -t "connection-dispatch" "modem${MODEM_ID}: bearer${BEARER_ID}: interface ${INTERFACE} ${STATE}"
+exit $?
diff --git a/data/dispatcher-connection/Makefile.am b/data/dispatcher-connection/Makefile.am
new file mode 100644
index 00000000..3b86e7f3
--- /dev/null
+++ b/data/dispatcher-connection/Makefile.am
@@ -0,0 +1,21 @@
+
+# Directory for user-enabled tools
+connectionuser = $(pkgsysconfdir)/connection.d
+
+# Directory for package-enabled tools
+connectionpackage = $(pkglibdir)/connection.d
+
+# Shipped but disabled FCC unlock tools
+connectionavailabledir = $(pkgdatadir)/connection.available.d
+connectionavailable_SCRIPTS = \
+ 99-log-event \
+ $(NULL)
+
+EXTRA_DIST = $(connectionavailable_SCRIPTS)
+
+install-data-hook:
+ $(MKDIR_P) $(DESTDIR)$(connectionuser); \
+ $(MKDIR_P) $(DESTDIR)$(connectionpackage); \
+ cd $(DESTDIR)$(connectionavailabledir); \
+ chmod go-rwx *; \
+ $(NULL)
diff --git a/data/dispatcher-connection/meson.build b/data/dispatcher-connection/meson.build
new file mode 100644
index 00000000..2e7ef8b4
--- /dev/null
+++ b/data/dispatcher-connection/meson.build
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
+
+# Shipped example connection info dispatcher
+mm_connectiondiravailable = mm_pkgdatadir / 'connection.available.d'
+
+# Directory for user-enabled scripts
+mm_connectiondiruser = mm_pkgsysconfdir / 'connection.d'
+
+# Directory for package-enabled tools
+mm_connectiondirpackage = mm_pkglibdir / 'connection.d'
+
+examples = files(
+ '99-log-event',
+)
+
+install_data(
+ examples,
+ install_mode: 'rwx------',
+ install_dir: mm_connectiondiravailable,
+)
+
+mkdir_cmd = 'mkdir -p ${DESTDIR}@0@'
+meson.add_install_script('sh', '-c', mkdir_cmd.format(mm_prefix / mm_connectiondiruser))
+meson.add_install_script('sh', '-c', mkdir_cmd.format(mm_prefix / mm_connectiondirpackage))