crappy quality ezjail replacement

root / rmjail

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh

# This script blindly assumes that the jail's name is identical to its file
# system basename.

## WARNING: This script will remove your jail and all associated data without
## asking for confirmation. Don't execute if you don't mean it.

DATADIR="/var/jails" # if yours is somewhere else, edit this please.
SERVICES="/srv"

JAILNAME=`basename "$1"`
[ -z "$JAILNAME" ] && JAILNAME=`dirname "$1"`

if [ -z "$1" -o ! -d "$1" ]; then
	echo "Expected parameter: Path to jail root directory" >&2
	exit 1
fi

if jls -j "$JAILNAME" >/dev/null 2>&1; then
	echo "Jail still running, stopping:"
	jail -r "$JAILNAME"
fi

echo Sleeping 10 seconds so you can abort with ^C
sleep 10;
chflags noschg "$1"/var/empty
rm -rf "$1"
rm "${DATADIR}/conf/50-${JAILNAME}.conf"
rm "${DATADIR}/fstab/${JAILNAME}"
rm "${SERVICES}/$JAILNAME" # symlink to $1/data