From 33c42bb8ceca67a76268f68a03a8db1928bc2a34 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 2 Jan 2008 07:44:32 +0000 Subject: Fetching first values from an ezjail archive in restore command. Still not functional. --- ezjail-admin | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ezjail-admin b/ezjail-admin index 02e9594..4bb361d 100755 --- a/ezjail-admin +++ b/ezjail-admin @@ -875,6 +875,7 @@ restore) ezjail_archivedir=${ezjail_archivedir:-`pwd -P`} while [ $# -gt 0 ]; do + unset ezjail_safename ezjail_fromarchive=$1 # if archive location is absolute and doesn't exist, fail @@ -885,12 +886,21 @@ restore) ezjail_fromarchive="${ezjail_archivedir}/${ezjail_fromarchive}" else # If archive is not found, try guessing by jail name - ezjail_safename=`echo -n "$1" | tr -c '[:alnum:]' _` - ezjail_fromarchive=`ls -tr ${ezjail_archivedir}/${ezjail_safename}* | head -n 1` + ezjail_safename=`echo -n "${ezjail_fromarchive}" | tr -c '[:alnum:]' _` + unset ezjail_fromarchive + for ezjail_archive in "${ezjail_archivedir}/${ezjail_safename}"*; do + [ -z "${ezjail_fromarchive}" -a -f "${ezjail_archive}" ] && ezjail_fromarchive=${ezjail_archive} + [ "${ezjail_archive}" -nt "${ezjail_fromarchive}" ] && ezjail_fromarchive=${ezjail_archive} + done [ -f "${ezjail_fromarchive}" ] || exerr "Error: No archive for pattern $1 can be found." fi fi - echo ${ezjail_fromarchive} + + ezjail_nameprop=`tar tzf ${ezjail_fromarchive} --fast-read prop.ezjail_\*` + [ $? -eq 0 -a "${ezjail_nameprop}" ] || exerr "Error: File ${ezjail_fromarchive} is not an ezjail archive." + + + shift 1 done ;; ######################## ezjail-admin CONFIG ######################## -- cgit v1.2.3