Files
cs53-portfolio/lab-01-trace-request/scenario/reset.sh
T
2026-09-22 17:32:15 +00:00

30 lines
770 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LAB_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
REPO_ROOT="$(cd "$LAB_DIR/../.." && pwd)"
source "$SCRIPT_DIR/config.sh"
source "$REPO_ROOT/shared/minicorp/lib/minicorp.sh"
source "$REPO_ROOT/shared/minicorp/topologies/client-router-server.sh"
printf '\n'
mc_log "Resetting $LAB_NAME"
# Stop services and remove the MiniCorp network namespaces.
mc_topology_client_router_server_down
# Remove the namespace-specific resolver configuration.
sudo rm -f "$LAB_CLIENT_RESOLV_CONF"
sudo rmdir "$LAB_CLIENT_RESOLV_DIR" 2>/dev/null || true
# Remove temporary service output.
sudo rm -f \
"$LAB_WEB_STDOUT" \
"$LAB_DNS_STDOUT"
printf '\n'
mc_log "$LAB_NAME has been reset."