#!/bin/sh # # zaptel This shell script takes care of loading and unloading \ # Zapata Telephony interfaces # chkconfig: 2345 9 92 # description: The zapata telephony drivers allow you to use your linux \ # computer to accept incoming data and voice interfaces # initdir=/etc/init.d # Source function library. . $initdir/functions || exit 0 LOCKFILE=/var/lock/subsys/zaptel # Specify the ethN interface controlling the fonebridge ETHERNET="eth1" MODULES="ztdynamic ztd_ethmf" RMODULES="ztd_ethmf ztdynamic" [ -f /etc/zaptel.conf ] || exit 0 if [ "${DEBUG}" = "yes" ]; then ARGS="debug=1" fi RETVAL=0 # See how we were called. case "$1" in start) # Load drivers action "Loading zaptel framework: " modprobe ztd-ethmf echo -n "Waiting for zap to come online..." /sbin/ifconfig $ETHERNET down TMOUT=10 # max secs to wait while [ ! -d /dev/zap ] ; do sleep 1 TMOUT=`expr $TMOUT - 1` if [ $TMOUT -eq 0 ] ; then echo "Error: missing /dev/zap!" exit 1 fi done echo "OK" echo -n "Loading zaptel/fonebridge hardware modules:" for x in $MODULES; do if modprobe ${x} ${ARGS} >& /dev/null; then echo -n " $x" fi done sleep 5 action "Running ztcfg:" /sbin/ztcfg [ $RETVAL -eq 0 ] && touch $LOCKFILE sleep 3 /sbin/ifconfig $ETHERNET up ;; stop) # Unload drivers echo -n "Unloading zaptel hardware drivers:" /sbin/ifconfig $ETHERNET down /sbin/ztcfg -s for x in $RMODULES; do if rmmod ${x} >& /dev/null; then echo -n " $x" fi done echo "." action "Removing zaptel module: " rmmod zaptel RETVAL=$? [ $RETVAL -eq 0 ] && rm -f $LOCKFILE sleep 3 /sbin/ifconfig $ETHERNET up ;; restart) $0 stop $0 start ;; *) echo "Usage: zaptel {start|stop|restart}" exit 1 esac exit $RETVAL