home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20110725.etc.tar.gz / bradford.20110725.etc.tar / etc / init.d / joystick < prev    next >
Text File  |  2006-05-02  |  3KB  |  132 lines

  1. #! /bin/bash
  2. # Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany.
  3. # Author: Takashi Iwai <tiwai@suse.de>, 2001
  4. #
  5. # /etc/init.d/joystick
  6. #
  7. ### BEGIN INIT INFO
  8. # Provides:       joystick
  9. # Required-Start: alsasound
  10. # Required-Stop:
  11. # Default-Start:  2 3 5
  12. # Default-Stop:
  13. # Description:   Loading joystick drivers
  14. ### END INIT INFO
  15.  
  16. . /etc/rc.status
  17. . /etc/sysconfig/joystick
  18.  
  19. alsactl=/usr/sbin/alsactl
  20. if [ -x /sbin/lsmod ]; then
  21.     lsmod=/sbin/lsmod
  22. else
  23.     lsmod=/bin/lsmod
  24. fi
  25.  
  26. # load joystick drivers
  27. function start () {
  28.     # first load joydev module
  29.     if [ -z "${JOYSTICK_MODULE_0}${JOYSTICK_MODULE_1}${JOYSTICK_MODULE_2}${JOYSTICK_MODULE_3}" ]; then
  30.     rc_failed 5
  31.     return
  32.     fi
  33.  
  34.     /sbin/modprobe joydev
  35.     for js in 0 1 2 3; do
  36.     # configure joystick port (if necessary)
  37.     eval jsport=\$JOYSTICK_CONTROL_PORT_$js
  38.     if [ -n "$jsport" ]; then
  39.         $alsactl set $js card:"Joystick Address" "port $jsport"
  40.     fi
  41.     # activate joystick (if necessary)
  42.     eval jsctrl=\$JOYSTICK_CONTROL_$js
  43.     if [ -n "$jsctrl" -a "$jsctrl" != no ]; then
  44.         if [ "$jsctrl" = yes ]; then
  45.         jsctrl="Joystick"
  46.         fi
  47.         $alsactl set $js card:"$jsctrl" true
  48.     fi
  49.     # load gameport module
  50.     eval jsmod=\$GAMEPORT_MODULE_$js
  51.     if [ -n "$jsmod" -a "$jsmod" != off ]; then
  52.         /sbin/modprobe $jsmod >/dev/null 2>&1
  53.     fi
  54.     # load joystick moulde
  55.     eval jsdev=\$JOYSTICK_MODULE_$js
  56.     eval jsdev_opts=\$JOYSTICK_MODULE_OPTION_$js
  57.     if [ -n "$jsdev" -a "$jsdev" != off ]; then
  58.         /sbin/modprobe $jsdev $jsdev_opts >/dev/null 2>&1
  59.     fi
  60.     done
  61. }
  62.  
  63. function stop () {
  64.     for js in 0 1 2 3; do
  65.     # deactivate joystick (if necessary)
  66.     eval jsctrl=\$JOYSTICK_CONTROL_$js
  67.     if [ -n "$jsctrl" -a "$jsctrl" != no ]; then
  68.         if [ "$jsctrl" = yes ]; then
  69.         jsctrl="Joystick"
  70.         fi
  71.         $alsactl set $js card:"$jsctrl" false
  72.     fi
  73.     # remove gameport module
  74.     eval jsmod=\$GAMEPORT_MODULE_$js
  75.     if [ -n "$jsmod" -a "$jsmod" != off ]; then
  76.         /sbin/modprobe -r $jsmod
  77.     fi
  78.     # remove joystick moulde
  79.     eval jsdev=\$JOYSTICK_MODULE_$js
  80.     if [ -n "$jsdev" -a "$jsdev" != off ]; then
  81.         /sbin/modprobe -r $jsdev
  82.     fi
  83.     done
  84. }
  85.  
  86. # See how we were called.
  87. case "$1" in
  88.     start)
  89.     echo -n "Starting joystick driver"
  90.     start
  91.     rc_status -v
  92.         ;;
  93.     stop)
  94.         # Stop daemons.
  95.         echo -n "Stopping joystick driver"
  96.     stop
  97.     rc_status -v
  98.         ;;
  99.     try-restart)
  100.         $0 status >/dev/null && $0 restart
  101.     rc_status
  102.     ;;
  103.     restart)
  104.     $0 stop
  105.     $0 start
  106.         rc_status
  107.     ;;
  108.     force-reload)
  109.     $0 stop && $0 start
  110.     rc_status
  111.     ;;
  112.     reload)
  113.         rc_failed 3
  114.     rc_status -v
  115.     ;;
  116.     status)
  117.     if $lsmod | grep -q joydev; then
  118.           echo -n "Joystick driver loaded."
  119.           rc_status -v
  120.         else
  121.           echo -n "Joystick driver not loaded."
  122.       rc_status -u
  123.         fi
  124.         ;;
  125.     *)
  126.     echo "Usage: $0 {start|stop|try-restart|restart|force-reload|reload|status}"
  127.         exit 1
  128. esac
  129.  
  130. rc_exit
  131.