41
#For remote only detection support, we need
42
#both REMOTE_DEVICE and TRANSMITTER_DEVICE undefined
43
if [ -z "$REMOTE_DEVICE" ] && [ -z "$TRANSMITTER_DEVICE" ] && [ -c $dev ]; then
47
#If we have a REMOTE_DEVICE or REMOTE_DRIVER defined (either because no devices
48
#were defined, OR if we explicitly did), then populate REMOTE_ARGS
49
if [ ! -z "$REMOTE_DEVICE" ] || [ ! -z "$REMOTE_DRIVER" ]; then
50
if [ -n "$REMOTE_DEVICE" ] && [ "$REMOTE_DEVICE" != "none" ]; then
51
REMOTE_ARGS="--device=$REMOTE_DEVICE $REMOTE_ARGS"
53
if [ -n "$REMOTE_DRIVER" ] && [ "$REMOTE_DRIVER" != "none" ]; then
54
REMOTE_ARGS="--driver=$REMOTE_DRIVER $REMOTE_ARGS"
57
#Now, if we ALSO have a transmitter defined, add some args
58
#To make the first lircd listen up
59
if [ ! -z "$TRANSMITTER_DEVICE" ] || [ ! -z "$TRANSMITTER_DRIVER" ]; then
60
REMOTE_ARGS="$REMOTE_ARGS --listen"
62
REMOTE_ARGS="--output=$REMOTE_SOCKET $REMOTE_ARGS"
41
if [ "${REMOTE_DEVICE[$REMOTE_NUM]}" != "none" ]; then
42
REMOTE_ARGS="--device=${REMOTE_DEVICE[$REMOTE_NUM]} $REMOTE_ARGS"
44
if [ -n "${REMOTE_DRIVER[$REMOTE_NUM]}" ] && [ "${REMOTE_DRIVER[$REMOTE_NUM]}" != "none" ]; then
45
REMOTE_ARGS="--driver=${REMOTE_DRIVER[$REMOTE_NUM]} $REMOTE_ARGS"
48
if [ $REMOTE_COUNT -ge 2 ]; then
49
if [ $REMOTE_NUM -gt 0 ]; then
50
REMOTE_ARGS="$REMOTE_ARGS --listen=${LIRC_PORT[$REMOTE_NUM]}"
52
for I in $(seq $(($REMOTE_COUNT - 1)) -1 1)
54
REMOTE_ARGS="$REMOTE_ARGS --connect=localhost:${LIRC_PORT[$I]}"
58
REMOTE_ARGS="--output=${REMOTE_SOCKET[$REMOTE_NUM]} $REMOTE_ARGS --pidfile=${REMOTE_PID[$REMOTE_NUM]}"
67
build_transmitter_args ()
71
#Transmitters must be explicitly be defined
72
if [ ! -z "$TRANSMITTER_DEVICE" ] || [ ! -z "$TRANSMITTER_DRIVER" ]; then
73
if [ -n "$TRANSMITTER_DEVICE" ] && [ "$TRANSMITTER_DEVICE" != "none" ]; then
74
TRANSMITTER_ARGS="--device=$TRANSMITTER_DEVICE $TRANSMITTER_ARGS"
76
if [ -n "$TRANSMITTER_DRIVER" ] && [ "$TRANSMITTER_DRIVER" != "none" ]; then
77
TRANSMITTER_ARGS="--driver=$TRANSMITTER_DRIVER $TRANSMITTER_ARGS"
80
#Now, if we ALSO have a remote defined, add some args
81
#To make the second lircd connect
82
if [ ! -z "$REMOTE_DEVICE" ] || [ ! -z "$REMOTE_DRIVER" ]; then
83
TRANSMITTER_SOCKET="${TRANSMITTER_SOCKET}1"
84
TRANSMITTER_ARGS="$TRANSMITTER_ARGS --connect=localhost:8765 --pidfile=/var/run/lirc/lircd1.pid"
86
TRANSMITTER_ARGS="--output=$TRANSMITTER_SOCKET $TRANSMITTER_ARGS"
88
echo $TRANSMITTER_ARGS
91
62
. /lib/lsb/init-functions
93
64
test -f /usr/sbin/lircd || exit 0
125
96
#We need default socket locations
126
OLD_SOCKET="/dev/lircd"
127
if [ -z "$REMOTE_SOCKET" ]; then
128
REMOTE_SOCKET="/var/run/lirc/lircd"
130
if [ -z "$TRANSMITTER_SOCKET" ]; then
131
TRANSMITTER_SOCKET="/var/run/lirc/lircd"
97
LEGACY_SOCKET="/dev/lircd"
98
DEFAULT_SOCKET="/var/run/lirc/lircd"
99
REMOTE_PID="/var/run/lirc/lircd.pid"
101
# Get the remote count
103
if [ ! -z "${REMOTE_DEVICE[0]}" ]; then
104
REMOTE_COUNT=${#REMOTE_DEVICE[*]}
107
# This section should eventually be removed
108
# Since there is nothing special about the transmitter variables, define as an additional remote instead
109
if [ ! -z "$TRANSMITTER_DEVICE" ]; then
110
REMOTE[$REMOTE_COUNT]="$TRANSMITTER"
111
REMOTE_MODULES="$REMOTE_MODULES $TRANSMITTER_MODULES"
112
REMOTE_DRIVER[$REMOTE_COUNT]="$TRANSMITTER_DRIVER"
113
REMOTE_DEVICE[$REMOTE_COUNT]="$TRANSMITTER_DEVICE"
114
REMOTE_SOCKET[$REMOTE_COUNT]="$TRANSMITTER_SOCKET"
115
REMOTE_LIRCD_CONF[$REMOTE_COUNT]="$TRANSMITTER_LIRCD_CONF"
116
REMOTE_LIRCD_ARGS[$REMOTE_COUNT]="$TRANSMITTER_LIRCD_ARGS"
117
REMOTE_COUNT=$(($REMOTE_COUNT + 1))
120
if [ $REMOTE_COUNT -eq 0 ] && [ -c $dev ]; then
136
128
if [ "$LOAD_MODULES" = "true" ] && [ "$START_LIRCD" = "true" ]; then
137
load_modules $2 $REMOTE_MODULES $TRANSMITTER_MODULES $MODULES
129
load_modules $2 $REMOTE_MODULES $MODULES
132
# Start the lircd instance(s)
140
133
if [ "$START_LIRCD" = "true" ]; then
134
# make sure the /var/run/lirc directory exists
141
135
[ -d "/var/run/lirc" ] || mkdir -p "/var/run/lirc"
142
137
log_daemon_msg "Starting remote control daemon(s) : LIRC "
143
REMOTE_LIRCD_ARGS=`build_remote_args $REMOTE_LIRCD_ARGS`
144
TRANSMITTER_LIRCD_ARGS=`build_transmitter_args $TRANSMITTER_LIRCD_ARGS`
146
#if we have a remote defined, it is primary process
147
if [ ! -z "$REMOTE_LIRCD_ARGS" ]; then
148
start-stop-daemon --start --quiet --oknodo --exec /usr/sbin/lircd -- $REMOTE_LIRCD_ARGS < /dev/null
150
if [ -S "$REMOTE_SOCKET" -a "$OLD_SOCKET" != "$REMOTE_SOCKET" ]; then
151
rm -f $OLD_SOCKET && ln -s $REMOTE_SOCKET $OLD_SOCKET
154
#now if we additionally have a transmitter defined, it is secondary process
155
if [ ! -z "$TRANSMITTER_LIRCD_ARGS" ]; then
156
/usr/sbin/lircd $TRANSMITTER_LIRCD_ARGS < /dev/null
157
if [ -S "$TRANSMITTER_SOCKET" ]; then
158
rm -f ${OLD_SOCKET}1 && ln -s $TRANSMITTER_SOCKET ${OLD_SOCKET}1
161
elif [ ! -z "$TRANSMITTER_LIRCD_ARGS" ]; then
162
start-stop-daemon --start --quiet --oknodo --exec /usr/sbin/lircd -- $TRANSMITTER_LIRCD_ARGS < /dev/null
164
if [ -S "$TRANSMITTER_SOCKET" -a "$OLD_SOCKET" != "$TRANSMITTER_SOCKET" ]; then
165
rm -f $OLD_SOCKET && ln -s $TRANSMITTER_SOCKET $OLD_SOCKET
139
# loop over all remotes defined - go backwards so the final one can connect to the rest
140
for REMOTE_NUM in $(seq $(($REMOTE_COUNT - 1)) -1 0)
142
# determine the defaults to use for this remote
143
if [ $REMOTE_NUM -gt 0 ]; then
144
LEGACY_SOCKET[$REMOTE_NUM]="$LEGACY_SOCKET$REMOTE_NUM"
145
DEFAULT_SOCKET[$REMOTE_NUM]="$DEFAULT_SOCKET$REMOTE_NUM"
146
REMOTE_PID[$REMOTE_NUM]="/var/run/lirc/lircd$REMOTE_NUM.pid"
147
if [ -z ${LIRC_PORT[$REMOTE_NUM]} ]; then
148
LIRC_PORT[$REMOTE_NUM]=$((8765 + $REMOTE_NUM))
152
# if no socket was specified, use the default
153
if [ -z ${REMOTE_SOCKET[$REMOTE_NUM]} ]; then
154
REMOTE_SOCKET[$REMOTE_NUM]=${DEFAULT_SOCKET[$REMOTE_NUM]}
157
# call build_remote_args
158
CURRENT_LIRCD_ARGS=`build_remote_args ${REMOTE_LIRCD_ARGS[$REMOTE_NUM]}`
160
# launch the lircd daemon with the supplied arguments
161
start-stop-daemon --start --quiet --oknodo --pidfile ${REMOTE_PID[$REMOTE_NUM]} --exec /usr/sbin/lircd -- $CURRENT_LIRCD_ARGS < /dev/null
162
# If lircd created the new socket and its not the same as the legacy socket, link the legacy socket to the newly created one
163
if [ -S "${REMOTE_SOCKET[$REMOTE_NUM]}" -a "${LEGACY_SOCKET[$REMOTE_NUM]}" != "${REMOTE_SOCKET[$REMOTE_NUM]}" ]; then
164
rm -f ${LEGACY_SOCKET[$REMOTE_NUM]} && ln -s ${REMOTE_SOCKET[$REMOTE_NUM]} ${LEGACY_SOCKET[$REMOTE_NUM]}
172
170
if [ "$START_LIRCMD" = "true" ]; then