mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-27 12:33:49 +08:00
Compare commits
7 Commits
devel-no-h
...
Bug_8056_r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6b1697529 | ||
|
|
0a52233bfe | ||
|
|
d20e81bc9f | ||
|
|
42cac79399 | ||
|
|
399dfc30fc | ||
|
|
46d1602379 | ||
|
|
4050e15755 |
@@ -13,7 +13,88 @@ PROG=/usr/sbin/qosmngr
|
||||
. /lib/functions.sh
|
||||
include /lib/qos
|
||||
|
||||
comparator() {
|
||||
awk '
|
||||
function find_duplicate_config() {
|
||||
#Eradicate leading zeros
|
||||
c = substr(c, 2)
|
||||
|
||||
if(c) {
|
||||
#Process first file
|
||||
if(FNR == NR) {
|
||||
qoscs[++count] = c
|
||||
}
|
||||
#Process second file and find the difference
|
||||
else {
|
||||
for(count in qoscs) {
|
||||
if(qoscs[count] == c) {
|
||||
qosds[count] = 1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
c = ""
|
||||
}
|
||||
|
||||
#Find the last config of the first file
|
||||
!fls && NR != FNR {
|
||||
#Eradicate leading zeros
|
||||
c = substr(c, 2)
|
||||
qoscs[++count] = c
|
||||
fls = 1
|
||||
}
|
||||
|
||||
#Match config section and find duplicate config
|
||||
/^config/ && c { find_duplicate_config() }
|
||||
|
||||
#Match the line starts with letters and aggregate the config section
|
||||
/^\s*[a-z]/ {
|
||||
sub("^\\s*", "")
|
||||
c = c "\n" $0
|
||||
}
|
||||
|
||||
#Identify the difference between the two files at the end
|
||||
END {
|
||||
find_duplicate_config()
|
||||
|
||||
#Loop through the config section in the first file and find the difference
|
||||
for(count in qoscs) {
|
||||
if(!(count in qosds)) {
|
||||
print qoscs[count] "\n"
|
||||
}
|
||||
}
|
||||
}' $1 $2 > $3
|
||||
}
|
||||
|
||||
#function to handle a policer section
|
||||
qos_reload_handler() {
|
||||
qos_mechanism_handler() {
|
||||
config_get cfgtype "$1" TYPE
|
||||
|
||||
if [ "$cfgtype" == "shaper" ]; then
|
||||
reload_qos $cfgtype
|
||||
elif [ "$cfgtype" == "classify" ]; then
|
||||
reload_qos $cfgtype
|
||||
elif [ "$cfgtype" == "policer" ]; then
|
||||
reload_qos $cfgtype
|
||||
elif [ "$cfgtype" == "queue" ]; then
|
||||
restart
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
config_load "/tmp/qos_config_diff"
|
||||
config_foreach qos_mechanism_handler
|
||||
}
|
||||
|
||||
|
||||
start_service() {
|
||||
if [ ! -f "/tmp/qos_config" ]; then
|
||||
touch /tmp/qos_config
|
||||
cp /etc/config/qos /tmp/qos_config
|
||||
fi
|
||||
|
||||
if [ -f "/etc/config/qos" ]; then
|
||||
reload_qos
|
||||
procd_open_instance qosmngr
|
||||
@@ -37,3 +118,15 @@ restart() {
|
||||
setup_qos
|
||||
start
|
||||
}
|
||||
|
||||
reload_service()
|
||||
{
|
||||
if [[ -f "/etc/config/qos" && -f "/tmp/qos_config" ]]; then
|
||||
comparator /etc/config/qos /tmp/qos_config /tmp/qos_config_diff
|
||||
cp /etc/config/qos /tmp/qos_config
|
||||
if [[ ! -z "/tmp/qos_config_diff" ]]; then
|
||||
qos_reload_handler
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user