diff options
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-x | ezjail-admin | 91 |
1 files changed, 50 insertions, 41 deletions
diff --git a/ezjail-admin b/ezjail-admin index 6b01ec3..fc5bc74 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
@@ -333,12 +333,12 @@ ezjail_queryftpserver () { | |||
333 | TIFS=${IFS}; IFS= | 333 | TIFS=${IFS}; IFS= |
334 | for ezjail_path in pub/FreeBSD/releases pub/FreeBSD/snapshot pub/FreeBSD releases snapshots pub/FreeBSD-Archive/old-releases NO; do | 334 | for ezjail_path in pub/FreeBSD/releases pub/FreeBSD/snapshot pub/FreeBSD releases snapshots pub/FreeBSD-Archive/old-releases NO; do |
335 | if [ ${ezjail_path} = "NO" ]; then | 335 | if [ ${ezjail_path} = "NO" ]; then |
336 | echo "Warning: I am having problems querying the ftp server you specified (${ezjail_ftphost})." | 336 | echo "Warning: I am having problems querying the ftp server you specified (${ezjail_disturi})." |
337 | _ret=1; break | 337 | _ret=1; break |
338 | fi | 338 | fi |
339 | ezjail_ftpresponse=`echo ls | ftp "${ezjail_ftphost}:${ezjail_path}/${ezjail_installarch}/" 2> /dev/null` 2> /dev/null | 339 | ezjail_ftpresponse=`echo ls | ftp "${ezjail_disturi}:${ezjail_path}/${ezjail_installarch}/" 2> /dev/null` 2> /dev/null |
340 | if [ $? -eq 0 ]; then | 340 | if [ $? -eq 0 ]; then |
341 | echo -e "The ftp server you specified (${ezjail_ftphost}) seems to provide the following builds:\n${ezjail_ftpresponse}" | 341 | echo -e "The ftp server you specified (${ezjail_disturi}) seems to provide the following builds:\n${ezjail_ftpresponse}" |
342 | _ret=0; break | 342 | _ret=0; break |
343 | fi | 343 | fi |
344 | done | 344 | done |
@@ -952,7 +952,7 @@ setup|update) | |||
952 | ######################## ezjail-admin INSTALL ######################## | 952 | ######################## ezjail-admin INSTALL ######################## |
953 | install) | 953 | install) |
954 | # Clean variables, prevent pollution | 954 | # Clean variables, prevent pollution |
955 | unset ezjail_release ezjail_installmanpages ezjail_installports ezjail_installsources ezjail_dir ezjail_reldir ezjail_ftpserverqueried | 955 | unset ezjail_release ezjail_installmanpages ezjail_installports ezjail_installsources ezjail_dir ezjail_ftpserverqueried ezjail_proto ezjail_disturi |
956 | 956 | ||
957 | shift; while getopts :mMpPsSh:r: arg; do case ${arg} in | 957 | shift; while getopts :mMpPsSh:r: arg; do case ${arg} in |
958 | m) ezjail_installmanpages=" manpages";; | 958 | m) ezjail_installmanpages=" manpages";; |
@@ -971,9 +971,9 @@ install) | |||
971 | ezjail_installarch=`uname -p` | 971 | ezjail_installarch=`uname -p` |
972 | ezjail_installplatform=`uname -m` | 972 | ezjail_installplatform=`uname -m` |
973 | : ${ezjail_ftphost="ftp.freebsd.org"} | 973 | : ${ezjail_ftphost="ftp.freebsd.org"} |
974 | ezjail_ftphost=${ezjail_ftphost#ftp://} | 974 | ezjail_proto=${ezjail_ftphost%%://*} |
975 | ezjail_dir=${ezjail_ftphost#file://} | 975 | [ "${ezjail_proto}" = "${ezjail_ftphost}" ] && ezjail_proto=ftp |
976 | [ "${ezjail_dir%%[!/]*}" ] || ezjail_reldir=`pwd -P` | 976 | ezjail_disturi=${ezjail_ftphost#*://} |
977 | 977 | ||
978 | [ "`sysctl -n kern.securelevel`" -gt 0 ] && exerr "Error: You are running in a secure level higher than 0.\n ${ezjail_admin} will not install correctly.\n Please reboot into a lower secure level." | 978 | [ "`sysctl -n kern.securelevel`" -gt 0 ] && exerr "Error: You are running in a secure level higher than 0.\n ${ezjail_admin} will not install correctly.\n Please reboot into a lower secure level." |
979 | 979 | ||
@@ -986,13 +986,13 @@ install) | |||
986 | ezjail_release_major=${ezjail_release%%.*} | 986 | ezjail_release_major=${ezjail_release%%.*} |
987 | 987 | ||
988 | # ftp servers normally wont provide non-RELEASE-builds | 988 | # ftp servers normally wont provide non-RELEASE-builds |
989 | if [ "${ezjail_dir}" = "${ezjail_ftphost}" ]; then | 989 | if [ "${ezjail_proto}" != "file" ]; then |
990 | case ${ezjail_release} in *-STABLE) ezjail_release="${ezjail_release%-STABLE}-RELEASE";; esac | 990 | case ${ezjail_release} in *-STABLE) ezjail_release="${ezjail_release%-STABLE}-RELEASE";; esac |
991 | if [ "${ezjail_release%-RELEASE}" = "${ezjail_release}" ]; then | 991 | if [ "${ezjail_release%-RELEASE}" = "${ezjail_release}" ]; then |
992 | echo "Your system is ${ezjail_release}. Normally FTP-servers don't provide non-RELEASE-builds." | 992 | echo "Your system is ${ezjail_release}. Normally FTP-servers don't provide non-RELEASE-builds." |
993 | [ ${ezjail_release_major} -ge 9 ] && ezjail_installarch="${ezjail_installplatform}/${ezjail_installarch}" | 993 | [ ${ezjail_release_major} -ge 9 ] && ezjail_installarch="${ezjail_installplatform}/${ezjail_installarch}" |
994 | ezjail_queryftpserver || echo "... I'll continue anyway." | 994 | [ "${ezjail_proto}" != "ftp" ] || ezjail_queryftpserver || echo "... I'll continue anyway." |
995 | echo -n "Release [ ${ezjail_release} ]: " | 995 | echo -n "Release to fetch [ ${ezjail_release} ]: " |
996 | read ezjail_releasetmp | 996 | read ezjail_releasetmp |
997 | [ "${ezjail_releasetmp}" ] && ezjail_release=${ezjail_releasetmp} | 997 | [ "${ezjail_releasetmp}" ] && ezjail_release=${ezjail_releasetmp} |
998 | ezjail_installarch=`uname -p` | 998 | ezjail_installarch=`uname -p` |
@@ -1003,14 +1003,15 @@ install) | |||
1003 | # From 9.0 releases come with a new layout | 1003 | # From 9.0 releases come with a new layout |
1004 | # It is now a single archive ${pkg}.txz instead of a list of archive parts under ${pkg}/* | 1004 | # It is now a single archive ${pkg}.txz instead of a list of archive parts under ${pkg}/* |
1005 | # man pages come with the base | 1005 | # man pages come with the base |
1006 | # We can use fetch to connect to the ftp host, allowing the use of proxies. We needed ftp | ||
1007 | # in pre-9.0-releases to make ${pkg}/* work. | ||
1006 | # We assume for now that jail's platform is supposed to be that of the host. That may change later. | 1008 | # We assume for now that jail's platform is supposed to be that of the host. That may change later. |
1007 | ezjail_release_major=${ezjail_release%%.*} | 1009 | ezjail_release_major=${ezjail_release%%.*} |
1010 | [ "${ezjail_release_major}" -eq "${ezjail_release_major}" ] 2>/dev/null || exerr ${ezjail_release} does not look like a valid FreeBSD version descriptor | ||
1008 | if [ ${ezjail_release_major} -ge 9 -a -n "${ezjail_installmanpages}" ]; then | 1011 | if [ ${ezjail_release_major} -ge 9 -a -n "${ezjail_installmanpages}" ]; then |
1009 | echo "Note: From FreeBSD 9.0 man pages are part of the base package" | 1012 | echo "Note: From FreeBSD 9.0 man pages are part of the base package" |
1010 | unset ezjail_installmanpages | 1013 | unset ezjail_installmanpages |
1011 | fi | 1014 | fi |
1012 | [ ${ezjail_release_major} -ge 9 ] && ezjail_installarch="${ezjail_installplatform}/${ezjail_installarch}" | ||
1013 | [ ${ezjail_release_major} -ge 9 ] && ezjail_pkgsuffix=".txz" || ezjail_pkgsuffix="/*" | ||
1014 | 1015 | ||
1015 | # Normally fulljail should be renamed by past ezjail-admin commands. | 1016 | # Normally fulljail should be renamed by past ezjail-admin commands. |
1016 | # However those may have failed | 1017 | # However those may have failed |
@@ -1030,46 +1031,54 @@ install) | |||
1030 | rm -rf "${ezjail_jailtemp}" | 1031 | rm -rf "${ezjail_jailtemp}" |
1031 | for pkg in ${ezjail_basesystem} ${ezjail_installmanpages} ${ezjail_installsources}; do | 1032 | for pkg in ${ezjail_basesystem} ${ezjail_installmanpages} ${ezjail_installsources}; do |
1032 | 1033 | ||
1033 | # The first case means, that a remote host has been specified. | 1034 | if [ "${ezjail_proto}" = "file" ]; then |
1034 | if [ "${ezjail_dir}" = "${ezjail_ftphost}" ]; then | 1035 | # The easy case means, that a local distribution directory has been specified. |
1036 | |||
1037 | if [ ${ezjail_release_major} -ge 9 ]; then | ||
1038 | [ -r "${ezjail_disturi}/${pkg}.txz" ] || exerr "Error: Can not access package file ${ezjail_disturi}/${pkg}.txz" | ||
1039 | xzdec ${ezjail_disturi}/${pkg}.txz | tar --unlink -xpJf - -C ${DESTDIR} | ||
1040 | else | ||
1041 | ezjail_backdir=`pwd -P` | ||
1042 | cd "${ezjail_disturi}/${pkg}" || exerr "Error: Could not cd to ${ezjail_disturi}." | ||
1043 | [ "${pkg}" = "base" ] && echo "Ignore the next question, ezjail answers it for you." | ||
1044 | set -- all | ||
1045 | [ -f install.sh ] && yes | . install.sh | ||
1046 | [ $? -eq 0 ] || exerr "Error: Package install script for ${pkg} failed." | ||
1047 | cd "${ezjail_backdir}" | ||
1048 | fi | ||
1049 | else | ||
1050 | # The hard case means, we have to fetch the distribution files from a remote server | ||
1051 | |||
1035 | # Create and try to access temp dir | 1052 | # Create and try to access temp dir |
1036 | mkdir -p "${ezjail_jailtemp}" || exerr "Error: Could not create temporary base jail directory ${ezjail_jailtemp}." | 1053 | mkdir -p "${ezjail_jailtemp}" || exerr "Error: Could not create temporary base jail directory ${ezjail_jailtemp}." |
1037 | cd "${ezjail_jailtemp}" || exerr "Error: Could not cd to ${ezjail_jailtemp}." | 1054 | cd "${ezjail_jailtemp}" || exerr "Error: Could not cd to ${ezjail_jailtemp}." |
1038 | 1055 | ||
1039 | # Try all paths as stolen from sysinstall, break on success. | 1056 | # Try all paths as stolen from sysinstall, break on success. |
1040 | for ezjail_path in pub/FreeBSD/releases pub/FreeBSD/snapshot pub/FreeBSD releases snapshots pub/FreeBSD-Archive/old-releases NO; do | 1057 | for ezjail_path in pub/FreeBSD/releases pub/FreeBSD/snapshot pub/FreeBSD releases snapshots pub/FreeBSD-Archive/old-releases NO; do |
1058 | # Once we tried all paths, we give up and nudge the user | ||
1041 | if [ "${ezjail_path}" = "NO" ]; then | 1059 | if [ "${ezjail_path}" = "NO" ]; then |
1042 | echo -e "\nCould not fetch ${pkg} from ${ezjail_ftphost}.\n Maybe your release (${ezjail_release}) is specified incorrectly or the host ${ezjail_ftphost} does not provide that release build.\n Use the -r option to specify an existing release or the -h option to specify an alternative ftp server." >&2 | 1060 | echo -e "\nCould not fetch ${pkg} from ${ezjail_proto}://${ezjail_disturi}.\n Maybe your release (${ezjail_release}) is specified incorrectly or the host ${ezjail_disturi} does not provide that release build.\n Use the -r option to specify an existing release or the -h option to specify an alternative ftp server." >&2 |
1043 | [ "${ezjail_ftpserverqueried}" ] || ezjail_queryftpserver | 1061 | [ "${ezjail_proto}" = "ftp" -a -z "${ezjail_ftpserverqueried}" ] && ezjail_queryftpserver |
1044 | exit 1 | 1062 | exit 1 |
1045 | fi | 1063 | fi |
1046 | ftp "${ezjail_ftphost}:${ezjail_path}/${ezjail_installarch}/${ezjail_release}/${pkg}${ezjail_pkgsuffix}" && break | ||
1047 | done | ||
1048 | 1064 | ||
1049 | if [ ${ezjail_release_major} -ge 9 ]; then | 1065 | # Fetching and extraction distributions has become much easier from 9.0 |
1050 | xzdec ${pkg}.txz | tar --unlink -xpJf - -C ${DESTDIR} | 1066 | if [ ${ezjail_release_major} -ge 9 ]; then |
1051 | else | 1067 | fetch "${ezjail_proto}://${ezjail_disturi}/${ezjail_path}/${ezjail_installplatform}/${ezjail_installarch}/${ezjail_release}/${pkg}.txz" || continue |
1052 | # These actions are really ugly: sources want $1 to contain the set | 1068 | xzdec ${pkg}.txz | tar --unlink -xpJf - -C ${DESTDIR} |
1053 | # of sources to install, base asks the user if he is sure, hence the | 1069 | else |
1054 | # yes and the set -- all | 1070 | ftp ${ezjail_disturi}:${ezjail_path}/${ezjail_installarch}/${ezjail_release}/${pkg}/* || continue |
1055 | [ "${pkg}" = "base" ] && echo "Ignore the next question, ezjail answers it for you." | 1071 | # These actions are really ugly: sources want $1 to contain the set |
1056 | set -- all | 1072 | # of sources to install, base asks the user if he is sure, hence the |
1057 | [ -f install.sh ] && yes | . install.sh | 1073 | # yes and the set -- all |
1058 | [ $? -eq 0 ] || exerr "Error: Package install script for ${pkg} failed." | 1074 | [ "${pkg}" = "base" ] && echo "Ignore the next question, ezjail answers it for you." |
1059 | fi | 1075 | set -- all |
1076 | [ -f install.sh ] && yes | . install.sh | ||
1077 | [ $? -eq 0 ] || exerr "Error: Package install script for ${pkg} failed." | ||
1078 | fi | ||
1060 | 1079 | ||
1061 | rm -rf "${ezjail_jailtemp}" | 1080 | rm -rf "${ezjail_jailtemp}" |
1062 | else | 1081 | done |
1063 | if [ ${ezjail_release_major} -ge 9 ]; then | ||
1064 | [ -r "${ezjail_reldir}/${ezjail_dir}/${pkg}.txz" ] || exerr "Error: Can not access package file ${ezjail_reldir}/${ezjail_dir}/${pkg}.txz" | ||
1065 | xzdec ${ezjail_reldir}/${ezjail_dir}/${pkg}.txz | tar --unlink -xpJf - -C ${DESTDIR} | ||
1066 | else | ||
1067 | cd "${ezjail_reldir}/${ezjail_dir}/${pkg}" || exerr "Error: Could not cd to ${ezjail_dir}." | ||
1068 | [ "${pkg}" = "base" ] && echo "Ignore the next question, ezjail answers it for you." | ||
1069 | set -- all | ||
1070 | [ -f install.sh ] && yes | . install.sh | ||
1071 | [ $? -eq 0 ] || exerr "Error: Package install script for ${pkg} failed." | ||
1072 | fi | ||
1073 | fi | 1082 | fi |
1074 | done | 1083 | done |
1075 | 1084 | ||