You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
3.5 KiB
135 lines
3.5 KiB
#!/bin/sh
|
|
#
|
|
# lirc Startup script for the Linux Infrared Remote Control daemons
|
|
#
|
|
# chkconfig: - 29 71
|
|
# description: Enables infrared controls through LIRC.
|
|
# processname: lircd
|
|
# processname: lircmd
|
|
# config: /etc/lirc/lircd.conf
|
|
# config: /etc/lirc/lircmd.conf
|
|
# pidfile: /var/run/lirc/lircd.pid
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: lirc
|
|
# Should-Start: $syslog $network
|
|
# Should-Stop: $syslog $network
|
|
# Short-Description: Linux Infrared Remote Control daemon
|
|
# Description: Enables remote control devices through LIRC.
|
|
### END INIT INFO
|
|
|
|
# Source function library.
|
|
. /etc/init.d/functions
|
|
|
|
exec="/usr/sbin/lircd"
|
|
exec2="/usr/sbin/lircmd"
|
|
prog=$(basename $exec)
|
|
prog2=$(basename $exec2)
|
|
|
|
[ -e /etc/sysconfig/lirc ] && . /etc/sysconfig/lirc
|
|
|
|
lockfile=/var/lock/subsys/lirc
|
|
|
|
# Default to first lirc character device and the lirc chardev driver
|
|
LIRC_DEVICE=${LIRC_DEVICE:-/dev/lirc0}
|
|
LIRC_DRIVER=${LIRC_DRIVER:-default}
|
|
|
|
start() {
|
|
echo -n $"Starting infrared remote control daemon ($prog): "
|
|
daemon $exec --driver=$LIRC_DRIVER --device=$LIRC_DEVICE $LIRCD_OPTIONS
|
|
retval=$?
|
|
echo
|
|
status $prog >/dev/null 2>&1
|
|
if [ $? -eq 0 -a "$ENABLE_LIRCMD" = "yes" ] ; then
|
|
echo -n $"Starting infrared remote control mouse daemon ($prog2): "
|
|
daemon $exec2 $LIRCMD_OPTIONS
|
|
retval=$?
|
|
echo
|
|
fi
|
|
[ $retval -eq 0 ] && touch $lockfile
|
|
|
|
# To prevent double key events w/both in-kernel and lirc decode,
|
|
# we disable the in-kernel decoding when lircd is started up
|
|
# successfully with a raw IR rc-core receiver
|
|
if [ $retval -eq 0 ]; then
|
|
if [ $(echo "$LIRC_DRIVER" | grep -c "default") -ge 1 ]; then
|
|
lircdev=$(basename $LIRC_DEVICE)
|
|
rcdev=$(find -L /sys/class/rc/ -maxdepth 2 -name $lircdev 2> /dev/null)
|
|
if [ ! -z ${rcdev} ]; then
|
|
(echo lirc > ${rcdev}/../protocols) 2> /dev/null
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
return $retval
|
|
}
|
|
|
|
stop() {
|
|
retval=0
|
|
if status $prog2 >/dev/null 2>&1 ; then
|
|
echo -n $"Stopping infrared remote control mouse daemon ($prog2): "
|
|
killproc $prog2
|
|
retval=$?
|
|
echo
|
|
fi
|
|
if [ $retval -eq 0 ] ; then
|
|
echo -n $"Stopping infrared remote control daemon ($prog): "
|
|
killproc $prog
|
|
retval=$?
|
|
echo
|
|
fi
|
|
[ $retval -eq 0 ] && rm -f $lockfile
|
|
|
|
# On lircd shutdown, turn all the in-kernel IR decoders back on
|
|
lircdev=$(basename $LIRC_DEVICE)
|
|
rcdev=$(find -L /sys/class/rc/ -maxdepth 2 -name $lircdev 2> /dev/null)
|
|
if [ ! -z ${rcdev} ]; then
|
|
protonode=${rcdev}/../protocols
|
|
echo none > ${protonode}
|
|
protos=$(cat ${protonode})
|
|
for p in $protos
|
|
do
|
|
(echo "+${p}" > ${protonode}) 2> /dev/null
|
|
done
|
|
fi
|
|
|
|
return $retval
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
start
|
|
}
|
|
|
|
reload() {
|
|
# lircmd doesn't apparently respond to HUP, so if it's running, restart.
|
|
if status $prog2 >/dev/null 2>&1 ; then
|
|
restart
|
|
else
|
|
echo -n $"Reloading infrared remote control daemon ($prog): "
|
|
killproc $prog -HUP
|
|
retval=$?
|
|
echo
|
|
return $retval
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
start|stop|restart|reload)
|
|
$1
|
|
;;
|
|
force-reload)
|
|
reload || restart
|
|
;;
|
|
status)
|
|
status $prog2
|
|
status $prog
|
|
;;
|
|
try-restart|condrestart)
|
|
[ ! -f $lockfile ] || restart
|
|
;;
|
|
*)
|
|
echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
|
|
exit 2
|
|
esac
|