mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add option to enable/disable vnstat backup
This commit is contained in:
parent
e06a8c4fcf
commit
d4b0cd82e6
3 changed files with 32 additions and 6 deletions
|
@ -554,6 +554,11 @@ function settings_add()
|
|||
ucic:set("openmptcprouter","settings","external_check",externalcheck)
|
||||
ucic:commit("openmptcprouter")
|
||||
|
||||
-- Enable/disable external check
|
||||
local savevnstat = luci.http.formvalue("savevnstat") or "0"
|
||||
luci.sys.exec("uci -q set vnstat.@vnstat[0].backup=%s" % savevnstat)
|
||||
ucic:commit("openmptcprouter")
|
||||
|
||||
-- Enable/disable fast open
|
||||
local fastopen = luci.http.formvalue("disablefastopen") or "0"
|
||||
ucic:foreach("shadowsocks-libev", "ss_redir", function (section)
|
||||
|
|
|
@ -157,6 +157,16 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Save vnstats stats%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input type="checkbox" name="savevnstat" class="cbi-input-checkbox" value="0" <% if luci.sys.exec("uci -q get vnstat.@vnstat[0].backup") == "1" then %>checked<% end %>>
|
||||
<br />
|
||||
<div class="cbi-value-description">
|
||||
<%:Save vnstats statistics on disk%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Master interface selection%></label>
|
||||
<div class="cbi-value-field">
|
||||
|
|
|
@ -16,13 +16,24 @@ vnstat_option() {
|
|||
BACKUP_FILE=/etc/vnstat_backup.tar.gz
|
||||
LOGGER_TAG=vnstat_backup
|
||||
VNSTAT_DIR="$(vnstat_option DatabaseDir)"
|
||||
|
||||
|
||||
_chk_omrquota() {
|
||||
config_get enabled $1 enabled
|
||||
[ "$enabled" = "1" ] && backup="true"
|
||||
}
|
||||
|
||||
backup_database() {
|
||||
if [ ! -d $VNSTAT_DIR ]; then
|
||||
logger -t $LOGGER_TAG -p err "cannot backup, data directory $VNSTAT_DIR does not exist (yet)"
|
||||
else
|
||||
logger -t $LOGGER_TAG -p info "backing up database"
|
||||
/bin/tar -zcf $BACKUP_FILE -C $VNSTAT_DIR .
|
||||
backup="false"
|
||||
config_load omr-quota
|
||||
config_foreach _chk_omrquota interface
|
||||
[ "$(uci -q get vnstat.@vnstat[0].backup)" = "1" ] && backup="true"
|
||||
if [ "$backup" = "true" ]; then
|
||||
if [ ! -d $VNSTAT_DIR ]; then
|
||||
logger -t $LOGGER_TAG -p err "cannot backup, data directory $VNSTAT_DIR does not exist (yet)"
|
||||
else
|
||||
logger -t $LOGGER_TAG -p info "backing up database"
|
||||
/bin/tar -zcf $BACKUP_FILE -C $VNSTAT_DIR .
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue