summaryrefslogtreecommitdiff
path: root/ezjail-admin
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2006-02-06 02:29:42 +0000
committererdgeist <erdgeist@erdgeist.org>2006-02-06 02:29:42 +0000
commitf0e838773bf51a1f52be00d149a6ee660f82d58e (patch)
tree518c74479e5f8a985ac74a02c26efe7d81dc8e93 /ezjail-admin
parent03175084a04ba3539d9abc41787b7e85288ab57a (diff)
provide braces for variable expansion, rename a to dir, remove templatejail_old only, if it exists
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-xezjail-admin40
1 files changed, 22 insertions, 18 deletions
diff --git a/ezjail-admin b/ezjail-admin
index 177bd42..4c1c82d 100755
--- a/ezjail-admin
+++ b/ezjail-admin
@@ -43,9 +43,9 @@ create)
43 newjail_softlink= 43 newjail_softlink=
44 newjail_fill="YES" 44 newjail_fill="YES"
45 45
46 set -- $args 46 set -- ${args}
47 for arg do 47 for arg do
48 case $arg in 48 case ${arg} in
49 -x) newjail_fill="NO"; shift;; 49 -x) newjail_fill="NO"; shift;;
50 -r) newjail_root="$2"; shift 2;; 50 -r) newjail_root="$2"; shift 2;;
51 -f) newjail_flavour="$2"; shift 2;; 51 -f) newjail_flavour="$2"; shift 2;;
@@ -97,7 +97,7 @@ create)
97 # passed here 97 # passed here
98 98
99 # now take a copy of our template jail 99 # now take a copy of our template jail
100 if [ "$newjail_fill" = "YES" ]; then 100 if [ "${newjail_fill}" = "YES" ]; then
101 mkdir -p ${newjail_root} && cd ${ezjail_jailtemplate} && \ 101 mkdir -p ${newjail_root} && cd ${ezjail_jailtemplate} && \
102 find * | cpio -p -v ${newjail_root} > /dev/null 102 find * | cpio -p -v ${newjail_root} > /dev/null
103 [ $? = 0 ] || exerr 'Error: Could not copy template jail' 103 [ $? = 0 ] || exerr 'Error: Could not copy template jail'
@@ -142,7 +142,7 @@ create)
142 [ $? = 0 ] || echo "Warning: IP ${newjail_ip} not configured on a local interface." 142 [ $? = 0 ] || echo "Warning: IP ${newjail_ip} not configured on a local interface."
143 143
144 # check, whether some host system services do listen on the Jails IP 144 # check, whether some host system services do listen on the Jails IP
145 TIFS=$IFS; IFS=_ 145 TIFS=${IFS}; IFS=_
146 newjail_listener=`sockstat -4 -l | grep ${newjail_ip}:[[:digit:]]` 146 newjail_listener=`sockstat -4 -l | grep ${newjail_ip}:[[:digit:]]`
147 if [ $? = 0 ]; then 147 if [ $? = 0 ]; then
148 echo "Warning: Some services already seem to be listening on IP ${newjail_ip}" 148 echo "Warning: Some services already seem to be listening on IP ${newjail_ip}"
@@ -156,7 +156,7 @@ create)
156 echo " This may cause some confusion, here they are:" 156 echo " This may cause some confusion, here they are:"
157 echo ${newjail_listener} 157 echo ${newjail_listener}
158 fi 158 fi
159 IFS=$TIFS 159 IFS=${TIFS}
160 160
161 ;; 161 ;;
162######################## ezjail-admin DELETE ######################## 162######################## ezjail-admin DELETE ########################
@@ -167,9 +167,9 @@ delete)
167 167
168 oldjail_wipe= 168 oldjail_wipe=
169 169
170 set -- $args 170 set -- ${args}
171 for arg do 171 for arg do
172 case $arg in 172 case ${arg} in
173 -w) oldjail_wipe="YES"; shift;; 173 -w) oldjail_wipe="YES"; shift;;
174 --) shift; break;; 174 --) shift; break;;
175 esac 175 esac
@@ -233,9 +233,9 @@ setup|update)
233 updatejail_installaction="world" 233 updatejail_installaction="world"
234 updatejail_provideports= 234 updatejail_provideports=
235 235
236 set -- $args 236 set -- ${args}
237 for arg do 237 for arg do
238 case $arg in 238 case ${arg} in
239 -i) updatejail_installaction="installworld"; shift;; 239 -i) updatejail_installaction="installworld"; shift;;
240 -s) ezjail_sourcetree="$2"; shift 2;; 240 -s) ezjail_sourcetree="$2"; shift 2;;
241 -p) updatejail_provideports="YES"; shift;; 241 -p) updatejail_provideports="YES"; shift;;
@@ -266,19 +266,24 @@ setup|update)
266 make distribution DESTDIR=${ezjail_jailfull} 266 make distribution DESTDIR=${ezjail_jailfull}
267 [ $? = 0 ] || exerr "make distribution failed" 267 [ $? = 0 ] || exerr "make distribution failed"
268 268
269 cd ${ezjail_jailfull}
270 # Fill basejail from installed world 269 # Fill basejail from installed world
270 cd ${ezjail_jailfull}
271 # This mkdir is important, since install will create intermediate
272 # directories with permission 0700 which is bad
271 mkdir -p ${ezjail_jailbase}/usr 273 mkdir -p ${ezjail_jailbase}/usr
272 for a in bin lib libexec sbin usr/bin usr/include usr/lib usr/libexec usr/sbin usr/src usr/share; do 274 for dir in bin lib libexec sbin usr/bin usr/include usr/lib usr/libexec usr/sbin usr/src usr/share; do
273 find ${a} | cpio -d -p -v ${ezjail_jailbase} 275 find ${dir} | cpio -d -p -v ${ezjail_jailbase}
274 [ $? = 0 ] || exerr "Installation of ${a} failed." 276 [ $? = 0 ] || exerr "Installation of ${dir} failed."
275 chflags -R noschg ${a}; rm -r ${a}; ln -s /basejail/${a} ${a} 277 chflags -R noschg ${dir}; rm -r ${dir}; ln -s /basejail/${dir} ${dir}
276 done 278 done
277 mkdir basejail 279 mkdir basejail
278 280
281 # Try to remove the old template jail
279 if [ -d ${ezjail_jailtemplate} ]; then 282 if [ -d ${ezjail_jailtemplate} ]; then
280 chflags -R noschg ${ezjail_jailtemplate}_old 283 if [ -d ${ezjail_jailtemplate}_old ]; then
281 rm -rf ${ezjail_jailtemplate}_old 284 chflags -R noschg ${ezjail_jailtemplate}_old
285 rm -rf ${ezjail_jailtemplate}_old
286 fi
282 mv ${ezjail_jailtemplate} ${ezjail_jailtemplate}_old 287 mv ${ezjail_jailtemplate} ${ezjail_jailtemplate}_old
283 fi 288 fi
284 mv ${ezjail_jailfull} ${ezjail_jailtemplate} 289 mv ${ezjail_jailfull} ${ezjail_jailtemplate}
@@ -289,7 +294,7 @@ setup|update)
289 fi # installaction="none" 294 fi # installaction="none"
290 295
291 # The user may want to have a ports tree in basejail 296 # The user may want to have a ports tree in basejail
292 if [ "$updatejail_provideports" ]; then 297 if [ "${updatejail_provideports}" = "YES" ]; then
293 # if /usr/ports/CVS exists, assume cvs up is safe 298 # if /usr/ports/CVS exists, assume cvs up is safe
294 if [ -f ${ezjail_jailbase}/usr/ports/CVS/Root ]; then 299 if [ -f ${ezjail_jailbase}/usr/ports/CVS/Root ]; then
295 echo -n "Updating ports from "; cat ${ezjail_jailbase}/usr/ports/CVS/Root 300 echo -n "Updating ports from "; cat ${ezjail_jailbase}/usr/ports/CVS/Root
@@ -301,7 +306,6 @@ setup|update)
301 cd ${ezjail_jailbase}/usr/; cvs -d ${ezjail_portscvsroot} co ports 306 cd ${ezjail_jailbase}/usr/; cvs -d ${ezjail_portscvsroot} co ports
302 fi 307 fi
303 [ $? = 0 ] || exerr "Updating ports failed." 308 [ $? = 0 ] || exerr "Updating ports failed."
304
305 fi 309 fi
306 310
307 # A ports collection inside jails is hardly useful w/o an appropriate /etc/make.conf 311 # A ports collection inside jails is hardly useful w/o an appropriate /etc/make.conf