守护脚本

创建日期

这是一个使用dhcp的客户端的守护脚本,用来保持到某个边缘节点网络是通的。这是由于目前软件存在bug,以后或许会修复。
20190707测试可能已经修复了.此脚本不再需要.

#!/bin/bash
supernode='x.x.x.x'
port='9876'
groupname='groupname'
password='password'
testip='10.x.x.x'
interface='n2n1'

#运行守护
while true;do
    die=`ping -c 1 "$testip"|grep '100% packet loss'|wc -l`;
    if [ "$die" = "1" ];then
        #如果已经运行,先杀掉
        pid=`ps aux |grep edge|grep "$interface"|awk '{print $2}'`;
        if [ "$pid" != "" ];then
            kill -9 "$pid";
        fi;
        #启动
        echo "restart"
        edge -d "$interface" -r -a dhcp:0.0.0.0 -c "$groupname" -k "$password" -l "$supernode:$port";
        dhclient "$interface";
    fi;
    echo "is ok";
    if [ "$1" = "1" ];then
        sleep 5;
    else
        break;
    fi;
done;

可以把他保存为run.sh并给予可执行权限
root用户使用run.sh 1来启动守护

文档更新时间: 2019-07-01 05:13   作者:ghostry