Skip to content

Commit

Permalink
[Feat]Support to remove existed br1 by parameter (sonic-net#9947)
Browse files Browse the repository at this point in the history
Approach
What is the motivation for this PR?
[Feat]Support to remove existed br1 by parameter

co-authorized by: jianquanye@microsoft.com
  • Loading branch information
yejianquan authored and mssonicbld committed Sep 12, 2023
1 parent cb4cd97 commit 19fab57
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions ansible/setup-management-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ if [[ $(id -u) -ne 0 ]]; then
exit
fi

function show_help_and_exit()
{
echo "Usage ${SCRIPT} [options]"
echo " options with (*) must be provided"
echo " -h -? : get this help"
echo " -d : Delete existed bridge"


exit $1
}

DEL_EXISTED_BRIDGE=false

while getopts "h?d" opt; do
case ${opt} in
h|\? )
show_help_and_exit 0
;;
d)
DEL_EXISTED_BRIDGE=true
;;
esac
done


echo "Refreshing apt package lists..."
apt-get update
echo
Expand Down Expand Up @@ -41,13 +66,15 @@ if ! command -v ethtool; then
fi
echo

# todo, add parameter to indicate whether remove br1 forcefully
echo "STEP 5: Remove existed br1..."
if ifconfig br1; then
echo "STEP 5: Delete existed br1..."
if [ "$DEL_EXISTED_BRIDGE" = true ] && ifconfig br1 >/dev/null 2>&1; then
echo "br1 exists, remove it."
ifconfig br1 down
brctl delbr br1
else
echo "Not delete existed bridge or br1 not exists, skipping..."
fi
echo

echo "STEP 6: Checking if bridge br1 already exists..."
if ! ifconfig br1; then
Expand Down

0 comments on commit 19fab57

Please sign in to comment.