PageRenderTime 35ms CodeModel.GetById 31ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/rc0.d/K20gpm

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