#!/sbin/runscript # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 or later # $Header: /var/cvsroot/gentoo-x86/net-dialup/slmodem/files/slmodem-2.9.init,v 1.5 2004/07/14 23:10:35 agriffis Exp $ depend() { need logger } checkconfig() { if [ -z "${COUNTRY}" ]; then eerror "You need to config /etc/conf.d/slmodem first" return 1 fi } function loadsalsa { ebegin "Starting slmodemd for ${DEV}" start-stop-daemon --start --background --nicelevel=${NICE} --make-pidfile \ --pidfile /var/run/slmodemd.pid --startas /usr/sbin/slmodemd \ -- -country=${COUNTRY} -g=${GROUP} --alsa hw:${HW_SLOT} return ${?} } function loadsmodule { modprobe ${MODULE}; if [ "$?" -gt 0 ] then eerror "Missing ${MODULE}. Please set up /etc/conf.d/slmodem" eend 1; fi #sleep as per http://bugs.gentoo.org/show_bug.cgi?id=47947#c59 ebegin "Waiting for ${MODULE} modem driver initialisation" local COUNT=0 echo -e "\e[A\e[49G " echo -ne "\e[A\e[49G" while [ ! -c ${MDEV} -a ${COUNT} -lt 5 ]; do sleep 0.5 echo -ne "." COUNT=`expr ${COUNT} + 1` done echo -ne "\n" if [ ! -c ${MDEV} ]; then eend 1 eerror "Module - ${MODULE} failed to initialise device ${MDEV}" eend 1 else eend 0 fi ebegin "Starting slmodemd for ${DEV}" start-stop-daemon --start --background --nicelevel=${NICE} --make-pidfile \ --pidfile /var/run/slmodemd.pid --startas /usr/sbin/slmodemd \ -- -country=${COUNTRY} -g=${GROUP} ${MDEV} return ${?} } start() { # either if we use alsa or not, the only thing we need is # ttySL0, which is created by slmodemd when started (points to a pts) if [ "${MODULE}" == "alsa" ]; then loadsalsa else loadsmodule fi result=${?} test ! -z "${LN_DEV}" && /bin/ln -s ${DEV} ${LN_DEV} 2> /dev/null eend ${result} } stop() { ebegin "Shutting down slmodemd" start-stop-daemon --stop --quiet --pidfile /var/run/slmodemd.pid && rm /var/run/slmodemd.pid result=${?} test "${MODULE}" != "alsa" && { sleep 2 && modprobe -r ${MODULE} 2> /dev/null; } & unlink ${LN_DEV} 2> /dev/null eend ${result} }