mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
sync (#457)
This commit is contained in:
commit
e79c99b008
6 changed files with 14 additions and 11 deletions
|
@ -11,8 +11,10 @@ shift
|
||||||
# main loop
|
# main loop
|
||||||
while true; do
|
while true; do
|
||||||
OMR_QUOTA_REAL_INTERFACE="$(ifstatus $OMR_QUOTA_INTERFACE | jsonfilter -e '@.l3_device')"
|
OMR_QUOTA_REAL_INTERFACE="$(ifstatus $OMR_QUOTA_INTERFACE | jsonfilter -e '@.l3_device')"
|
||||||
rx=`vnstat -i $OMR_QUOTA_REAL_INTERFACE --json | jsonfilter -q -e '@.interfaces[0].traffic.month[-1].rx' | tr -d "\n"`
|
rx_bits=`vnstat -i $OMR_QUOTA_REAL_INTERFACE --json | jsonfilter -q -e '@.interfaces[0].traffic.month[-1].rx' | tr -d "\n"`
|
||||||
tx=`vnstat -i $OMR_QUOTA_REAL_INTERFACE --json | jsonfilter -q -e '@.interfaces[0].traffic.month[-1].tx' | tr -d "\n"`
|
tx_bits=`vnstat -i $OMR_QUOTA_REAL_INTERFACE --json | jsonfilter -q -e '@.interfaces[0].traffic.month[-1].tx' | tr -d "\n"`
|
||||||
|
rx=$((rx_bits/1024))
|
||||||
|
tx=$((tx_bits/1024))
|
||||||
tt=$((rx + tx))
|
tt=$((rx + tx))
|
||||||
if [ -n "$OMR_QUOTA_RX" ] && [ "$OMR_QUOTA_RX" -gt 0 ] && [ -n "$rx" ] && [ "$OMR_QUOTA_RX" -le "$rx" ]; then
|
if [ -n "$OMR_QUOTA_RX" ] && [ "$OMR_QUOTA_RX" -gt 0 ] && [ -n "$rx" ] && [ "$OMR_QUOTA_RX" -le "$rx" ]; then
|
||||||
if [ "$(ifstatus $OMR_QUOTA_INTERFACE | jsonfilter -e '@.up')" = "true" ]; then
|
if [ "$(ifstatus $OMR_QUOTA_INTERFACE | jsonfilter -e '@.up')" = "true" ]; then
|
||||||
|
@ -29,7 +31,7 @@ while true; do
|
||||||
logger -t "OMR-QUOTA" "Set interface $OMR_QUOTA_INTERFACE down, RX+TX quota reached"
|
logger -t "OMR-QUOTA" "Set interface $OMR_QUOTA_INTERFACE down, RX+TX quota reached"
|
||||||
ifdown $OMR_QUOTA_INTERFACE
|
ifdown $OMR_QUOTA_INTERFACE
|
||||||
fi
|
fi
|
||||||
elif [ -n "$OMR_QUOTA_RX" ] && [ "$OMR_QUOTA_RX" -gt 0 ] && [ -n "$OMR_QUOTA_TX" ] && [ "$OMR_QUOTA_TX" -gt 0 ] && [ -n "$OMR_QUOTA_TT" ] && [ "$OMR_QUOTA_TT" -gt 0 ] && [ "$(ifstatus $OMR_QUOTA_INTERFACE | jsonfilter -e '@.up')" = "false" ]; then
|
elif [ "$(ifstatus $OMR_QUOTA_INTERFACE | jsonfilter -e '@.up')" = "false" ]; then
|
||||||
logger -t "OMR-QUOTA" "Set interface $OMR_QUOTA_INTERFACE up"
|
logger -t "OMR-QUOTA" "Set interface $OMR_QUOTA_INTERFACE up"
|
||||||
ifup $OMR_QUOTA_INTERFACE
|
ifup $OMR_QUOTA_INTERFACE
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -6,16 +6,17 @@ EXTRA_HELP=<<EOF
|
||||||
restore Restore vnstat database
|
restore Restore vnstat database
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
START=98
|
START=50
|
||||||
STOP=10
|
STOP=60
|
||||||
|
|
||||||
vnstat_option() {
|
vnstat_option() {
|
||||||
sed -ne "s/^[;]*$1[[:space:]]*['\"]\([^'\"]*\)['\"].*/\1/p" /etc/vnstat.conf
|
sed -ne "s/^[[:space:]]*$1[[:space:]]*['\"]\([^'\"]*\)['\"].*/\1/p" /etc/vnstat.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
BACKUP_FILE=/etc/vnstat_backup.tar.gz
|
BACKUP_FILE=/etc/vnstat_backup.tar.gz
|
||||||
LOGGER_TAG=vnstat_backup
|
LOGGER_TAG=vnstat_backup
|
||||||
VNSTAT_DIR="$(vnstat_option DatabaseDir)"
|
VNSTAT_DIR="$(vnstat_option DatabaseDir)"
|
||||||
|
[ -n "$VNSTAT_DIR" ] || VNSTAT_DIR="/var/lib/vnstat"
|
||||||
|
|
||||||
_chk_omrquota() {
|
_chk_omrquota() {
|
||||||
config_get enabled $1 enabled
|
config_get enabled $1 enabled
|
||||||
|
@ -59,4 +60,4 @@ backup() {
|
||||||
|
|
||||||
restore() {
|
restore() {
|
||||||
restore_database
|
restore_database
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ let type, hook, priority, redir_port;
|
||||||
if (proto == "tcp") {
|
if (proto == "tcp") {
|
||||||
type = "nat";
|
type = "nat";
|
||||||
hook = "prerouting";
|
hook = "prerouting";
|
||||||
priority = -1;
|
priority = 1;
|
||||||
redir_port = o_redir_tcp_port;
|
redir_port = o_redir_tcp_port;
|
||||||
} else if (proto == "udp") {
|
} else if (proto == "udp") {
|
||||||
type = "filter";
|
type = "filter";
|
||||||
|
|
|
@ -43,7 +43,7 @@ let type, hook, priority, redir_port;
|
||||||
if (proto == "tcp") {
|
if (proto == "tcp") {
|
||||||
type = "nat";
|
type = "nat";
|
||||||
hook = "prerouting";
|
hook = "prerouting";
|
||||||
priority = -1;
|
priority = 1;
|
||||||
redir_port = o_redir_tcp_port;
|
redir_port = o_redir_tcp_port;
|
||||||
} else if (proto == "udp") {
|
} else if (proto == "udp") {
|
||||||
type = "filter";
|
type = "filter";
|
||||||
|
|
|
@ -43,7 +43,7 @@ let type, hook, priority, redir_port;
|
||||||
if (proto == "tcp") {
|
if (proto == "tcp") {
|
||||||
type = "nat";
|
type = "nat";
|
||||||
hook = "prerouting";
|
hook = "prerouting";
|
||||||
priority = -1;
|
priority = 1;
|
||||||
redir_port = o_redir_tcp_port;
|
redir_port = o_redir_tcp_port;
|
||||||
} else if (proto == "udp") {
|
} else if (proto == "udp") {
|
||||||
type = "filter";
|
type = "filter";
|
||||||
|
|
|
@ -43,7 +43,7 @@ let type, hook, priority, redir_port;
|
||||||
if (proto == "tcp") {
|
if (proto == "tcp") {
|
||||||
type = "nat";
|
type = "nat";
|
||||||
hook = "prerouting";
|
hook = "prerouting";
|
||||||
priority = -1;
|
priority = 1;
|
||||||
redir_port = o_redir_tcp_port;
|
redir_port = o_redir_tcp_port;
|
||||||
} else if (proto == "udp") {
|
} else if (proto == "udp") {
|
||||||
type = "filter";
|
type = "filter";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue