#!/bin/bash # chkconfig: 2345 92 25 # description: Squid Service Control Script CMD="/usr/local/squid/sbin/squid" PID="/usr/local/squid/var/run/squid.pid" CONF="/etc/squid.conf" case "$1" in start) netstat -ntap | grep squid &> /dev/null if [ $? -eq 0 ];then echo "squid is running" else echo "正在啓動 squid" $CMD fi ;; stop) $CMD -k kill &> /dev/null rm -rf $PID &> /dev/null ;; status) [ -f $PID ] &>/dev/null if [ $? -eq 0 ] then netstat -ntap | 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 "Usage: $0 {start|stop|restart|reload|check|status}" exit 1 esac