dahdi_span_config_hook: automatically register new dahdi channels
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>
Thu, 3 Jul 2014 14:08:02 +0000 (14:08 +0000)
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>
Thu, 3 Jul 2014 14:08:02 +0000 (14:08 +0000)
Install a hook script for DAHDI to register new spans with Asterisk
automatically by running:

  asterisk -rx 'dahdi create channel FIRST LAST'

Review: https://reviewboard.asterisk.org/r/3157/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@417863 65c4cc65-6c06-0410-ace0-fbb531ad65f3

Makefile
contrib/scripts/dahdi_span_config_hook [new file with mode: 0755]

index 09bcb5b..6a51788 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -157,6 +157,8 @@ LINKER_SYMBOL_PREFIX=
 # The file /etc/asterisk.makeopts will also be included but can be overridden
 # by the file in your home directory.
 
+DAHDI_UDEV_HOOK_DIR = /usr/share/dahdi/span_config.d
+
 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
 
@@ -589,6 +591,8 @@ bininstall: _all installdirs $(SUBDIRS_INSTALL) main-bininstall
        if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
                $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin "$(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin"; \
        fi
+       $(INSTALL) -d $(DESTDIR)/$(DAHDI_UDEV_HOOK_DIR)
+       $(INSTALL) -m 644 contrib/scripts/dahdi_span_config_hook $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk
 
 $(SUBDIRS_INSTALL):
        +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
diff --git a/contrib/scripts/dahdi_span_config_hook b/contrib/scripts/dahdi_span_config_hook
new file mode 100755 (executable)
index 0000000..13f3395
--- /dev/null
@@ -0,0 +1,32 @@
+#! /bin/sh
+
+# This script is intended to be called from
+# /usr/share/dahdi/dahdi_span_config, which is is typically called from
+# a udev hook script.
+#
+# Environment is set in
+# http://git.asterisk.org/gitweb/?p=dahdi/tools.git;a=blob;f=hotplug/dahdi_span_config
+
+if [ "$ACTION" != 'add' ]; then
+       # Nothing to do here
+       exit 0
+fi
+
+# Add to asterisk
+asterisk -rx "dahdi create channels $BASECHAN $ENDCHAN"
+#! /bin/sh
+
+# This script is intended to be called from
+# /usr/share/dahdi/dahdi_span_config, which is is typically called from
+# a udev hook script.
+#
+# Environment is set in
+# http://git.asterisk.org/gitweb/?p=dahdi/tools.git;a=blob;f=hotplug/dahdi_span_config
+
+if [ "$ACTION" != 'add' ]; then
+       # Nothing to do here
+       exit 0
+fi
+
+# Add to asterisk
+asterisk -rx "dahdi create channels $BASECHAN $ENDCHAN"