Include experimental support for upgrading the basejail
This commit is contained in:
parent
b3c7e95edb
commit
283c672f39
21
ezjail-admin
21
ezjail-admin
@ -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_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_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_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_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_console="Usage: ${ezjail_admin} console [-f] [-e command] jailname"
|
||||||
ezjail_usage_archive="Usage: ${ezjail_admin} archive [-Af] [-a archive] [-d archivedir] jailname [jailname...]"
|
ezjail_usage_archive="Usage: ${ezjail_admin} archive [-Af] [-a archive] [-d archivedir] jailname [jailname...]"
|
||||||
@ -837,12 +837,13 @@ list)
|
|||||||
######################## ezjail-admin UPDATE ########################
|
######################## ezjail-admin UPDATE ########################
|
||||||
setup|update)
|
setup|update)
|
||||||
# Clean variables, prevent polution
|
# 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
|
shift; while getopts :biupPs: arg; do case ${arg} in
|
||||||
b) ezjail_installaction="buildworld installworld";;
|
b) ezjail_installaction="buildworld installworld";;
|
||||||
i) ezjail_installaction="installworld";;
|
i) ezjail_installaction="installworld";;
|
||||||
u) ezjail_installaction="freebsd-update";;
|
u) ezjail_installaction="freebsd-update";;
|
||||||
|
U) ezjail_installaction="freebsd-upgrade";;
|
||||||
s) ezjail_sourcetree=${OPTARG};;
|
s) ezjail_sourcetree=${OPTARG};;
|
||||||
P) ezjail_provideports="YES"; ezjail_installaction="none";;
|
P) ezjail_provideports="YES"; ezjail_installaction="none";;
|
||||||
p) ezjail_provideports="YES";;
|
p) ezjail_provideports="YES";;
|
||||||
@ -870,6 +871,22 @@ setup|update)
|
|||||||
[ -z "$TERM" -o "$TERM" = "dumb" ] && ezjail_urgency="cron" || ezjail_urgency="fetch"
|
[ -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"`
|
[ "${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
|
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
|
else
|
||||||
# Bump the user for some of the most common errors
|
# 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."
|
[ -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."
|
||||||
|
@ -566,6 +566,18 @@ Update the base jail to the next release using
|
|||||||
.Xr freebsd-update 8
|
.Xr freebsd-update 8
|
||||||
(i.e. using binary packages). This may be used only to update an
|
(i.e. using binary packages). This may be used only to update an
|
||||||
existing installation.
|
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
|
.El
|
||||||
.Ss Jail Creation Examples
|
.Ss Jail Creation Examples
|
||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
|
@ -54,9 +54,9 @@
|
|||||||
.Ar archive | jailname...
|
.Ar archive | jailname...
|
||||||
.Nm
|
.Nm
|
||||||
.Cm update
|
.Cm update
|
||||||
.Op Fl s Ar sourcetree
|
.Op Fl s Ar sourcetree | sourceosversion
|
||||||
.Op Fl p
|
.Op Fl p
|
||||||
.Fl b | Fl i | Fl P | Fl u
|
.Fl b | Fl i | Fl P | Fl u | Fl U
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
@ -535,6 +535,19 @@ uses
|
|||||||
to determine the currently running system, the base jail and the host
|
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
|
need to be updated at the same time, without rebooting on the new
|
||||||
kernel in the meantime.
|
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
|
.It Fl P
|
||||||
Install only the ports tree, assuming the basejail has already been
|
Install only the ports tree, assuming the basejail has already been
|
||||||
created. This can be done while jails are running. The
|
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
|
Give the new basejail a copy of FreeBSD's ports tree. The
|
||||||
.Xr portsnap 8
|
.Xr portsnap 8
|
||||||
utility is invoked to do the actual work.
|
utility is invoked to do the actual work.
|
||||||
.It Fl s Ar sourcedir
|
.It Fl s Ar sourcedir | sourceosversion
|
||||||
Use the sources in
|
In the
|
||||||
|
.Fl b No and Fl i No case: Use the sources in
|
||||||
.Ar sourcedir
|
.Ar sourcedir
|
||||||
instead of
|
instead of
|
||||||
.Pa /usr/src .
|
.Pa /usr/src .
|
||||||
Variable:
|
Variable:
|
||||||
.Dq Li $ezjail_sourcetree .
|
.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
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
See the
|
See the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user