Jared K. Smith d22517c
[Unit]
Jared K. Smith d22517c
Description=The DAHDI drivers allow you to use your linux computer to accept incoming data and voice interfaces
Jared K. Smith d22517c
After=local-fs.target
Jared K. Smith d22517c
Jared K. Smith d22517c
[Service]
Jared K. Smith d22517c
Type=oneshot
Jared K. Smith d22517c
RemainAfterExit=yes
Jared K. Smith d22517c
Jared K. Smith d22517c
Environment=DAHDI_MODULES_FILE=/etc/dahdi/modules
Jared K. Smith d22517c
Environment=DAHDI_CFG_CMD=/usr/sbin/dahdi_cfg
Jared K. Smith d22517c
Environment=XPP_SYNC=auto
Jared K. Smith d22517c
EnvironmentFile=-/etc/dahdi/init.conf
Jared K. Smith d22517c
Jared K. Smith d22517c
ExecStartPre=/usr/bin/test -f ${DAHDI_MODULES_FILE}
Jared K. Smith d22517c
ExecStartPre=/usr/bin/test -x ${DAHDI_CFG_CMD}
Jared K. Smith d22517c
ExecStartPre=/usr/sbin/modprobe dahdi
Jared K. Smith d22517c
# Note:  Some of the commands in the following script are fatal, others are not.
Jared K. Smith d22517c
ExecStart=/bin/sh -c '\
Jared K. Smith d22517c
	/usr/bin/sed -e "s/#.*//" ${DAHDI_MODULES_FILE} | xargs -r -n1 /usr/sbin/modprobe ;\
Jared K. Smith d22517c
	if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = "yes" ]; then \
Jared K. Smith d22517c
		aas_param="/sys/module/dahdi/parameters/auto_assign_spans" ;\
Jared K. Smith d22517c
		aas=$(cat "$aas_param" 2>/dev/null) ;\
Jared K. Smith d22517c
		if [ "$aas" -ge 0 ]; then \
Jared K. Smith d22517c
			/usr/share/dahdi/waitfor_xpds || exit 1 ;\
Jared K. Smith d22517c
		fi ;\
Jared K. Smith d22517c
	fi ;\
Jared K. Smith d22517c
	/usr/share/dahdi/dahdi_auto_assign_compat ;\
Jared K. Smith d22517c
	$DAHDI_CFG_CMD || exit 1 ;\
Jared K. Smith d22517c
	[ -x /usr/sbin/fxotune ] && [ -r /etc/fxotune.conf ] && /usr/sbin/fxotune -s ;\
Jared K. Smith d22517c
	[ -e /sys/bus/astribanks ] && LC_ALL=C /usr/sbin/xpp_sync "$XPP_SYNC" ;\
Jared K. Smith d22517c
	if echo /var/lib/digium/licenses/HPEC-*.lic | grep -v "\*" | grep -q .; then \
Jared K. Smith d22517c
		if [ ! -x /usr/sbin/dahdihpec_enable ]; then \
Jared K. Smith d22517c
			echo "The dahdihpec_enable binary is not installed" ;\
Jared K. Smith d22517c
			exit 1 ;\
Jared K. Smith d22517c
		fi ;\
Jared K. Smith d22517c
		/usr/sbin/dahdihpec_enable || exit 1 ;\
Jared K. Smith d22517c
	fi ;\
Jared K. Smith d22517c
	echo Done ;\
Jared K. Smith d22517c
'
Jared K. Smith d22517c
Jared K. Smith d22517c
ExecStop=/bin/sh -c '/usr/sbin/modprobe -r $(/usr/bin/sed -e "s/#.*//" ${DAHDI_MODULES_FILE}) ${DAHDI_UNLOAD_MODULES}'
Jared K. Smith d22517c
Jared K. Smith d22517c
[Install]
Jared K. Smith d22517c
WantedBy=multi-user.target