Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > contrib-release > by-pkgid > bb6675d5350e4c63218e1a24ca6ccec9 > files > 2

dkms-zaptel-1.4.9-1mdv2008.1.x86_64.rpm

#!/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
#
# config: /etc/sysconfig/zaptel

### BEGIN INIT INFO
# Provides: zaqptel
# Shold-Start: dkms
# Default-Start: 3 4 5
# Short-Description: Zaptel kernel module
# Description: The zapata telephony drivers allow you to use your linux
#              computer to accept incoming data and voice interfaces
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions || exit 0

[ -f /etc/sysconfig/zaptel ] && . /etc/sysconfig/zaptel
	LOCKFILE=/var/lock/subsys/zaptel

# Check that telephony is up.
[ "${TELEPHONY}" = "yes" ] || exit 0





[ -f /sbin/ztcfg ] || exit 0
[ -f /etc/zaptel.conf ] || exit 0

if [ "${DEBUG}" = "yes" ]; then
    ARGS="debug=1"
fi

if [ -z "${MODULES}" ]; then 
	# Populate defaults if not present
	MODULES="tor2 wct4xxp wct1xxp wcte11xp wcfxo wctdm wctdm24xxp" 
fi

RMODULES=""
# Reverse list for un-loading; don't change
for x in $MODULES; do 
    RMODULES="$x $RMODULES"
done




RETVAL=0

# See how we were called.
case "$1" in
  start)
	# Load drivers
	rmmod wcusb >& /dev/null
	rmmod wcfxsusb >& /dev/null
	rmmod audio >& /dev/null
	action "Loading zaptel framework: " modprobe zaptel
	gprintf "Waiting for zap to come online..."
	TMOUT=10 # max secs to wait
	while [ ! -d /dev/zap ] ; do
 		sleep 1
		TMOUT=`expr $TMOUT - 1`
		if [ $TMOUT -eq 0 ] ; then
			gprintf "Error: missing /dev/zap!\n"
			exit 1
		fi
	done
	gprintf "OK\n"
	gprintf "Loading zaptel hardware modules:"
	for x in $MODULES; do 
		eval localARGS="\$${x}_ARGS"
		if modprobe ${x} ${ARGS} ${localARGS} >& /dev/null; then
			gprintf " %s" "$x"
		fi
	done
	echo
	sleep 3
	if [ ! -e /proc/zaptel/1 ]; then
		gprintf "No functioning zap hardware found in /proc/zaptel, loading ztdummy\n"
		modprobe ztdummy >& /dev/null
	fi
	    action "Running ztcfg: " /sbin/ztcfg
	RETVAL=$?

	[ $RETVAL -eq 0 ] && touch $LOCKFILE
	;;
  stop)
	# Unload drivers
	gprintf "Unloading zaptel hardware drivers:"
	for x in $RMODULES; do 
		if rmmod ${x} >& /dev/null; then
			gprintf " %s" "$x"
		fi
	done
	gprintf ".\n"

	action "Removing zaptel module: " rmmod zaptel
	RETVAL=$?

	[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
	;;
  restart)
	$0 stop
	$0 start
	RETVAL=$?
	;;
  reload)
	action "Reloading ztcfg: " /sbin/ztcfg
	;;
  status)
	status zaptel
	;;
  *)
	gprintf "Usage: zaptel {start|stop|restart|reload|status}\n"
	exit 1
esac

exit $RETVAL