diff options
Diffstat (limited to 'abs/mv-core/runit-scripts-mv/runitscripts/services/lircd')
-rwxr-xr-x | abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/finish | 6 | ||||
-rwxr-xr-x | abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/run | 169 |
2 files changed, 132 insertions, 43 deletions
diff --git a/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/finish b/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/finish index 754bca1..1afc41c 100755 --- a/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/finish +++ b/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/finish @@ -1,4 +1,8 @@ #!/bin/bash +export TERM=linux +. /etc/rc.conf +. /etc/rc.d/functions + killall -9 lircd 2>/dev/null rm -f /var/run/lirc*.pid [ -e /etc/sv/lircd/.runtime ] || mkdir -p /etc/sv/lircd/.runtime @@ -8,5 +12,5 @@ if [ $numfiles -gt 3 ] then rm -f /etc/sv/lircd/.runtime/* 2>/dev/null sv stop lircd - echo "lircd is not able to start, disabling it" + printhl " lircd is not able to start, disabling it" fi diff --git a/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/run b/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/run index ceda8db..0a398ac 100755 --- a/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/run +++ b/abs/mv-core/runit-scripts-mv/runitscripts/services/lircd/run @@ -1,53 +1,138 @@ #!/bin/bash + exec 2>&1 -run_lircd2=false -. /etc/systemconfig -[ -e /etc/sv/lircd/.runtime ] || mkdir -p /etc/sv/lircd/.runtime +export TERM=linux -function dvico_detect { +. /etc/rc.conf +. /etc/rc.d/functions +#since what we do may not be enough +#if your one of those people, this is where you place your stuff - if [ x$Remotetype = "xdvico" ] - then - DEVICE="/dev/usb/hiddev0" - fi -} +LOG=/tmp/lirc.log -function imon_detect { -if [ -e /dev/lirc_imon ] +if [ -f $LOG ] then -lircd2_cmd="/usr/sbin/lircd -d /dev/lirc_imon --output=/dev/lircd --pidfile=/var/run/lircd2.pid --connect=localhost:8765" -run_lircd2=true + rm -f $LOG fi -} - - - -case $ReceiverType in - Serial) - /usr/bin/setserial /dev/$ReceiverSerialport uart none - /sbin/modprobe lirc_serial - DEVICE=`ls /dev/lirc[0-9] 2>/dev/null |sort |sed '/./,$!d'|head -n 1 ` - imon_detect - ;; - Usb-imon) - DEVICE=/dev/lirc_imon - ;; - Hauppauge) - DEVICE=/dev/lirc3 - ;; - *) - - DEVICE=`ls /dev/lirc[0-9] 2>/dev/null |sort |sed '/./,$!d'|head -n 1 ` - imon_detect - dvico_detect - ;; -esac - -if [ "$run_lircd2" = "true" ] + +if [ -f /etc/runit/lirc.sh ] then - $lircd2_cmd 2>/dev/null 1>/dev/null - exec /usr/sbin/lircd -n -d $DEVICE --output /dev/lircd1 --listen 2>/dev/null 1>/dev/null + #program must not terminate. + + stat_runit "Starting lirc" + + /etc/runit/lirc.sh else - exec /usr/sbin/lircd -n -d $DEVICE 2>/dev/null 1>/dev/null + . /etc/systemconfig + stat_runit "Starting lirc" + + [ -e /etc/sv/lircd/.runtime ] || mkdir -p /etc/sv/lircd/.runtime + + function dvico_detect { + if [ x$Remotetype = "xdvico" ] || [ x$Remotetype = "xDvico-Dual-Digital4-rev2" ] + then + RunDvico=true + else + RunDvico=false + fi + } + + num_lirc=`ls -la /dev/lirc[0-9] 2>/dev/null |wc -l ` + num_lirc=$((num_lirc-1)) + + serial_port="" + + if [ x$ReceiverType = xSerial ] + then + serial_port=$ReceiverSerialport + elif [ x$HostBlasterType = xSerial ] + then + serial_port=$HostSerialPort_blasterlirc + fi + + if [ -n "$serial_port" ] + then + #/dev/ttyS0 (COM1), port 0x3f8, irq 4 + #/dev/ttyS1 (COM2), port 0x2f8, irq 3 + #/dev/ttyS2 (COM3), port 0x3e8, irq 4 + #/dev/ttyS3 (COM4), port 0x2e8, irq 3 + + case $serial_port in + ttyS0) + FLAGS="io=0x3f8 irq=4" + ;; + ttyS1) + FLAGS="io=0x2f8 irq=3" + ;; + ttyS2) + FLAGS="io=0x3e8 irq=4" + ;; + ttyS3) + FLAGS="io=0x2e8 irq=3" + ;; + esac + /usr/bin/setserial /dev/serial_port uart none + sleep 0.5 + /sbin/modprobe lirc_serial $FLAGS + sleep 0.5 + fi + + dvico_detect + + if [ x$HostBlasterType = xCommandIR -o x$ReceiverType = xCommandIR ] + then + CMD="/usr/sbin/lircd -n --driver=commandir" + printhl " Using commandir" + $CMD >>$LOG 2>>$LOG +#echo $CMD + elif [ x$HostBlasterType = xiguanaIR-usb -o x$ReceiverType = xiguanaIR-usb ] + then + sv start igdaemon + CMD="/usr/sbin/lircd -n --driver=iguanaIR" + printhl " Using iguanaIR usb" +#echo $CMD + $CMD >>$LOG 2>>$LOG + else + LASTCMD="" + + for i in `seq 1 $num_lirc` + do + CMD="/usr/sbin/lircd -d /dev/lirc$i --output=/dev/lircd$i --pidfile=/var/run/lircd$i.pid --listen=876$i" + printhl " Device $i" +#echo $CMD + $CMD >>$LOG 2>>$LOG + LASTCMD="--connect=localhost:876$i $LASTCMD " + done + + if [ $RunDvico = "true" ] + then + if [ x$Remotetype = "xdvico" ] + then + LCMD="/usr/sbin/lircd -n -d /dev/usb/dvicoIR --driver=dvico --output /dev/lircd" + else + LCMD="/usr/sbin/lircd -n -d /dev/input/irremote --driver=devinput --output /dev/lircd" + fi + + if [ $num_lirc -lt 0 ] + then + # Only run Dvico + printhl " Device $Remotetype" +#echo $LCMD + exec $LCMD >>$LOG 2>>$LOG + elif [ $num_lirc -gt -1 ] + then + i=$((i+1)) + CMD="$LCMD --output=/dev/lircd$i --pidfile=/var/run/lircd$i.pid --listen=876$i" + $CMD >> $LOG + LASTCMD="--connect=localhost:876$i $LASTCMD " + printhl " Device Dvico" + /usr/sbin/lircd -n -d /dev/lirc0 --output /dev/lircd $LASTCMD >>$LOG 2>>$LOG + fi + else + LCMD="/usr/sbin/lircd -n -d /dev/lirc0 --output /dev/lircd $LASTCMD" +#echo $LCMD + exec $LCMD >>$LOG 2>>$LOG + fi + fi fi |