zoukankan      html  css  js  c++  java
  • rsyncd启动脚本

    #!/bin/bash
    ##############################################################
    # File Name: 05-05.sh
    # Version: V1.0
    # Author: guojintao
    # Organization: https://www.cnblogs.com/guojintao/
    # Created Time : 2018-12-12 23:25:55
    # Description:
    ##############################################################
    . /etc/init.d/functions
    RETVAL=0
    prog="rsyncd"
    rsyncd=/usr/bin/rsync
    pid_file=/var/run/rsyncd.pid
    lockfile=/var/lock/subsys/$prog
    conf_file=/etc/rsyncd.conf
    
    if [ -f $conf_file ];then
        grep "pid file=$pid_file" $conf_file |grep -v "^#" >/dev/null || { 
         action "pid file undefined in $conf_file" /bin/false
         exit 2 
        }   
    else
        action "$conf_file not exist" /bin/false
        exit 3
    fi
    start(){
        echo -n $"Starting $prog: "
        rsync --daemon && success || failure
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch $lockfile
        echo
        return $RETVAL
    }
    stop(){
        echo -n $"Stopping $prog: "
        killproc -p $pid_file $rsyncd
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f $lockfile
        echo
    }
    rh_status() {
            status -p $pid_file rsyncd
    }
    rh_status_q() {
            rh_status >/dev/null 2>&1
    }
    case "$1" in 
        "start")
            rh_status_q && exit 0
            start
            ;;
        "stop")
            if ! rh_status_q; then
                rm -f $lockfile
                exit 0
            fi
            stop
            ;;
        "status")
            rh_status
            RETVAL=$?
            if [ $RETVAL -eq 3 -a -f $lockfile ] ; then
                RETVAL=2
            fi
            ;;
        "restart")
            stop
            start
            ;;
        *)
            echo "Usage: $0 {start|stop|restart}"
            RETVAL=2
    esac
    exit $RETVAL
  • 相关阅读:
    三 面向对象之绑定方法与非绑定方法
    二 面向对象三大特性
    一 面向对象定义
    面向对象路线
    七 递归与二分法、匿名函数、内置函数
    线程同步测试
    Oracle12c的安装
    git教程:添加远程仓库
    git教程:远程仓库
    git教程:删除文件
  • 原文地址:https://www.cnblogs.com/guojintao/p/10116536.html
Copyright © 2011-2022 走看看