From 446f497c4c911929ecb6a54d531bb06a82142926 Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Wed, 22 Feb 2012 12:13:20 -0500 Subject: [PATCH] Created deleteJail function. Ready to begin debugging. --- conf/type/__jail/gencode-remote | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/conf/type/__jail/gencode-remote b/conf/type/__jail/gencode-remote index 5e1bdc02..37aa8d56 100755 --- a/conf/type/__jail/gencode-remote +++ b/conf/type/__jail/gencode-remote @@ -109,13 +109,31 @@ startJail() { } deleteJail() { -# If the jail's mountpoints are mounted, unmount them # Remove the jail's rw mountpoints -# Remove the jail's ro mountpoint + echo "rm -rf /usr/jail/rw/${name}" +# Remove the jail's fstab + echo "rm -f /etc/fstab.${name}" # Remove the jail directory -# If the jail's devfs rules are custom (!="jailrules"), remove them + echo "rm -rf /usr/jail/${name}" # Remove jail_$name_* lines from rc.conf + echo <<-EOF + sed -i '.bak' "/^jail_${name}_/d" /etc/rc.conf +EOF # Remove " $name " from jail_list if it's there + echo <<-EOF + eval $(grep '^jail_list=' /etc/rc.conf) + + for JAIL in ${jail_list}; do + if [ ! "${JAIL}" = "${name}" ]; then + new_list="${new_list} ${JAIL}" + fi + done + jail_list="${new_list}" + + sed -i '.bak' "s/^jail_list=\".*\"/jail_list=\"${jail_list}\"/" /etc/rc.conf + unset jail_list + rm -f /etc/rc.conf.bak +EOF } createJail() { @@ -194,8 +212,9 @@ if [ "$onboot" = "true" ]; then echo <<-EOF eval $(grep '^jail_list=' /etc/rc.conf) jail_list="${jail_list} ${name}" - sed -i "s/^jail_list=\".*\"/jail_list=\"${jail_list}\"/" /etc/rc.conf + sed -i '.bak' "s/^jail_list=\".*\"/jail_list=\"${jail_list}\"/" /etc/rc.conf unset jail_list + rm -f /etc/rc.conf.bak EOF fi