squid源码安装的服务启动脚本

#!/bin/bash
# squid     This shell script takes care of starting and stopping
#       Squid Internet Object Cache
#
# chkconfig: - 90 25
# description: Squid - Internet Object Cache. Internet object caching is \
#   a way to store requested Internet objects (i.e., data available \
#   via the HTTP, FTP, and gopher protocols) on a system closer to the \
#   requesting site than to the source. Web browsers can then use the \
#   local Squid cache as a proxy HTTP server, reducing access time as \
#   well as bandwidth consumption.
# pidfile: /var/run/squid.pid
# config: /etc/squid/squid.conf     

PATH=/usr/bin:/sbin:/bin:/usr/sbin
export PATH     

# Source function library.
. /etc/rc.d/init.d/functions     

# Source networking configuration.
. /etc/sysconfig/network     

# don't raise an error if the config file is incomplete
# set defaults instead:
SQUID_OPTS=${SQUID_OPTS:-"-D"}
SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}     

# determine the name of the squid binary
[ -f /usr/local/squid/sbin/squid ] && SQUID=/usr/local/squid/sbin/squid && SQUID_id=squid    

prog="$SQUID"

# determine which one is the cache_swap directory
CACHE_SWAP=`sed -e 's/#.*//g' /usr/local/squid/etc/squid.conf | \
    grep cache_dir |  awk '{ print $3 }'`
[ -z "$CACHE_SWAP" ] && CACHE_SWAP=/usr/local/squid/var/cache     

RETVAL=0    

start() {
        #check if the squid conf file is present
        if [ ! -f /usr/local/squid/etc/squid.conf ]; then
            echo "Configuration file /usr/local/squid/etc/squid.conf missing" 1>&2
            exit 6
        fi
        . /etc/sysconfig/squid     

        # don't raise an error if the config file is incomplete.
        # set defaults instead:
        SQUID_OPTS=${SQUID_OPTS:-"-D"}
        SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
        SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
        if [ -z "$SQUID" ]; then
                echo "Insufficient privilege" 1>&2
                exit 4
        fi
        for adir in $CACHE_SWAP; do
        if [ ! -d $adir/00 ]; then
         echo -n "init_cache_dir $adir... "
         $SQUID -z -F -D >> /usr/local/squid/var/logs/squid.out 2>&1
    fi
    done
    echo -n $"Starting $prog: "
    $SQUID $SQUID_OPTS >> /usr/local/squid/var/logs/squid.out 2>&1
    RETVAL=$?
    if [ $RETVAL -eq 0 ]; then
       timeout=0;
       while : ; do
          [ ! -f /usr/local/squid/var/run/squid.pid ] || break
      if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then
         RETVAL=1
         break
      fi
      sleep 1 && echo -n "."
      timeout=$((timeout+1))
       done
    fi
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SQUID_uid
    [ $RETVAL -eq 0 ] && echo_success
    [ $RETVAL -ne 0 ] && echo_failure
    echo
    return $RETVAL
}     

stop() {
    . /etc/sysconfig/squid
    # don't raise an error if the config file is incomplete.
    # set defaults instead:
    SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
    echo -n  $"Stopping $prog: "
    $SQUID -k check >> /usr/local/squid/var/logs/squid.out 2>&1
    RETVAL=$?
    if [ $RETVAL -eq 0 ] ; then
        $SQUID -k shutdown &
        rm -f /var/lock/subsys/$SQUID_id
    timeout=0
    while : ; do
        [ -f /usr/local/squid/var/run/squid.pid ] || break
        if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
            echo
            return 1
        fi
        sleep 2 && echo -n "."
        timeout=$((timeout+2))
        done
    echo_success
    echo
    else
        echo_failure
    if [ ! -e /var/lock/subsys/$SQUID_id ]; then
        RETVAL=0
    fi
    echo
    fi
    return $RETVAL
}     

reload() {
    . /etc/sysconfig/squid
    # don't raise an error if the config file is incomplete.
    # set defaults instead:
    SQUID_OPTS=${SQUID_OPTS:-"-D"}     

    $SQUID $SQUID_OPTS -k reconfigure
}     

restart() {
    stop
    start
}     

condrestart() {
    [ -e /var/lock/subsys/squid_id ] && restart || :
}     

rhstatus() {
    status $SQUID_id && $SQUID -k check
}     

probe() {
    return 0
}     

case "$1" in
start)
    start
    ;;     

stop)
    stop
    ;;     

reload)
    reload
    ;;     

restart)
    restart
    ;;     

condrestart)
    condrestart
    ;;     

status)
    rhstatus
    ;;     

probe)
    exit 0
    ;;     

*)
    echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
    exit 2
esac     

exit $?

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索timeout
, echo
, squid
, squid error
, local
, Timeout 
RETVAL
squid启动脚本、http服务启动脚本、linux 服务自启动脚本、linux服务启动脚本、windows启动服务脚本,以便于您获取更多的相关知识。

