| View previous topic :: View next topic |
| Author |
Message |
revoohc Tux's lil' helper


Joined: 12 Oct 2002 Posts: 128
|
Posted: Mon Mar 31, 2003 7:50 pm Post subject: help with init startup order |
|
|
I need some help. I just installed dansguardian (http://www.dansguardian.org) onto my gentoo system. Since no emege exists for this, I just compiled it from source. However, I am having problem with startup of it. Dansguardian needs to be dependent on the starting of squid. I have tried to add a "depends () { needs squid }" to the dansguardian init.d file and I have added it to the default level via the rc-update script, but it is not loading squid first.
Could someone please clarify how to make this init script run after squid starts or to force it to load squid?
Thanks,
Chris |
|
| Back to top |
|
 |
Jimbow Guru


Joined: 18 Feb 2003 Posts: 597 Location: Silver City, NM
|
Posted: Mon Mar 31, 2003 8:13 pm Post subject: |
|
|
Try: | Code: | depend() {
need squid
} |
No trailing s'es. _________________ After Perl everything else is just assembly language. |
|
| Back to top |
|
 |
revoohc Tux's lil' helper


Joined: 12 Oct 2002 Posts: 128
|
Posted: Mon Mar 31, 2003 8:24 pm Post subject: |
|
|
Sorry, that was a posting typo on my behalf. What you listed is exactly what I have in the top of my dansguardian init file. Here is the actual contents:
#!/bin/sh
#
# Startup script for dansguardian
#
# chkconfig: 35 92 8
# description: A web content filtering plugin for web \
# proxies, developed to filter using lists of \
# banned phrases, MIME types, filename \
# extensions and PICS labling.
# processname: dansguardian
# pidfile: /var/run/dansguardian.pid
# config: /etc/dansguardian/dansguardian.conf
CONFFILELOCATION=/etc/dansguardian/
BINARYLOCATION=/usr/sbin/
PIDDIR=/var/run/
## make sure squid is loaded
depend() {
need squid
}
# See how we were called.
case "$1" in
start)
if [ -f ${BINARYLOCATION}dansguardian ] &&
[ -f ${CONFFILELOCATION}dansguardian.conf ]; then
echo -n "Starting dansguardian: "
if ${BINARYLOCATION}dansguardian 2> /dev/null; then
echo -e "\\033[60G\c"
echo -e "[ \\033[1;32m\c"
echo -e "OK\c"
echo -e "\\033[0;39m\c"
echo " ]"
[ -d /var/lock/subsys ] && touch /var/lock/subsys/dansguardian
else
echo -e "\\033[60G\c"
echo -e "[ \\033[1;31m\c"
echo -e "FAILED\c"
echo -e "\\033[0;39m\c"
echo " ]"
fi
fi
;;
stop)
echo -n "Shutting down dansguardian: "
if ${BINARYLOCATION}dansguardian -q 2> /dev/null; then
echo -e "\\033[60G\c"
echo -e "[ \\033[1;32m\c"
echo -e "OK\c"
echo -e "\\033[0;39m\c"
echo " ]"
/bin/rm -f ${PIDDIR}dansguardian.pid
/bin/rm -f /tmp/.dguardianipc
[ -d /var/lock/subsys ] && /bin/rm -f /var/lock/subsys/dansguardian
else
echo -e "\\033[60G\c"
echo -e "[ \\033[1;31m\c"
echo -e "FAILED\c"
echo -e "\\033[0;39m\c"
echo " ]"
fi
;;
restart)
$0 stop ;;
status)
if [ -f ${BINARYLOCATION}dansguardian ]; then
${BINARYLOCATION}dansguardian -s
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}" >&2
;;
esac
exit 0
$0 start |
|
| Back to top |
|
 |
Jimbow Guru


