virtual-deployment/libvirt/cleanup_network.sh
Dean Troyer d79107ba70 Clean up the libvirt install bits
* Split the network setup/teardown bits into their own scripts
  so you can shoot yourself in the foot with intention
  rather then unexpectedly.
* Cowardly refuse to configure a network if the first interface name exists
* Change the default bridge name to stxbr
* Make the network variables all configurable via the environment
* Don't make assumptions about where ISOIMAGE is located
* Include a basic doc that outlines the differences from existing
  installation steps. (Needs more!)

Change-Id: Ic46c03a09da97765b9f6bfe07e089efa38738993
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2018-08-30 10:40:57 -05:00

18 lines
578 B
Bash
Executable File

#!/usr/bin/env bash
#
# cleanup_network.sh - Cleans up network interfaces - not safe to run blindly!
NETWORK_DEFAULT=${NETWORK_DEFAULT:-default}
BRIDGE_INTERFACE=${BRIDGE_INTERFACE=stxbr0}
if virsh net-list --name | grep ${NETWORK_DEFAULT} ; then
sudo virsh net-destroy ${NETWORK_DEFAULT}
sudo virsh net-undefine ${NETWORK_DEFAULT}
sudo rm -rf /etc/libvirt/qemu/networks/autostart/${NETWORK_DEFAULT}.xml
fi
if [ -d "/sys/class/net/${BRIDGE_INTERFACE}" ]; then
sudo ifconfig ${BRIDGE_INTERFACE} down || true
sudo brctl delbr ${BRIDGE_INTERFACE} || true
fi