Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
help with init startup order
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
revoohc
Tux's lil' helper
Tux's lil' helper


Joined: 12 Oct 2002
Posts: 128

PostPosted: Mon Mar 31, 2003 7:50 pm    Post subject: help with init startup order Reply with quote

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
View user's profile Send private message
Jimbow
Guru
Guru


Joined: 18 Feb 2003
Posts: 597
Location: Silver City, NM

PostPosted: Mon Mar 31, 2003 8:13 pm    Post subject: Reply with quote

Try:
Code:
depend() {
    need squid
}

No trailing s'es.
_________________
After Perl everything else is just assembly language.
Back to top
View user's profile Send private message
revoohc
Tux's lil' helper
Tux's lil' helper


Joined: 12 Oct 2002
Posts: 128

PostPosted: Mon Mar 31, 2003 8:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jimbow
Guru
Guru


Joined: 18 Feb 2003
Posts: 597
Location: Silver City, NM

PostPosted: Mon Mar 31, 2003 8:58 pm    Post subject: Reply with quote

Aha! You are mixing up two different kinds of scripts. Since you started your script with
Code:
#!/bin/sh

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
Code:
#!/sbin/runscript


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
View user's profile Send private message
revoohc
Tux's lil' helper
Tux's lil' helper


Joined: 12 Oct 2002
Posts: 128

PostPosted: Mon Mar 31, 2003 9:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
GamesBond
n00b
n00b


Joined: 15 Mar 2004
Posts: 66
Location: Amsterdam

PostPosted: Wed Apr 07, 2004 6:26 am    Post subject: Reply with quote

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
View user's profile Send private message
tomk
Bodhisattva
Bodhisattva


Joined: 23 Sep 2003
Posts: 7221
Location: Sat in front of my computer

PostPosted: Wed Apr 07, 2004 8:32 am    Post subject: Reply with quote

AFAIK you'll have to change the case switch to start(), stop() and restart() functions.
_________________
Search | Read | Answer | Report | Strip
Back to top
View user's profile Send private message
GamesBond
n00b
n00b


Joined: 15 Mar 2004
Posts: 66
Location: Amsterdam

PostPosted: Wed Apr 07, 2004 10:55 am    Post subject: Reply with quote

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
View user's profile Send private message
tomk
Bodhisattva
Bodhisattva


Joined: 23 Sep 2003
Posts: 7221
Location: Sat in front of my computer

PostPosted: Wed Apr 07, 2004 11:32 am    Post subject: Reply with quote

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
View user's profile Send private message
GamesBond
n00b
n00b


Joined: 15 Mar 2004
Posts: 66
Location: Amsterdam

PostPosted: Thu Apr 08, 2004 7:26 am    Post subject: Reply with quote

It works!!!! Thanks!

Guess the thing about the case command shows why it says n00b below my name :)
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