时间: 2024-05-11 10:56:19

squid源码安装的服务启动脚本的相关文章

CentOS6.4下源码安装SVN服务的方法

SVN其实就是Subversion,分为服务器端和客户端.本次折腾是记录在服务器端的安装过程. 系统环境说明如下: 操作系统:        Centos6.4 x86 SVN:             subversion-1.8.0 Apache:          httpd-2.4.6 如开启防火墙,则需添加如下列的规则以放行svn的3690端口 iptables -A INPUT -p tcp --dport 3690 -j ACCEPT iptables save 检查是否安装了低版

Nginx源码安装及调优配置

由于Nginx本身的一些优点,轻量,开源,易用,越来越多的公司使用nginx作为自己公司的web应用服务器,本文详细介绍nginx源码安装的同时并对nginx进行优化配置. Nginx编译前的优化 [root@linuxprobe ~]# wget http://nginx.org/download/nginx-1.10.1.tar.gz [root@linuxprobe ~]# tar xvf nginx-1.10.1.tar.gz -C /usr/local/src/ [root@linux

linux下mysql 5.1.73 源码安装笔记

linux下安装mysql有多种方式,相对而言源码安装速度最快,兼容性也会好些.相反,源码安装更麻烦一些. 第一步,下载和解压安装包: mysql 5.1.73官方下载地址. http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz md5:887f869bcc757957067b9198f707f32f 1 md5sum mysql-5.5.38.tar.gz      #计算md5校验和 2 tar -zxf mysql

CentOS6.8下源码安装MySQL5.6.15

方式一:####################################################### 一.环境介绍 操作系统:CentOS6.8  yum163源:http://mirrors.163.com/.help/CentOS6-Base-163.repo   二.安装软件,源码安装方式 1.mysql 安装包mysql-5.6.15.tar.gz cmake-2.8.4.tar.gz mysql下载地址:http://dev.mysql.com/downloads/m

apache的源码安装详细过程全纪录_Linux

最近要开始学习nagios监控方面的知识了,但是nagios与apache结合的比较紧密,所以本篇文章就先把apache的源码安装学习下. 我们现在分以下步骤进行安装apache: 1. 安装编译环境 2. 卸载原有apache 3. 下载解压源码包 4. 安装apache 5. 测试apache 6. 查看apache安装生成的目录 7. 查看apache的配置文件 8. apache加入系统服务 一.安装编译环境 在安装apache之前,我们需要安装编译apache时所需要的相关软件包,如下

CentOS 6.3/6.4 Minimal 源码安装 MySQL 5.6.10

CentOS MySQL 5.6正式版发布了,相对于5.5版本作出了不少改进,其源码安装配置方式也有所变化,本文根据实际操作,不断尝试,精确还原了安装的具体步骤. 环境:CentOS 6.3/6.4 最小化缺省安装,配置好网卡. 安装MySQL前,确认Internet连接正常,以便下载安装文件. 先使用 yum -y update 指令升级系统到最新版本. 本安装将MySQL的数据文件与执行文件分离,如果你打算设置到不同的路径,注意修改对应的执行命令和数据库初始化脚本. # 修改防火墙设置,打开

【原创】源码安装 Atlas-1.0.3 遇到的问题以及解决办法

      今天 360 团队在 GitHub 上发布了 Atlas-2.0.0 版本.可喜可贺,希望 360 的开发团队能够一直保持下去.借此时机,将之前对 Atlas-1.0.3 的一些理解和使用,以博客形式总结一下.本文主要讲一下在源码安装和刚开始运行 Atlas-1.0.3 时可能遇到的问题.  =====  按照安装说明,Atlas-1.0.3 的安装有如下依赖项: glib(2.32.x).libevent(1.4以上).Lua(5.1.x).OpenSSL(0.9.8以上)  基本

LNMP源码安装及phpwind应用

lnmp =linux+nginx+mysql+php 以前我们做过LAMP环境的搭建,而对于nginx而言,其性能相对apache提高了很多, 实验借助于nginx来LNMP环境, 环境搭建分三步:mysql绿色包安装,php源码包安装,nginx源码包安装 最后phpwind应用 一.安装mysql 1.[root@localhost ]# tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local [root@localhost lo

CentOS6.4 LVS rpm包安装及源码安装

RPM包安装 系统平台 CentOS 6.4 x64 minimal KERNEL 2.6.32-358.23.2.el6.x86_64 LVS版本 ipvsadm-1.25-10.el6.x86_64 KEEPALIVED 版本 keepalived-1.2.7-3.el6.x86_64 centos minimal 安装好后 开始搭建 LVS 服务器,关于 yum 包的配置安装我之前提过,略过 有两种方式安装 LVS 所需要的软件: 源码 和 YUM 源码 wget http://www.l