• 服务管理脚本


    测试后,逻辑通过验证的代码:

    BEEF_PID=1
    MITM_PID=1
    LOG_PID=1
    
    TESTING(){
            if [ $1 -eq 0 ];then
                    echo "SUCCESS"
            else
                    echo "ERROR"
            fi
    }
    
    PID_STATUS(){
            if [ ! -n "$1" ];then
                    echo "is_NULL"
                    return 45
            else
                    echo "not_NULL"
                    return 0
            fi
    }
    
    PID_STATUS $MITM_PID
    num=$?
    if [ $num -eq 0 ];then
            echo "already"
    else
            ls
            TESTING $?
    fi
    

      待修改的脚本

    MITM_PID=$(pgrep -f mitm)
    GET_PID=$(pgrep -f getmac)
    LOG_PID=$(pgrep -f logprocessing)
    TESTING(){
            PID_STATUS=$1
            if [ $PID_STATUS -eq 0 ];then
                    echo "SUCCESS"
            else
                    echo "ERROR"
                    exit 1
            fi
    }
    
    #
    #if [ ! -n "$MITM_PID" ];then
    #       echo "is NULL";
    #else
    #       echo "not NULL";
    #fi
    
    
    for i in {"$MITM_PID","$GET_PID","$LOG_PID"}
    do
        if [ ! -n "$i" ];then
            echo "is NULL";
        else
            echo "not NULL";
        fi
    done
    
    case $1 in
        start)
            #echo $1
            #ruby /usr/share/beef-xss/beef -v
            #true
            TESTING $?
            #mitmdump -s /usr/share/beef-xss/mitm.py -m transparent
            #true
            /bin/sh /root/22.sh
            TESTING $?
            #python3 /home/code/logprocessing.py
            #true
            /bin/sh /root/33.sh
            TESTING $?
            ;;
        stop)
            #echo $1
            #kill -9 ${BEEF_PID}
            true
            TESTING $?
            #kill -9 ${MITM_PID}
            true
            TESTING $?
            #kill -9 ${LOG_PID}
            true
            TESTING $?
            ;;
        reload)
            echo $1
            ;;
        *)
            echo "USAGE:$0{start|stop|reload}"
    esac
    

      

    for i in {"$MITM_PID","$GET_PID","$LOG_PID"}
    do
    	if [ ! -n "$i" ];then
    		echo "is NULL";
    	else
    		echo "not NULL";
    	fi
    done
    

      

  • 相关阅读:
    【leetcode】153. 寻找旋转排序数组中的最小值
    vue下载网络图片
    前端开发项目细节
    如何在手机上预览本地h5页面
    react拖拽添加新组件
    js拖入并复制和拖动改变位置和改变大小
    dva model
    postMessage跨源通信
    react-router
    event.stopPropagation()和event.preventDefault(),return false的区别
  • 原文地址:https://www.cnblogs.com/linuxws/p/11053962.html
Copyright © 2020-2023  润新知