summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xMakefile9
-rwxr-xr-xezjail42
-rwxr-xr-xezjail-admin55
-rwxr-xr-xezjail.conf.sample32
4 files changed, 138 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100755
index 0000000..ec3d9ba
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,9 @@
1all:
2
3install:
4 sed s:EZJAIL_PREFIX:${PREFIX}: ezjail > ${PREFIX}/etc/rc.d/ezjail
5 chmod 755 ${PREFIX}/etc/rc.d/ezjail
6 sed s:EZJAIL_PREFIX:${PREFIX}: ezjail-admin > ${PREFIX}/bin/ezjail-admin
7 chmod 755 ${PREFIX}/bin/ezjail-admin
8 cp -p ezjail.conf.sample ${PREFIX}/etc/
9 mkdir -p ${PREFIX}/etc/ezjail/
diff --git a/ezjail b/ezjail
new file mode 100755
index 0000000..e3f1443
--- /dev/null
+++ b/ezjail
@@ -0,0 +1,42 @@
1#/bin/sh
2
3# $FreeBSD$
4#
5# PROVIDE: ezjail
6#
7# Note: Add the following lines to $PREFIX/etc/rc.conf to enable ezjail,
8#
9#ezjail_enable="YES"
10#
11# Please do not change this file, configure in $PREFIX/etc/ezjail.conf
12
13# ugly: this variable will be set on port install time
14ezjail_prefix=EZJAIL_PREFIX
15
16. /etc/rc.subr
17
18name=ezjail
19ezjail_enable=${ezjail_enable:-"NO"}
20rcvar=`set_rcvar`
21
22start_cmd="do_start"
23stop_cmd="do_stop"
24
25do_start()
26{
27 jail_enable=${ezjail_enable}
28 jail_list=`ls ${ezjail_prefix}/etc/ezjail/`
29 for jail in $jail_list; do . ${ezjail_prefix}/etc/ezjail/${jail}; done
30 sh /etc/rc.d/jail start $*
31}
32
33do_stop()
34{
35 jail_enable=${ezjail_enable}
36 jail_list=`ls ${ezjail_prefix}/etc/ezjail/`
37 for jail in $jail_list; do . ${ezjail_prefix}/etc/ezjail/${jail}; done
38 sh /etc/rc.d/jail stop $*
39}
40
41load_rc_config $name
42run_rc_command $*
diff --git a/ezjail-admin b/ezjail-admin
new file mode 100755
index 0000000..e7fe216
--- /dev/null
+++ b/ezjail-admin
@@ -0,0 +1,55 @@
1#!/bin/sh
2
3# ugly: this variable is set during port install time
4ezjail_prefix=EZJAIL_PREFIX
5
6if [ "0" != "`id -u`" ]; then
7 echo "Retry as root"; exit 1;
8fi
9
10exit
11if [ -f ${ezjail_prefix}/etc/ezjail.conf ]; then
12 . ${ezjail_prefix}/etc/ezjail.conf;
13fi
14
15if [ -z "$1" ];
16 then echo "Syntax: $0 [create|delete|list|update] {params}"; exit;
17fi
18
19case "$1" in
20create)
21 mkdir ${newjail_root} && cd ${ezjail_jailtemplate} \
22 && find * | cpio -p -v ${newjail_root}
23 ;;
24delete)
25
26 ;;
27list)
28
29 ;;
30update)
31
32 if [ ! -d ${ezjail_sourcetree} ]; then
33 echo "Cannot find your copy of the FreeBSD source tree in $ezjail_sourcetree."; exit 1;
34 fi
35
36 cd ${ezjail_sourcetree}
37 rm -r ${ezjail_jailfull}; mkdir -p ${ezjail_jailfull}
38 make world DESTDIR=${ezjail_jailfull}
39 make distribution DESTDIR=${ezjail_jailfull}
40
41 cd ${ezjail_jailfull}
42 mkdir -p ${ezjail_jailbase}
43 for a in bin sbin usr/bin usr/include usr/lib usr/libexec usr/sbin usr/src usr/share; do
44 find ${a} | cpio -d -p -v ${ezjail_jailbase};
45 chflags -R noschg ${a}; rm -r ${a}; ln -s /basejail/${a} ${a}
46 done
47 mkdir basejail
48
49 if [ -d ${ezjail_jailtemplate} ]; then
50 mv ${ezjail_jailtemplate} ${ezjail_jailtemplate}_old
51 fi
52 mv ${ezjail_jailfull} ${ezjail_jailtemplate}
53
54 ;;
55esac
diff --git a/ezjail.conf.sample b/ezjail.conf.sample
new file mode 100755
index 0000000..837f500
--- /dev/null
+++ b/ezjail.conf.sample
@@ -0,0 +1,32 @@
1# ezjail.conf - Example file, see ezjail(x)
2#
3# Note: If you alter some of those variables AFTER creating your first
4# jail, you may have to adapt /etc/fstab.* and ${PREFIX}/etc/ezjail/* by
5# hand
6
7# Location of jail root directories
8#
9# Note: If you habe spread your jails to multiple locations, use softlinks
10# to collect them in this directory
11ezjail_jaildir=/usr/jails/
12
13# Location of the tiny skeleton jail template
14ezjail_jailtemplate=$ezjail_jaildir/newjail
15
16# Location of the huge base jail
17ezjail_jailbase=$ezjail_jaildir/basejail
18
19# Location of your copy of FreeBSD's source tree
20ezjail_sourcetree=/usr/src
21
22# Default options for newly created jails
23#
24# Note: Be VERY careful about disabling ezjail_mount_enable. Mounting
25# basejail via nullfs depends on this. You will have to find other
26# ways to provide your jail with essential system files
27ezjail_mount_enable="YES"
28ezjail_devfs_enable="YES"
29ezjail_devfs_ruleset="devfsrules_jail"
30ezjail_procfs_enable="YES"
31ezjail_fdescfs_enable="YES"
32