summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/runit-scripts/runitscripts/services/lircd/run
blob: 242dcb304bf4c8f6fab17e5242eb70de352d5bbb (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
#!/bin/bash
exec 2>&1
#since what we do may not be enough
#if your one of those people, this is where you place your stuff
if [ -f /etc/runit/lirc.sh ]
then
    #program must not terminate.
    /etc/runit/lirc.sh
else
    . /etc/systemconfig
    [ -e /etc/sv/lircd/.runtime ] || mkdir -p /etc/sv/lircd/.runtime

    function dvico_detect {
        if [ x$Remotetype = "xdvico" ]
        then
            RunDvico=true
        else
            RunDvico=false
        fi
    }

    num_lirc=`ls -la /dev/lirc[0-9] |wc -l`
    num_lirc=$((num_lirc-1))
    echo $num_lirc

    #/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
    if [ x$ReceiverType = xSerial ]
    then
        case $ReceiverSerialport in
        ttyS0)
                FLAGS="io=0x3f8  irq=4"
               ;;
        ttyS1)
               FLAGS="io=0x2f8  irq=3"
               ;;
        ttyS2)
               FLAGS="io=0x3e8  irq=4"
               ;;
        ttyS3)
               FLAGS="io=0x2f8  irq=3"
               ;;
        esac
        /usr/bin/setserial /dev/$ReceiverSerialport uart none
        /sbin/modprobe lirc_serial $FLAGS
    fi
    if [ x$HostBlasterType = xSerial ]
    then
        case $HostSerialPort_blasterlirc in
        ttyS0)
                FLAGS="io=0x3f8  irq=4"
               ;;
        ttyS1)
               FLAGS="io=0x2f8  irq=3"
               ;;
        ttyS2)
               FLAGS="io=0x3e8  irq=4"
               ;;
        ttyS3)
               FLAGS="io=0x2f8  irq=3"
               ;;
        esac
        /usr/bin/setserial /dev/$ReceiverSerialport uart none
        /sbin/modprobe lirc_serial $FLAGS
    fi

    dvico_detect


    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"
        echo $CMD
        $CMD
        LASTCMD="--connect=localhost:876$i   $LASTCMD    "
    done
    if [ $RunDvico = "true" -a $num_lirc -lt 0 ]
    then
      #only run dvicio
      LCMD="/usr/sbin/lircd -n -d /dev/usb/hiddev0 --driver=dvico  --output /dev/lircd"
      echo $LCMD
      exec $LCMD
    elif [ $RunDvico = true -a $num_lirc -gt -1  ]
    then
        #chain them together
        i=$((i+1))
        CMD="/usr/sbin/lircd -d /dev/usb/hiddev0 --driver=dvico  --output=/dev/lircd$i --pidfile=/var/run/lircd$i.pid --listen=876$i"
        echo $CMD
        $CMD
        LASTCMD="--connect=localhost:876$i   $LASTCMD    "
        /usr/sbin/lircd -n -d /dev/lirc0 --output /dev/lircd  $LASTCMD
    else
       LCMD="/usr/sbin/lircd -n -d /dev/lirc0 --output /dev/lircd  $LASTCMD"
       echo $LCMD
       exec $LCMD
    fi
fi