Created
January 10, 2025 19:58
-
-
Save elico/43b02e6f1a23eafd5368a3eef964456e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
SWITCH_NAME="switch0" | |
apk update | |
apk add openvswitch openvswitch-bash-completion bash bash-completion openvswitch-doc openvswitch-openrc vim tcpdump ruby ruby-rdoc git | |
sed -i -e "s@mouse\=a@mouse=r@g" /usr/share/vim/vim*/defaults.vim | |
grep "mouse=a" /usr/share/vim/vim*/defaults.vim | |
grep "auto ${SWITCH_NAME}" /etc/network/interfaces >/dev/null | |
RES="$?" | |
if [ "${RES}" -gt "0" ] | |
then | |
START_INT_NUM="1" | |
END_INT_NUM="23" | |
for i in $(seq ${START_INT_NUM} ${END_INT_NUM}) | |
do | |
echo eth$i | |
cat <<EOF >> /etc/network/interfaces | |
auto eth${i} | |
iface eth${i} inet manual | |
EOF | |
done | |
cat <<EOF >> /etc/network/interfaces | |
auto ${SWITCH_NAME} | |
iface ${SWITCH_NAME} inet manual | |
EOF | |
fi | |
rc-update add ovs-modules | |
rc-update add ovsdb-server | |
rc-update add ovs-vswitchd | |
rc-service ovs-modules start | |
rc-service ovsdb-server start | |
rc-service ovs-vswitchd start | |
### | |
ovs-vsctl add-br ${SWITCH_NAME} | |
ovs-vsctl set bridge ${SWITCH_NAME} stp_enable=true | |
### | |
for i in $(seq ${START_INT_NUM} ${END_INT_NUM}) | |
do | |
ovs-vsctl add-port ${SWITCH_NAME} eth${i} | |
done | |
### | |
for i in $(seq ${START_INT_NUM} ${END_INT_NUM}) | |
do | |
ifup eth$i | |
done | |
ifup ${SWITCH_NAME} | |
### | |
ovs-vsctl list-br | |
ovs-vsctl list-ports ${SWITCH_NAME} | |
ovs-vsctl show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment