source: src-sh/warden/scripts/backend/deletejail.sh @ 0988d23

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1
Last change on this file since 0988d23 was 0988d23, checked in by Kris Moore <kris@…>, 20 months ago

Add my working directory for the new warden backend changes.

Includes patches from John Hixson (john@…) to change
how warden uses "nicknames" instead of IP addresses for jail
identification.

  • Property mode set to 100755
File size: 1.4 KB
Line 
1#!/bin/sh
2# Script to stop a jail
3# Args $1 = jail-dir
4#######################################################################
5
6# Source our functions
7PROGDIR="/usr/local/share/warden"
8
9# Source our variables
10. ${PROGDIR}/scripts/backend/functions.sh
11
12JAILNAME="$1"
13
14if [ -z "${JAILNAME}" ]
15then
16  echo "ERROR: No jail specified to delete!"
17  rtn
18  exit 5
19fi
20
21if [ -z "${JDIR}" ]
22then
23  echo "ERROR: JDIR is unset!!!!"
24  rtn
25  exit 5
26fi
27
28JAILDIR="${JDIR}/${JAILNAME}"
29
30if [ ! -d "${JAILDIR}" ] ; then
31   echo "ERROR: No such jail at ${JAILDIR}"
32   exit 5
33fi
34
35set_warden_metadir
36
37# Check if the jail is running first
38${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
39if [ "$?" = "0" ]
40then
41  # Make sure the jail is stopped
42  ${PROGDIR}/scripts/backend/stopjail.sh "${JAILNAME}"
43fi
44
45# Confirm jail was shutdown and no mounts are left
46${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
47if [ "$?" = "0" ] ; then
48   echo "ERROR: Jail is still running, or has active mount-points.. Please stop manually."
49   exit 5
50fi
51
52echo -e "Deleting Jail...\c"
53isDirZFS "${JAILDIR}" "1"
54if [ $? -eq 0 ] ; then
55  # Create ZFS mount
56  tank=`getZFSTank "$JDIR"`
57  jailp=`getZFSRelativePath "${JAILDIR}"`
58  zfs destroy -r ${tank}${jailp}
59  rmdir ${JAILDIR} 2>/dev/null
60else
61  chflags -R noschg "${JAILDIR}"
62  rm -rf "${JAILDIR}"
63fi
64
65if [ ! -z "${JMETADIR}" -a "${JMETADIR}" != " " ] ; then
66  rm -rf "${JMETADIR}"
67fi
68
69echo "Done"
Note: See TracBrowser for help on using the repository browser.