diff options
-rwxr-xr-x | Makefile | 9 | ||||
-rwxr-xr-x | ezjail | 42 | ||||
-rwxr-xr-x | ezjail-admin | 55 | ||||
-rwxr-xr-x | ezjail.conf.sample | 32 |
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 @@ | |||
1 | all: | ||
2 | |||
3 | install: | ||
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/ | ||
@@ -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 | ||
14 | ezjail_prefix=EZJAIL_PREFIX | ||
15 | |||
16 | . /etc/rc.subr | ||
17 | |||
18 | name=ezjail | ||
19 | ezjail_enable=${ezjail_enable:-"NO"} | ||
20 | rcvar=`set_rcvar` | ||
21 | |||
22 | start_cmd="do_start" | ||
23 | stop_cmd="do_stop" | ||
24 | |||
25 | do_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 | |||
33 | do_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 | |||
41 | load_rc_config $name | ||
42 | run_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 | ||
4 | ezjail_prefix=EZJAIL_PREFIX | ||
5 | |||
6 | if [ "0" != "`id -u`" ]; then | ||
7 | echo "Retry as root"; exit 1; | ||
8 | fi | ||
9 | |||
10 | exit | ||
11 | if [ -f ${ezjail_prefix}/etc/ezjail.conf ]; then | ||
12 | . ${ezjail_prefix}/etc/ezjail.conf; | ||
13 | fi | ||
14 | |||
15 | if [ -z "$1" ]; | ||
16 | then echo "Syntax: $0 [create|delete|list|update] {params}"; exit; | ||
17 | fi | ||
18 | |||
19 | case "$1" in | ||
20 | create) | ||
21 | mkdir ${newjail_root} && cd ${ezjail_jailtemplate} \ | ||
22 | && find * | cpio -p -v ${newjail_root} | ||
23 | ;; | ||
24 | delete) | ||
25 | |||
26 | ;; | ||
27 | list) | ||
28 | |||
29 | ;; | ||
30 | update) | ||
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 | ;; | ||
55 | esac | ||
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 | ||
11 | ezjail_jaildir=/usr/jails/ | ||
12 | |||
13 | # Location of the tiny skeleton jail template | ||
14 | ezjail_jailtemplate=$ezjail_jaildir/newjail | ||
15 | |||
16 | # Location of the huge base jail | ||
17 | ezjail_jailbase=$ezjail_jaildir/basejail | ||
18 | |||
19 | # Location of your copy of FreeBSD's source tree | ||
20 | ezjail_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 | ||
27 | ezjail_mount_enable="YES" | ||
28 | ezjail_devfs_enable="YES" | ||
29 | ezjail_devfs_ruleset="devfsrules_jail" | ||
30 | ezjail_procfs_enable="YES" | ||
31 | ezjail_fdescfs_enable="YES" | ||
32 | |||