Joined: 18 Feb 2003 Posts: 597 Location: Silver City, NM
|
Posted: Mon Mar 31, 2003 8:58 pm Post subject: |
|
|
Aha! You are mixing up two different kinds of scripts. Since you started your script with
It is run as a regular shell script and depend() is never called.
If you want to use depend() then you will need to start your script with
And then put your start and stop code inside of start() and stop(). This should be pretty easy since 90% of what your script does (echos and flag decoding) is already done for you.
Take a look in /etc/init.d/* for examples and also see | Code: | | /sbin/runscript --help | less |
_________________ After Perl everything else is just assembly language. |
|
| Back to top |
|
 |
revoohc Tux's lil' helper


Joined: 12 Oct 2002 Posts: 128
|
Posted: Mon Mar 31, 2003 9:42 pm Post subject: |
|
|
Jimbow,
Thanks for pointing that out (still getting familiar with Gentoo). I used the ntp startup script to rewrite dansguardian and now everything is working great.
Chris |
|
| Back to top |
|
 |
GamesBond n00b

Joined: 15 Mar 2004 Posts: 66 Location: Amsterdam
|
Posted: Wed Apr 07, 2004 6:26 am Post subject: |
|
|
This doesn't work for me. I modified the standard script that came with dansguardian, just modified the need bit to:
depend() {
need squid
}
Still when I start dansguardain without squid running it bombs out with:
* Starting DansGuardian...
Error creating connecting to test proxy
If I start squid manually first and then start dansguardian all is well.
The default init.d script uses #!/sbin/runscript as required.
Idea's anyone? |
|
| Back to top |
|
 |
tomk Bodhisattva


Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Wed Apr 07, 2004 8:32 am Post subject: |
|
|
AFAIK you'll have to change the case switch to start(), stop() and restart() functions. _________________ Search | Read | Answer | Report | Strip |
|
| Back to top |
|
 |
GamesBond n00b

Joined: 15 Mar 2004 Posts: 66 Location: Amsterdam
|
Posted: Wed Apr 07, 2004 10:55 am Post subject: |
|
|
Now I'm really lost!
If the casing of some command would have been wrong I assume the scripts would not work if I started them one after another??
Could dansguardian be starting before squid has fully started up and reports itself as operational? |
|
| Back to top |
|
 |
tomk Bodhisattva


Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Wed Apr 07, 2004 11:32 am Post subject: |
|
|
When I was talking about case, I meant the case command. Using the rc script from revoohc, it should look something like this:
| Code: | #!/sbin/runscript
#
# Startup script for dansguardian
#
# chkconfig: 35 92 8
# description: A web content filtering plugin for web \
# proxies, developed to filter using lists of \
# banned phrases, MIME types, filename \
# extensions and PICS labling.
# processname: dansguardian
# pidfile: /var/run/dansguardian.pid
# config: /etc/dansguardian/dansguardian.conf
CONFFILELOCATION=/etc/dansguardian/
BINARYLOCATION=/usr/sbin/
PIDDIR=/var/run/
## make sure squid is loaded
depend() {
need squid
}
# See how we were called.
start() {
if [ -f ${BINARYLOCATION}dansguardian ] &&
[ -f ${CONFFILELOCATION}dansguardian.conf ]; then
echo -n "Starting dansguardian: "
if ${BINARYLOCATION}dansguardian 2> /dev/null; then
echo -e "\\033[60G\c"
echo -e "[ \\033[1;32m\c"
echo -e "OK\c"
echo -e "\\033[0;39m\c"
echo " ]"
[ -d /var/lock/subsys ] && touch /var/lock/subsys/dansguardian
else
echo -e "\\033[60G\c"
echo -e "[ \\033[1;31m\c"
echo -e "FAILED\c"
echo -e "\\033[0;39m\c"
echo " ]"
fi
fi
}
stop() {
echo -n "Shutting down dansguardian: "
if ${BINARYLOCATION}dansguardian -q 2> /dev/null; then
echo -e "\\033[60G\c"
echo -e "[ \\033[1;32m\c"
echo -e "OK\c"
echo -e "\\033[0;39m\c"
echo " ]"
/bin/rm -f ${PIDDIR}dansguardian.pid
/bin/rm -f /tmp/.dguardianipc
[ -d /var/lock/subsys ] && /bin/rm -f /var/lock/subsys/dansguardian
else
echo -e "\\033[60G\c"
echo -e "[ \\033[1;31m\c"
echo -e "FAILED\c"
echo -e "\\033[0;39m\c"
echo " ]"
fi
}
status() {
if [ -f ${BINARYLOCATION}dansguardian ]; then
${BINARYLOCATION}dansguardian -s
}
exit 0
|
or even better nicely formatted and using ebegin and eend:
| Code: | #!/sbin/runscript
#
# Startup script for dansguardian
#
# chkconfig: 35 92 8
# description: A web content filtering plugin for web \
# proxies, developed to filter using lists of \
# banned phrases, MIME types, filename \
# extensions and PICS labling.
# processname: dansguardian
# pidfile: /var/run/dansguardian.pid
# config: /etc/dansguardian/dansguardian.conf
CONFFILELOCATION=/etc/dansguardian/
BINARYLOCATION=/usr/sbin/
PIDDIR=/var/run/
## make sure squid is loaded
depend() {
need squid
}
start() {
if [ -f ${BINARYLOCATION}dansguardian ] &&
[ -f ${CONFFILELOCATION}dansguardian.conf ]; then
ebegin "Starting dansguardian"
${BINARYLOCATION}dansguardian 2> /dev/null
rtnval=${?}
eend ${rtnval}
if [[ rtnval == 0 ]]; then
[ -d /var/lock/subsys ] && touch /var/lock/subsys/dansguardian
fi
fi
}
stop() {
ebegin "Shutting down dansguardian"
${BINARYLOCATION}dansguardian -q 2> /dev/null
rtnval=${?}
eend ${rtnval}
if [[ rtnval == 0 ]]; then
/bin/rm -f ${PIDDIR}dansguardian.pid
/bin/rm -f /tmp/.dguardianipc
[ -d /var/lock/subsys ] && /bin/rm -f /var/lock/subsys/dansguardian
fi
}
status() {
if [ -f ${BINARYLOCATION}dansguardian ]; then
${BINARYLOCATION}dansguardian -s
fi
}
|
Haven't tested this so there may be a mistake or two. _________________ Search | Read | Answer | Report | Strip |
|
| Back to top |
|
 |
GamesBond n00b

Joined: 15 Mar 2004 Posts: 66 Location: Amsterdam
|
Posted: Thu Apr 08, 2004 7:26 am Post subject: |
|
|
It works!!!! Thanks!
Guess the thing about the case command shows why it says n00b below my name  |
|
| Back to top |
|
 |
|