aboutsummaryrefslogtreecommitdiffstats
path: root/numlock.init
blob: 0f7e325ac5a6a60c173dc1ace0b8cd3458a53354 (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
#!/bin/sh
#
# Startup script for NumLock
#
# description: Locks NumLock key at init runlevel change
# chkconfig: 345 85 15

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

#	The following file make bash to relock the numlock key when logging
#	since login unlock it.
SYSCONF_FILE=/var/lock/subsys/numlock
#SYSCONF_FILE=/etc/sysconfig/numlock

# See how we were called.
case "$1" in
  start)
	echo -n "Starting numlock: "
	echo_success
	echo
	touch $SYSCONF_FILE
	
	for tty in /dev/tty[1-8]; do
		setleds -D +num < $tty
	done

	;;
  stop)
	echo -n "Disabling numlocks on ttys: "
	for tty in /dev/tty[1-8]; do
		setleds -D -num < $tty
	done
	echo_success
	echo
	rm -f $SYSCONF_FILE
	;;
  status)
#	status NumLock
#	echo "dead status as reported is normal since NumLock doesn't need to daemonize"
	if [ -f $SYSCONF_FILE ]
	then
		echo "numlock is enabled"
	else
		echo "numlock is disabled"
	fi
	;;
  restart)
	$0 stop
	$0 start
	;;
  reload)
	echo -n "Reloading numlock: "
	$0 start
	echo
	;;
  *)
	echo "Usage: $0 {start|stop|restart|reload|status}"
	exit 1
esac

exit 0