import: Use new functions

This commit is contained in:
tschettervictor
2025-02-27 16:54:50 -07:00
committed by GitHub
parent 22854addf9
commit c22bd866eb

View File

@@ -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