summaryrefslogtreecommitdiff
path: root/gpm.init
blob: b73b14b48c23c5f48a48592b829ed4a2439e7f7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/sh
#
# chkconfig:	2345 85 15
#
# description:	GPM adds mouse support to text-based Linux applications such \
#		the Midnight Commander. Is also allows mouse-based console \
#		cut-and-paste operations, and includes support for pop-up \
#		menus on the console.
# description(es.UTF-8): GPM añade soporte al ratón para aplicaciones Linux \
#		consola como el Midnight Commander.  También permite \
#		operaciones con el ratón de cortar y pegar e incluye soporte \
#		para menús pop-up en la consola.
# description(pt_BR.UTF-8): O GPM adiciona suporte a mouse para aplicações Linux \
#		console como o Midnight Commander. Também permite \
#		operações com o mouse de cortar-e-colar e inclui suporte \
#		a menus pop-up no console.
#
# processname:	gpm
# pidfile:	/var/run/gpm.pid
# config:	/etc/sysconfig/mouse

# Source function library
. /etc/rc.d/init.d/functions

upstart_controlled

# Get service config
[ -f /etc/sysconfig/mouse ] && . /etc/sysconfig/mouse

start() {
	# Check if the service is already running?
	if [ -f /var/lock/subsys/gpm ]; then
		msg_already_running "Gpm"
		return
	fi

	[ -z "$DEVICE" ] && nls "Please set %s in /etc/sysconfig/mouse" "DEVICE"
	[ -z "$MOUSETYPE" ] && nls "Please set %s in /etc/sysconfig/mouse" "MOUSETYPE"

	msg_starting "Gpm"
	OPTIONS=""
	[ -n "$DEVICE" ] && OPTIONS="-m $DEVICE"
	[ -n "$MOUSETYPE" ] && OPTIONS="$OPTIONS -t $MOUSETYPE"
	[ -n "$BAUD_RATE" ] && OPTIONS="$OPTIONS -b $BAUD_RATE"
	[ -n "$CLEAR_LINES" ] && OPTIONS="$OPTIONS -o $CLEAR_LINES"
	[ -n "$BUTTON_SEQ" ] && OPTIONS="$OPTIONS -B $BUTTON_SEQ"
	[ -n "$TAP_BUTTON" ] && OPTIONS="$OPTIONS -g $TAP_BUTTON"
	[ -n "$ACCEL" ] && OPTIONS="$OPTIONS -a $ACCEL"
	[ -n "$DELTA" ] && OPTIONS="$OPTIONS -d $DELTA"
	[ -n "$INTERVAL" ] && OPTIONS="$OPTIONS -i $INTERVAL"
	[ -n "$RESP" ] && OPTIONS="$OPTIONS -r $RESP"
	[ -n "$SAMPLE_RATE" ] && OPTIONS="$OPTIONS -s $SAMPLE_RATE"
	[ -n "$CHARSET" ] && OPTIONS="$OPTIONS -l \"$CHARSET\""
	[ "$BUTTON_COUNT" = "2" ] && OPTIONS="$OPTIONS -2"
	[ "$BUTTON_COUNT" = "3" ] && OPTIONS="$OPTIONS -3"
	if [ -n "$POINTER_VIS" ] && [ "$POINTER_VIS" != "no" ]; then
		OPTIONS="$OPTIONS -p"
	fi
	if [ -n "$REPEATER" ] && [ "$REPEATER" != "no" ]; then
		OPTIONS="$OPTIONS -R"
	fi
	daemon /usr/sbin/gpm $OPTIONS $GPM_OPTIONS < /dev/null
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/gpm
}

stop() {
	if [ ! -f /var/lock/subsys/gpm ]; then
		msg_not_running "Gpm"
		return
	fi

	msg_stopping "Gpm"
	killproc gpm
	rm -f /var/lock/subsys/gpm >/dev/null 2>&1
}

condrestart() {
	if [ ! -f /var/lock/subsys/gpm ]; then
		msg_not_running "Gpm"
		RETVAL=$1
		return
	fi

	stop
	start
}

RETVAL=0
# See how we were called.
case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
	stop
	start
	;;
  try-restart)
	condrestart 0
	;;
  force-reload)
	condrestart 7
	;;
  status)
	status gpm
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
	exit 3
esac

exit $RETVAL