View previous topic :: View next topic |
Author |
Message |
pblinux2 n00b
Joined: 16 Mar 2006 Posts: 29
|
Posted: Fri Jan 14, 2011 12:35 am Post subject: [SOLVED] The depend() function in init.d scripts |
|
|
I'm trying to set up multiple lircd devices in a relatively straightforward and manageable manner. I'm using lirc's listen/connect to pass traffic from all of the lircd.XXX daemons up to the master lircd
Code: | morocco ~ # ls -l /etc/init.d/lircd*
-rwxr-xr-x 1 root root 1094 Jan 13 18:52 /etc/init.d/lircd
lrwxrwxrwx 1 root root 5 Jan 6 00:30 /etc/init.d/lircd.udp -> lircd
morocco ~ # cat /etc/conf.d/lircd
LIRCD_OPTS="--device=/dev/lirc0 --driver=default --connect=localhost:8765"
RC_NEED="lircd.udp"
morocco ~ # cat /etc/conf.d/lircd.udp
LIRCD_OPTS="--device=5000 --driver=udp --listen=127.0.0.1:8765" |
I also edited /etc/init.d/lircd to make the socket unique to each instance
Code: | morocco ~ # cat /etc/init.d/lircd |
Code: | PIDFILE=/var/run/lirc/${SVCNAME}.pid
LIRCD_SYMLINKFILE=/dev/${SVCNAME}
LIRCD_SOCKET=/var/run/lirc/${SVCNAME} |
Code: | depend() {
need localmount
use modules
[[ ${SVCNAME} -eq 'lircd' ]] && provide lirc
} |
Code: | start-stop-daemon --start --quiet --pidfile "${PIDFILE}" --exec /usr/sbin/lircd -- \
-P "${PIDFILE}" -o "${LIRCD_SOCKET}" ${LIRCD_OPTS} |
Basically it works
Code: | morocco ~ # /etc/init.d/lircd start
* Service lircd starting
* Service lircd.udp starting
* Service lircd.udp started
* Service lircd started
|
However, when the depcache is regenerated, I get this error:
Code: | morocco ~ # touch /etc/init.d/lircd && /etc/init.d/lircd start
* Caching service dependencies ...
/var/lib/init.d/depcache: line 1819: [[: lircd.udp: syntax error: invalid arithmetic operator (error token is ".udp")
* Service lircd starting
* Service lircd.udp starting
* Service lircd.udp started
* Service lircd started |
The relevant bit from the depcache:
Code: | morocco ~ # grep -n lircd.udp -A39 /var/lib/init.d/depcache
1791:#*** /etc/init.d/lircd.udp ***
1792-
1793:SVCNAME="/etc/init.d/lircd.udp"
1794-SVCNAME="${SVCNAME##*/}"
1795-myservice="${SVCNAME}"
1796-echo "RCSCRIPT ${SVCNAME}"
1797-
1798-echo "MTIME 1294291835"
1799-
1800-(
1801- # Get settings for rc-script ...
1802-
1803- [ -e /etc/conf.d/net ] && \
1804- [ "${SVCNAME%%.*}" = "net" ] && \
1805- [ "${SVCNAME#*.}" != "${SVCNAME}" ] && source /etc/conf.d/net
1806-
1807- [ -e "/etc/conf.d/${SVCNAME}" ] && source "/etc/conf.d/${SVCNAME}"
1808-
1809- [ -e /etc/rc.conf ] && source /etc/rc.conf
1810-
1811- depend() {
1812- return 0
1813- }
1814-
1815- # Actual depend() function ...
1816- depend() {
1817- need localmount
1818- use modules
1819- [[ ${SVCNAME} -eq 'lircd' ]] && provide lirc
1820- return 0
1821- }
1822-
1823- depend
1824-
1825- for x in ${RC_NEED} ; do
1826- need "${x}"
1827- done
1828-
1829- for x in ${RC_USE} ; do
1830- use "${x}"
1831- done
1832-) |
My question is, what is depcache error all about? As far as I can tell, this method is working quite well, but apparently I'm Doing It Wrong. What is the preferred way to accomplish this?
Last edited by pblinux2 on Fri Jan 14, 2011 3:23 am; edited 1 time in total |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Fri Jan 14, 2011 3:15 am Post subject: |
|
|
Remove the bash-isms and do what the rest of the rc code does - "[ ${SVCNAME} = "lircd" ]" |
|
Back to top |
|
|
pblinux2 n00b
Joined: 16 Mar 2006 Posts: 29
|
Posted: Fri Jan 14, 2011 3:21 am Post subject: |
|
|
Perfect. Thank you |
|
Back to top |
|
|
|