source: src-sh/warden/scripts/backend/checkstatus.sh @ 4994f5cd

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 4994f5cd was 4994f5cd, checked in by Kris Moore <kris@…>, 9 months ago

Fix detection of some active jails

Thanks Adam!

  • Property mode set to 100755
File size: 992 bytes
Line 
1#!/bin/sh
2# Script to check a jail status
3# Args $1 = JAILNAME
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: You must specify a jail name to check"
17  exit 5
18fi
19
20if [ -z "${JDIR}" ]
21then
22  echo "ERROR: JDIR is unset!!!!"
23  exit 5
24fi
25
26JAILDIR="${JDIR}/${JAILNAME}"
27
28if [ ! -d "${JAILDIR}" ]
29then
30  echo "ERROR: No jail located at ${JAILDIR}"
31  exit 5
32fi
33
34# End of error checking, now see if the jail is active
35#####################################################################
36
37# Check if anything is still mounted in this jail
38hasmount="0"
39for mountpoint in $(mount | grep -e "${JAILDIR}/" | cut -d" " -f3); do
40  hasmount="1"
41done
42
43# Check if the jail is active
44jls | grep "${JAILDIR}$" >/dev/null 2>/dev/null
45if [ "$?" = "0" -o "$hasmount" = "1" ]; then
46  exit 0
47else
48  exit 1
49fi
Note: See TracBrowser for help on using the repository browser.