起動時にDNSテストをスキップする"-D"が指定されていることに注意。
/etc/init.d/squid:
#!/bin/sh
# chkconfig: 345 98 20
# description: squid server
# processname: squid
# description for chkconfig: 345 98 20
# 345: run levels
# 98: priority to start
# 20: priority to stop
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/squid
NAME=squid
DESC="squid server"
PIDFILE=/var/run/$NAME.pid
test -x $DAEMON || exit 0
if [ -f /etc/default/$NAME ]; then
. /etc/default/$NAME
fi
DAEMON_OPTS="-D"
start_proc() {
$DAEMON $DAEMON_OPTS
if [ "$?" -eq 0 ]
then
pidof $DAEMON > $PIDFILE
return 0
fi
return 1
}
stop_proc() {
kill -9 `cat $PIDFILE 2>/dev/null`
[ "$?" -ne 0 ] && return 1
rm -f $PIDFILE
return 0
}
status_proc() {
killall -0 $DAEMON 2>/dev/null
return "$?"
}
case "$1" in
start)
echo "Starting ${DESC}"
start_proc
[ "$?" -eq 0 ] || echo "failed"
;;
stop)
echo "Shutting down ${DESC}"
stop_proc
[ "$?" -eq 0 ] || echo "failed"
;;
restart|force-reload)
echo "Restarting ${DESC}"
stop_proc
if [ $? -ne 0 ]; then
failure ; echo ; exit 0
fi
sleep 1
start_proc
[ "$?" -eq 0 ] || echo "failed"
;;
status)
status_proc
[ $? -eq 0 ] && echo "$DESC is alive" || echo "$DESC is dead"
echo
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0
0 件のコメント:
コメントを投稿