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

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 0988d23 was 0988d23, checked in by Kris Moore <kris@…>, 17 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: 3.1 KB
Line 
1#!/bin/sh
2# Prints a listing of the installed jails
3######################################################################
4
5# Source our functions
6PROGDIR="/usr/local/share/warden"
7
8# Source our variables
9. ${PROGDIR}/scripts/backend/functions.sh
10
11# Check if we have any jails
12if [ ! -d "${JDIR}" ]
13then
14  echo "Error: No jails found!"
15  exit 4
16fi
17
18line()
19{
20  len="${1}"
21
22  i=0
23  while [ "${i}" -lt "${len}" ] ; do
24    i=`expr ${i} + 1`
25    echo -n '-' 
26  done
27  echo 
28}
29
30lineline=0
31VERBOSE="NO"
32JAILS=
33while [ "$#" -gt "0" ] ; do
34  case "$1" in
35    -v) VERBOSE="YES" ;;
36     *) JAILS="${JAILS} .$1.meta" ;;
37  esac
38  shift
39done
40
41if [ "${VERBOSE}" != "YES" ] ; then
42# Prints a listing of the available jails
43  printf "%-24s%-12s%-12s%-12s\n" ID AUTOSTART STATUS TYPE
44  line "75"
45fi
46
47cd ${JDIR}
48if [ -z "${JAILS}" ] ; then
49  JAILS=`ls -d .*.meta 2>/dev/null`
50fi
51
52for i in ${JAILS}
53do
54  AUTO="Disabled" 
55  STATUS="<unknown>"
56
57  if [ ! -e "${i}/id" ] ; then 
58     # Check if its an old-style jail
59     if [ ! -e "${i}/ip" ] ; then
60        continue
61     fi
62     # This is an old style jail, lets convert it
63     cp ${i}/ip ${i}/id
64     cp ${i}/ip ${i}/ipv4
65  fi
66
67  ID="`cat ${i}/id 2>/dev/null`"
68  HOST="`cat ${i}/host 2>/dev/null`"
69
70  #
71  # IPv4 networking
72  #
73  IPS4=
74  IP4=`cat ${i}/ipv4 2>/dev/null`
75  if [ -e "${i}/alias-ipv4" ] ; then
76    while read line
77    do
78      IPS4="${IPS4} ${line}" 
79    done < "${i}/alias-ipv4"
80  fi
81
82  BRIDGEIPS4=
83  BRIDGEIP4=`cat ${i}/bridge-ipv4 2>/dev/null`
84  if [ -e "${i}/alias-bridge-ipv4" ] ; then
85    while read line
86    do
87      BRIDGEIPS4="${BRIDGEIPS4} ${line}" 
88    done < "${i}/alias-bridge-ipv4"
89  fi
90
91  GATEWAY4=`cat ${i}/defaultrouter-ipv4 2>/dev/null`
92
93  #
94  # IPv6 networking
95  #
96  IPS6=
97  IP6=`cat ${i}/ipv6 2>/dev/null`
98  if [ -e "${i}/alias-ipv6" ] ; then
99    while read line
100    do
101      IPS6="${IPS6} ${line}" 
102    done < "${i}/alias-ipv6"
103  fi
104
105  BRIDGEIPS6=
106  BRIDGEIP6=`cat ${i}/bridge-ipv6 2>/dev/null`
107  if [ -e "${i}/alias-bridge-ipv6" ] ; then
108    while read line
109    do
110      BRIDGEIPS6="${BRIDGEIPS6} ${line}" 
111    done < "${i}/alias-bridge-ipv6"
112  fi
113
114  GATEWAY6=`cat ${i}/defaultrouter-ipv6 2>/dev/null`
115
116  # Check if we are autostarting this jail
117  if [ -e "${i}/autostart" ] ; then
118    AUTO="Enabled"
119  fi
120 
121  # Figure out the type of jail
122  if [ -e "${i}/jail-portjail" ] ; then
123    TYPE="portjail"
124  elif [ -e "${i}/jail-pluginjail" ] ; then
125    TYPE="pluginjail"
126  elif [ -e "${i}/jail-linux" ] ; then
127    TYPE="linuxjail"
128  else
129    TYPE="standard"
130  fi
131
132  JAILNAME=`echo ${i}|sed 's|.meta$||'|sed 's|^.||'`
133
134  ${PROGDIR}/scripts/backend/checkstatus.sh ${JAILNAME} 2>/dev/null
135  if [ "$?" = "0" ]
136  then
137    STATUS="Running"
138  else
139    STATUS="Stopped"
140  fi
141
142  if [ "${VERBOSE}" = "YES" ] ; then
143    cat<<__EOF__
144
145id: ${ID}
146host: ${HOST}
147ipv4: ${IP4}
148alias-ipv4: ${IPS4}
149bridge-ipv4: ${BRIDGEIP4}
150alias-bridge-ipv4: ${BRIDGEIPS4}
151defaultrouter-ipv4: ${GATEWAY4}
152ipv6: ${IP6}
153alias-ipv6: ${IPS6}
154bridge-ipv6: ${BRIDGEIP6}
155alias-bridge-ipv6: ${BRIDGEIPS6}
156defaultrouter-ipv6: ${GATEWAY6}
157autostart: ${AUTO}
158status: ${STATUS}
159type: ${TYPE}
160
161__EOF__
162
163  else
164    printf "%-24s%-12s%-12s%-12s\n" ${JAILNAME} ${AUTO} ${STATUS} ${TYPE}
165  fi
166done
167
Note: See TracBrowser for help on using the repository browser.