分类:
2009-02-05 10:01:30
|
启动脚本都放置在/etc/init.d目录下
主要有:start ,stop ,restart ,status 其它部份可以跟据需求增加
#!/bin/bash
#要chkconfig必须要这两行,就是必须要这个注释
chkconfig:- 60 50
# chkconfig: - 60 50
# description: Vsftpd is a ftp daemon, which is the program \
# that answers incoming ftp service requests.
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
RETVAL=0
prog="vsftpd-pam"
# 主要是写start 和stop两块,其它的部分不用管
start() {
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 1
[ -x /usr/local/sbin/vsftpd-pam ] || exit 1
if [ -x /usr/local/sbin/vsftpd-pam ];
then
CONFS=`ls /etc/vsftpd-pam.conf 2>/dev/null`
[ -z $CONFS ] && exit 6
for i in $CONFS; do
echo -n $"Starting $prog for $site: "
daemon /usr/Local/sbin/vsftpd-pam $i &
RETVAL=$?
#这里的返回值为0时是正常的,错误的值为127
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
done
else
RETVAL=1
fi
return $RETVAL
}
stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
RETVAL=$?
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"