diff options
author | erdgeist <erdgeist@erdgeist.org> | 2006-03-18 22:04:03 +0000 |
---|---|---|
committer | erdgeist <erdgeist@erdgeist.org> | 2006-03-18 22:04:03 +0000 |
commit | c6763b6e35e1cfcd0e6aa3fba945b9326bb9054d (patch) | |
tree | 705b87eadc8dc6bc1ac7ba41e5baca325aa987ff | |
parent | b924c9a6c71abebeec51f927c309ebcacde6efec (diff) |
Got the first running image-jails. Need more testing and sanity checking.
-rw-r--r-- | ezjail-img.sh | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/ezjail-img.sh b/ezjail-img.sh index 2514499..6e28c45 100644 --- a/ezjail-img.sh +++ b/ezjail-img.sh | |||
@@ -1,7 +1,8 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | # ugly: this variable is set during port install time | 3 | # ugly: this variable is set during port install time |
4 | ezjail_prefix=EZJAIL_PREFIX | 4 | #ezjail_prefix=EZJAIL_PREFIX |
5 | ezjail_prefix=/usr/local/ | ||
5 | ezjail_etc=${ezjail_prefix}/etc | 6 | ezjail_etc=${ezjail_prefix}/etc |
6 | ezjail_share=${ezjail_prefix}/share/ezjail | 7 | ezjail_share=${ezjail_prefix}/share/ezjail |
7 | ezjail_examples=${ezjail_prefix}/share/examples/ezjail | 8 | ezjail_examples=${ezjail_prefix}/share/examples/ezjail |
@@ -29,13 +30,12 @@ ezjail_fdescfs_enable=${ezjail_fdescfs_enable:-"YES"} | |||
29 | exerr () { echo -e "$*"; exit 1; } | 30 | exerr () { echo -e "$*"; exit 1; } |
30 | 31 | ||
31 | # define detach strategy for image jails | 32 | # define detach strategy for image jails |
32 | detach () { | 33 | detach_images () { |
33 | # unmount and detach memory disc | 34 | # unmount and detach memory disc |
34 | if [ "${newjail_device}" ]; then | 35 | if [ "${newjail_device}" ]; then |
35 | umount ${newjail_root} | 36 | umount ${newjail_root} |
36 | mdconfig -d -u ${newjail_device} | 37 | mdconfig -d -u ${newjail_device} |
37 | fi | 38 | fi |
38 | return 0 | ||
39 | } | 39 | } |
40 | 40 | ||
41 | # check for command | 41 | # check for command |
@@ -140,7 +140,7 @@ create) | |||
140 | if [ "${newjail_fill}" = "YES" ]; then | 140 | if [ "${newjail_fill}" = "YES" ]; then |
141 | mkdir -p ${newjail_root} && cd ${ezjail_jailtemplate} && \ | 141 | mkdir -p ${newjail_root} && cd ${ezjail_jailtemplate} && \ |
142 | find * | cpio -p -v ${newjail_root} > /dev/null | 142 | find * | cpio -p -v ${newjail_root} > /dev/null |
143 | [ $? != 0 ] || detach() || exerr "Error: Could not copy template jail." | 143 | [ $? = 0 ] || detach_images || exerr "Error: Could not copy template jail." |
144 | fi | 144 | fi |
145 | 145 | ||
146 | # if a soft link is necessary, create it now | 146 | # if a soft link is necessary, create it now |
@@ -148,19 +148,22 @@ create) | |||
148 | 148 | ||
149 | # if the automount feature is not disabled, this fstab entry for new jail | 149 | # if the automount feature is not disabled, this fstab entry for new jail |
150 | # will be obeyed | 150 | # will be obeyed |
151 | echo ${ezjail_jailbase} ${newjail_root}/basejail nullfs ro 0 0 > /etc/fstab.${newjail_nname} | 151 | echo -n > /etc/fstab.${newjail_nname} |
152 | [ "${newjail_imagesize}" ] && \ | ||
153 | echo ${newjail_root}.device ${newjail_root} ufs rw 0 0 >> /etc/fstab.${newjail_nname} | ||
154 | echo ${ezjail_jailbase} ${newjail_root}/basejail nullfs ro 0 0 >> /etc/fstab.${newjail_nname} | ||
152 | 155 | ||
153 | # now, where everything seems to have gone right, create control file in | 156 | # now, where everything seems to have gone right, create control file in |
154 | # ezjails config dir | 157 | # ezjails config dir |
155 | mkdir -p ${ezjail_jailcfgs} | 158 | mkdir -p ${ezjail_jailcfgs} |
156 | echo export jail_${newjail_nname}_hostname=\"${newjail_name}\" > ${ezjail_jailcfgs}/${newjail_nname} | 159 | echo export jail_${newjail_nname}_hostname=\"${newjail_name}\" > ${ezjail_jailcfgs}/${newjail_nname} |
157 | echo export jail_${newjail_nname}_ip=\"${newjail_ip}\" >> ${ezjail_jailcfgs}/${newjail_nname} | 160 | echo export jail_${newjail_nname}_ip=\"${newjail_ip}\" >> ${ezjail_jailcfgs}/${newjail_nname} |
158 | echo export jail_${newjail_nname}_rootdir=\"${newjail_root}\" >> ${ezjail_jailcfgs}/${newjail_nname} | 161 | echo export jail_${newjail_nname}_rootdir=\"${newjail_root}\" >> ${ezjail_jailcfgs}/${newjail_nname} |
159 | echo export jail_${newjail_nname}_exec=\"/bin/sh /etc/rc\" >> ${ezjail_jailcfgs}/${newjail_nname} | 162 | echo export jail_${newjail_nname}_exec=\"/bin/sh /etc/rc\" >> ${ezjail_jailcfgs}/${newjail_nname} |
160 | echo export jail_${newjail_nname}_mount_enable=\"${ezjail_mount_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} | 163 | echo export jail_${newjail_nname}_mount_enable=\"${ezjail_mount_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} |
161 | echo export jail_${newjail_nname}_devfs_enable=\"${ezjail_devfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} | 164 | echo export jail_${newjail_nname}_devfs_enable=\"${ezjail_devfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} |
162 | echo export jail_${newjail_nname}_devfs_ruleset=\"devfsrules_jail\" >> ${ezjail_jailcfgs}/${newjail_nname} | 165 | echo export jail_${newjail_nname}_devfs_ruleset=\"devfsrules_jail\" >> ${ezjail_jailcfgs}/${newjail_nname} |
163 | echo export jail_${newjail_nname}_procfs_enable=\"${ezjail_procfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} | 166 | echo export jail_${newjail_nname}_procfs_enable=\"${ezjail_procfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} |
164 | echo export jail_${newjail_nname}_fdescfs_enable=\"${ezjail_fdescfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} | 167 | echo export jail_${newjail_nname}_fdescfs_enable=\"${ezjail_fdescfs_enable}\" >> ${ezjail_jailcfgs}/${newjail_nname} |
165 | [ "${newjail_imagesize}" ] && \ | 168 | [ "${newjail_imagesize}" ] && \ |
166 | echo export jail_${newjail_nname}_image=\"${newjail_image}\" >> ${ezjail_jailcfgs}/${newjail_nname} | 169 | echo export jail_${newjail_nname}_image=\"${newjail_image}\" >> ${ezjail_jailcfgs}/${newjail_nname} |
@@ -181,7 +184,8 @@ create) | |||
181 | fi | 184 | fi |
182 | fi | 185 | fi |
183 | 186 | ||
184 | detach() | 187 | # Detach (crypto and) memory discs |
188 | detach_images | ||
185 | 189 | ||
186 | # | 190 | # |
187 | # For user convenience some scenarios commonly causing headaches are checked | 191 | # For user convenience some scenarios commonly causing headaches are checked |