diff --git a/usr/local/share/bastille/import.sh b/usr/local/share/bastille/import.sh index ade9f648..e966877e 100644 --- a/usr/local/share/bastille/import.sh +++ b/usr/local/share/bastille/import.sh @@ -41,8 +41,9 @@ usage() { cat << EOF Options: - -f | --force -- Force an archive import regardless if the checksum file does not match or missing. - -v | --verbose -- Be more verbose during the ZFS receive operation. + -f | --force Force an archive import regardless if the checksum file does not match or missing. + -v | --verbose Be more verbose during the ZFS receive operation. + -x | --debug Enable debug mode. Tip: If no option specified, container should be imported from standard input. @@ -50,49 +51,51 @@ EOF exit 1 } -# Handle special-case commands first -case "$1" in -help|-h|--help) - usage - ;; -esac +# Handle options. +FORCE=0 +ZRECV="-u" +USER_IMPORT= +while [ "$#" -gt 0 ]; do + case "${1}" in + -h|--help|help) + usage + ;; + -f|--force) + FORCE="1" + shift + ;; + -v|--verbose) + ZRECV="-u -v" + shift + ;; + -x|--debug) + enable_debug + shift + ;; + -*) + for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do + case ${_opt} in + f) FORCE=1 ;; + v) ZRECV="-u -v" ;; + x) enable_debug ;; + *) error_exit "Unknown Option: \"${1}\"" ;; + esac + done + shift + ;; + *) + break + ;; + esac +done if [ $# -gt 3 ] || [ $# -lt 1 ]; then usage fi -bastille_root_check - TARGET="${1}" -OPT_FORCE= -USER_IMPORT= -OPT_ZRECV="-u" -# Handle and parse option args -while [ $# -gt 0 ]; do - case "${1}" in - -f|--force) - OPT_FORCE="1" - TARGET="${2}" - shift - ;; - -v|--verbose) - OPT_ZRECV="-u -v" - TARGET="${2}" - shift - ;; - --*|-*) - error_notify "Unknown Option." - usage - ;; - *) - if [ $# -gt 1 ] || [ $# -lt 1 ]; then - usage - fi - shift - ;; - esac -done +bastille_root_check # Fallback to default if missing config parameters if [ -z "${bastille_decompress_xz_options}" ]; then @@ -162,7 +165,7 @@ update_jailconf() { fi } -update_fstab() { +update_fstab_import() { # Update fstab .bastille mountpoint on thin containers only # Set some variables FSTAB_CONFIG="${bastille_jailsdir}/${TARGET_TRIM}/fstab" @@ -585,7 +588,7 @@ jail_import() { # Update the jail.conf and fstab if required # This is required on foreign imports only update_jailconf - update_fstab + update_fstab_import if [ -z "${USER_IMPORT}" ]; then info "Container '${TARGET_TRIM}' imported successfully." fi