Change to per-interface post-commands
This is needed on systems where tc-gen is ran multiple times on different interfaces to not reapply the post-commands every time.
This commit is contained in:
parent
11a68ee0c4
commit
82c4e8e47c
26
src/tc-gen
26
src/tc-gen
|
|
@ -77,12 +77,15 @@ OPTIONS
|
||||||
relative priority to other classes when there is a need to prioritize
|
relative priority to other classes when there is a need to prioritize
|
||||||
traffic.
|
traffic.
|
||||||
-d DOWN_RATE
|
-d DOWN_RATE
|
||||||
-p POST_COMMANDS_FILE
|
-p CONFIG_DIR
|
||||||
Override path to post commands file. By default tc-gen checks if
|
By default tc-gen checks if "/etc/tc-gen/post-commands.<if>" exists and
|
||||||
"/etc/tc-gen/post-commands" exists and if so, sources that file after
|
if so, sources that file after tc-gen have finished setting up its
|
||||||
tc-gen have finished setting up its ordinary configuration.
|
ordinary configuration. Some nice to have environment variables
|
||||||
Some nice to have environment variables available for that file are
|
available for those files are:
|
||||||
|
|
||||||
TC, IF_NAME, IFB_IF_NAME, UP_RATE, DOWN_RATE and BURST_SIZE
|
TC, IF_NAME, IFB_IF_NAME, UP_RATE, DOWN_RATE and BURST_SIZE
|
||||||
|
|
||||||
|
Use this option to look in another dir for these files.
|
||||||
-u UP_RATE
|
-u UP_RATE
|
||||||
-x
|
-x
|
||||||
Clear all traffic control config on interface.
|
Clear all traffic control config on interface.
|
||||||
|
|
@ -443,6 +446,9 @@ convert_rate () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Defaults
|
||||||
|
CONFIG_DIR="/etc/tc-gen"
|
||||||
|
|
||||||
while getopts ":i:u:d:b:f:q:c:C:p:xV" OPT; do
|
while getopts ":i:u:d:b:f:q:c:C:p:xV" OPT; do
|
||||||
case ${OPT} in
|
case ${OPT} in
|
||||||
i)
|
i)
|
||||||
|
|
@ -467,7 +473,7 @@ while getopts ":i:u:d:b:f:q:c:C:p:xV" OPT; do
|
||||||
IFB_CLASS_CONFIG="${OPTARG}"
|
IFB_CLASS_CONFIG="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
POST_COMMANDS="${OPTARG}"
|
CONFIG_DIR="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
x)
|
x)
|
||||||
CLEAR_CONFIG=1
|
CLEAR_CONFIG=1
|
||||||
|
|
@ -519,7 +525,11 @@ if [[ -n ${DOWN_RATE} ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Execute post commands
|
# Execute post commands
|
||||||
[[ -n ${POST_COMMANDS} ]] || POST_COMMANDS="/etc/tc-gen/post-commands"
|
IF_POST_COMMANDS="${CONFIG_DIR}/post-commands.${IF_NAME}"
|
||||||
[[ -r ${POST_COMMANDS} ]] && . "${POST_COMMANDS}"
|
IFB_POST_COMMANDS="${CONFIG_DIR}/post-commands.${IFB_IF_NAME}"
|
||||||
|
|
||||||
|
for f in "${IF_POST_COMMANDS}" "${IFB_POST_COMMANDS}"; do
|
||||||
|
[[ -r $f ]] && . "$f"
|
||||||
|
done
|
||||||
|
|
||||||
trap - ERR INT TERM
|
trap - ERR INT TERM
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue