diff options
author | erdgeist <erdgeist@erdgeist.org> | 2011-03-14 01:31:14 +0000 |
---|---|---|
committer | erdgeist <erdgeist@erdgeist.org> | 2011-03-14 01:31:14 +0000 |
commit | 283c672f391e73d0b83211f3763acfa13d6a6a41 (patch) | |
tree | 7c44e12ac5832238d477c275a19cd2d7c1e33bec /ezjail-admin | |
parent | b3c7e95edbe869118f9e5a9c2e9495712fa42ee0 (diff) |
Include experimental support for upgrading the basejail
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-x | ezjail-admin | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/ezjail-admin b/ezjail-admin index 418c89d..5f7fcdc 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
@@ -47,7 +47,7 @@ ezjail_usage_ezjailadmin="${ezjail_admin} v3.1.1b\nUsage: ${ezjail_admin} [archi | |||
47 | ezjail_usage_install="Usage: ${ezjail_admin} install [-mMpPsS] [-h host] [-r release]" | 47 | ezjail_usage_install="Usage: ${ezjail_admin} install [-mMpPsS] [-h host] [-r release]" |
48 | ezjail_usage_create="Usage: ${ezjail_admin} create [-xbi] [-f flavour] [-r jailroot] [-s size] [-c bde|eli|zfs] [-C args] [-a archive] jailname jailip" | 48 | ezjail_usage_create="Usage: ${ezjail_admin} create [-xbi] [-f flavour] [-r jailroot] [-s size] [-c bde|eli|zfs] [-C args] [-a archive] jailname jailip" |
49 | ezjail_usage_delete="Usage: ${ezjail_admin} delete [-wf] jailname" | 49 | ezjail_usage_delete="Usage: ${ezjail_admin} delete [-wf] jailname" |
50 | ezjail_usage_update="Usage: ${ezjail_admin} update [-s sourcetree] [-p] (-b|-i|-u|-P)" | 50 | ezjail_usage_update="Usage: ${ezjail_admin} update [-s sourcetree|sourceosversion] [-p] (-b|-i|-u|-U|-P)" |
51 | ezjail_usage_config="Usage: ${ezjail_admin} config [-r run|norun] [-n newname] [-c cpuset] [-z zfs-datasets] [-f fib] [-i attach|detach|fsck] jailname" | 51 | ezjail_usage_config="Usage: ${ezjail_admin} config [-r run|norun] [-n newname] [-c cpuset] [-z zfs-datasets] [-f fib] [-i attach|detach|fsck] jailname" |
52 | ezjail_usage_console="Usage: ${ezjail_admin} console [-f] [-e command] jailname" | 52 | ezjail_usage_console="Usage: ${ezjail_admin} console [-f] [-e command] jailname" |
53 | ezjail_usage_archive="Usage: ${ezjail_admin} archive [-Af] [-a archive] [-d archivedir] jailname [jailname...]" | 53 | ezjail_usage_archive="Usage: ${ezjail_admin} archive [-Af] [-a archive] [-d archivedir] jailname [jailname...]" |
@@ -837,12 +837,13 @@ list) | |||
837 | ######################## ezjail-admin UPDATE ######################## | 837 | ######################## ezjail-admin UPDATE ######################## |
838 | setup|update) | 838 | setup|update) |
839 | # Clean variables, prevent polution | 839 | # Clean variables, prevent polution |
840 | unset ezjail_provideports ezjail_installaction | 840 | unset ezjail_provideports ezjail_installaction ezjail_osversion_source ezjail_osversion_destination |
841 | 841 | ||
842 | shift; while getopts :biupPs: arg; do case ${arg} in | 842 | shift; while getopts :biupPs: arg; do case ${arg} in |
843 | b) ezjail_installaction="buildworld installworld";; | 843 | b) ezjail_installaction="buildworld installworld";; |
844 | i) ezjail_installaction="installworld";; | 844 | i) ezjail_installaction="installworld";; |
845 | u) ezjail_installaction="freebsd-update";; | 845 | u) ezjail_installaction="freebsd-update";; |
846 | U) ezjail_installaction="freebsd-upgrade";; | ||
846 | s) ezjail_sourcetree=${OPTARG};; | 847 | s) ezjail_sourcetree=${OPTARG};; |
847 | P) ezjail_provideports="YES"; ezjail_installaction="none";; | 848 | P) ezjail_provideports="YES"; ezjail_installaction="none";; |
848 | p) ezjail_provideports="YES";; | 849 | p) ezjail_provideports="YES";; |
@@ -870,6 +871,22 @@ setup|update) | |||
870 | [ -z "$TERM" -o "$TERM" = "dumb" ] && ezjail_urgency="cron" || ezjail_urgency="fetch" | 871 | [ -z "$TERM" -o "$TERM" = "dumb" ] && ezjail_urgency="cron" || ezjail_urgency="fetch" |
871 | [ "${ezjail_use_zfs}" = "YES" ] && zfs snapshot ${ezjail_jailzfs}/basejail@`date -v -7d +"%C%y%m%d_%H:%M:%S"` | 872 | [ "${ezjail_use_zfs}" = "YES" ] && zfs snapshot ${ezjail_jailzfs}/basejail@`date -v -7d +"%C%y%m%d_%H:%M:%S"` |
872 | freebsd-update -b ${ezjail_jailbase} ${ezjail_urgency} install | 873 | freebsd-update -b ${ezjail_jailbase} ${ezjail_urgency} install |
874 | elif [ "${ezjail_installaction}" == "freebsd-upgrade" ]; then | ||
875 | [ -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." | ||
876 | |||
877 | [ -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." | ||
878 | |||
879 | # That would be the part where we try to lookup the osversion from a file in the basejail | ||
880 | ezjail_osversion_source="${ezjail_sourcetree}" | ||
881 | |||
882 | # Make the host systems os version our target version | ||
883 | # Users can override this by setting the UNAME_r environment variable | ||
884 | ezjail_osversion_target="`uname -r`" | ||
885 | |||
886 | # Finally run freebsd-update to upgrade our basejail | ||
887 | env UNAME_r="${ezjail_osversion_source}" freebsd-update -b ${ezjail_jailbase} -r ${ezjail_osversion_target} upgrade install | ||
888 | |||
889 | # Here we should write the file with the new osversion in case of success | ||
873 | else | 890 | else |
874 | # Bump the user for some of the most common errors | 891 | # Bump the user for some of the most common errors |
875 | [ -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." | 892 | [ -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." |