mirror of
https://github.com/hackacad/bastille.git
synced 2026-01-03 19:23:42 +01:00
Revert the improved import command due conflicts, later re add.
This commit is contained in:
@@ -32,11 +32,7 @@
|
|||||||
. /usr/local/etc/bastille/bastille.conf
|
. /usr/local/etc/bastille/bastille.conf
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
error_exit "Usage: bastille import FILE [option]
|
error_exit "Usage: bastille import file [force]"
|
||||||
\n
|
|
||||||
\nOptions:
|
|
||||||
\n
|
|
||||||
-f|--force -- Force an archive import even if the checksum file is missing or don't match\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle special-case commands first
|
# Handle special-case commands first
|
||||||
@@ -51,21 +47,8 @@ if [ $# -gt 2 ] || [ $# -lt 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
TARGET="${1}"
|
TARGET="${1}"
|
||||||
|
OPTION="${2}"
|
||||||
shift
|
shift
|
||||||
OPT_FORCE=
|
|
||||||
|
|
||||||
# Handle and parse option args
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case "${1}" in
|
|
||||||
-f|force|--force)
|
|
||||||
OPT_FORCE="1"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
validate_archive() {
|
validate_archive() {
|
||||||
# Compare checksums on the target archive
|
# Compare checksums on the target archive
|
||||||
@@ -83,7 +66,7 @@ validate_archive() {
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Check if user opt to force import
|
# Check if user opt to force import
|
||||||
if [ -n "${OPT_FORCE}" ]; then
|
if [ "${OPTION}" = "-f" -o "${OPTION}" = "force" ]; then
|
||||||
warn "Warning: Skipping archive validation!"
|
warn "Warning: Skipping archive validation!"
|
||||||
else
|
else
|
||||||
error_exit "Checksum file not found. See 'bastille import TARGET -f'."
|
error_exit "Checksum file not found. See 'bastille import TARGET -f'."
|
||||||
@@ -420,17 +403,6 @@ jail_import() {
|
|||||||
else
|
else
|
||||||
update_config
|
update_config
|
||||||
fi
|
fi
|
||||||
elif [ -z "${FILE_EXT}" ]; then
|
|
||||||
if echo "${TARGET}" | grep -q '_[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}$'; then
|
|
||||||
# Based on the file name, looks like we are importing a raw bastille image
|
|
||||||
# Import from uncompressed image file
|
|
||||||
info "Importing '${TARGET_TRIM}' from uncompressed image archive."
|
|
||||||
info "Receiving ZFS data stream..."
|
|
||||||
zfs receive -u "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${TARGET_TRIM}" < "${bastille_backupsdir}/${TARGET}"
|
|
||||||
|
|
||||||
# Update ZFS mountpoint property if required
|
|
||||||
update_zfsmount
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
error_exit "Unknown archive format."
|
error_exit "Unknown archive format."
|
||||||
fi
|
fi
|
||||||
@@ -493,9 +465,9 @@ fi
|
|||||||
# Check if archive exist then trim archive name
|
# Check if archive exist then trim archive name
|
||||||
if [ -f "${bastille_backupsdir}/${TARGET}" ]; then
|
if [ -f "${bastille_backupsdir}/${TARGET}" ]; then
|
||||||
# Filter unsupported/unknown archives
|
# Filter unsupported/unknown archives
|
||||||
if echo "${TARGET}" | grep -q '_[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}$\|_[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.xz$\|_[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.txz$\|_[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.zip$\|-[0-9]\{12\}.[0-9]\{2\}.tar.gz$\|@[0-9]\{12\}.[0-9]\{2\}.tar$'; then
|
if echo "${TARGET}" | grep -q '_[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.xz$\|_[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.txz$\|_[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}.zip$\|-[0-9]\{12\}.[0-9]\{2\}.tar.gz$\|@[0-9]\{12\}.[0-9]\{2\}.tar$'; then
|
||||||
if ls "${bastille_backupsdir}" | awk "/^${TARGET}$/" >/dev/null; then
|
if ls "${bastille_backupsdir}" | awk "/^${TARGET}$/" >/dev/null; then
|
||||||
TARGET_TRIM=$(echo "${TARGET}" | sed "s/_[0-9]*-[0-9]*-[0-9]*-[0-9]*.xz//;s/_[0-9]*-[0-9]*-[0-9]*-[0-9]*.txz//;s/_[0-9]*-[0-9]*-[0-9]*.zip//;s/-[0-9]\{12\}.[0-9]\{2\}.tar.gz//;s/@[0-9]\{12\}.[0-9]\{2\}.tar//;s/_[0-9]*-[0-9]*-[0-9]*-[0-9]*//")
|
TARGET_TRIM=$(echo "${TARGET}" | sed "s/_[0-9]*-[0-9]*-[0-9]*-[0-9]*.xz//;s/_[0-9]*-[0-9]*-[0-9]*-[0-9]*.txz//;s/_[0-9]*-[0-9]*-[0-9]*.zip//;s/-[0-9]\{12\}.[0-9]\{2\}.tar.gz//;s/@[0-9]\{12\}.[0-9]\{2\}.tar//")
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
error_exit "Unrecognized archive name."
|
error_exit "Unrecognized archive name."
|
||||||
|
|||||||
Reference in New Issue
Block a user