summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xezjail-admin24
1 files changed, 21 insertions, 3 deletions
diff --git a/ezjail-admin b/ezjail-admin
index 648247c..02e9594 100755
--- a/ezjail-admin
+++ b/ezjail-admin
@@ -860,7 +860,7 @@ archive)
860####################### ezjail-admin RESTORE ######################## 860####################### ezjail-admin RESTORE ########################
861restore) 861restore)
862 # Clean variables, prevent polution 862 # Clean variables, prevent polution
863 unset ezjail_fromarchive ezjail_archivedir 863 unset ezjail_archivedir
864 864
865#ezjail_usage_restore="Usage: ${ezjail_admin} restore [-d archivedir] (archive|jailname)..." 865#ezjail_usage_restore="Usage: ${ezjail_admin} restore [-d archivedir] (archive|jailname)..."
866 866
@@ -871,9 +871,27 @@ restore)
871 871
872 [ $# -eq 0 ] && exerr ${ezjail_usage_restore} 872 [ $# -eq 0 ] && exerr ${ezjail_usage_restore}
873 873
874 # Jail name mandatory 874 # Default archive directory to .
875 fetchjailinfo $1 875 ezjail_archivedir=${ezjail_archivedir:-`pwd -P`}
876 876
877 while [ $# -gt 0 ]; do
878 ezjail_fromarchive=$1
879
880 # if archive location is absolute and doesn't exist, fail
881 [ "${ezjail_fromarchive%%[!/]*}" -a ! -f "${ezjail_fromarchive}" ] && exerr "Error: File for archive ${ezjail_fromarchive} not found."
882 if [ -z "${ezjail_fromarchive%%[!/]*}" ]; then
883 # Try archive location
884 if [ -r "${ezjail_archivedir}/${ezjail_fromarchive}" ]; then
885 ezjail_fromarchive="${ezjail_archivedir}/${ezjail_fromarchive}"
886 else
887 # If archive is not found, try guessing by jail name
888 ezjail_safename=`echo -n "$1" | tr -c '[:alnum:]' _`
889 ezjail_fromarchive=`ls -tr ${ezjail_archivedir}/${ezjail_safename}* | head -n 1`
890 [ -f "${ezjail_fromarchive}" ] || exerr "Error: No archive for pattern $1 can be found."
891 fi
892 fi
893 echo ${ezjail_fromarchive}
894 done
877 ;; 895 ;;
878######################## ezjail-admin CONFIG ######################## 896######################## ezjail-admin CONFIG ########################
879config) 897config)