source: src-sh/warden/bin/warden

Last change on this file was 433584d, checked in by JoshDW19 <joshms@…>, 4 months ago

Correct a string typo in the warden's command line output.

  • Property mode set to 100755
File size: 38.2 KB
Line 
1#!/bin/sh
2# Command-line interaction script for the warden
3# Author: Kris Moore
4# License: BSD
5# "The Warden" Copyright 2013 PC-BSD Software (iXsystems)
6######################################################################
7
8# Source external functions
9. /usr/local/share/pcbsd/scripts/functions.sh
10
11require_root() 
12{
13  UTEST="`whoami`"
14  if [ "$UTEST" != "root" ] ; then
15     exit_err "This command must be run as root!"
16  fi
17}
18
19# Source our functions
20PROGDIR="/usr/local/share/warden"
21
22# Source our variables
23. ${PROGDIR}/scripts/backend/functions.sh
24
25title()
26{
27  echo "Warden version ${WARDENVER}
28---------------------------------"
29};
30
31
32# Function to display help information
33help_main()
34{
35  title
36  echo "Available commands
37
38Type in help <command> for information and usage about that command
39
40         help - This help file"
41
42if [ -e "${PROGDIR}/bin/warden-gui" ] ; then
43   echo "          gui - Launch the GUI menu"
44fi
45
46cat<<__EOF__
47         auto - Toggles the autostart flag for a jail
48      bspkgng - BootStrap pkgng and setup TrueOS repo
49      checkup - Check for updates to a jail
50       chroot - Launches chroot into a jail
51       create - Creates a new jail
52      details - Display usage details about a jail
53       delete - Deletes a jail
54       export - Exports a jail to a .wdn file
55   fbsdupdate - Update the FreeBSD world inside jail
56  fbsdupgrade - Upgrade the version of FreeBSD inside a jail
57        fstab - Start users \$EDITOR on jails custom fstab
58          get - Gets options list for a jail
59       import - Imports a jail from a .wdn file
60         list - Lists the installed jails
61    pkgupdate - Update packages inside a jail
62         pkgs - Lists the installed packages in a jail
63         pbis - Lists the installed pbis in a jail
64          set - Sets options for a jail
65        unset - Unsets (clears) options for a jail
66        start - Start a jail
67         stop - Stops a jail
68         type - Set the jail type (pluginjail|portjail|standard)
69     template - Manage jail templates
70         snap - Jail snapshot management
71        clone - Clone an existing jail to a new jail
72     cronsnap - Schedule snapshot creation via cron
73__EOF__
74};
75
76help_get()
77{
78 title
79 echo "Help get
80
81Lets you get options for your jail
82
83Available options:
84
85             iface: Lets you see the network interface for this jail
86              ipv4: Lets you see the IPv4 address for this jail
87              ipv6: Lets you see the IPv6 address for this jail
88        alias-ipv4: Lets you see additional IPv4 addresses for this jail
89        alias-ipv6: Lets you see additional IPv6 addresses for this jail
90       bridge-ipv4: Lets you see the vnet bridge IPv4 address for this jail
91       bridge-ipv6: Lets you see the vnet bridge IPv6 address for this jail
92 alias-bridge-ipv4: Lets you see additional vnet bridge IPv4 addresses for this jail
93 alias-bridge-ipv6: Lets you see additional vnet bridge IPv6 addresses for this jail
94defaultrouter-ipv4: Lets you see the default IPv4 router for this jail
95defaultrouter-ipv6: Lets you see the default IPv6 router for this jail
96     devfs-ruleset: Lets you see the devfs ruleset for this jail
97             flags: Lets you see additional flags to pass to the 'jail' command at startup
98
99Usage:
100
101  warden get ipv4 <Jail>
102
103  warden get flags <Jail>
104
105Example:
106
107  warden get ipv4 myjail
108
109  warden get flags myjail
110"
111};
112
113help_set()
114{
115 title
116 echo "Help set
117
118Lets you set options for your jail
119
120Available options:
121
122             iface: Set the network interface for this jail
123              ipv4: Set the IPv4 address for this jail
124              ipv6: Set the IPv6 address for this jail
125        alias-ipv4: Set additional IPv4 addresses for this jail
126        alias-ipv6: Set additional IPv6 addresses for this jail
127       bridge-ipv4: Set the vnet bridge IPv4 address for this jail
128       bridge-ipv6: Set the vnet bridge IPv6 address for this jail
129 alias-bridge-ipv4: Set additional vnet bridge IPv4 for this jail
130 alias-bridge-ipv6: Set additional vnet bridge IPv6 for this jail
131defaultrouter-ipv4: Set the default vnet IPv4 router for this jail
132defaultrouter-ipv6: Set the default vnet IPv6 router for this jail
133     devfs-ruleset: Set the devfs ruleset for this jail
134             flags: Set additional flags to pass to the 'jail' command
135       vnet-enable: Enables vnet support for the jail
136      vnet-disable: Disables vnet support for this jail
137
138Usage:
139
140  warden set ipv4 <Jail> <IP1>,<IP2>,<IP3>
141
142  warden set flags <Jail> <Flag1>,<Flag2>,<Flag3>
143
144Example:
145
146  warden set ipv4 myjail 192.168.1.50,192.168.2.10
147
148  warden set ipv6 myjail fe80::8e89:a5ff:fe52:ad19,fe80::8e89:a5ff:fe52:ad21
149
150  warden set flags myjail allow.raw_sockets=true,allow.chflags=true
151
152  warden set vnet-enable myjail
153"
154};
155
156help_unset()
157{
158 title
159 echo "Help unset
160
161Lets you unset (clear) options for your jail
162
163Available options:
164
165             iface: Unset the network interface for this jail
166              ipv4: Unset the IPv4 address for this jail
167              ipv6: Unset the IPv6 address for this jail
168        alias-ipv4: Unset additional IPv4 addresses for this jail
169        alias-ipv6: Unset additional IPv6 addresses for this jail
170       bridge-ipv4: Unset the vnet bridge IPv4 address for this jail
171       bridge-ipv6: Unset the vnet bridge IPv6 address for this jail
172 alias-bridge-ipv4: Unset additional vnet bridge IPv4 for this jail
173 alias-bridge-ipv6: Unset additional vnet bridge IPv6 for this jail
174defaultrouter-ipv4: Unset the default vnet IPv4 router for this jail
175defaultrouter-ipv6: Unset the default vnet IPv6 router for this jail
176     devfs-ruleset: Unset the devfs ruleset for this jail
177             flags: Unset additional flags to pass to the 'jail' command
178
179Usage:
180
181  warden unset ipv4 <Jail> <IP1>,<IP2>,<IP3>
182
183  warden unset flags <Jail> <Flag1>,<Flag2>,<Flag3>
184
185Example:
186
187  warden unset ipv4 myjail
188
189  warden unset ipv6 myjail
190
191  warden unset flags myjail
192"
193};
194
195help_checkup()
196{
197 title
198 echo "Help checkup
199
200Check for updates to a jail(s)
201
202Usage:
203
204  warden checkup <Jail>
205   or
206  warden checkup all
207
208Example:
209
210  warden checkup myjail
211"
212};
213
214help_snap()
215{
216 title
217 echo "Help snap
218
219Perform Snapshot operations on a jail
220
221Available Sub-Commands: list make remove removedate revert
222
223list:
224
225  warden snap list <jail>
226
227make:
228
229  warden snap make <jail> <Optional Comment>
230
231remove:
232
233  warden snap remove <jail> <snapshot>
234
235removedate:
236
237  warden snap removedate <jail> <date>
238
239  NOTE: Removes all snapshots older than the given date.
240        Valid dates are YYYY-MM-DD and YYYYMMDD
241
242revert:
243
244  warden snap revert <jail> <snapshot>
245
246"
247};
248
249help_clone()
250{
251 title
252 echo "Help clone
253
254Clone an existing jail into a new jail with (optional) new IP address
255
256Usage:
257
258  warden clone <Jail> <NewJail>
259
260Example:
261
262  warden clone myjail newjail --ipv4=127.0.0.4/24
263"
264};
265
266help_cronsnap()
267{
268 title
269 echo "Help cronsnap
270
271Schedule a jail snapshot
272
273Usage:
274
275  warden cronsnap <Jail> <action> <frequency> <daysToKeep>
276 
277  action = start / stop
278  frequency = daily / hourly
279  daysToKeep = Number of days to keep snapshots
280
281Example:
282
283  warden cronsnap myjail start daily 10
284
285  or
286
287  warden cronsnap myjail stop
288"
289};
290
291help_details()
292{
293 title
294 echo "Help details
295
296View usage details about a jail
297
298Usage:
299
300  warden details <Jail>
301
302Example:
303
304  warden details myjail
305"
306};
307
308help_template()
309{
310 title
311 echo "Help template
312
313Manage the jail templates used to create new FreeBSD jails
314
315Required subcommands:
316
317  create - Create a new jail template
318  delete - Delete a jail template
319    list - List jail templates on system
320
321Flags:
322
323  create:
324     -fbsd <version>   - FreeBSD Version, 9.1-RELEASE, 9.0-RELEASE, etc
325     -trueos <version> - TrueOS Version, 9.1-RELEASE, 9-STABLE, etc
326     -arch <arch type> - System architecture, i386/amd64
327     -tar <file>       - Use tar archive as template contents (Ignores -arch / -fbsd)
328     -nick <nickname>  - Template nickname for creating jails / deleting templates
329
330Usage:
331
332  warden template create <flags>
333   or
334  warden template delete <template nickname>
335   or
336  warden template list
337
338Example:
339
340  warden template create -fbsd 9.1-RELEASE -arch amd64 -nick 91amd64
341"
342};
343
344
345help_type()
346{
347 title
348 echo "Help type
349
350Lets you set the type of jail to these options:
351
352portjail: Jail with access to your home directories and Xorg
353pluginjail: Jail that can be used to install FreeNAS plugins
354standard: Normal FreeBSD secure jail environment
355
356The flag status can be checked with 'warden list'.
357
358Usage:
359
360  warden type <Jail> <type>
361
362Example:
363
364  warden type myjail portjail
365"
366};
367
368
369help_bspkgng()
370{
371 title
372 echo "Help bspkgng
373
374BootStraps the pkgng package system, and installs the TrueOS repository
375and utilities into a jail.
376
377Usage:
378
379  warden bspkgng <Jail>
380
381Example:
382
383  warden bspkgng myjail
384"
385};
386
387
388
389help_auto()
390{
391 title
392 echo "Help auto
393
394Toggles the autostart flag for a specified jail. If the flag is
395enabled, then the jail will be started at system bootup automatically.
396The flag status can be checked with 'warden list'.
397
398Usage:
399
400  warden auto <Jail>
401
402Example:
403
404  warden auto myjail
405"
406};
407
408help_pkgs()
409{
410 title
411 echo "Help pkgs
412
413Generates a listing of the installed ports in a jail.
414
415Usage:
416
417  warden pkgs <Jail>
418
419Example:
420
421  warden pkgs myjail
422"
423};
424
425help_pbis()
426{
427 title
428 echo "Help pbis
429
430Generates a listing of the installed pbi's in a jail.
431
432Usage:
433
434  warden pbis <Jail>
435
436Example:
437
438  warden pbis myjail
439"
440};
441
442help_list()
443{
444 title
445 echo "Help list
446
447Generates a quick listing of the installed jails, including the running
448status.
449
450Available Flags:
451  -v           (Verbose listing)
452
453Usage:
454
455  warden list [flags] [hosts]
456"
457};
458
459help_export()
460{
461 title
462 echo "Help export
463
464Export will backup a full copy of your jail, compressing it and
465saving it to a .wdn file. This file can then be taken and
466imported on another system to migrate the jail to new hardware.
467Also a .wdn file may be imported on the same system, in order to
468'clone' an existing jail with a new IP address.
469
470Available Flags:
471  --dir=<DIR>  (Specify the directory you want to place the finished .wdn file)
472
473Usage:
474
475  warden export <Jail> --dir=<path>
476
477Example:
478
479  warden export myjail --dir=/tmp
480"
481};
482
483help_fstab()
484{
485 title
486 echo "Help fstab
487
488Runs the users \$EDITOR on the jails custom fstab file. Can be used to setup
489nullfs mounts and others for a specific jail
490
491Usage:
492
493  warden fstab [hosts]
494"
495};
496
497help_import()
498{
499 title
500 echo "Help import
501
502Imports a jail from a .wdn file. Can assign a new IP / Hostname to
503the imported jail on the fly using optional flags. 
504
505Available Flags:
506  --ipv4=<IP/NETMASK> (Specify a new IPv4/NETMASK address to assign to this jail)
507  --ipv6=<IP/NETMASK> (Specify a new IPv6/NETMASK address to assign to this jail)
508  --host=<HOST>       (Specify a new host name to assign to this jail)
509
510Usage:
511
512  warden import <jailname> <.wdn file>
513
514Example:
515
516  warden import myjail /home/kris/myjail.wdn
517"
518};
519
520help_fbsdupgrade()
521{
522 title
523 echo "Help fbsdupgrade
524
525Upgrades the version of FreeBSD inside the jail
526
527Usage:
528
529  warden fbsdupgrade <jail> <new version>
530
531Example:
532
533  warden fbsdupgrade myjail 10.2-RELEASE
534"
535};
536
537help_fbsdupdate()
538{
539 title
540 echo "Help fbsdupdate
541
542Updates the freebsd world inside a jail
543
544Available Flags:
545  --pkgupdate (Also update the packages in the jail)
546
547Usage:
548
549  warden fbsdupdate <jail>
550
551Example:
552
553  warden fbsdupdate myjail
554"
555};
556
557help_pkgupdate()
558{
559 title
560 echo "Help pkgupdate
561
562Updates all the packages inside a jail
563
564Usage:
565
566  warden pkgupdate <Jail>
567
568Example:
569
570  warden pkgupdate myjail
571
572NOTE:
573
574  The upgrade will stop the jail, and do the package upgrade in stopped mode.
575  If the jail was previously running, it will be re-started upon completion.
576"
577};
578
579help_chroot()
580{
581 title
582 echo "Help chroot
583
584Logs into a jail using chroot, or runs the supplied command.
585
586Usage:
587
588  warden chroot <Jail> <optional cmd>
589
590Example:
591
592  warden chroot myjail
593"
594};
595
596
597help_start()
598{
599 title
600 echo "Help start
601
602Starts a stopped jail
603
604Usage:
605
606  warden start <Jail>
607
608Example:
609
610  warden start myjail
611"
612};
613
614help_stop()
615{
616 title
617 echo "Help stop
618
619Stops a running jail
620
621Usage:
622  warden stop <Jail>
623
624Example:
625
626  warden stop myjail
627"
628};
629
630
631help_delete()
632{
633 title
634 echo "Help delete
635
636Stops and deletes a jail
637
638Available Flags:
639  --confirm       (Does not prompt to confirm deletion. DANGEROUS)
640
641Usage:
642
643  warden delete <Jail>
644
645Example:
646
647  warden delete myjail
648"
649};
650
651
652
653help_create()
654{
655 title
656 echo "Help create
657
658Creates a new jail, with options for system source, ports and autostarting.
659
660Available Flags:
661  -32                          Create 32bit jail on 64bit system
662  --autoipv4                   Use the next available IPv4 address from the pool
663  --ipv4=<ip/mask>             Set primary IPv4 address for jail
664  --ipv6=<ip/mask>             Set primary IPv6 address for jail
665  --archive <tar>              Use specified tar file for BSD jail creation
666  --bulk <number>              Create <number> of new jails, using default IP4 pool
667                               or address pool specified with --ip4pool
668  --ip4pool <address>          Starting IPv4 address to use when creating jails in bulk
669  --linuxjail <script>         Make this a linux jail and use supplied script for installation
670  --linuxarchive <tar>         Use specified tar file for Linux jail creation
671  --pluginjail                 Make this a pluginjail
672  --ports                      Includes the ports tree
673  --portjail                   Make this a portjail
674  --src                        Includes /usr/src system source
675  --startauto                  Start this jail at system boot
676  --template <string>          Specify a jail template to build with
677  --vanilla                    Don't install PC-BSD pkgng repo and utilities
678  --version <string>           Use this instead of /etc/version
679
680Usage:
681
682  warden create <JAILNAME> <flags>
683
684Example:
685
686  warden create jailbird --ipv4=192.168.0.25/24 --src --ports --startauto
687"
688};
689
690# Fix old style meta-data, can be removed after 9.1
691fix_old_meta
692
693# This checks if we have JDIR on a valid ZFS dataset
694zfs_prog_check
695
696# Check what the user wants to do
697case "$1" in
698
699   help) case "$2" in
700             auto) help_auto ;;
701          bspkgng) help_bspkgng ;;
702           create) help_create ;;
703           start) help_start ;;
704           stop) help_stop ;;
705           delete) help_delete ;;
706           details) help_details ;;
707           checkup) help_checkup ;;
708           chroot) help_chroot ;;
709           fbsdupdate) help_fbsdupdate ;;
710           fbsdupgrade) help_fbsdupgrade ;;
711           list) help_list ;;
712           export) help_export ;;
713           fstab) help_fstab ;;
714           import) help_import ;;
715           pbis) help_pbis ;;
716           pkgs) help_pkgs ;;
717           pkgupdate) help_pkgupdate ;;
718           template) help_template ;;
719           type) help_type ;;
720           get) help_get ;;
721           set) help_set ;;
722           unset) help_unset ;;
723           snap) help_snap ;;
724           cronsnap) help_cronsnap ;;
725           clone) help_clone ;;
726           *) help_main ;;
727         esac  ;;
728
729
730    pkgs) JAILNAME="${2}"
731         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
732         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
733         set_warden_metadir
734
735         ${PROGDIR}/scripts/backend/listpkgs.sh "${JAILNAME}" 
736         ;;
737pkgupdate) JAILNAME="${2}"
738         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
739         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
740         set_warden_metadir
741
742         ${PROGDIR}/scripts/backend/pkgupdate.sh "${JAILNAME}" 
743         ;;
744fbsdupdate) JAILNAME="${2}"
745         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
746         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
747         set_warden_metadir
748
749         ${PROGDIR}/scripts/backend/fbsdupdate.sh "${JAILNAME}" "$3"
750         ;;
751fbsdupgrade) JAILNAME="${2}"
752         NEWFBSDVER="${3}"
753         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
754         if [ -z "${NEWFBSDVER}" ]; then exit_err "No FreeBSD version specified!"; fi
755         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
756         set_warden_metadir
757
758         ${PROGDIR}/scripts/backend/fbsdupgrade.sh "$JAILNAME" "$NEWFBSDVER"
759         ;;
760details) JAILNAME="${2}"
761         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
762         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
763         set_warden_metadir
764
765         ${PROGDIR}/scripts/backend/details.sh "${JAILNAME}" 
766         ;;
767    pbis) JAILNAME="${2}"
768         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
769         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
770         set_warden_metadir
771
772         ${PROGDIR}/scripts/backend/listpbis.sh "${JAILNAME}" 
773         ;;
774    fstab) JAILNAME="${2}"
775         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
776         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
777         set_warden_metadir
778         if [ ! -e "${JMETADIR}/fstab" ] ; then
779            echo "# Device      Mountpoint      FStype          Options Dump Pass" > ${JMETADIR}/fstab
780         fi
781         if [ -z "$EDITOR" ]; then EDITOR="vi"; fi
782         $EDITOR ${JMETADIR}/fstab
783         exit $?
784         ;;
785template) require_root
786         OPT="$2"
787         case $OPT in
788            create) shift ; shift;
789                    # Read our flags
790                    while [ $# -gt 0 ]; do
791                    case $1 in
792                          -fbsd) shift
793                                 if [ -z "$1" ] ; then exit_err "No FreeBSD version specified"; fi
794                                 FBSDVER="${1}"
795                                 ;;
796                        -trueos) shift
797                                 if [ -z "$1" ] ; then exit_err "No TrueOS version specified"; fi
798                                 TRUEOSVER="${1}"
799                                 ;;
800                          -arch) shift
801                                 if [ -z "$1" ] ; then exit_err "No FreeBSD architecture specified"; fi
802                                 FBSDARCH="${1}"
803                                 ;;
804                           -tar) shift
805                                 if [ -z "$1" ] ; then exit_err "No tar file specified"; fi
806                                 if [ ! -e "$1" ] ; then exit_err "Could not find tar file: $1"; fi
807                                 FBSDTAR="${1}"
808                                 ;;
809                          -nick) shift
810                                 if [ -z "$1" ] ; then exit_err "No nickname specified"; fi
811                                 TNICK="`echo ${1} | sed 's| |_|g'`"
812                                 ;;
813                    -pluginjail) shift
814                                 TPLUGJAIL="YES"
815                                 ;;
816                              *) exit_err "Invalid option: $1" ;;
817                    esac
818                    shift
819                    done
820                    export TPLUGJAIL TNICK FBSDTAR FBSDARCH TRUEOSVER FBSDVER
821                    ${PROGDIR}/scripts/backend/createtemplate.sh ; exit $? ;;
822            delete) delete_template "$3" ;;
823              list) list_templates ;;
824                 *) help_template ; exit 1 ;;
825         esac
826         ;;
827    get) require_root
828         OPT="${2}"
829         JAILNAME="${3}"
830         if [ -z "${JAILNAME}" ] ; then help_get; exit 1; fi
831         if [ ! -e "${JDIR}/${JAILNAME}" ] ; then exit_err "No such jail!"; fi
832         set_warden_metadir
833
834         case $OPT in
835             flags) cat "${JMETADIR}/jail-flags" 2>/dev/null | sed 's| |,|g' ;;
836             iface) cat "${JMETADIR}/iface"  2>/dev/null ;;
837              ipv4) cat "${JMETADIR}/ipv4"  2>/dev/null | sed 's| |,|g' ;;
838              ipv6) cat "${JMETADIR}/ipv6"  2>/dev/null | sed 's| |,|g' ;;
839        alias-ipv4) cat "${JMETADIR}/alias-ipv4"  2>/dev/null | sed 's| |,|g' ;;
840        alias-ipv6) cat "${JMETADIR}/alias-ipv6"  2>/dev/null | sed 's| |,|g' ;;
841       bridge-ipv4) cat "${JMETADIR}/bridge-ipv4" 2>/dev/null | sed 's| |,|g' ;;
842       bridge-ipv6) cat "${JMETADIR}/bridge-ipv6" 2>/dev/null | sed 's| |,|g' ;;
843 alias-bridge-ipv4) cat "${JMETADIR}/alias-bridge-ipv4" 2>/dev/null | sed 's| |,|g' ;;
844 alias-bridge-ipv6) cat "${JMETADIR}/alias-bridge-ipv6" 2>/dev/null | sed 's| |,|g' ;;
845defaultrouter-ipv4) cat "${JMETADIR}/defaultrouter-ipv4" 2>/dev/null | sed 's| |,|g' ;;
846defaultrouter-ipv6) cat "${JMETADIR}/defaultrouter-ipv6" 2>/dev/null | sed 's| |,|g' ;;
847     devfs-ruleset) cat "${JMETADIR}/devfs-ruleset" 2>/dev/null ;;
848              *) exit_err "Invalid option!" ;;
849         esac
850         ;;
851
852    set) require_root
853         OPT="${2}" 
854         JAILNAME="${3}"
855         if [ -z "${JAILNAME}" ] ; then exit_err "No jail specified!"; fi
856         if [ ! -e "${JDIR}/${JAILNAME}" ] ; then exit_err "No such jail!"; fi
857         set_warden_metadir
858
859         case $OPT in
860          iface) IFACE="${4}"
861                 if [ -z "$IFACE" ] ; then
862                    rm "${JMETADIR}/iface"
863                    exit 0
864                 fi
865                 ifconfig $IFACE 2>/dev/null >/dev/null
866                 if [ $? -ne 0 ] ; then
867                    echo "WARNING: The interface ($IFACE) does not exist"
868                 fi
869                 echo $IFACE > "${JMETADIR}/iface"
870                 ;;
871             ipv4) IP4="${4}"
872                 get_ip_and_netmask "${IP4}"
873                 IP4="${JIP}"
874                 MASK4="${JMASK}"
875                 if [ -z "$MASK4" ] ; then MASK4="24"; fi
876                 echo "$IP4/$MASK4" > "${JMETADIR}/ipv4"
877                 ;;
878             ipv6) IP6="${4}"
879                 get_ip_and_netmask "${IP6}"
880                 IP6="${JIP}"
881                 MASK6="${JMASK}"
882                 if [ -z "$MASK6" ] ; then MASK4="64"; fi
883                 echo "$IP6/$MASK6" > "${JMETADIR}/ipv6"
884                 ;;
885       alias-ipv4) EXTRAIPS="${4}"
886                 IPS=`echo $EXTRAIPS | sed 's|,| |g'`
887                 rm "${JMETADIR}/alias-ipv4" >/dev/null 2>/dev/null
888                 for _ip in $IPS
889                 do
890                    echo "$_ip" >> "${JMETADIR}/alias-ipv4"
891                 done
892                ;;
893       alias-ipv6) EXTRAIPS="${4}"
894                 IPS=`echo $EXTRAIPS | sed 's|,| |g'`
895                 rm "${JMETADIR}/alias-ipv6" >/dev/null 2>/dev/null
896                 for _ip in $IPS
897                 do
898                    echo "$_ip" >> "${JMETADIR}/alias-ipv6"
899                 done
900                ;;
901       bridge-ipv4) BIP4="${4}"
902                 echo "$BIP4" > "${JMETADIR}/bridge-ipv4"
903                 ;;
904       bridge-ipv6) BIP6="${4}"
905                 echo "$BIP6" > "${JMETADIR}/bridge-ipv6"
906                 ;;
907 alias-bridge-ipv4) EXTRAIPS="${4}"
908                 IPS=`echo $EXTRAIPS | sed 's|,| |g'`
909                 rm "${JMETADIR}/alias-bridge-ipv4" >/dev/null 2>/dev/null
910                 for _ip in $IPS
911                 do
912                    echo "$_ip" >> "${JMETADIR}/alias-bridge-ipv4"
913                 done
914                ;;
915 alias-bridge-ipv6) EXTRAIPS="${4}"
916                 IPS=`echo $EXTRAIPS | sed 's|,| |g'`
917                 rm "${JMETADIR}/alias-bridge-ipv6" >/dev/null 2>/dev/null
918                 for _ip in $IPS
919                 do
920                    echo "$_ip" >> "${JMETADIR}/alias-bridge-ipv6"
921                 done
922                ;;
923defaultrouter-ipv4) DEFAULTROUTER="${4}"
924                 echo "$DEFAULTROUTER" > "${JMETADIR}/defaultrouter-ipv4"
925                 ;;
926defaultrouter-ipv6) DEFAULTROUTER="${4}"
927                 echo "$DEFAULTROUTER" > "${JMETADIR}/defaultrouter-ipv6"
928                 ;;
929     devfs-ruleset) DEVFS_RULESET="${4}"
930           if [ -z "$DEVFS_RULESET" ] ; then
931                    rm "${JMETADIR}/devfs-ruleset"
932                    exit 0
933           fi
934           # check if the rule is valid
935           SYS_DEVFS_RULESETS=`devfs rule showsets`
936           RULE_VALID=0
937           for RULESET in $SYS_DEVFS_RULESETS
938           do
939              if [ "$RULESET" -eq "$DEVFS_RULESET" ]; then
940                 RULE_VALID=1
941                 break
942              fi
943           done
944           if [ "$RULE_VALID" -eq 0 ]; then
945              echo "WARNING: The specified ruleset ($DEVFS_RULESET) does not exist"
946           fi
947
948           echo "$DEVFS_RULESET" > "${JMETADIR}/devfs-ruleset"
949                 ;;                 
950          flags) EXTRAFLAGS="${4}"
951                 echo $EXTRAFLAGS | sed 's|,| |g' > "${JMETADIR}/jail-flags"
952                 ;;
953    vnet-enable) touch "${JMETADIR}/vnet" ;;
954    vnet-disable) rm "${JMETADIR}/vnet" 2>/dev/null ;;
955              *) exit_err "Invalid option!" ;;
956           esac
957         ;;
958
959    unset) require_root
960   OPT="${2}" 
961         JAILNAME="${3}"
962         if [ -z "${JAILNAME}" ] ; then exit_err "No jail specified!"; fi
963         if [ ! -e "${JDIR}/${JAILNAME}" ] ; then exit_err "No such jail!"; fi
964   set_warden_metadir
965
966   case $OPT in
967            iface) if [ -e "${JMETADIR}/iface" ]; then rm "${JMETADIR}/iface"; fi
968                 ;;
969
970             ipv4) if [ -e "${JMETADIR}/ipv4" ]; then rm "${JMETADIR}/ipv4"; fi
971                 ;;
972
973             ipv6) if [ -e "${JMETADIR}/ipv6" ]; then rm "${JMETADIR}/ipv6"; fi
974                 ;;
975
976       alias-ipv4) if [ -e "${JMETADIR}/alias-ipv4" ]; then rm "${JMETADIR}/alias-ipv4"; fi
977                 ;;
978
979       alias-ipv6) if [ -e "${JMETADIR}/alias-ipv6" ]; then rm "${JMETADIR}/alias-ipv6"; fi
980                 ;;
981
982       bridge-ipv4) if [ -e "${JMETADIR}/bridge-ipv4" ]; then rm "${JMETADIR}/bridge-ipv4"; fi
983                 ;;
984
985       bridge-ipv6) if [ -e "${JMETADIR}/bridge-ipv6" ]; then rm "${JMETADIR}/bridge-ipv6"; fi
986                 ;;
987
988 alias-bridge-ipv4) if [ -e "${JMETADIR}/alias-bridge-ipv4" ]; then rm "${JMETADIR}/alias-bridge-ipv4"; fi
989                 ;;
990
991 alias-bridge-ipv6) if [ -e "${JMETADIR}/alias-bridge-ipv6" ]; then rm "${JMETADIR}/alias-bridge-ipv6"; fi
992                 ;;
993
994defaultrouter-ipv4) if [ -e "${JMETADIR}/defaultrouter-ipv4" ]; then rm "${JMETADIR}/defaultrouter-ipv4"; fi
995                 ;;
996
997defaultrouter-ipv6) if [ -e "${JMETADIR}/defaultrouter-ipv6" ]; then rm "${JMETADIR}/defaultrouter-ipv6"; fi
998                 ;;
999
1000     devfs-ruleset) if [ -e "${JMETADIR}/devfs-ruleset" ]; then rm "${JMETADIR}/devfs-ruleset"; fi
1001                 ;;
1002
1003                 *) exit_err "Invalid option!" ;;
1004                 esac
1005                 ;;
1006
1007   type) require_root
1008         JAILNAME="${2}"
1009         TYPE="${3}"
1010         JAILDIR="${JDIR}/${JAILNAME}"
1011
1012         if [ -z "${JAILNAME}" ] ; then exit_err "No jail specified!"; fi
1013         if [ ! -e "${JAILDIR}" ] ; then exit_err "No such jail!"; fi
1014
1015         set_warden_metadir
1016         if [ -e "${JMETADIR}/jail-linux" ] ; then exit_err "Cannot change type on Linux jail!"; fi
1017
1018         case $TYPE in
1019           portjail)
1020              rm ${JMETADIR}/jail-pluginjail > /dev/null 2>/dev/null
1021              mkportjail "${JAILDIR}"
1022              ;;
1023           standard)
1024              rm ${JMETADIR}/jail-pluginjail > /dev/null 2>/dev/null
1025              rm ${JMETADIR}/jail-portjail >/dev/null 2>/dev/null
1026              ;;
1027           pluginjail)
1028              mkpluginjail "${JAILDIR}"
1029              ;;
1030           *) exit_err "Invalid TYPE" ;;
1031         esac
1032         ;;
1033
1034 bspkgng) require_root
1035    JAILNAME="${2}"
1036         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1037         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
1038         bootstrap_pkgng "${JDIR}/${JAILNAME}"
1039         ;;
1040
1041   auto) require_root
1042         JAILNAME="${2}"
1043
1044         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1045
1046         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
1047         set_warden_metadir
1048
1049         if [ -e "${JMETADIR}/autostart" ]
1050         then
1051            rm "${JMETADIR}/autostart"
1052            echo "Disabled autostart for ${JAILNAME}"
1053         else
1054            touch "${JMETADIR}/autostart"
1055            echo "Enabled autostart for ${JAILNAME}"
1056         fi 
1057
1058         # Update flags so syscache knows to re-scan
1059         pc-systemflag WARDENUPDATE SUCCESS
1060       
1061         sleep 2
1062
1063         ;;
1064
1065    gui) require_root
1066          ${PROGDIR}/bin/warden-gui ;;
1067
1068    list) require_root
1069        shift
1070        ${PROGDIR}/scripts/backend/listjails.sh $* ;;
1071   
1072   start) require_root
1073          # Time to startup the jail
1074          JAILNAME="${2}"
1075
1076          if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1077          if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
1078          set_warden_metadir
1079         
1080          # Check if this jail is already running
1081          ${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
1082          if [ "$?" = "0" ]; then exit_err "This jail is already running!"; fi
1083 
1084          ${PROGDIR}/scripts/backend/startjail.sh "${JAILNAME}" 
1085          ;;
1086   stop)  require_root
1087          # Time to stop the jail
1088          JAILNAME="${2}"
1089
1090          if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1091          if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
1092          set_warden_metadir
1093         
1094          ${PROGDIR}/scripts/backend/stopjail.sh "${JAILNAME}" 
1095          ;;
1096
1097 checkup) # Log a user into chroot session
1098          JAILNAME="${2}"
1099
1100          if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1101          if [ ! -e "${JDIR}/${JAILNAME}" -a "${JAILNAME}" != "all" ]; then exit_err "No such jail!"; fi
1102
1103          ${PROGDIR}/scripts/backend/checkupdates.sh "${JAILNAME}"
1104          ;;
1105
1106
1107 chroot) # Log a user into chroot session
1108          JAILNAME="${2}"
1109
1110          if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1111          if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
1112          set_warden_metadir
1113
1114          ${PROGDIR}/scripts/backend/chrootjail.sh "${JAILNAME}" "${3}"
1115          ;;
1116
1117 import) require_root
1118         # The user wants to import a jail, lets do it!
1119         NAME="$2"
1120         IFILE="$3"
1121         if [ ! -e "$IFILE" -o -z "$IFILE" ]; then exit_err "Invalid filename: ${IFILE}"; fi
1122
1123         # Parse the IP / Host flags
1124         HOST="OFF"
1125         IP4="OFF"
1126         IP6="OFF"
1127         get_ip_host_flags "$@"
1128         if [ "${IP4}" != "OFF" ] ; then
1129            IP4="${IP4}/${MASK4}"
1130         fi
1131         if [ "${IP6}" != "OFF" ] ; then
1132            IP6="${IP6}/${MASK6}"
1133         fi
1134
1135         # Import the jail now!
1136         ${PROGDIR}/scripts/backend/importjail.sh "$NAME" "$IFILE" "$HOST" "$IP4" "$IP6"
1137        ;;
1138
1139 export) require_root
1140         # The user wants to export a jail, lets do it!
1141         JAILNAME="$2"
1142         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1143         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
1144         set_warden_metadir
1145
1146         # Check if the user wants to place the file in their own DIR
1147         DIR=""
1148         for i in "$@"
1149         do
1150           echo ${i} | grep "\-\-dir=" >/dev/null 2>/dev/null
1151           if [ "$?" = "0" ]
1152           then
1153              DIR="`echo ${i} | cut -d '=' -f 2`"
1154              # Check if the directory exists
1155              if [ ! -d "${DIR}" ]; then exit_err "No such directory ${DIR}!"; fi
1156           fi
1157
1158         done
1159
1160         # Export the jail now
1161         ${PROGDIR}/scripts/backend/exportjail.sh "${JAILNAME}" "${DIR}"
1162
1163         ;;
1164
1165 snap) require_root
1166         JAILNAME="$3"
1167         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1168         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
1169         set_warden_metadir
1170
1171         # Get the sub-command here
1172         case $2 in
1173            list) ${PROGDIR}/scripts/backend/zfslistsnap.sh "${JAILNAME}" ;;
1174            make) ${PROGDIR}/scripts/backend/zfsmksnap.sh "${JAILNAME}" "$4" ;;
1175          remove) ${PROGDIR}/scripts/backend/zfsrmsnap.sh "${JAILNAME}" "$4" ;;
1176      removedate) ${PROGDIR}/scripts/backend/zfsrmsnapdate.sh "${JAILNAME}" "$4" ;;
1177          revert) ${PROGDIR}/scripts/backend/zfsrevertsnap.sh "${JAILNAME}" "$4" ;;
1178                *) help_snap ; exit 1 ;;
1179         esac
1180         ;;
1181
1182 clone) require_root
1183         JAILNAME="$2"
1184         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1185         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
1186         set_warden_metadir
1187
1188         get_ip_host_flags "$@"
1189
1190         if [ "${IP4}" != "OFF" ] ; then
1191            IP4="${IP4}/${MASK4}"
1192         fi
1193         if [ "${IP6}" != "OFF" ] ; then
1194            IP6="${IP6}/${MASK6}"
1195         fi
1196
1197         ${PROGDIR}/scripts/backend/zfsclone.sh "${JAILNAME}" "$3" "$IP4" "$IP6"
1198         ;;
1199
1200 cronsnap) require_root
1201         JAILNAME="$2"
1202         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1203         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
1204         set_warden_metadir
1205         ${PROGDIR}/scripts/backend/zfscronsnap.sh "${JAILNAME}" "$3" "$4" "$5"
1206         ;;
1207
1208
1209 create) require_root
1210         # The user wants to create a new jail, do error checking
1211         JAILNAME="$2"
1212         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1213         echo "$2" | grep -q '^-'
1214         if [ $? -eq 0 ] ; then
1215            exit_err "Jailname must be specified first before -- flags!"
1216         fi
1217
1218
1219         # Parse the IP flags
1220         IP4="OFF"
1221         IP6="OFF"
1222         get_ip_host_flags "$@"
1223         if [ "${IP4}" != "OFF" ] ; then
1224            IP4="${IP4}/${MASK4}"
1225         fi
1226         if [ "${IP6}" != "OFF" ] ; then
1227            IP6="${IP6}/${MASK6}"
1228         fi
1229
1230         # Set the hostname
1231         HOST="$2"
1232         export HOST
1233
1234         #Now check for the presence of the optional flags
1235         SRC="NO"
1236         SOURCE="NO"
1237         PORTS="NO"
1238         AUTOSTART="NO"
1239         VANILLA="NO"
1240         CREATEVERSION=""
1241         JAILTYPE="standard"
1242         ARCHIVE_FILE= 
1243         while [ $# -gt 0 ]; do
1244           case $1 in
1245             --src) SRC="YES" ; SOURCE="YES" ;;
1246             --ports) PORTS="YES" ;;
1247             --startauto) AUTOSTART="YES" ;;
1248             --autoipv4) AUTOIPV4="YES" ;;
1249             --vanilla) VANILLA="YES" ;;
1250             --portjail) JAILTYPE="portjail" ;;
1251             --pluginjail) JAILTYPE="pluginjail" ; VANILLA="YES" ;;
1252             --linuxjail) JAILTYPE="linuxjail" ; shift
1253                          if [ -z "$1" ] ; then exit_err "No linux setup script specified!"; fi
1254                          LINUX_JAIL_SCRIPT="$1" ; export LINUX_JAIL_SCRIPT
1255                          if [ -n "$LINUXARCHIVE_FILE" ] ; then
1256                             exit_err "--linuxjail and --linuxarchive are mutually exclusive!"
1257                          fi
1258                          ;;
1259                     -32) if [ "$REALARCH" != "amd64" ] ; then
1260                                exit_err "-32 can only be used on amd64 host"
1261                          fi
1262                          ARCH=i386
1263                          export ARCH
1264                          ;;
1265             --archive) shift
1266                          if [ -z "$1" ] ; then exit_err "No archive file specified!"; fi
1267                          ARCHIVE_FILE="$1" ; export ARCHIVE_FILE
1268                          if [ ! -e "$ARCHIVE_FILE" ] ; then
1269                             exit_err "No such file: $ARCHIVE_FILE"
1270                          fi
1271                          ;;
1272             --linuxarchive) JAILTYPE="linuxjail" ; shift
1273                          if [ -z "$1" ] ; then exit_err "No archive file specified!"; fi
1274                          LINUXARCHIVE_FILE="$1" ; export LINUXARCHIVE_FILE
1275                          if [ ! -e "$LINUXARCHIVE_FILE" ] ; then
1276                             exit_err "No such file: $LINUXARCHIVE_FILE"
1277                          fi
1278                          if [ -n "$LINUX_JAIL_SCRIPT" ] ; then
1279                             exit_err "--linuxjail and --linuxarchive are mutually exclusive!"
1280                          fi
1281                          ;;
1282             --version) shift
1283                          if [ -z "$1" ] ; then exit_err "No version string specified!"; fi
1284                          CREATEVERSION="${1}"
1285                          ;;
1286             --bulk) shift
1287                          if [ -z "$1" ] ; then exit_err "No bulk number specified!"; fi
1288                          BULKCOUNT="${1}"
1289                          ;;
1290             --ip4pool) shift
1291                          if [ -z "$1" ] ; then exit_err "No IPv4 pool specified!"; fi
1292                          IP4POOL="${1}"
1293                          ;;
1294             --template) shift
1295                          if [ -z "$1" ] ; then exit_err "No template string specified!"; fi
1296                          isDirZFS "${JDIR}"
1297                          if [ $? -eq 0 ] ; then
1298                             TDIR="${JDIR}/.warden-template-$1"
1299                          else
1300                             TDIR="${JDIR}/.warden-template-$1.tbz"
1301                          fi
1302                          if [ ! -e "$TDIR" ] ; then
1303                             exit_err "Invalid template specified: $1"
1304                          fi
1305                          TEMPLATE="${1}"
1306                          ;;
1307           esac
1308           shift
1309         done
1310
1311         #
1312         # Redonkulous number of parameters that exceeds 9,
1313         # export into environment
1314         #
1315         export SRC SOURCE PORTS AUTOSTART JAILTYPE ARCHIVE_FILE CREATEVERSION VANILLA TEMPLATE
1316
1317         # Are we doing bulk creation?
1318         if [ -n "$BULKCOUNT" ] ; then
1319           if [ ! $(is_num "$BULKCOUNT") ] ; then exit_err "Invalid bulk number"; fi
1320
1321           # Set the IP pool to use
1322           if [ -z "$IP4POOL" ] ; then IP4POOL="$DEFAULT_IP4POOL"; fi
1323           if [ -z "$IP4POOL" ] ; then
1324              exit_err "No IPv4 pool specified! Use --ipv4pool or setup IP4POOL: in warden.conf"
1325           fi
1326           curNum="`echo $IP4POOL | cut -d '.' -f 4`"
1327           baseIP="`echo $IP4POOL | cut -d '.' -f 1-3`"
1328           if [ ! $(is_num "$curNum") ] ; then exit_err "Invalid IPv4 pool number"; fi
1329
1330           num=0
1331           while :
1332           do
1333             # Is this host / jail directory available?
1334             if [ -e "${JDIR}/${JAILNAME}${curNum}" ] ; then
1335                curNum=`expr $curNum + 1`
1336                continue
1337             fi
1338
1339             # Now check if this IP address is available
1340             ipConflict=0
1341             for i in `ls -d ${JDIR}/.*.meta 2>/dev/null`
1342             do
1343                if [ ! -e "${i}/ipv4" ] ; then continue ; fi
1344                if [ "`cat ${i}/ipv4`" = "${baseIP}.${curNum}/24" ] ; then
1345                   ipConflict=1 ; break
1346                fi
1347             done
1348             if [ $ipConflict -eq 1 ] ; then
1349                curNum=`expr $curNum + 1`
1350                continue
1351             fi
1352
1353             IP="${baseIP}.${curNum}/24" ; export IP
1354
1355             # Passed all tests, create the jail now
1356             echo "Creating BULK jail: ${JAILNAME}${curNum} - ${IP}"
1357             ${PROGDIR}/scripts/backend/createjail.sh "${JAILNAME}${curNum}"
1358             if [ $? -ne 0 ] ; then
1359                exit 1
1360             fi
1361             echo ""
1362
1363             num=`expr $num + 1`
1364             if [ $num -ge $BULKCOUNT ] ; then break ; fi
1365           done
1366
1367         else
1368
1369           # Check to ensure this jail does not already exist
1370           if [ -e "${JDIR}/${JAILNAME}" ]; then exit_err "A jail with this name already exists!"; fi
1371
1372           if [ -n "$AUTOIPV4" ] ; then
1373             # Get the pool addresses loaded
1374             if [ -z "$IP4POOL" ] ; then IP4POOL="$DEFAULT_IP4POOL"; fi
1375             curNum="`echo $IP4POOL | cut -d '.' -f 4`"
1376             baseIP="`echo $IP4POOL | cut -d '.' -f 1-3`"
1377             if [ ! $(is_num "$curNum") ] ; then exit_err "Invalid IPv4 pool number"; fi
1378
1379             # Get the next available IPv4 Address in this pool
1380             while :
1381             do
1382               ipConflict=0
1383               for i in `ls -d ${JDIR}/.*.meta 2>/dev/null`
1384               do
1385                if [ ! -e "${i}/ipv4" ] ; then continue ; fi
1386                if [ "`cat ${i}/ipv4`" = "${baseIP}.${curNum}/24" ] ; then
1387                   ipConflict=1 ; break
1388                fi
1389               done
1390               if [ $ipConflict -eq 0 ] ; then break; fi
1391               curNum=`expr $curNum + 1`
1392             done
1393
1394             # Set the next IP address
1395             IP4="${baseIP}.${curNum}/24"
1396           fi
1397
1398           export IP4 IP6
1399
1400           # Passed all tests, create the jail now
1401           ${PROGDIR}/scripts/backend/createjail.sh "${JAILNAME}"
1402           exit $?
1403         fi
1404
1405        ;;
1406  delete|destroy) require_root
1407          # Time to delete a jail
1408          JAILNAME="${2}"
1409
1410          if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
1411          if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
1412          set_warden_metadir
1413
1414          if [ "$3" != "--confirm" ]
1415          then
1416            echo "Are you sure you want to delete ${JAILNAME}?"
1417            echo -e "Choice: (y/n)\c"
1418            read confirm
1419            if [ "$confirm" != "y" ]; then exit_err "Canceled!"; fi
1420          fi
1421
1422          # Check if this jail is running
1423          ${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
1424          if [ "$?" = "0" ] ; then
1425            ${PROGDIR}/scripts/backend/stopjail.sh "${JAILNAME}"
1426          fi
1427
1428          # Check if this jail is STILL running
1429          ${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
1430          if [ "$?" = "0" ] ; then exit_err "Jail still is running or has leftovers.."; fi
1431
1432          # Delete it now
1433          ${PROGDIR}/scripts/backend/deletejail.sh "${JAILNAME}"
1434        ;;
1435   *) help_main ;;
1436esac
1437
1438
1439exit 0
Note: See TracBrowser for help on using the repository browser.