new udev scripts to plug unplug a SmartLink USB soft modem
golfer
golfbuf at gmail.com
Wed Feb 15 15:07:43 GMT 2006
HOWTO use udev with linux-2.6.15+ to plug and play a SmartLink USB soft modem
The modem is a BestData SmartLink USB modem, and works with
slmodem-2.9.11-20051101.tar.gz from linmodems.org on Ubuntu testing
(dapper), which has linux-2.6.15 and udev-079.
lsusb reveals:
Bus 001 Device 002: ID 0483:7554 SGS Thomson Microelectronics 56k SoftModem
To get the plug and unplug action, create
/etc/udev/rules.d/10-slmodem.rules with this content:
BUS=="usb", SYSFS{idProduct}=="7554", SYSFS{idVendor}=="0483",
ACTION=="add", RUN+="/etc/init.d/slmodem-usb start", ENV{slmodem}="%p"
ACTION=="remove", ENV{slmodem}=="%p", RUN+="/etc/init.d/slmodem-usb stop"
To create/delete the /dev/slusb0 node, start/stop the daemon, and
create/delete a /dev/modem symlink, create /etc/init.d/slmodem-usb
with this content:
#!/bin/sh
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
test -x /usr/sbin/slmodemd || exit 0
start() {
/sbin/modprobe slusb
if ! [ -e /dev/slusb0 ]; then
mknod /dev/slusb0 c 243 0
fi
echo -n "Starting SmartLink Modem driver for: slusb0"
/sbin/start-stop-daemon --start --pidfile /var/run/slmodemd.pid
--exec /usr/sbin/slmodemd --make-pidfile --background --quiet -- -c
USA /dev/slusb0
RETVAL=$?
if [ "$RETVAL" = 0 ] ; then
echo "Creating /dev/modem symlink, pointing to: /dev/ttySL0."
ln -sf /dev/ttySL0 /dev/modem
fi
}
stop() {
echo -n "Shutting down SmartLink Modem driver normally"
RETVAL=0
if [ "`pidof slmodemd`" ] ; then
if /sbin/start-stop-daemon --stop --quiet --pidfile
/var/run/slmodemd.pid --exec /usr/sbin/slmodemd --retry 1 ; then
echo .
else
echo " probably failed."
echo "Trying it the hard way (send SIGKILL all slmodemd
processes): "
/usr/bin/killall -KILL slmodemd || RETVAL=1
fi
else
echo " ... no slmodemd daemon running."
fi
if [ "$RETVAL" = 0 ] ; then
rm -f "/var/run/slmodemd.pid"
rm -f /dev/modem
rm -f /dev/slusb0
echo -n "Unloading modem driver from kernel ... "
msg="none found."
if grep -l -q slusb /proc/modules ; then
/sbin/modprobe -r slusb 2>/dev/null && msg="slusb." || msg="failed."
fi
echo $msg
fi
}
status() {
echo -n "Status of SmartLink modem daemon: "
if [ ! -r "/var/run/slmodemd.pid" ]; then
echo "slmodemd is not running."
exit 3
fi
if read pid < "/var/run/slmodemd.pid" && ps -p "$pid" > /dev/null 2>&1; then
echo "slmodemd is running."
exit 0
else
echo "slmodemd is not running but /var/run/slmodemd.pid exists."
exit 1
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: /etc/init.d/slmodem-usb {start|stop|restart|status}"
exit 1
esac
More information about the ubuntu-devel
mailing list