zoukankan      html  css  js  c++  java
  • 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: - 60 50
    # 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=0
    prog="vsftpd"
    
    start() {
            # Start daemons.
    
        # Check that networking is up.
        [ ${NETWORKING} = "no" ] && exit 1
    
        [ -x /usr/sbin/vsftpd ] || exit 1
    
            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" != "0" ]; then
                    pgrp=`ps -p $chld -o pgrp= | sed s/^ *//`
                    if [ "$pgrp" = "$chld" ]; then
                        # chld is group to kill
                        kill -9 -$chld
                    else
                        # chld to kill
                        kill -9 $chld
                    fi
                fi
            fi
        done
    }
    
    stop() {
            # Stop daemons.
            echo -n $"Shutting down $prog: "
            killproc $prog
            RETVAL=$?
            kill_rest_children
            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|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 1
    esac
    
    exit $RETVAL
  • 相关阅读:
    解决PHP处理图片时内存占用过高问题
    destoon下动态链接301到伪静态(ngnix)
    微信小程序转百度小程序代码
    解决:本图片来自微信公众号,未经许可,不能引用 问题
    MP4文件批量转码成MP3
    dt框架自定义url规则
    织梦后台基本参数无法保存解决办法
    关于tomcat启动没有进行编译或者编译报错的问题
    zf-安徽桐城关于(资源中心-数据录入)上传文件后没有进行处理Excel文件的原因
    zf-关于平台的用户名密码的设置
  • 原文地址:https://www.cnblogs.com/wpjamer/p/6973752.html
Copyright © 2011-2022 走看看