Skip to content

Commit

Permalink
refactor: General improvements to create_config function
Browse files Browse the repository at this point in the history
  • Loading branch information
lj3954 authored and flexiondotorg committed Jul 14, 2024
1 parent 113bd4d commit d3a95c2
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions quickget
Original file line number Diff line number Diff line change
Expand Up @@ -3300,13 +3300,17 @@ function create_config() {
INPUT="$(web_redirect "${INPUT}")"
if [[ "${INPUT}" == *".iso" ]] || [[ "${INPUT}" == *".img" ]]; then
web_get "${INPUT}" "${VM_PATH}"
INPUT="${VM_PATH}/${INPUT##*/}"
INPUT="${INPUT##*/}"
else
echo "ERROR! Only ISO,IMG and QCOW2 file types are supported for --create-config"
exit 1
fi
fi
if [[ "${INPUT}" == *".iso" ]]; then

if [ ! -f "${INPUT}" ]; then
echo "ERROR! The input must be a valid URL or path to an ISO, IMG, or QCOW2 file."
exit 1
elif [[ "${INPUT}" == *".iso" ]]; then
echo "Moving image to VM dir" && mv "${INPUT}" "${VM_PATH}"
CUSTOM_IMAGE_TYPE="iso"
elif [[ "${INPUT}" == *".img" ]]; then
Expand All @@ -3319,10 +3323,15 @@ function create_config() {
echo "ERROR! Only ISO,IMG and QCOW2 file types are supported for --create-config"
exit 1
fi
INPUT="$(basename "${INPUT}")"

echo "Creating custom VM config for ${INPUT##*/}."
case "${INPUT,,}" in
*windows-server*) CUSTOM_OS="windows-server";;
*windows*)
*freebsd*) CUSTOM_OS="freebsd";;
*kolibrios*) CUSTOM_OS="kolibrios";;
*reactos*) CUSTOM_OS="reactos";;
*windows-server*|*eval_oemret_x*|*eval_x*) CUSTOM_OS="windows-server";;
*windows*|win*)
CUSTOM_OS="windows"
while [ $# -gt 2 ]; do
case "${3}" in
Expand All @@ -3338,18 +3347,10 @@ function create_config() {
done
;;

*freebsd*) CUSTOM_OS="freebsd";;
*kolibrios*) CUSTOM_OS="kolibrios";;
*reactos*) CUSTOM_OS="reactos";;
*) CUSTOM_OS="linux";;
esac
echo "Selecting OS: ${CUSTOM_OS}. If this is incorrect, please modify the config file to include the correct OS."
echo
if [ -n "${FIXED_ISO}" ]; then
make_vm_config "${INPUT}" "${FIXED_ISO}"
else
make_vm_config "${INPUT}"
fi
echo -e "Selecting OS: ${CUSTOM_OS}. If this is incorrect, please modify the config file to include the correct OS.\n"
make_vm_config "${INPUT}" "${FIXED_ISO}"
}

# Use command -v command to check if quickemu is in the system's PATH and
Expand Down

0 comments on commit d3a95c2

Please sign in to comment.