Re: [squid-users] squid can not automatically run when system boot

From: Joost de Heer <sanguis@dont-contact.us>
Date: Tue, 5 Sep 2006 16:34:06 +0200 (CEST)

Adrian Chadd wrote:
> On Tue, Sep 05, 2006, wangzicai wrote:
>> Thanks Adrian Chadd
>> The squid is not the version shipped with the system.
>> I installed it by my self.
>> But I do not to know how to do "created the relevant symlinks"
>> Could you tell me hou to do.
>
> I -think- the magic command under Redhat is 'chkconfig'.
> You'll need to find a SYSV init script that starts squid from
> somewhere and put it into /etc/init.d/ first.
>
> Could anyone more redhat-cluey point out where an init script for
> squid is? I always spend the two minutes writing it when I need one :)

I use the following script. Place in /etc/init.d, chmod 755, 'chkconfig
--add squid' and 'chkconfig --level 2345 squid on'. Provided as is, if
this script reformats your drive, it's your own fault for not checking
what it does properly, or what the abovementioned commands do.

#!/bin/bash
#
# chkconfig: - 85 15
# description: Squid
# processname: squid
# pidfile: /opt/squid/2.5.13/var/logs/squid.pid
# config: /opt/squid/2.5.13/etc/squid.conf

. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/squid ]; then
        . /etc/sysconfig/squid
fi

INITLOG_ARGS=""

SQUID_HOME=/opt/squid/2.5.13
squid=${SQUID_HOME}/sbin/squid
prog=squid
RETVAL=0
OPTIONS="-D"

ulimit -Sn 8192

start()
{
        echo -n $"Starting $prog: "
        daemon $squid $OPTIONS
        RETVAL=$?
        echo
# [ $RETVAL = 0 ] && touch /var/lock/subsys/squid
        return $RETVAL
}

stop()
{
        echo -n $"Stopping $prog: "
        $squid -k shutdown
        RETVAL=$?
        echo
# [ $RETVAL = 0 ] && rm -f /var/log/subsys/squid
/opt/squid-master/var/logs/squid.pid
}

reload()
{
        echo -n $"Reloading $prog: "
        $squid -k reconfigure
        RETVAL=$?
        echo
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        status)
                status $squid
                RETVAL=$?
                ;;
        restart)
                stop
                start
                ;;
        condrestart)
                if [ -f /opt/squid-master/var/logs/squid.pid ]; then
                        stop
                        start
                fi
                ;;
        reload)
                reload
                ;;
        *)
                echo $"Usage: $prog
{start|stop|restart|condrestart|reload|status}"
                exit 1
esac

exit $RETVAL
Received on Tue Sep 05 2006 - 08:34:09 MDT

This archive was generated by hypermail pre-2.1.9 : Sun Oct 01 2006 - 12:00:03 MDT