summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xezjail27
-rwxr-xr-xezjail-admin38
-rwxr-xr-xezjail.conf.sample2
3 files changed, 40 insertions, 27 deletions
diff --git a/ezjail b/ezjail
index e3f1443..b75b467 100755
--- a/ezjail
+++ b/ezjail
@@ -16,27 +16,38 @@ ezjail_prefix=EZJAIL_PREFIX
16. /etc/rc.subr 16. /etc/rc.subr
17 17
18name=ezjail 18name=ezjail
19ezjail_enable=${ezjail_enable:-"NO"}
20rcvar=`set_rcvar` 19rcvar=`set_rcvar`
20load_rc_config $name
21 21
22ezjail_enable=${ezjail_enable:-"NO"}
23
24restart_cmd="do_restart"
22start_cmd="do_start" 25start_cmd="do_start"
23stop_cmd="do_stop" 26stop_cmd="do_stop"
24 27
25do_start() 28do_start()
26{ 29{
27 jail_enable=${ezjail_enable} 30 [ -n "$*" ] && jail_list=`echo $* | tr /~. ___`;
28 jail_list=`ls ${ezjail_prefix}/etc/ezjail/` 31 jail_list=${jail_list:-`ls ${ezjail_prefix}/etc/ezjail/`}
29 for jail in $jail_list; do . ${ezjail_prefix}/etc/ezjail/${jail}; done 32 for jail in $jail_list; do . ${ezjail_prefix}/etc/ezjail/${jail}; done
30 sh /etc/rc.d/jail start $* 33 sh /etc/rc.d/jail onestart $jail_list
34}
35
36do_restart()
37{
38 [ -n "$*" ] && jail_list=`echo $* | tr /~. ___`;
39 jail_list=${jail_list:-`ls ${ezjail_prefix}/etc/ezjail/`}
40 for jail in $jail_list; do . ${ezjail_prefix}/etc/ezjail/${jail}; done
41 sh /etc/rc.d/jail onestop $jail_list
42 sh /etc/rc.d/jail onestart $jail_list
31} 43}
32 44
33do_stop() 45do_stop()
34{ 46{
35 jail_enable=${ezjail_enable} 47 [ -n "$*" ] && jail_list=`echo $* | tr /~. ___`;
36 jail_list=`ls ${ezjail_prefix}/etc/ezjail/` 48 jail_list=${jail_list:-`ls ${ezjail_prefix}/etc/ezjail/`}
37 for jail in $jail_list; do . ${ezjail_prefix}/etc/ezjail/${jail}; done 49 for jail in $jail_list; do . ${ezjail_prefix}/etc/ezjail/${jail}; done
38 sh /etc/rc.d/jail stop $* 50 sh /etc/rc.d/jail onestop $jail_list
39} 51}
40 52
41load_rc_config $name
42run_rc_command $* 53run_rc_command $*
diff --git a/ezjail-admin b/ezjail-admin
index 649fde1..ac12f18 100755
--- a/ezjail-admin
+++ b/ezjail-admin
@@ -43,7 +43,8 @@ create)
43 newjail_softlink= 43 newjail_softlink=
44 newjail_fill="YES" 44 newjail_fill="YES"
45 45
46 for arg in args; do 46 set -- $args
47 for arg do
47 case $arg in 48 case $arg in
48 -x) newjail_fill="NO"; shift;; 49 -x) newjail_fill="NO"; shift;;
49 -r) newjail_root="$2"; shift 2;; 50 -r) newjail_root="$2"; shift 2;;
@@ -58,7 +59,7 @@ create)
58 fi 59 fi
59 60
60 # relative paths don't make sense in rc.scripts 61 # relative paths don't make sense in rc.scripts
61 if [ "${ezjail_jaildir#/}" == "${ezjail_jaildir}" ]; then 62 if [ ${ezjail_jaildir#/} = ${ezjail_jaildir} ]; then
62 echo Error: Need an absolute path in ezjail_jaildir, it is currently set to: $ezjail_jaildir 63 echo Error: Need an absolute path in ezjail_jaildir, it is currently set to: $ezjail_jaildir
63 exit 1; 64 exit 1;
64 fi 65 fi
@@ -73,7 +74,7 @@ create)
73 74
74 # if jail root specified on command line is not absolute, 75 # if jail root specified on command line is not absolute,
75 # make it absolute inside our jail directory 76 # make it absolute inside our jail directory
76 if [ "${newjail_root#/}" = "${newjail_root}" ]; then 77 if [ ${newjail_root#/} = ${newjail_root} ]; then
77 newjail_root=$ezjail_jaildir/$newjail_root 78 newjail_root=$ezjail_jaildir/$newjail_root
78 fi 79 fi
79 80
@@ -100,22 +101,20 @@ create)
100 101
101 # if the automount feature is not disabled, create an 102 # if the automount feature is not disabled, create an
102 # fstab entry for new jail 103 # fstab entry for new jail
103 echo $ezjail_jailbase $newjail_root/basejail nullfs ro 0 0 > /etc/fstab.$newjail_name 104 echo $ezjail_jailbase $newjail_root/basejail nullfs ro 0 0 > /etc/fstab.$newjail_nname
104 105
105 # now, where everything seems to have gone right, 106 # now, where everything seems to have gone right,
106 # create control file in ezjails config dir 107 # create control file in ezjails config dir
107 mkdir -p $ezjail_jailcfgs 108 mkdir -p $ezjail_jailcfgs
108 echo \ 109 echo export jail_${newjail_nname}_hostname=\"${newjail_name}\" >> ${ezjail_jailcfgs}/${newjail_nname}
109 jail_${newjail_nname}_hostname=\"${newjail_name}\" \n \ 110 echo export jail_${newjail_nname}_ip=\"${newjail_ip}\" >> ${ezjail_jailcfgs}/${newjail_nname}
110 jail_${newjail_nname}_ip=\"${newjail_ip}\" \n \ 111 echo export jail_${newjail_nname}_rootdir=\"${newjail_root}\" >> ${ezjail_jailcfgs}/${newjail_nname}
111 jail_${newjail_nname}_rootdir=\"${newjail_root}\" \n \ 112 echo export jail_${newjail_nname}_exec=\"/bin/sh /etc/rc\" >> ${ezjail_jailcfgs}/${newjail_nname}
112 jail_${newjail_nname}_exec=\"/bin/sh /etc/rc\" 113 echo export jail_${newjail_nname}_mount_enable=\"${ezjail_mount_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname}
113 jail_${newjail_nname}_mount_enable=\"${ezjail_mount_enable}\" \n \ 114 echo export jail_${newjail_nname}_devfs_enable=\"${ezjail_devfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname}
114 jail_${newjail_nname}_devfs_enable=\"${ezjail_devfs_enable}\" \n \ 115 echo export jail_${newjail_nname}_devfs_ruleset=\"devfsrules_jail\" >> ${ezjail_jailcfgs}/${newjail_nname}
115 jail_${newjail_nname}_devfs_ruleset="devfsrules_jail" 116 echo export jail_${newjail_nname}_procfs_enable=\"${ezjail_procfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname}
116 jail_${newjail_nname}_procfs_enable=\"${ezjail_procfs_enable}\" \n \ 117 echo export jail_${newjail_nname}_fdescfs_enable=\"${ezjail_fdescfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname}
117 jail_${newjail_nname}_fdescfs_enable=\"${ezjail_fdescfs_enable}\" \n \
118 > ${ezail_jailcfgs}/newjail_nname
119 118
120 ;; 119 ;;
121delete) 120delete)
@@ -132,11 +131,12 @@ update)
132 exit 1; 131 exit 1;
133 fi 132 fi
134 133
135 updatejail_installaction=world 134 updatejail_installaction="world"
136 135
137 for arg in args; do 136 set -- $args
137 for arg do
138 case $arg in 138 case $arg in
139 -i) updatejail_installaction=installworld; shift;; 139 -i) updatejail_installaction="installworld"; shift;;
140 -s) ezjail_sourcetree="$2"; shift 2;; 140 -s) ezjail_sourcetree="$2"; shift 2;;
141 --) shift; break;; 141 --) shift; break;;
142 esac 142 esac
@@ -158,8 +158,10 @@ update)
158 chflags -R noschg ${a}; rm -r ${a}; ln -s /basejail/${a} ${a} 158 chflags -R noschg ${a}; rm -r ${a}; ln -s /basejail/${a} ${a}
159 done 159 done
160 mkdir basejail 160 mkdir basejail
161 ln -s /basejail/usr/ports usr/ports
161 162
162 if [ -d ${ezjail_jailtemplate} ]; then 163 if [ -d ${ezjail_jailtemplate} ]; then
164 rm -rf ${ezjail_jailtemplate}_old
163 mv ${ezjail_jailtemplate} ${ezjail_jailtemplate}_old 165 mv ${ezjail_jailtemplate} ${ezjail_jailtemplate}_old
164 fi 166 fi
165 mv ${ezjail_jailfull} ${ezjail_jailtemplate} 167 mv ${ezjail_jailfull} ${ezjail_jailtemplate}
diff --git a/ezjail.conf.sample b/ezjail.conf.sample
index 5d0667b..9a2cc64 100755
--- a/ezjail.conf.sample
+++ b/ezjail.conf.sample
@@ -8,7 +8,7 @@
8# 8#
9# Note: If you have spread your jails to multiple locations, use softlinks 9# Note: If you have spread your jails to multiple locations, use softlinks
10# to collect them in this directory 10# to collect them in this directory
11ezjail_jaildir=/usr/jails/ 11ezjail_jaildir=/usr/jails
12 12
13# Location of the tiny skeleton jail template 13# Location of the tiny skeleton jail template
14ezjail_jailtemplate=$ezjail_jaildir/newjail 14ezjail_jailtemplate=$ezjail_jaildir/newjail