vsftp管理脚本(CentOS6用)
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: vsftpd
# Required-Start: $local_fs $network $named $remote_fs $syslog
# Required-Stop: $local_fs $network $named $remote_fs $syslog
# Short-Description: Very Secure Ftp Daemon
# Description: vsftpd is a Very Secure FTP daemon. It was written completely from
# scratch
### END INIT INFO # vsftpd This shell script takes care of starting and stopping
# standalone vsftpd.
#
# chkconfig: -
# description: Vsftpd is a ftp daemon, which is the program \
# that answers incoming ftp service requests.
# processname: vsftpd
# config: /etc/vsftpd/vsftpd.conf # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network RETVAL=
prog="vsftpd" start() {
# Start daemons. # Check that networking is up.
[ ${NETWORKING} = "no" ] && exit [ -x /usr/sbin/vsftpd ] || exit if [ -d /etc/vsftpd ] ; then
CONFS=`ls /etc/vsftpd/*.conf 2>/dev/null`
[ -z "$CONFS" ] && exit 6
PROC_FAILED=0
for i in $CONFS; do
site=`basename $i .conf`
echo -n $"Starting $prog for $site: "
daemon /usr/sbin/vsftpd $i
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] && [ ! -f /var/lock/subsys/$prog ]; then
touch /var/lock/subsys/$prog
elif [ $RETVAL -ne 0 ]; then
ps -FC vsftpd | grep "$i" > /dev/null
RETVAL=$?
if [ $PROC_FAILED -eq 0 ] && [ $RETVAL -ne 0 ]; then
PROC_FAILED=1
fi
fi
done
if [ $RETVAL -eq 0 ] && [ $PROC_FAILED -ne 0 ]; then
RETVAL=1
fi
else
RETVAL=1
fi
return $RETVAL
} kill_rest_children() {
# all vsftpd processes their parent is init
for chld in `pgrep -P 1 '^vsftpd$'`; do
if [ -n $chld ]; then
puid=`ps -p $chld -o uid= | sed s/^\ *//`
# process UID isn't root - children to kill
if [ "$puid" != "" ]; then
pgrp=`ps -p $chld -o pgrp= | sed s/^\ *//`
if [ "$pgrp" = "$chld" ]; then
# chld is group to kill
kill - -$chld
else
# chld to kill
kill - $chld
fi
fi
fi
done
} stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc $prog
RETVAL=$?
kill_rest_children
echo
[ $RETVAL -eq ] && 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|try-restart|force-reload)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
RETVAL=$?
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
exit
esac exit $RETVAL
vsftp管理脚本(CentOS6用)的更多相关文章
- 如何写SysV服务管理脚本
本文目录: 1.1 SysV脚本的特性1.2 SysV脚本要具备的能力1.3 start函数分析1.4 stop函数分析1.5 reload函数分析1.6 status.restart.force-r ...
- [转贴]systemd 编写服务管理脚本
[转贴]sparkdev大神的博客, 关于 systemd的配置文件的 介绍, 自己之前二进制安装 k8s 时 超过一个 service文件 但是当时不明不白的. 现在再学习一下大神的文章 的确牛B ...
- Ubuntu操作系统编写zabbix的启动管理脚本
Ubuntu操作系统编写zabbix的启动管理脚本 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.修改zabbix的pid存放路径 1>.创建存放zabbix的pid目录 ...
- systemd 编写服务管理脚本
我们运行 linux 服务器的主要目的是通过运行程序提供服务,比如 mysql.web server等.因此管理 linux 服务器主要工作就是配置并管理上面运行的各种服务程序.在 linux 系统中 ...
- 大数据项目之_15_帮助文档_NTP 配置时间服务器+Linux 集群服务群起脚本+CentOS6.8 升级到 python 到 2.7
一.NTP 配置时间服务器1.1.检查当前系统时区1.2.同步时间1.3.检查软件包1.4.修改 ntp 配置文件1.5.重启 ntp 服务1.6.设置定时同步任务二.Linux 集群服务群起脚本2. ...
- systemd 编写服务管理脚本---学习
转载:https://www.cnblogs.com/sparkdev/p/8521812.html 我们运行 linux 服务器的主要目的是通过运行程序提供服务,比如 mysql.web serve ...
- Memcache 服务管理脚本
自定义脚本将memcached作为系统服务启动以及开机启动. 一.编写脚本 在/etc/init.d/目录下新建一个脚本,名称为:memcached.内容如下: vi /etc/init.d/memc ...
- linux 程序启动与停止管理脚本
公司接了一个第三方的系统,基于linux写的几个程序,一共有9个部件,第三方没有给脚本,每次启动或停止都得一个一个手工去停止或修改.......,这里稍微鄙视下. 没办法,求人还不如自己动手写, 需求 ...
- 编写shell管理脚本(二)
8.1 先测试“/etc/vsftpd”.“/etc/hosts”是否为目录,并通过“$?”变量查看返回状态值,据此判断测试结果.[root@localhost ~]# [ -d /etc/vsft ...
随机推荐
- Boosting
Boosting is a greedy alogrithm. The alogrithm works by applying the weak learner sequentially to wei ...
- Json:前台对象数组传到后台解析
本文转自:http://blog.csdn.net/kymegg/article/details/50964581 方法:使用JsonArray进行解析 步骤: 一.引入一系列JAR包 要使程序便于解 ...
- TOYS
TOYS Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a ...
- 解决nginx重启“var/run/nginx/nginx.pid" no such file or directory问题
重启虚拟机后,再次重启nginx会报错“/var/run/nginx/nginx.pid” no such file or directory. 方法一(已试过可行): 到/var/run下看没有ng ...
- 消费Restful的web服务(三)
构架工程 创建一个springboot工程,去消费RESTFUL的服务.这个服务是 http:///gturnquist-quoters.cfapps.io/api/random ,它会随机返回Jso ...
- Redis在linux环境下的安装和部署
官网:http://redis.io windows版本下载地址https://github.com/MicrosoftArchive/redis/releases 1Redis建议 ...
- bash 调试
bashdb test.sh step edit visual 跳到那一行 R restart http://www.ibm.com/developerworks/cn/linux/l-cn-she ...
- 函数后面跟throw
1.函数后面跟throw(),表示该函数不会抛出异常 2.函数后面跟throw(...),表示该函数可能会抛出任何形式的异常 3.函数后面跟throw(int),表示该函数只抛出int类型的异常
- 逆袭之旅DAY16.东软实训.Oracle.匿名块
2018-07-1216:41:19 六.匿名块 .定义匿名块: declare 定义部分: ---可选部分 begin 执行部分: ---必选部分 exception 异常处理部分: ---可选部分 ...
- centos6.5 安装php-5.6.31
1 从PHP官网下载所需要的PHP版本 下载地址: http://php.net/get/php-5.6.31.tar.gz/from/a/mirror 把下载好的文件上传到服务器 2 安装PHP ...