Skip to content

Commit

Permalink
Refactor getLimit script (Closes #65)
Browse files Browse the repository at this point in the history
  • Loading branch information
chros authored and chros committed Jul 16, 2016
1 parent bccc5df commit 86b9f28
Showing 1 changed file with 35 additions and 17 deletions.
52 changes: 35 additions & 17 deletions ubuntu-14.04/home/chros73/bin/getLimits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,54 @@ allup=${2%.*};
slowup=${3%.*};
maxslowup=${4%.*};

# checking parameters
if [ ! $# -ge 3 ] && ([ ! "$action" == "up" ] || [ ! "$action" == "down" ] || [ ! "$action" == "info" ]); then
echo -n "";
exit 0;
fi;

# get mainup speed
let mainup=${allup// /}-${slowup// /};
if [ "$mainup" -lt 0 ]; then
mainup=0;
fi;
# Function: get mainup speed
getMainUp () {
let local mainup=${allup// /}-${slowup// /};
if [ "$mainup" -lt 0 ]; then
mainup=0;
fi;
echo -e $mainup
}


# getting up limit
if [ "$action" == "up" ]; then
let newslowup=${sluplimit// /}-${mainup// /};
# Function: get up speed limit for slowup throttle group
up () {
let local newslowup=${sluplimit// /}-${mainup// /};
if [ "$newslowup" -gt "$sluplimit" ]; then
echo -n $sluplimit;
elif [ "$newslowup" -gt "$sldownlimit" ]; then
echo -n $newslowup;
else
echo -n $sldownlimit;
fi
# getting down limit
elif [ "$action" == "down" ]; then
}


# Function: get global down speed limit
down () {
if [ "$allup" -gt "$alluplimit" ] && [ "$mainup" -gt "$mainuplimit" ] ; then
echo -n $gldownlimitmin;
else
echo -n $gldownlimitmax;
fi;
# getting info
elif [ "$action" == "info" ]; then
}


# Function: get info about speed and limits
info () {
echo -n "MainUpRate: $mainup , ThrottleUpRate: $slowup , ThrottleLimit: $maxslowup"
}



# Main script: checks parameters and fires up one of the actions
if [ ! $# -ge 3 ] && ([ ! "$action" == "up" ] || [ ! "$action" == "down" ] || [ ! "$action" == "info" ]); then
echo -n "";
exit 0;
else
mainup=$(getMainUp)
$1
fi;


0 comments on commit 86b9f28

Please sign in to comment.