move parameters to cpio.sh

This commit is contained in:
Tobias Powalowski 2023-10-26 08:49:19 +02:00
parent 255461510e
commit 753e19e031
2 changed files with 26 additions and 22 deletions

View file

@ -12,28 +12,7 @@ if [[ -z "${1}" ]]; then
_usage
fi
_root_check
while [ $# -gt 0 ]; do
case "${1}" in
-c) shift
_CONFIG="${1}"
;;
-k) shift
_KERNEL="${1}"
;;
-d) shift
_TARGET_DIR="${1}"
;;
-g) shift
[[ -d "${1}" ]] && _abort "Invalid image path -- ${1} is a directory!"
if ! _GENERATE_IMAGE="$(readlink -f "${1}")" || [[ ! -e "${_GENERATE_IMAGE%/*}" ]]; then
_abort "Unable to write to path!" "${1}"
fi
;;
-h) _usage
;;
esac
shift
done
_parameters
#shellcheck disable="SC1090"
. "${_CONFIG}" 2>"${_NO_LOG}" || _abort "Failed to read ${_CONFIG} configuration file"
if [[ -z "${_KERNEL}" ]]; then

View file

@ -28,6 +28,31 @@ EOF
exit 0
}
_parameters() {
while [ $# -gt 0 ]; do
case "${1}" in
-c) shift
_CONFIG="${1}"
;;
-k) shift
_KERNEL="${1}"
;;
-d) shift
_TARGET_DIR="${1}"
;;
-g) shift
[[ -d "${1}" ]] && _abort "Invalid image path -- ${1} is a directory!"
if ! _GENERATE_IMAGE="$(readlink -f "${1}")" || [[ ! -e "${_GENERATE_IMAGE%/*}" ]]; then
_abort "Unable to write to path!" "${1}"
fi
;;
-h) _usage
;;
esac
shift
done
}
_abort() {
echo "ERROR:" "$@"
exit 1