/rc4.d/S20gpm

http://github.com/brinkman83/bashrc · Shell · 101 lines · 68 code · 12 blank · 21 comment · 21 complexity · 26fbbba2ebe3cca196be277b003d318f MD5 · raw file

  1. #!/bin/sh
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides: gpm
  5. # Required-Start: $remote_fs $syslog
  6. # Required-Stop: $remote_fs $syslog
  7. # Should-Start:
  8. # Should-Stop:
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Short-Description: gpm sysv init script
  12. # Description: general purpose mouse event server
  13. ### END INIT INFO
  14. #
  15. PIDFILE=/var/run/gpm.pid
  16. GPM=/usr/sbin/gpm
  17. CFG=/etc/gpm.conf
  18. test -x $GPM || exit 0
  19. . /lib/lsb/init-functions
  20. if [ "$(id -u)" != "0" ]
  21. then
  22. log_failure_msg "You must be root to start, stop or restart gpm."
  23. exit 1
  24. fi
  25. cmdln=
  26. niceness=0
  27. if [ -f $CFG ]; then
  28. . $CFG
  29. if [ -n "$device" ]; then cmdln="$cmdln -m $device"; fi
  30. if [ -n "$type" ]; then cmdln="$cmdln -t $type"; fi
  31. if [ -n "$responsiveness" ]; then cmdln="$cmdln -r $responsiveness"; fi
  32. if [ -n "$sample_rate" ]; then cmdln="$cmdln -s $sample_rate"; fi
  33. # Yes, this /IS/ correct! There is no space after -R!!!!!!
  34. # I reserve the right to throw manpages at anyone who disagrees.
  35. if [ -n "$repeat_type" ] && [ "$repeat_type" != "none" ]; then
  36. cmdln="$cmdln -R$repeat_type"
  37. fi
  38. if [ -n "$append" ]; then cmdln="$cmdln $append"; fi
  39. # If both the second device and type are specified, use it.
  40. if [ -n "$device2" ] && [ -n "$type2" ] ; then
  41. cmdln="$cmdln -M -m $device2 -t $type2"
  42. fi
  43. fi
  44. gpm_strace () {
  45. log_daemon_msg "Running mouse interface server under strace" "gpm"
  46. eval strace -T -o /root/gpm.strace $GPM -V -D -e $cmdln > /root/gpm.out 2>&1
  47. log_end_msg $?
  48. return $?
  49. }
  50. gpm_start () {
  51. log_daemon_msg "Starting mouse interface server" "gpm"
  52. # HACK - kernel module init is asynchronous in kernel 2.6, EVEN FROM
  53. # REQUEST_MODULE(). That would include 'mousedev'. The correct
  54. # solution is a hotplug script, but we cannot depend on hotplug being
  55. # available just yet, either kernel-side or user-side.
  56. for foo in 1 2 3; do
  57. if :< ${device-/dev/mouse}; then break; fi
  58. sleep 1
  59. done
  60. eval start-stop-daemon --start --quiet --nicelevel $niceness --exec $GPM \
  61. -- $cmdln
  62. log_end_msg $?
  63. return $?
  64. }
  65. gpm_stop () {
  66. log_daemon_msg "Stopping mouse interface server" "gpm"
  67. $GPM -k
  68. log_end_msg $?
  69. return $?
  70. }
  71. case "$1" in
  72. strace)
  73. gpm_strace || exit 1
  74. ;;
  75. start)
  76. gpm_start || exit 1
  77. ;;
  78. stop)
  79. gpm_stop || exit 1
  80. ;;
  81. force-reload|restart)
  82. gpm_stop && sleep 3
  83. gpm_start || exit 1
  84. ;;
  85. *)
  86. echo "Usage: /etc/init.d/gpm {start|stop|restart|force-reload|strace}"
  87. exit 1
  88. esac
  89. exit 0