solana/scripts/net-shaper.sh
Ashwin Sekar 12c2cd4e86
Fix net shaper script to properly query interfaces (#17065)
Previously was using ifconfig which is not available on gce
2021-05-05 19:02:38 -07:00

25 lines
500 B
Bash
Executable File

#!/usr/bin/env bash
#
# Start/Stop network shaper
#
set -e
[[ $(uname) == Linux ]] || exit 0
cd "$(dirname "$0")"
sudo=
if sudo true; then
sudo="sudo -n"
fi
set -x
iface="$(ip link show | grep mtu | grep -iv loopback | grep "state UP" | awk 'BEGIN { FS = ": " } ; {print $2}')"
if [[ "$1" = cleanup ]]; then
$sudo ~solana/.cargo/bin/solana-net-shaper cleanup -f "$2" -s "$3" -p "$4" -i "$iface"
else
$sudo ~solana/.cargo/bin/solana-net-shaper shape -f "$2" -s "$3" -p "$4" -i "$iface"
fi