dapper udev not working on ACTION remove
golfer
golfbuf at gmail.com
Sat Feb 11 22:38:19 GMT 2006
I'm running dapper and trying to use udev (v 079-0ubuntu10) to start
and stop my usb modem, when it is plugged and unplugged.
I have /etc/udev/rules.d/010_slmodem.rules:
SYSFS{idProduct}=="7554", SYSFS{idVendor}=="0483", ACTION=="add",
PROGRAM="/etc/init.d/sl-modem-daemon start"
SYSFS{idProduct}=="7554", SYSFS{idVendor}=="0483", ACTION=="remove",
PROGRAM="/etc/init.d/sl-modem-daemon stop"
In /etc/init.d/sl-modem-daemon is a line to log whenever it's called
(see the script at the end), so I can try to debug it. It executes
fine when I plug the modem in, but when I unplug it, the script never
gets called. I know this because the logger entry is not made when
the modem is unplugged. So, it's not a script problem, it's just not
being called by udev.
The remove action of the script actually works fine when executed
manually (sudo /etc/init.d/sl-modem-daemon stop) after unplugging the
modem.
I used udevmonitor to verify that the udev events of add and remove
are being recognized by udev, so it makes me think something's wrong
with the ACTION=="remove" in my script.
Any ideas on how to fix this or troubleshoot it further?
regards,
golfbuf
Below is the /etc/init.d/sl-modem-daemon:
#!/bin/sh
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
logger sl-modem-daemon executed at $(date)
DAEMON=/usr/sbin/slmodemd
NAME=slmodemd
PIDFILE=/var/run/$NAME.pid
DESC="SmartLink modem daemon"
modprobe="$(cat /proc/sys/kernel/modprobe 2>/dev/null || echo modprobe)"
test -x $DAEMON || exit 0
config() {
if grep -q 'slusb\..*o' /lib/modules/`uname -r`/modules.dep ; then
$modprobe slusb
SLMODEMD_DEVICE=slusb0
if ! [ -e /dev/slusb0 ]; then
mknod /dev/slusb0 c 243 0
fi
OPTS="-c USA /dev/$SLMODEMD_DEVICE"
fi
}
start() {
config
echo -n "Starting SmartLink Modem driver for: $SLMODEMD_DEVICE"
start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON
--make-pidfile --background --quiet -- $OPTS
RETVAL=$?
if [ "$RETVAL" = 0 ] ; then
echo "."
# echo "Creating /dev/modem symlink, pointing to: /dev/ttySL0."
# ln -sf ttySL0 /dev/modem
fi
}
stop() {
echo -n "Shutting down SmartLink Modem driver normally"
RETVAL=0
if [ "`pidof $NAME`" ] ; then
if start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec
$DAEMON --retry 1 ; then
echo .
else
echo " probably failed."
echo "Trying it the hard way (send SIGKILL all $NAME processes): "
killall -KILL $NAME || RETVAL=1
fi
else
echo " ... no $NAME daemon running."
fi
if [ "$RETVAL" = 0 ] ; then
rm -f "$PIDFILE"
# 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
$modprobe -r slusb 2>/dev/null && msg="slusb." || msg="failed."
fi
echo $msg
fi
}
status() {
echo -n "Status of $DESC: "
if [ ! -r "$PIDFILE" ]; then
echo "$NAME is not running."
exit 3
fi
if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
echo "$NAME is running."
exit 0
else
echo "$NAME is not running but $PIDFILE exists."
exit 1
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
stop
start
;;
status)
status
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|status}"
exit 1
esac
More information about the kubuntu-devel
mailing list