summaryrefslogtreecommitdiff
path: root/ezjail-admin
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2006-01-16 05:06:04 +0000
committererdgeist <erdgeist@erdgeist.org>2006-01-16 05:06:04 +0000
commit0c133c53cd3b4c5ad7d4cfddacedb44d67608661 (patch)
treed8d68f3258c9ff7d20d351aa83b6ed7f573fcd7b /ezjail-admin
parent32a96ad615da4287925764ac03b7ca7f6f0b54b9 (diff)
Introducing the -P flag to allow ports updating only
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-xezjail-admin111
1 files changed, 74 insertions, 37 deletions
diff --git a/ezjail-admin b/ezjail-admin
index 1a5c535..b875da1 100755
--- a/ezjail-admin
+++ b/ezjail-admin
@@ -18,6 +18,7 @@ ezjail_jailbase=${ezjail_jailbase:-"$ezjail_jaildir/basejail"}
18ezjail_jailfull=${ezjail_jailfull:-"$ezjail_jaildir/fulljail"} 18ezjail_jailfull=${ezjail_jailfull:-"$ezjail_jaildir/fulljail"}
19ezjail_flavours=${ezjail_flavours:-"$ezjail_jaildir/flavours"} 19ezjail_flavours=${ezjail_flavours:-"$ezjail_jaildir/flavours"}
20ezjail_sourcetree=${ezjail_sourcetree:-"/usr/src"} 20ezjail_sourcetree=${ezjail_sourcetree:-"/usr/src"}
21ezjail_portscvsroot=${ezjail_portscvsroot:-":pserver:anoncvs@anoncvs.at.FreeBSD.org:/home/ncvs"}
21 22
22ezjail_mount_enable=${ezjail_mount_enable:-"YES"} 23ezjail_mount_enable=${ezjail_mount_enable:-"YES"}
23ezjail_devfs_enable=${ezjail_devfs_enable:-"YES"} 24ezjail_devfs_enable=${ezjail_devfs_enable:-"YES"}
@@ -54,11 +55,11 @@ create)
54 newjail_name=$1; newjail_ip=$2; 55 newjail_name=$1; newjail_ip=$2;
55 56
56 # we need at least a name and an ip for new jail 57 # we need at least a name and an ip for new jail
57 [ "$newjail_name" -a "$newjail_ip" -a $# = 2 ] || exerr 'Usage: ezjail create [-f flavour] [-r jailroot] [-x] jailname jailip' 58 [ "${newjail_name}" -a "${newjail_ip}" -a $# = 2 ] || exerr 'Usage: ezjail create [-f flavour] [-r jailroot] [-x] jailname jailip'
58 59
59 # check, whether ezjail-update has been called. existence of 60 # check, whether ezjail-update has been called. existence of
60 # ezjail_jailbase is our indicator 61 # ezjail_jailbase is our indicator
61 [ -d $ezjail_jailbase ] || exerr "Error: base jail does not exist. Please run 'ezjail-admin update' first" 62 [ -d ${ezjail_jailbase} ] || exerr "Error: base jail does not exist. Please run 'ezjail-admin update' first"
62 63
63 # relative paths don't make sense in rc.scripts 64 # relative paths don't make sense in rc.scripts
64 [ ${ezjail_jaildir#/} = ${ezjail_jaildir} ] && exerr "Error: Need an absolute path in ezjail_jaildir, it currently is set to: $ezjail_jaildir" 65 [ ${ezjail_jaildir#/} = ${ezjail_jaildir} ] && exerr "Error: Need an absolute path in ezjail_jaildir, it currently is set to: $ezjail_jaildir"
@@ -215,56 +216,92 @@ delete)
215######################## ezjail-admin UPDATE ######################## 216######################## ezjail-admin UPDATE ########################
216setup|update) 217setup|update)
217 shift 218 shift
218 args=`getopt is: $*` 219 args=`getopt ipPs: $*`
219 [ $? = 0 ] || exerr 'Usage: ezjail update [-s sourcetree] [-i]' 220 [ $? = 0 ] || exerr 'Usage: ezjail update [-s sourcetree] [-i] [-pP]'
220 221
221 updatejail_installaction="world" 222 updatejail_installaction="world"
223 updatejail_provideports=
222 224
223 set -- $args 225 set -- $args
224 for arg do 226 for arg do
225 case $arg in 227 case $arg in
226 -i) updatejail_installaction="installworld"; shift;; 228 -i) updatejail_installaction="installworld"; shift;;
227 -s) ezjail_sourcetree="$2"; shift 2;; 229 -s) ezjail_sourcetree="$2"; shift 2;;
230 -p) updatejail_provideports="YES"; shift;;
231 -P) updatejail_provideports="YES"; updatejail_installaction="none"; shift;;
228 --) shift; break;; 232 --) shift; break;;
229 esac 233 esac
230 done; 234 done;
231 235
232 # Bump the user for some of the most common errors 236 if [ $updatejail_installaction = "none" ]; then
233 [ -d ${ezjail_sourcetree} ] || exerr "Cannot find your copy of the FreeBSD source tree in $ezjail_sourcetree." 237 # check, whether ezjail-update has been called. existence of
234 [ -f ${ezjail_sourcetree}/Makefile ] || exerr "Your source tree in $ezjail_sourcetree seems to be incomplete (Makefile missing)." 238 # ezjail_jailbase is our indicator
235 239 [ -d ${ezjail_jailbase} ] || exerr "Error: base jail does not exist. You cannot fill base jails ports tree before creating it. Please run 'ezjail-admin update' first"
236 cd ${ezjail_sourcetree} 240 else
237 # Normally fulljail should be renamed by past ezjail-admin commands 241 # Bump the user for some of the most common errors
238 # However those may have failed 242 [ -d ${ezjail_sourcetree} ] || exerr "Cannot find your copy of the FreeBSD source tree in $ezjail_sourcetree."
239 rm -rf ${ezjail_jailfull}; mkdir -p ${ezjail_jailfull} 243 [ -f ${ezjail_sourcetree}/Makefile ] || exerr "Your source tree in $ezjail_sourcetree seems to be incomplete (Makefile missing)."
240 244
241 # make our world 245 cd ${ezjail_sourcetree}
242 make ${updatejail_installaction} DESTDIR=${ezjail_jailfull} 246 # Normally fulljail should be renamed by past ezjail-admin commands
243 [ $? = 0 ] || exerr "make ${updatejail_installaction} failed" 247 # However those may have failed
244 248 rm -rf ${ezjail_jailfull}; mkdir -p ${ezjail_jailfull}
245 # setup world 249
246 make distribution DESTDIR=${ezjail_jailfull} 250 # make our world
247 [ $? = 0 ] || exerr "make distribution failed" 251 make ${updatejail_installaction} DESTDIR=${ezjail_jailfull}
248 252 [ $? = 0 ] || exerr "make ${updatejail_installaction} failed"
249 cd ${ezjail_jailfull} 253
250 # Fill basejail from installed world 254 # setup world
251 mkdir -p ${ezjail_jailbase}/usr ${ezjail_jailbase}/config/pkg 255 make distribution DESTDIR=${ezjail_jailfull}
252 for a in bin lib libexec sbin usr/bin usr/include usr/lib usr/libexec usr/sbin usr/src usr/share; do 256 [ $? = 0 ] || exerr "make distribution failed"
253 find ${a} | cpio -d -p -v ${ezjail_jailbase}; 257
254 chflags -R noschg ${a}; rm -r ${a}; ln -s /basejail/${a} ${a} 258 cd ${ezjail_jailfull}
255 done 259 # Fill basejail from installed world
256 mkdir basejail 260 mkdir -p ${ezjail_jailbase}/usr ${ezjail_jailbase}/config/pkg
257 ln -s /basejail/usr/ports usr/ports 261 for a in bin lib libexec sbin usr/bin usr/include usr/lib usr/libexec usr/sbin usr/src usr/share; do
262 find ${a} | cpio -d -p -v ${ezjail_jailbase};
263 chflags -R noschg ${a}; rm -r ${a}; ln -s /basejail/${a} ${a}
264 done
265 mkdir basejail
266
267 if [ -d ${ezjail_jailtemplate} ]; then
268 chflags -R noschg ${ezjail_jailtemplate}_old
269 rm -rf ${ezjail_jailtemplate}_old
270 mv ${ezjail_jailtemplate} ${ezjail_jailtemplate}_old
271 fi
272 mv ${ezjail_jailfull} ${ezjail_jailtemplate}
273
274 # If the default flavour example has not yet been copied, do it now
275 [ -d ${ezjail_flavours}/default ] || cp -p -r ${ezjail_examples}/default ${ezjail_flavours}/
276
277 fi # installaction="none"
278
279 # The user may want to have a ports tree in basejail
280 if [ "$updatejail_provideports" ]; then
281 # if /usr/ports/CVS exists, assume cvs up is safe
282 if [ -f ${ezjail_jailbase}/usr/ports/CVS/Root ]; then
283 echo -n "Updating ports from "; cat ${ezjail_jailbase}/usr/ports/CVS/Root
284 echo "Gathering local information may take a while."
285 cd ${ezjail_jailbase}/usr/ports/; cvs up -APd
286 else
287 echo "Checking out ports from ${ezjail_portscvsroot}"
288 mkdir -p ${ezjail_jailbase}/usr/ports/
289 cd ${ezjail_jailbase}/usr/; cvs -d ${ezjail_portscvsroot} co ports
290 fi
291
292 [ $? = 0 ] || exerr "Updating ports failed."
293 [ -f ${ezjail_jailtmeplate}/usr/ports ] || ln -s /basejail/usr/ports ${ezjail_jailtemplate}/usr/ports
258 294
259 if [ -d ${ezjail_jailtemplate} ]; then
260 chflags -R noschg ${ezjail_jailtemplate}_old
261 rm -rf ${ezjail_jailtemplate}_old
262 mv ${ezjail_jailtemplate} ${ezjail_jailtemplate}_old
263 fi 295 fi
264 mv ${ezjail_jailfull} ${ezjail_jailtemplate}
265 296
266 # If the default flavour example has not yet been copied, do it now 297 # A ports collection inside jails is hardly useful w/o an appropriate /etc/make.conf
267 [ -d ${ezjail_flavours}/default ] || cp -p -r ${ezjail_examples}/default ${ezjail_flavours}/ 298 # if we find basejail/usr/ports/Makefile, assume that the admin wants a working make.conf in new jails
299 if [ -f ${ezjail_jailbase}/usr/ports/Makefile -a -f ${ezjail_examples}/default/etc/make.conf -a \
300 ! -f ${ezjail_jailtemplate}/etc/make.conf ]; then
301 cp -p ${ezjail_examples}/default/etc/make.conf ${ezjail_jailtemplate}/etc/
302 echo Note: a non-standard /etc/make.conf was copied to the template jail
303 echo in order to get the ports collection running inside jails
304 fi
268 305
269 ;; 306 ;;
270*) 307*)