Permalink
Browse files

Include experimental support for upgrading the basejail

  • Loading branch information...
1 parent 5ef4113 commit 5214901c70f75afa725bb462daa98aabc70f216b erdgeist committed Mar 14, 2011
Showing with 55 additions and 7 deletions.
  1. +20 −3 ezjail-admin
  2. +12 −0 man7/ezjail.7
  3. +23 −4 man8/ezjail-admin.8
View
23 ezjail-admin
@@ -1,5 +1,5 @@
#!/bin/sh
-# $Id: ezjail-admin,v 1.263 2011/03/07 04:04:25 erdgeist Exp $
+# $Id: ezjail-admin,v 1.264 2011/03/14 01:31:14 erdgeist Exp $
# ugly: this variable is set during port install time
ezjail_prefix=EZJAIL_PREFIX
@@ -47,7 +47,7 @@ ezjail_usage_ezjailadmin="${ezjail_admin} v3.1.1b\nUsage: ${ezjail_admin} [archi
ezjail_usage_install="Usage: ${ezjail_admin} install [-mMpPsS] [-h host] [-r release]"
ezjail_usage_create="Usage: ${ezjail_admin} create [-xbi] [-f flavour] [-r jailroot] [-s size] [-c bde|eli|zfs] [-C args] [-a archive] jailname jailip"
ezjail_usage_delete="Usage: ${ezjail_admin} delete [-wf] jailname"
-ezjail_usage_update="Usage: ${ezjail_admin} update [-s sourcetree] [-p] (-b|-i|-u|-P)"
+ezjail_usage_update="Usage: ${ezjail_admin} update [-s sourcetree|sourceosversion] [-p] (-b|-i|-u|-U|-P)"
ezjail_usage_config="Usage: ${ezjail_admin} config [-r run|norun] [-n newname] [-c cpuset] [-z zfs-datasets] [-f fib] [-i attach|detach|fsck] jailname"
ezjail_usage_console="Usage: ${ezjail_admin} console [-f] [-e command] jailname"
ezjail_usage_archive="Usage: ${ezjail_admin} archive [-Af] [-a archive] [-d archivedir] jailname [jailname...]"
@@ -837,12 +837,13 @@ list)
######################## ezjail-admin UPDATE ########################
setup|update)
# Clean variables, prevent polution
- unset ezjail_provideports ezjail_installaction
+ unset ezjail_provideports ezjail_installaction ezjail_osversion_source ezjail_osversion_destination
shift; while getopts :biupPs: arg; do case ${arg} in
b) ezjail_installaction="buildworld installworld";;
i) ezjail_installaction="installworld";;
u) ezjail_installaction="freebsd-update";;
+ U) ezjail_installaction="freebsd-upgrade";;
s) ezjail_sourcetree=${OPTARG};;
P) ezjail_provideports="YES"; ezjail_installaction="none";;
p) ezjail_provideports="YES";;
@@ -870,6 +871,22 @@ setup|update)
[ -z "$TERM" -o "$TERM" = "dumb" ] && ezjail_urgency="cron" || ezjail_urgency="fetch"
[ "${ezjail_use_zfs}" = "YES" ] && zfs snapshot ${ezjail_jailzfs}/basejail@`date -v -7d +"%C%y%m%d_%H:%M:%S"`
freebsd-update -b ${ezjail_jailbase} ${ezjail_urgency} install
+ elif [ "${ezjail_installaction}" == "freebsd-upgrade" ]; then
+ [ -d "${ezjail_jailbase}" ] || exerr "Error: base jail does not exist.\n You cannot update a base jail until it is created.\n Please run '${ezjail_admin} update' or '${ezjail_admin} install' first."
+
+ [ -z "${ezjail_sourcetree}" ] && exerr "Error: Can not (yet automatically) infer the basejail's osversion.\n Please run ${ezjail_admin} update -U -s X.X-RELEASE, with X.X-RELEASE being to osversion currently installed in the basejail in need of an upgrade."
+
+ # That would be the part where we try to lookup the osversion from a file in the basejail
+ ezjail_osversion_source="${ezjail_sourcetree}"
+
+ # Make the host systems os version our target version
+ # Users can override this by setting the UNAME_r environment variable
+ ezjail_osversion_target="`uname -r`"
+
+ # Finally run freebsd-update to upgrade our basejail
+ env UNAME_r="${ezjail_osversion_source}" freebsd-update -b ${ezjail_jailbase} -r ${ezjail_osversion_target} upgrade install
+
+ # Here we should write the file with the new osversion in case of success
else
# Bump the user for some of the most common errors
[ -d "${ezjail_sourcetree}" ] || exerr "Error: Cannot find your copy of the FreeBSD source tree in ${ezjail_sourcetree}.\n Consider using '${ezjail_admin} install' to create the base jail from an ftp server."
View
12 man7/ezjail.7
@@ -566,6 +566,18 @@ Update the base jail to the next release using
.Xr freebsd-update 8
(i.e. using binary packages). This may be used only to update an
existing installation.
+.It Nm Cm update Fl U s Ar 8.0-RELEASE
+Upgrade the base jail to the host system's release using
+.Xr freebsd-update 8 . This may be used only to upgrade an
+existing installation. Tell freebsd-update which OS version to expect
+in the basejail via the
+.Fl s No option.
+.Pp
+Note: Check
+.Xr uname 1
+and especially the
+.Pa UNAME_r
+environment variable to upgrade to different versions.
.El
.Ss Jail Creation Examples
.Bl -tag -width indent
View
27 man8/ezjail-admin.8
@@ -54,9 +54,9 @@
.Ar archive | jailname...
.Nm
.Cm update
-.Op Fl s Ar sourcetree
+.Op Fl s Ar sourcetree | sourceosversion
.Op Fl p
-.Fl b | Fl i | Fl P | Fl u
+.Fl b | Fl i | Fl P | Fl u | Fl U
.Sh DESCRIPTION
The
.Nm
@@ -535,6 +535,19 @@ uses
to determine the currently running system, the base jail and the host
need to be updated at the same time, without rebooting on the new
kernel in the meantime.
+.It Fl U
+Use
+.Xr freebsd-update 8
+to upgrade the basejail to the hosts operating system version, or a version
+you may pass freebsd-update's call to
+.Dq uname -r
+via the
+.Pa UNAME_r
+environment variable. Since there currently is no way of infering the
+osversion currently installed in the basejail, you need to remember the
+original osversion and pass it to this script using the
+.Fl s
+option.
.It Fl P
Install only the ports tree, assuming the basejail has already been
created. This can be done while jails are running. The
@@ -548,13 +561,19 @@ The following options are available:
Give the new basejail a copy of FreeBSD's ports tree. The
.Xr portsnap 8
utility is invoked to do the actual work.
-.It Fl s Ar sourcedir
-Use the sources in
+.It Fl s Ar sourcedir | sourceosversion
+In the
+.Fl b No and Fl i No case: Use the sources in
.Ar sourcedir
instead of
.Pa /usr/src .
Variable:
.Dq Li $ezjail_sourcetree .
+.Pp
+In the
+.Fl U No case: Pass this release tag to
+.Xr freebsd-update 8
+as the source OS version of the basejail.
.El
.Pp
See the

0 comments on commit 5214901

Please sign in to comment.