#!/bin/bash #chkconfig: 2345 90 25 #config: /etc/squid.conf #pidfile: /usr/local/squid/var/run/squid.pid #Description: Squid - Internet Object Cache

PID="/usr/local/squid/var/run/squid.pid" CONF="/etc/squid.conf" CMD="/usr/local/squid/sbin/squid"

case "$1" in start) netstat -utpln | grep squid &>/dev/null if [ $? -eq 0 ] then echo "Squid is running" else $CMD fi ;; stop) $CMD -k kill &>/dev/null rm -rf $PID &>/dev/null ;; status) [ -f $PID ] &>/dev/null if [ $? -eq 0 ] then netstat -utpln | grep squid else echo "Squid is not running" fi ;; restart) $0 stop &>/dev/null echo "正在关闭Squid..." $0 start &>/dev/null echo "正在启动Squid..." ;; reload) $CMD -k reconfigure ;; check) $CMD -k parse ;; *) echo "用法:{ start | stop | restart | reload | check | status}" ;; esac