#!/bin/sh # # slmodemd: Starts the SmartLink Modem Daemon # # chkconfig: 345 90 10 # description: This is the user space part of the SmartLink Modem driver # processname: slmodemd # config: /etc/sysconfig/slmodem # # # by Luca Boni, 10/02/2005 # http://www.ok--computer.com # # # NOTE: # If you put '#' at the begin of a line, it becomes a comment and it will be ignored # If you want to re-enable the line, uncomment it removing the '#' # Source function library . /etc/init.d/functions # Some vars that will be used: DON'T change them # if you don't known exactly what you are doing! PROG=slmodemd DAEMON_BIN=/usr/sbin/$PROG CONFIG=/etc/sysconfig/slmodem SLMODEMD_OPTS= RETVAL=0 # Default configuration for Device and Country # If you have a USB modem, replace "slamr" with "slusb" and "slamr0" in "slusb0" # Do "slmodemd --countrylist" from shell for a complete list of country names MODULE=slamr SLMODEMD_DEVICE=slamr0 SLMODEMD_COUNTRY=ITALY # Test daemon binary presence # Maybe you don't need this: comment next 5 line if you wish test -f $DAEMON_BIN || { gprintf "Error: needed \"$DAEMON_BIN\" daemon binary not present.\n" gprintf "Please install SmartLink modem sotware properly and retry.\n" exit -1 } # Test kernel module presence # (do not try to start on a kernel which does not support it) # Maybe you don't need this: comment next 5 lines if you wish grep -q $MODULE\..*o /lib/modules/`uname -r`/modules.dep || { gprintf "Sorry, your kernel doesn't support SmartLink modem driver or it is not installed properly.\n" gprintf "Please go to http://www.smlink.com and download it.\n" exit -1 } # Override default group and permissions if defined in $CONFIG; # other valid options also can be put into SLMODEMD_OPTS variable # Maybe you don't need this: comment next 5 lines if you wish if [ -f $CONFIG ]; then . $CONFIG [ "$GROUP" ] && SLMODEMD_OPTS="$SLMODEMD_OPTS --group=$GROUP" [ "$PERMS" ] && SLMODEMD_OPTS="$SLMODEMD_OPTS --perm=$PERMS" fi start() { # Load kernel module only if it is not loaded yet # Two seconds are required to my system to load it # and create the device /dev/slamr0 (or slusb0) # Starting slmodemd daemon binary before that time # will fail. Test your system to verify if it also # needs this pause, otherwise you can remove it cat /proc/modules | grep $MODULE >/dev/null || { /sbin/modprobe $MODULE || { gprintf "Error loading kernel module \"$MODULE.(k)o\" ... exiting.\n" gprintf "Please reinstall SmartLink modem driver.\n" exit -1 } sleep 2 } # Start modem binary daemon and make necessary symlink # Only modem driver versions > 2.9.7 support "-v" command line option # If you are using an older version, a small error message will appear; # to avoid this, comment next 2 lines and uncomment the thirth one VERSION=`$DAEMON_BIN -v | gawk '{print $5}'` gprintf "Starting SmartLink modem driver version $VERSION for $SLMODEMD_DEVICE: " #gprintf "Starting SmartLink modem driver for $SLMODEMD_DEVICE: " $DAEMON_BIN /dev/null 2>/dev/null --country=$SLMODEMD_COUNTRY $SLMODEMD_OPTS /dev/$SLMODEMD_DEVICE & RETVAL=$? [ $RETVAL -eq 0 ] && success $"$PROG startup" || failure $"$PROG startup" echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROG [ $RETVAL -eq 0 ] && ln -s /dev/ttySL0 /dev/modem return $RETVAL } stop() { gprintf "Shutting down SmartLink modem driver: " killproc $PROG RETVAL=$? /sbin/modprobe -r slamr slusb echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG [ $RETVAL -eq 0 ] && rm -f /dev/modem return $RETVAL } # See how we were called case "$1" in start) start ;; stop) stop ;; status) status $PROG RETVAL=$? ;; restart|reload) stop start RETVAL=$? ;; condrestart) if [ -f /var/lock/subsys/$PROG ]; then stop start RETVAL=$? fi ;; *) gprintf "*** Usage: $PROG {start|stop|status|restart|condrestart}\n" exit 1 esac exit $RETVAL