machine_setup/ansible/roles/poudriere/files/poudriere_delete_jail.bash
2024-08-28 18:20:34 -04:00

23 lines
629 B
Bash

#!/usr/bin/env bash
#
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
jail_name="$1"
jail_list=$(poudriere jail -l -n -q)
if ! grep -q "${jail_name}" <<<"$jail_list"; then
die "No jail named ${jail_name} found."
fi
# We could do
# poudriere pkgclean -A -y -j "$jail_name"
# instead of the packages line below but we'd need to know every set
poudriere jail -d -j "$jail_name" -C all
rm -rf /usr/local/poudriere/data/images/${jail_name}-repo \
/usr/obj/usr/local/poudriere/jails/${jail_name} \
/usr/local/poudriere/data/packages/${jail_name}-*
echo "Deleted jail $jail_name"