Exemple #1
0
def execute_action():
    action = request.form["action"]
    if action == "reboot":
        pi_reboot()
    elif action == "shutdown":
        pi_shutdown()
    elif action == "start_vpn":
        start_vpn()
        flash("VPN Started!", "notice")
    elif action == "stop_vpn":
        stop_vpn()
        flash("VPN Stopped!", "notice")
    elif action == "restart_vpn":
        restart_vpn()
        flash("VPN Restarted!", "notice")
    elif action == "ssh_service":
        start_ssh_service()
        flash("SSH Service Started! It will be turned off on reboot.")
    elif action == "update_client":
        update_client()
        flash("Client will reboot... please reload this page in 1 minute.")
    else:
        form = initialSetupForm()
        flash("Error! Invalid Action!", "error")
        
    return redirect(url_for("status"))
def execute_action():
    action = request.form["action"]
    if action == "reboot":
        pi_reboot()
    elif action == "shutdown":
        pi_shutdown()
    elif action == "start_vpn":
        start_vpn()
        flash("VPN Started!", "notice")
    elif action == "stop_vpn":
        stop_vpn()
        flash("VPN Stopped!", "notice")
    elif action == "restart_vpn":
        restart_vpn()
        flash("VPN Restarted!", "notice")
    elif action == "ssh_service":
        start_ssh_service()
        flash("SSH Service Started! It will be turned off on reboot.")
    elif action == "update_client":
        update_client()
        flash("Client will reboot... please reload this page in 1 minute.")
    else:
        form = initialSetupForm()
        flash("Error! Invalid Action!", "error")
        
    return redirect(url_for("status"))
Exemple #3
0
def api_vpn_actions():
    if request.method == "POST":
        if request.headers['Content-Type'] == 'application/json':
            action = request.json["action"]
            if action == "start_vpn":
                if start_vpn():
                    return "VPN service started, VPN is ESTABLISHED"
                else:
                    return "VPN service started, VPN is NOT ESTABLISHED"
                
            elif action == "stop_vpn":
                stop_vpn()
                return "VPN service stopped, VPN is NOT ESTABLISHED"
            
            elif action == "restart_vpn":
                if restart_vpn():
                    return "VPN service restarted, VPN is ESTABLISHED"
                else:
                    return "VPN service restarted, VPN is NOT ESTABLISHED"
            else:
                return "Error! Invalid Action!"

        else:
            return "415 Unsupported Media Type - Use application/json"
    else:
        return "Only POST method is supported. Refer to the API Documentation"
def api_vpn_actions():
    if(request.method == "POST"):
        if(request.headers['Content-Type'] == 'application/json'):
            action = request.json["action"]
            if(action == "start_vpn"):
                if(start_vpn()):
                    return "VPN service started, VPN is ESTABLISHED"
                else:
                    return "VPN service started, VPN is NOT ESTABLISHED"
                
            elif(action == "stop_vpn"):
                stop_vpn()
                return "VPN service stopped, VPN is NOT ESTABLISHED"
            
            elif(action == "restart_vpn"):
                if(restart_vpn()):
                    return "VPN service restarted, VPN is ESTABLISHED"
                else:
                    return "VPN service restarted, VPN is NOT ESTABLISHED"
            else:
                return "Error! Invalid Action!"

        else:
            return "415 Unsupported Media Type - Use application/json"
    else:
        return "Only POST method is supported. Refer to the API Documentation"
def execute_action():
    action = request.form["action"]
    if(action == "reboot"):
        pi_reboot()
    elif(action == "shutdown"):
        pi_shutdown()
    elif(action == "start_vpn"):
        start_vpn()
        flash("VPN Started!", "notice")
    elif(action == "stop_vpn"):
        stop_vpn()
        flash("VPN Stopped!", "notice")
    elif(action == "restart_vpn"):
        restart_vpn()
        flash("VPN Restarted!", "notice")
    elif(action == "ssh_service"):
        start_ssh_service()
        flash("SSH Service Started! It will be turned off on reboot.")
    else:
        form = initialSetupForm()
        flash("Error! Invalid Action!", "error")
        
    return redirect(url_for("status"))