1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add backup to VPS interface and simplify IPv6 enable/disable

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-10-09 18:40:05 +02:00
parent e9556c107c
commit 88706de9b2
9 changed files with 142 additions and 116 deletions

View file

@ -19,6 +19,8 @@ function index()
entry({"admin", "system", "openmptcprouter", "settings"}, template("openmptcprouter/settings"), _("Advanced Settings"), 3).leaf = true
entry({"admin", "system", "openmptcprouter", "settings_add"}, post("settings_add")).leaf = true
entry({"admin", "system", "openmptcprouter", "update_vps"}, post("update_vps")).leaf = true
entry({"admin", "system", "openmptcprouter", "backup"}, template("openmptcprouter/backup"), _("Backup on server"), 3).leaf = true
entry({"admin", "system", "openmptcprouter", "backupgr"}, post("backupgr")).leaf = true
entry({"admin", "system", "openmptcprouter", "debug"}, template("openmptcprouter/debug"), _("Show all settings"), 5).leaf = true
end
@ -263,9 +265,10 @@ function wizard_add()
ucic:commit("network")
-- Enable/disable IPv6
local disable_ipv6 = luci.http.formvalue("enableipv6") or "1"
local ut = require "luci.util"
local result = ut.ubus("openmptcprouter", "set_ipv6_state", { disable_ipv6 = disable_ipv6 })
local disableipv6 = luci.http.formvalue("enableipv6") or "1"
ucic:set("openmptcprouter","settings","disable_ipv6",disable_ipv6)
--local ut = require "luci.util"
--local result = ut.ubus("openmptcprouter", "set_ipv6_state", { disable_ipv6 = disableipv6 })
-- Get VPN set by default
local default_vpn = luci.http.formvalue("default_vpn") or "glorytun_tcp"
@ -699,6 +702,17 @@ function update_vps()
end
end
function backupgr()
local get_backup = luci.http.formvalue("restore") or ""
if get_backup ~= "" then
luci.sys.call("/etc/init.d/openmptcprouter-vps backup_get >/dev/null 2>/dev/null")
end
local send_backup = luci.http.formvalue("save") or ""
if send_backup ~= "" then
luci.sys.call("/etc/init.d/openmptcprouter-vps backup_send >/dev/null 2>/dev/null")
end
end
function get_device(interface)
local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
return dump['l3_device']

View file

@ -0,0 +1,35 @@
<%+header%>
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
<form class="inline" method="post" action="<%=url('admin/system/openmptcprouter/backupgr')%>">
<div class="cbi-map">
<h2 name="content"><%:Backup on server%></h2>
<fieldset class="cbi-section" id="networks">
<%
uci:foreach("openmptcprouter","server", function(s)
servername = s[".name"]
%>
<h3><%=servername%></h3>
<%
if luci.model.uci.cursor():get("openmptcprouter",servername,"lastbackup") ~= "" then
%>
<div class="cbi-section-node">
<%:Last available backup on server:%> <%=os.date('%d-%b-%Y', luci.model.uci.cursor():get("openmptcprouter",servername,"lastbackup"))%>
</div>
<input type="hidden" name="token" value="<%=token%>" />
<input type="submit" class="cbi-button cbi-button-action important" name="restore" value="<%:Restore backup%>"/>
<input type="submit" class="cbi-button cbi-button-action important" name="save" value="<%:Send backup%>"/>
<% else %>
<div class="cbi-section-node">
<%:No available backup on server.%>
</div>
<input type="hidden" name="token" value="<%=token%>" />
<input type="submit" class="cbi-button cbi-button-action important" name="save" value="<%:Send backup%>"/>
<% end %>
<%
end)
%>
</fieldset>
</div>
</form>
<%+footer%>

View file

@ -1,12 +1,10 @@
<%+header%>
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
<form class="inline" method="post" action="<%=url('admin/system/openmptcprouter/update_vps')%>">
<div class="cbi-map">
<h2 name="content"><%:All router settings%></h2>
<div class="cbi-section">
<pre><%=luci.sys.exec("uci show")%></pre>
</div>
<div class="cbi-map">
<h2 name="content"><%:All router settings%></h2>
<div class="cbi-section">
<pre><%=luci.sys.exec("uci show")%></pre>
</div>
</form>
</div>
<%+footer%>