2006-12-19 16:57:00 +01:00
|
|
|
#! /bin/bash
|
|
|
|
# Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany.
|
|
|
|
#
|
|
|
|
# Author: Takashi Iwai <tiwai@suse.de>, 2001
|
|
|
|
#
|
|
|
|
# /etc/init.d/joystick
|
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: joystick
|
|
|
|
# Required-Start: alsasound
|
2008-08-18 19:01:56 +02:00
|
|
|
# Required-Stop: alsasound
|
2006-12-19 16:57:00 +01:00
|
|
|
# Default-Start: 2 3 5
|
|
|
|
# Default-Stop:
|
2009-03-24 18:42:25 +01:00
|
|
|
# Short-Description: Set up analog joysticks
|
2006-12-19 16:57:00 +01:00
|
|
|
# Description: Loading joystick drivers
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
. /etc/rc.status
|
|
|
|
. /etc/sysconfig/joystick
|
|
|
|
|
|
|
|
alsactl=/usr/sbin/alsactl
|
|
|
|
if [ -x /sbin/lsmod ]; then
|
|
|
|
lsmod=/sbin/lsmod
|
|
|
|
else
|
|
|
|
lsmod=/bin/lsmod
|
|
|
|
fi
|
|
|
|
|
|
|
|
# load joystick drivers
|
|
|
|
function start () {
|
|
|
|
# first load joydev module
|
|
|
|
if [ -z "${JOYSTICK_MODULE_0}${JOYSTICK_MODULE_1}${JOYSTICK_MODULE_2}${JOYSTICK_MODULE_3}" ]; then
|
|
|
|
rc_failed 5
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
/sbin/modprobe joydev
|
|
|
|
for js in 0 1 2 3; do
|
|
|
|
# load gameport module
|
|
|
|
eval jsmod=\$GAMEPORT_MODULE_$js
|
|
|
|
if [ -n "$jsmod" -a "$jsmod" != off ]; then
|
|
|
|
/sbin/modprobe $jsmod >/dev/null 2>&1
|
|
|
|
fi
|
2013-04-05 18:23:31 +02:00
|
|
|
# load joystick module
|
2006-12-19 16:57:00 +01:00
|
|
|
eval jsdev=\$JOYSTICK_MODULE_$js
|
|
|
|
eval jsdev_opts=\$JOYSTICK_MODULE_OPTION_$js
|
|
|
|
if [ -n "$jsdev" -a "$jsdev" != off ]; then
|
|
|
|
/sbin/modprobe $jsdev $jsdev_opts >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function stop () {
|
|
|
|
for js in 0 1 2 3; do
|
|
|
|
# remove gameport module
|
|
|
|
eval jsmod=\$GAMEPORT_MODULE_$js
|
|
|
|
if [ -n "$jsmod" -a "$jsmod" != off ]; then
|
|
|
|
/sbin/modprobe -r $jsmod
|
|
|
|
fi
|
2013-04-05 18:23:31 +02:00
|
|
|
# remove joystick module
|
2006-12-19 16:57:00 +01:00
|
|
|
eval jsdev=\$JOYSTICK_MODULE_$js
|
|
|
|
if [ -n "$jsdev" -a "$jsdev" != off ]; then
|
|
|
|
/sbin/modprobe -r $jsdev
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
echo -n "Starting joystick driver"
|
|
|
|
start
|
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
# Stop daemons.
|
|
|
|
echo -n "Stopping joystick driver"
|
|
|
|
stop
|
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
try-restart)
|
|
|
|
$0 status >/dev/null && $0 restart
|
|
|
|
rc_status
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
rc_status
|
|
|
|
;;
|
|
|
|
force-reload)
|
|
|
|
$0 stop && $0 start
|
|
|
|
rc_status
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
rc_failed 3
|
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
if $lsmod | grep -q joydev; then
|
|
|
|
echo -n "Joystick driver loaded."
|
|
|
|
rc_status -v
|
|
|
|
else
|
|
|
|
echo -n "Joystick driver not loaded."
|
|
|
|
rc_status -u
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|try-restart|restart|force-reload|reload|status}"
|
|
|
|
exit 1
|
2008-10-22 17:31:24 +02:00
|
|
|
;;
|
2006-12-19 16:57:00 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
rc_exit
|