Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] The depend() function in init.d scripts
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
pblinux2
n00b
n00b


Joined: 16 Mar 2006
Posts: 29

PostPosted: Fri Jan 14, 2011 12:35 am    Post subject: [SOLVED] The depend() function in init.d scripts Reply with quote

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
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Fri Jan 14, 2011 3:15 am    Post subject: Reply with quote

Remove the bash-isms and do what the rest of the rc code does - "[ ${SVCNAME} = "lircd" ]"
Back to top
View user's profile Send private message
pblinux2
n00b
n00b


Joined: 16 Mar 2006
Posts: 29

PostPosted: Fri Jan 14, 2011 3:21 am    Post subject: Reply with quote

Perfect. Thank you :-)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum