FDD-book/examples/part-07/ch30-virtualisation/lab04-vnet/teardown.sh
Edson Brandi 6e6dac94fe Add book companion files under examples/
Organize companion code and materials by book part:

  part-01/      Foundations
  part-02/      Kernel & driver fundamentals
  part-03/      Character & block devices
  part-04/      Networking & storage
  part-05/      Buses & advanced topics
  part-06/      Debugging & performance
  part-07/      Real-world drivers
  appendices/   Supplementary material
  README.md     Overview and build instructions
2026-04-25 16:51:00 +00:00

26 lines
530 B
Bash
Executable file

#!/bin/sh
#
# teardown.sh - Clean up the VNET jail set up by setup.sh.
# Chapter 30, Lab 4.
set -eu
JAIL_NAME="vnet-test"
if [ "$(id -u)" -ne 0 ]; then
echo "$0: must be run as root" >&2
exit 1
fi
if jls | awk '{ print $3 }' | grep -q "^${JAIL_NAME}$"; then
jail -r "${JAIL_NAME}"
echo "jail ${JAIL_NAME} removed"
else
echo "no jail named ${JAIL_NAME}"
fi
# Remove the epair (will succeed whichever end is left on the host).
if ifconfig epair0a >/dev/null 2>&1; then
ifconfig epair0a destroy
echo "epair destroyed"
fi