[ltp] tpctl 2.1, mwavem

Thomas Hood linux-thinkpad@www.bm-soft.com
Sun, 04 Feb 2001 21:52:56 -0500


This is a multi-part message in MIME format.
--------------43FC28FF0D0E84E75DFEC3FE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

tpctl 2.1 has been released.  It supports Linux kernel 2.4.x only.
This release has a new feature: it can power the serial port on
and off.  Unfortunately, enabling this feature still requires a
kernel patch.  Please let me know if there are any bugs.  Get it via: 
   http://tpctl.sourceforge.net/tpctlhome.htm

Also note that my Mwave/ACP modem support scripts for Debian have
been improved slightly.  Get the latest versions via: 
   http://panopticon.csustan.edu/thood/tp600lnx.htm

My site also has a link to a version of the mwavedd.o module
that will link with a 2.4.1 Linux kernel.

Thomas
--------------43FC28FF0D0E84E75DFEC3FE
Content-Type: text/plain; charset=us-ascii;
 name="modutils_mwavem"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="modutils_mwavem"

alias char-major-96 mwavedd




--------------43FC28FF0D0E84E75DFEC3FE
Content-Type: text/plain; charset=us-ascii;
 name="init.d_mwavem"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="init.d_mwavem"

#!/bin/sh

PIDFILE=/var/run/mwavemd.pid
MWAVEM="/usr/local/bin/mwavem"
DEV="/dev/ttyS1"

case "$1" in
start)
	echo -n "Starting Mwave modem: "
	start-stop-daemon --start --startas /usr/sbin/mwavemd --background --pidfile $PIDFILE -- $MWAVEM $DEV
	[ $? -ne 0 ] && exit 1
	# Wait for pidfile to be created, indicating that the daemon is ready
	for w in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 timeout; do
		if [ "$w" = "timeout" ]; then
			echo "(timed out)."
			exit 1
		fi
		if [ -f $PIDFILE ]; then
			echo "(daemon:) mwavemd."
			exit 0
		fi
		sleep 1
	done
	exit 2   # We shouldn't reach here
	;;
stop)
	echo -n "Stopping Mwave modem: "
	( start-stop-daemon --stop --quiet --pidfile $PIDFILE && echo -n "(daemon:) mwavemd " ) || ( start-stop-daemon --stop --quiet --exec $MWAVEM && echo -n "(process:) mwavem " ) || echo -n "(no Mwave process running) "
	rm -f $PIDFILE   # in case it was left behind by some murdered mwavemd
	lsmod | grep -q -s '^mwavedd' > /dev/null 2>&1
	if [ $? -ne 0 ]; then # module not present
		echo "(and module not loaded)."
		exit 0
	fi
	# Module present.
	# Try to remove it.
	for w in 1 2 3 4 giveup; do
		if [ "$w" = "giveup" ]; then
			echo "(could not remove module mwavedd)."
			exit 1
		fi
		rmmod mwavedd >> /dev/null 2>&1
		if [ $? -eq 0 ]; then
			echo "(module:) mwavedd."
			exit 0
		fi
		sleep 1
	done
	exit 2   # We shouldn't reach here
	;;
restart)
	$0 stop && $0 start
	;;
esac



--------------43FC28FF0D0E84E75DFEC3FE
Content-Type: text/plain; charset=us-ascii;
 name="event.d_mwavem"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="event.d_mwavem"

#!/bin/sh

case "$1" in
suspend)
	/etc/init.d/mwavem stop | logger -t '/etc/apm/event.d/mwavem'
	;;
resume)
	/etc/init.d/mwavem start | logger -t '/etc/apm/event.d/mwavem'
	;;
esac



--------------43FC28FF0D0E84E75DFEC3FE
Content-Type: text/plain; charset=us-ascii;
 name="mwavemd"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="mwavemd"

#!/bin/sh
# /usr/sbin/mwavemd
# This script runs the Mwave modem support program and configures the serial
# port driver for the Mwave modem serial interface; then it creates a process
# i.d. file under /var/run.  Having done this it waits for a signal. 
# When it receives a SIGTERM, it deletes its process i.d. file, kills the
# modem support process and exits once the latter is dead.

if [ "$2" = "" ]; then
	echo "mwavemd: Requires two arguments"
	exit 1
fi

# The Mwave support daemon executable
MWAVEM=$1

# The serial device used to access the Mwave modem
DEV=$2

# Delete any old pidfile
rm -f /var/run/mwavemd.pid

trap 'logger -t mwavemd "Passing SIGTERM to modem support process ..." ; killall -v $MWAVEM 2>&1 | logger -t mwavemd ; trap - 15' 15

# Note that creation of the pidfile is the signal that the modem is ready to use
logger -t mwavemd 'Starting modem support process ...'
$MWAVEM | awk -W interactive '/STARTED/ { print ; print "... started. Now setserial'"'"'ing '"$DEV".'" ; system("setserial '"$DEV"' autoconfig") ; system("echo '"$$"' >| /var/run/mwavemd.pid") ; exit } { print }' | logger -t mwavemd &

# Wait for our child, the Mwave modem support process, to complete.
# This wait will be interrupted by a SIGTERM signal, which will cause
# the trap command set above to be executed.  The bash man page currently
# (Dec 2000) says that the wait will "return" when such a signal is received;
# but what actually happens is that the wait resumes.  That is why the trap
# command has to kill the child processes---otherwise we will wait forever.
wait

# In case the man page is (or becomes) right and the wait above "returns"
# on receipt of a singal, let us wait again for the death of our children.
wait

# Deletion of the pidfile indicates that the killing is complete
rm -f /var/run/mwavemd.pid

exit 0



--------------43FC28FF0D0E84E75DFEC3FE--


----- The Linux ThinkPad mailing list -----
The linux-thinkpad mailing list home page is at:
http://www.bm-soft.com/~bm/tp_mailing.html