Exemplo n.º 1
0
def check_handler(data):
    action = data["action"]
    jsonhelper = utils.JsonHelper()
    if action == "checkwifi":
        rtcode, output = utils.execmdcommunicate("./shell/makeap.sh check")
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "check3g":
        rtcode, output = utils.execmdcommunicate("./shell/ztedial.sh check")
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
Exemplo n.º 2
0
def rclocal_handler(data):
    action = data["action"]
    jsonhelper = utils.JsonHelper()
    if action == "get":
        rtcode1, output1 = utils.execmdcommunicate("cat /etc/rc.local")
        jsonhelper.addkeyvalue("rclocal", output1)
        jsonhelper.setreturncode("0", "success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "refresh_rclocal":
        rclocal = data["rclocal"]
        rtcode, output = utils.execmdcommunicate("echo '" + rclocal + "' > /etc/rc.local")
        jsonhelper.setreturncode(rtcode, output)
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
Exemplo n.º 3
0
def ssh_pubkey_handler(data):
    action = data["action"]
    jsonhelper = utils.JsonHelper()
    if action == "get":
        rtcode1, output1 = utils.execmdcommunicate("cat /root/.ssh/id_rsa.pub")
        jsonhelper.addkeyvalue("pubkey", output1)
        rtcode2, output2 = utils.execmdcommunicate("cat /root/.ssh/authorized_keys")
        jsonhelper.addkeyvalue("authorized_keys", output2)
        jsonhelper.setreturncode("0", "success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "remake":
        utils.execmd("rm -rf /root/.ssh/id_rsa*")
        utils.execmd("ssh-keygen  -t rsa -f /root/.ssh/id_rsa  -N ''")
        rtcode, output = utils.execmdcommunicate("cat /root/.ssh/id_rsa.pub")
        jsonhelper.setreturncode(rtcode, output)
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "set_authorized_keys":
        authorized_keys = data["authorized_keys"]
        rtcode, output = utils.execmdcommunicate("echo '" + authorized_keys + "' > /root/.ssh/authorized_keys")
        jsonhelper.setreturncode(rtcode, output)
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
Exemplo n.º 4
0
def hostapd_handler(data):
    action = data["action"]
    jsonhelper = utils.JsonHelper()
    if action == "get":
        rtcode1, output1 = utils.execmdcommunicate("cat /etc/hostapd/hostapd.conf")
        jsonhelper.addkeyvalue("hostapd", output1)
        jsonhelper.setreturncode("0", "success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "refresh_hostapd":
        rclocal = data["hostapd"]
        f1 = open("/etc/hostapd/hostapd.conf", "w+")
        f1.write(rclocal)
        jsonhelper.setreturncode("0", "success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
Exemplo n.º 5
0
def zte3g_handler(action):
    jsonhelper = utils.JsonHelper()
    if action == "turnon":
        rtcode = utils.execmd("./shell/ztedial.sh start")
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "turnoff":
        rtcode = utils.execmd("./shell/ztedial.sh stop")
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()
    elif action == "check":
        rtcode, output = utils.execmdcommunicate("./shell/ztedial.sh check")
        jsonhelper.setreturncode(rtcode, "exec success")
        print(jsonhelper.getjsonstring())
        sys.stdout.flush()