diff options
author | Alan Hicks <alan@lizella.net> | 2010-05-11 20:01:10 +0200 |
---|---|---|
committer | Robby Workman <rworkman@slackbuilds.org> | 2010-05-11 20:01:10 +0200 |
commit | bfa15f6fd3fe9670e5e0600f181c5a792c9d5443 (patch) | |
tree | 051f3a90da93baef409f47f61b5dfeefc85b273d /misc/zaptel | |
parent | aeaff03f0e132d1b3d97f68ec5e79d130c932170 (diff) | |
download | slackbuilds-bfa15f6fd3fe9670e5e0600f181c5a792c9d5443.tar.gz |
misc/zaptel: Added to 12.0 repository
Diffstat (limited to 'misc/zaptel')
-rw-r--r-- | misc/zaptel/README | 43 | ||||
-rw-r--r-- | misc/zaptel/doinst.sh | 27 | ||||
-rw-r--r-- | misc/zaptel/rc.zaptel | 209 | ||||
-rw-r--r-- | misc/zaptel/slack-desc | 19 | ||||
-rw-r--r-- | misc/zaptel/zaptel.SlackBuild | 84 | ||||
-rw-r--r-- | misc/zaptel/zaptel.info | 8 |
6 files changed, 390 insertions, 0 deletions
diff --git a/misc/zaptel/README b/misc/zaptel/README new file mode 100644 index 0000000000..8a4a745bf1 --- /dev/null +++ b/misc/zaptel/README @@ -0,0 +1,43 @@ +The zaptel drivers and binaries are needed to use popular digital and +analogue telephony equipment and are typically installed alongside the +asterisk PBX (although these are not required for asterisk if you are +not using any hardware to interface with the POTS/PSTN system). Note +that if you change your kernel after installing zaptel, you'll have to +re-compile zaptel (a simple re-install will not suffice). + +The rc script included will handle loading and unloading kernel modules +for you. By default, it will attempt to load the wctdm module for the +common Digium cards, and if this fails, will load ztdummy to give you +a timing device. Simply edit the MODULES variable at the top of the +rc script to load other modules if your hardware requires it. These +modules should *not* be loaded in rc.local or rc.modules, but rather +here, as starting and stopping rc.zaptel will cause these modules to +re-read their config file if you make any changes. + +Users outside of North America may find that they need to edit the +zconfig.h file to specify their region's tones. This script does not +handle that at present. The statement you'll wish to change is: + #define DEFAULT_TONE_ZONE=0 + +The Asterisk Handbook First Edition lists the following zones: + 0 - North America + 1 - Australia + 2 - France + 7 - Japan + 14 - Taiwan +There are many others. Consult your documentation, or google. + +To start zaptel at system boot, do the following: + # chmod +x /etc/rc.d/rc.zaptel + +Also, you'll need to add a statement such as the following to rc.local: + if [ -x /etc/rc.d/rc.zaptel ]; then + /etc/rc.d/rc.zaptel start + fi + +rc.zaptel will create a lockfile that is removed when the service is +stopped using this script. Thus, you should probably put this in +rc.local_shutdown: + if [ -x /etc/rc.d/rc.zaptel ]; then + /etc/rc.d/rc.zaptel stop + fi diff --git a/misc/zaptel/doinst.sh b/misc/zaptel/doinst.sh new file mode 100644 index 0000000000..c3cebabe6b --- /dev/null +++ b/misc/zaptel/doinst.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +# Keep same perms on rc.zaptel.new: +if [ -e etc/rc.d/rc.zaptel ]; then + cp -a etc/rc.d/rc.zaptel etc/rc.d/rc.zaptel.new.incoming + cat etc/rc.d/rc.zaptel.new > etc/rc.d/rc.zaptel.new.incoming + mv etc/rc.d/rc.zaptel.new.incoming etc/rc.d/rc.zaptel.new +fi + +config etc/rc.d/rc.zaptel.new +config etc/zaptel.conf.new + +# Since we're creating kernel modules, this is necessary +chroot . depmod -a 2>/dev/null + diff --git a/misc/zaptel/rc.zaptel b/misc/zaptel/rc.zaptel new file mode 100644 index 0000000000..1ab703e7ab --- /dev/null +++ b/misc/zaptel/rc.zaptel @@ -0,0 +1,209 @@ +#!/bin/sh +# +# This shell script takes care of loading and unloading +# Zapata Telephony interfaces +# +# This script is a heavily modified version of zaptel.init found +# in the zaptel source archive and thus is covered under the GNU +# General Public License version 2. +# +# Some parts Copyright 2007, Alan Hicks, Lizella, GA +# + +# What modules should we try to load on 'start'? By default, we'll +# attempt to load the driver for the popular Digium WildCat cards. If +# this fails or no modules are specified, the ztdummy module will be +# automatically loaded to provide a timing mechanism in the kernel. +# If you need some other modules loaded, seperate them with spaces. +# MODULES="foo bar" +MODULES="wctdm" + +ZTCFG_CMD=/sbin/ztcfg +FXOTUNE=/sbin/fxotune +LOCKFILE=/var/lock/subsys/zaptel + +# The default syncer Astribank. Usually set automatically to a sane +# value by xpp_sync(1) if you have an Astribank. You can set this to an +# explicit Astribank (e.g: 01). +XPP_SYNC=auto + +# The maximal timeout (seconds) to wait for udevd to finish generating +# device nodes after the modules have loaded and before running ztcfg. +ZAP_DEV_TIMEOUT=20 + +##################################################################### +## ## +## NOTHING BELOW HERE SHOULD NEED TO BE CHANGED ## +## ## +##################################################################### + +# recursively unload a module and its dependencies, if possible. +# For some reason, modprobe can't seem to remove these modules +# on its own, so we kludge this here. +# inputs: module to unload. +# returns: the result from +unload_module() { + module="$1" + line=$(lsmod 2>/dev/null | grep "^$1 ") + if [ "$line" = '' ]; then return; fi # module was not loaded + + set -- $line + # $1: the original module, $2: size, $3: refcount, $4: deps list + mods=$(echo $4 | tr , ' ') + # xpp_usb keeps the xpds below busy if an xpp hardware is + # connected. Hence must be removed before them: + case "$module" in xpd_*) mods="xpp_usb $mods";; esac + for mod in $mods; do + # run in a subshell, so it won't step over our vars: + (unload_module $mod) + # TODO: the following is probably the error handling we want: + # if [ $? != 0 ]; then return 1; fi + done + rmmod $module +} + +# I have not tested this function in the least, so I cannot say if it +# works properly with Slackware or not. If you can, please test this +# and report back any problems or successes you may have so we can fix +# this in the SlackBuild script. With that said, I don't see any reason +# why this function would not work. +# -- Alan Hicks +hpec_start() { + # HPEC license found + if ! echo /var/lib/digium/licenses/HPEC-*.lic | grep -v '\*' | grep -q .; then + return + fi + + # zaphpec_enable not installed in /usr/sbin + if [ ! -f /usr/sbin/zaphpec_enable ]; then + echo -n "Running zaphpec_enable: Failed" + echo -n "." + echo " The zaphpec_enable binary is not installed in /usr/sbin." + return + fi + + # zaphpec_enable not set executable + if [ ! -x /usr/sbin/zaphpec_enable ]; then + echo -n "Running zaphpec_enable: Failed" + echo -n "." + echo " /usr/sbin/zaphpec_enable is not set as executable." + return + fi + + # zaphpec_enable properly installed + action "Running zaphpec_enable: " /usr/sbin/zaphpec_enable + if [ $? = 0 ]; then + echo -n "done" + echo "." + else + echo -n "Failed" + echo -n "." + echo " This can be caused if you had already run zaphpec_enable, or if your HPEC license is no longer valid." + fi +} + + +# Check that telephony is up. +#[ "${TELEPHONY}" = "yes" ] || exit 0 + +if [ ! -f /etc/zaptel.conf ]; then + echo "Could not find /etc/zaptel.conf! Abandon ship!" + exit 1 +fi + +if [ "${DEBUG}" = "yes" ]; then + ARGS="debug=1" +fi + +RETVAL=0 + +# See how we were called. +case "$1" in + start) + # Load drivers + rmmod wcusb 2> /dev/null + rmmod wcfxsusb 2> /dev/null + rmmod audio 2> /dev/null + + echo "Loading zaptel framework: " + modprobe zaptel ${ARGS} + + echo -n "Waiting for zap to come online..." + TMOUT=$ZAP_DEV_TIMEOUT # max secs to wait + while [ ! -d /dev/zap ] ; do + echo -n "$TMOUT " + sleep 1 + TMOUT=$(expr $TMOUT - 1) + if [ $TMOUT -eq 0 ] ; then + echo " " # line break + echo "Error: missing /dev/zap!" + exit 1 + fi + done + echo "OK" + echo -n "Loading zaptel hardware modules:" + for x in $MODULES; do + if modprobe ${x} ${ARGS} 2> /dev/null; then + echo "Loaded module: ${x}." + fi + done + sleep 3 # TODO: remove it + + if [ ! -e /proc/zaptel/1 ]; then + echo "No functioning zap hardware found in /proc/zaptel, loading ztdummy" + modprobe ztdummy 2> /dev/null + fi + + echo "Running ztcfg: " + $ZTCFG_CMD 2> /dev/null + RETVAL=$? + + if [ $RETVAL -eq 0 ]; then + touch $LOCKFILE + else + echo "Something went wrong. Try running ztcfg -vvv." + fi + + # This is allowed to fail (or not even run). These files may not + # be present, and aren't required for Asterisk. + if [ -x "$FXOTUNE" ] && [ -r /etc/fxotune.conf ]; then + $FXOTUNE -s || : + fi + + hpec_start + ;; + stop) + # Unload drivers + echo -n "Unloading zaptel hardware drivers:" + unload_module zaptel + RETVAL=$? + echo "." + + [ $RETVAL -eq 0 ] && rm -f $LOCKFILE + ;; + unload) + # We don't have zaptel helper, so let's not replicate too much code: + # allow others to use the unload command. + unload_module zaptel + ;; + restart) + $0 stop + $0 start + ;; + reload) + echo "Reloading ztcfg: " + if $ZTCFG_CMD 2> /dev/null; then + echo -n "done" + RETVAL=0 + else + echo "ztcfg failed. Are your modules loaded?" + RETVAL=1 + fi + ;; + *) + echo "Usage: zaptel {start|stop|restart|reload}" + exit 1 +esac + +exit $RETVAL + diff --git a/misc/zaptel/slack-desc b/misc/zaptel/slack-desc new file mode 100644 index 0000000000..d40f9842a2 --- /dev/null +++ b/misc/zaptel/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':'. + + |-----handy-ruler-----------------------------------------------------| +zaptel: Zaptel (zaptel drivers) +zaptel: +zaptel: The zaptel drivers enable userland applications to interface with +zaptel: certain digital and analogue devices, primarily of use with the +zaptel: Asterisk PBX (Private Branch Exchange). +zaptel: +zaptel: +zaptel: +zaptel: +zaptel: +zaptel: diff --git a/misc/zaptel/zaptel.SlackBuild b/misc/zaptel/zaptel.SlackBuild new file mode 100644 index 0000000000..7c0b3bb5ca --- /dev/null +++ b/misc/zaptel/zaptel.SlackBuild @@ -0,0 +1,84 @@ +#!/bin/bash +# Copyright 2006, Alan Hicks, Lizella, GA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Modified by Robby Workman <rworkman@slackbuilds.org> with a few things +# related to udev rules and such + +set -e + +PRGNAM="zaptel" +VERSION="1.4.6" +ARCH=${ARCH:-i486} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG="$TMP/package-$PRGNAM" +OUTPUT=${OUTPUT:-/tmp} + +rm -rf $PKG $TMP/$PRGNAM-$VERSION +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +tar xvf $CWD/$PRGNAM-$VERSION.tar.gz +cd $PRGNAM-$VERSION +chown -R root:root . +chmod -R a-s,u+w,go+r-w . + +# There's no ./configure script here. "make" has to be run once to +# configure the system and even when everything is ok, make will +# exit with a non-zero status the first time. We have to kludge this +# so the script doesn't bail when called with "set -e". +make || true +make +make install DESTDIR=$PKG + +( cd $PKG + find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null + find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null +) + +mkdir -p $PKG/install $PKG/usr/doc/$PRGNAM-$VERSION $PKG/etc/rc.d +cp -a ChangeLog LICENSE README* $PKG/usr/doc/$PRGNAM-$VERSION/ +cat $CWD/zaptel.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/zaptel.SlackBuild +find $PKG/usr/doc -type f -exec chmod 0644 {} \; +chown -R root:root $PKG/usr/doc + +# Fix up the manpages +mv $PKG/usr/share/man $PKG/usr/man +gzip -9 $PKG/usr/man/man?/*.? + +# Don't clobber config file and init script +mv $PKG/etc/zaptel.conf $PKG/etc/zaptel.conf.new +install -m 0755 $CWD/rc.zaptel $PKG/etc/rc.d/rc.zaptel.new + +# udev handles device node creation +rm -fr $PKG/dev +# hotplug is dead +rm -rf $PKG/etc/hotplug +# rename udev rules file +mv $PKG/etc/udev/rules.d/xpp.rules $PKG/etc/udev/rules.d/96-xpp.rules + +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz diff --git a/misc/zaptel/zaptel.info b/misc/zaptel/zaptel.info new file mode 100644 index 0000000000..2e3b180b04 --- /dev/null +++ b/misc/zaptel/zaptel.info @@ -0,0 +1,8 @@ +PRGNAM="zaptel" +VERSION="1.4.6" +HOMEPAGE="http://www.digium.com" +DOWNLOAD="http://downloads.digium.com/pub/zaptel/releases/zaptel-1.4.6.tar.gz" +MD5SUM="f0cf2e89028235c3dc447810e5089dbb" +MAINTAINER="Alan Hicks" +EMAIL="alan@lizella.net" +APPROVED="rworkman" |