summaryrefslogtreecommitdiff
path: root/ezjail-admin
diff options
context:
space:
mode:
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-xezjail-admin17
1 files changed, 9 insertions, 8 deletions
diff --git a/ezjail-admin b/ezjail-admin
index 8744417..587dcd6 100755
--- a/ezjail-admin
+++ b/ezjail-admin
@@ -45,7 +45,7 @@ ezjail_usage_update="Usage: ${ezjail_admin} update [-s sourcetree] [-i] [-pP]"
45ezjail_usage_config="Usage: ${ezjail_admin} config [-r run|norun] [-n newname] [-i attach|detach|fsck] jailname" 45ezjail_usage_config="Usage: ${ezjail_admin} config [-r run|norun] [-n newname] [-i attach|detach|fsck] jailname"
46ezjail_usage_console="Usage: ${ezjail_admin} console [-f] [-e command] jailname" 46ezjail_usage_console="Usage: ${ezjail_admin} console [-f] [-e command] jailname"
47ezjail_usage_archive="Usage: ${ezjail_admin} archive [-Af] [-a archive] [-d archivedir] jailname [jailname...]" 47ezjail_usage_archive="Usage: ${ezjail_admin} archive [-Af] [-a archive] [-d archivedir] jailname [jailname...]"
48ezjail_usage_restore="Usage: ${ezjail_admin} restore [-d archivedir] (archive|jailname)..." 48ezjail_usage_restore="Usage: ${ezjail_admin} restore [-f] [-d archivedir] (archive|jailname)..."
49ezjail_usage_list="Usage: ${ezjail_admin} list" 49ezjail_usage_list="Usage: ${ezjail_admin} list"
50 50
51################################ 51################################
@@ -867,7 +867,7 @@ archive)
867 # If no archive name was specified, make one up 867 # If no archive name was specified, make one up
868 [ "${ezjail_archive}" ] || ezjail_archive="${ezjail_archive_tag}.tar.gz" 868 [ "${ezjail_archive}" ] || ezjail_archive="${ezjail_archive_tag}.tar.gz"
869 869
870 # Archives need to now, where they came from. Restore by default only 870 # Archives need to know, where they came from. Restore by default only
871 # reinstalls jails on the same machine. We also warn on OS upgrades and 871 # reinstalls jails on the same machine. We also warn on OS upgrades and
872 # processor type changes 872 # processor type changes
873 ezjail_hostsystem_name=$( echo -n `uname -n` | tr -c '[:alnum:].' _ ) 873 ezjail_hostsystem_name=$( echo -n `uname -n` | tr -c '[:alnum:].' _ )
@@ -915,10 +915,11 @@ archive)
915####################### ezjail-admin RESTORE ######################## 915####################### ezjail-admin RESTORE ########################
916restore) 916restore)
917 # Clean variables, prevent polution 917 # Clean variables, prevent polution
918 unset ezjail_archivedir ezjail_safename 918 unset ezjail_archivedir ezjail_safename ezjail_forcerestore
919 919
920 shift; while getopts :d: arg; do case ${arg} in 920 shift; while getopts :d:f arg; do case ${arg} in
921 d) ezjail_archivedir=${OPTARG};; 921 d) ezjail_archivedir=${OPTARG};;
922 f) ezjail_forcerestore="YES";;
922 ?) exerr ${ezjail_usage_restore};; 923 ?) exerr ${ezjail_usage_restore};;
923 esac; done; shift $(( ${OPTIND} - 1 )) 924 esac; done; shift $(( ${OPTIND} - 1 ))
924 925
@@ -944,7 +945,7 @@ restore)
944 [ -z "${ezjail_fromarchive}" -a -f "${ezjail_archive}" ] && ezjail_fromarchive=${ezjail_archive} 945 [ -z "${ezjail_fromarchive}" -a -f "${ezjail_archive}" ] && ezjail_fromarchive=${ezjail_archive}
945 [ "${ezjail_archive}" -nt "${ezjail_fromarchive}" ] && ezjail_fromarchive=${ezjail_archive} 946 [ "${ezjail_archive}" -nt "${ezjail_fromarchive}" ] && ezjail_fromarchive=${ezjail_archive}
946 done 947 done
947 [ -f "${ezjail_fromarchive}" ] || exerr "Error: No archive for pattern $1 can be found." 948 [ -f "${ezjail_fromarchive}" ] || exerr "Error: No archive for pattern ${ezjail_safename} can be found."
948 fi 949 fi
949 fi 950 fi
950 951
@@ -971,8 +972,8 @@ restore)
971 972
972 # Catch all errors that will likely create a broken backup 973 # Catch all errors that will likely create a broken backup
973 [ "${ezjail_safename}" -a "${ezjail_safename}" != "${ezjail_nameprop_safename}" ] && exerr "Error: Archive name ${ezjail_fromarchive} does not match archived jail ${ezjail_nameprop_safename}." 974 [ "${ezjail_safename}" -a "${ezjail_safename}" != "${ezjail_nameprop_safename}" ] && exerr "Error: Archive name ${ezjail_fromarchive} does not match archived jail ${ezjail_nameprop_safename}."
974 [ "${ezjail_hsname}" != "${ezjail_nameprop_hsname}" ] && exerr "Error: Archive was created on host named ${ezjail_hsname}. Can only use restore on the same machine. Consider using \"ezjail-admin create -a\" when migrating ezjails." 975 [ "${ezjail_hsname}" != "${ezjail_nameprop_hsname}" && -z "${ezjail_forcerestore}" ] && exerr "Error: Archive was created on host named ${ezjail_hsname}. Consider using \"ezjail-admin create -a\" when migrating ezjails or -f to force restore."
975 [ "${ezjail_hscpu}" != "${ezjail_nameprop_hscpu}" ] && exerr "Error: Archive was created on a different CPU. Can not restore. Consider using \"ezjail-admin create -a\" when migrating ezjails." 976 [ "${ezjail_hscpu}" != "${ezjail_nameprop_hscpu}" && -z "${ezjail_forcerestore}" ] && exerr "Error: Archive was created on a different CPU. Can not restore. Consider using \"ezjail-admin create -a\" when migrating ezjails or -f to force restore."
976 977
977 # Save config to tempfile and source it 978 # Save config to tempfile and source it
978 ezjail_config=`mktemp /tmp/ezjail.prop.XXXXXXXX` 979 ezjail_config=`mktemp /tmp/ezjail.prop.XXXXXXXX`
@@ -981,11 +982,11 @@ restore)
981 fetchjailinfo ${ezjail_safename} ${ezjail_config} 982 fetchjailinfo ${ezjail_safename} ${ezjail_config}
982 983
983 # Now all parameters are here, invoke ezjail-admin create 984 # Now all parameters are here, invoke ezjail-admin create
985 [ "${ezjail_rootdir}" -a "$ezjail_ip}" -a "${ezjail_hostname}" ] || exerr "Error: Archive does not contain a valid ezjail properties file."
984 if [ "${ezjail_imagetype}" ]; then 986 if [ "${ezjail_imagetype}" ]; then
985 ezjail_imagedata="-c ${ezjail_imagetype} -C '${ezjail_attachparams}' -s ${ezjail_nameprop_imgagesize}" 987 ezjail_imagedata="-c ${ezjail_imagetype} -C '${ezjail_attachparams}' -s ${ezjail_nameprop_imgagesize}"
986 fi 988 fi
987 989
988 echo $0 create -a "${ezjail_fromarchive}" -A "${ezjail_config}" ${ezjail_imagedata} -r "${ezjail_rootdir}" "${ezjail_hostname}" "${ezjail_ip}"
989 $0 create -a "${ezjail_fromarchive}" -A "${ezjail_config}" ${ezjail_imagedata} -r "${ezjail_rootdir}" "${ezjail_hostname}" "${ezjail_ip}" || exerr "Error: create failed." 990 $0 create -a "${ezjail_fromarchive}" -A "${ezjail_config}" ${ezjail_imagedata} -r "${ezjail_rootdir}" "${ezjail_hostname}" "${ezjail_ip}" || exerr "Error: create failed."
990 rm -f "${ezjail_config}" 991 rm -f "${ezjail_config}"
991 992