Chinaunix首页 | 论坛 | 博客
  • 博客访问: 177637
  • 博文数量: 134
  • 博客积分: 1215
  • 博客等级: 少尉
  • 技术积分: 564
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-20 11:04
文章分类

全部博文(134)

文章存档

2017年(88)

2012年(46)

我的朋友

分类: 系统运维

2017-04-14 10:29:21

原文地址:pureftpd自启动脚本 作者:鸟哥のlinux

配置完pureftpd后,启动它需要写全路径,如果想像启动系统服务那样 service  服务  start  等,下面的脚本就能够实现!
#!/bin/sh
#
# ScriptName: /etc/init.d/pureftpd
# chkconfig: - 60 50
# description: pureftpd is a ftp daemon, which is the program \
# that answers incoming ftp service requests.
# processname: pureftpd
#
# Author : cnscn
# Time : 2006-04-18 09:30
#

#tput func
funcTput()
{
tput init
for args
do
case "$args" in
green_black)
echo -e -n "\033[;32m"
;;
red_black)
echo -e -n "\033[;31m"
;;
endtput)
tput sgr0
esac
done
}

case "$1" in
start)
ps aux | grep pure-ftp | grep -v grep > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo -n "Pureftpd has already been running ... "
funcTput red_black
echo "[failed]"
funcTput endtput
exit 1
fi
echo -n "start pureftpd.... "
/usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf > /dev/null 2>&1
if [ $? -eq 0 ] ; then
funcTput green_black
echo " [OK]"
funcTput endtput
else
funcTput red_black
echo " [Failed] ";
funcTput endtput
fi
;;
stop)
ps aux | grep pure-ftp | grep -v grep > /dev/null 2>&1
if [ $? -eq 1 ]
then
echo -n "Pureftpd has not been runned now ... "
funcTput red_black
echo "[failed]"
funcTput endtput
exit 1
fi
echo -n "Stop pureftpd... "
killall pure-ftpd > /dev/null 2>&1
if [ $? -eq 0 ] ; then
funcTput green_black
echo " [OK]"
funcTput endtput
else
funcTput red_black
echo " [Failed] ";
funcTput endtput
fi
;;
restart)
ps aux | grep pure-ftp | grep -v grep > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo -n "Stop pureftpd... "
killall pure-ftpd > /dev/null 2>&1
if [ $? -eq 0 ] ; then
funcTput green_black
echo " [OK]"
funcTput endtput
else
funcTput red_black
echo " [Failed] ";
funcTput endtput
fi
fi

echo -n "start pureftpd.... "
/usr/local/pureftpd/bin/pure-config.pl /usr/local/pureftpd/etc/pure-ftpd.conf >/dev/null 2>&1
if [ $? -eq 0 ] ; then
funcTput green_black
echo " [OK]"
funcTput endtput
else
funcTput red_black
echo " [Failed] ";
funcTput endtput
fi
;;
*)
echo "Usage: `basename $0` {start | stop | restart}"
;;
esac
exit 0
阅读(964) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~