refactor: move create_config function to the bottom
move it below unattended_windows and web_get functions to reference them later
This commit is contained in:
parent
8d9c63ff6c
commit
9276573c02
95
quickget
95
quickget
|
@ -308,51 +308,6 @@ function csv_data() {
|
||||||
wait
|
wait
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_config() {
|
|
||||||
local VM_PATH="${1}"
|
|
||||||
local INPUT="${2}"
|
|
||||||
OS="custom"
|
|
||||||
if ! mkdir "${VM_PATH}" 2>/dev/null; then
|
|
||||||
echo "ERROR! Could not create directory: ${VM_PATH}. Please verify that it does not already exist"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ "${INPUT}" == "http://"* ]] || [[ "${INPUT}" == "https://"* ]]; then
|
|
||||||
INPUT="$(web_redirect "${INPUT}")"
|
|
||||||
if [[ "${INPUT}" == *".iso" ]] || [[ "${INPUT}" == *".img" ]]; then
|
|
||||||
web_get "${INPUT}" "${VM_PATH}"
|
|
||||||
INPUT="${VM_PATH}/${INPUT##*/}"
|
|
||||||
else
|
|
||||||
echo "ERROR! Only ISO,IMG and QCOW2 file types are supported for --create-config"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ "${INPUT}" == *".iso" ]]; then
|
|
||||||
echo "Moving image to VM dir" && mv "${INPUT}" "${VM_PATH}"
|
|
||||||
CUSTOM_IMAGE_TYPE="iso"
|
|
||||||
elif [[ "${INPUT}" == *".img" ]]; then
|
|
||||||
echo "Moving image to VM dir" && mv "${INPUT}" "${VM_PATH}"
|
|
||||||
CUSTOM_IMAGE_TYPE="img"
|
|
||||||
elif [[ "${INPUT}" == *".qcow2" ]]; then
|
|
||||||
echo "Moving image to VM dir" && mv "${INPUT}" "${VM_PATH}/disk.qcow2"
|
|
||||||
CUSTOM_IMAGE_TYPE="qcow2"
|
|
||||||
else
|
|
||||||
echo "ERROR! Only ISO,IMG and QCOW2 file types are supported for --create-config"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Creating custom VM config for ${INPUT##*/}."
|
|
||||||
case "${INPUT,,}" in
|
|
||||||
*windows-server*) CUSTOM_OS="windows-server";;
|
|
||||||
*windows*) CUSTOM_OS="windows";;
|
|
||||||
*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
|
|
||||||
make_vm_config "${INPUT}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function list_supported() {
|
function list_supported() {
|
||||||
list_csv | cut -d ',' -f2,3,4 | tr ',' ' '
|
list_csv | cut -d ',' -f2,3,4 | tr ',' ' '
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -3326,6 +3281,56 @@ function create_vm() {
|
||||||
make_vm_config "${ISO}"
|
make_vm_config "${ISO}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_config() {
|
||||||
|
local VM_PATH="${1}"
|
||||||
|
local INPUT="${2}"
|
||||||
|
local FIXED_ISO=""
|
||||||
|
|
||||||
|
OS="custom"
|
||||||
|
if ! mkdir "${VM_PATH}" 2>/dev/null; then
|
||||||
|
echo "ERROR! Could not create directory: ${VM_PATH}. Please verify that it does not already exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "${INPUT}" == "http://"* ]] || [[ "${INPUT}" == "https://"* ]]; then
|
||||||
|
INPUT="$(web_redirect "${INPUT}")"
|
||||||
|
if [[ "${INPUT}" == *".iso" ]] || [[ "${INPUT}" == *".img" ]]; then
|
||||||
|
web_get "${INPUT}" "${VM_PATH}"
|
||||||
|
INPUT="${VM_PATH}/${INPUT##*/}"
|
||||||
|
else
|
||||||
|
echo "ERROR! Only ISO,IMG and QCOW2 file types are supported for --create-config"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ "${INPUT}" == *".iso" ]]; then
|
||||||
|
echo "Moving image to VM dir" && mv "${INPUT}" "${VM_PATH}"
|
||||||
|
CUSTOM_IMAGE_TYPE="iso"
|
||||||
|
elif [[ "${INPUT}" == *".img" ]]; then
|
||||||
|
echo "Moving image to VM dir" && mv "${INPUT}" "${VM_PATH}"
|
||||||
|
CUSTOM_IMAGE_TYPE="img"
|
||||||
|
elif [[ "${INPUT}" == *".qcow2" ]]; then
|
||||||
|
echo "Moving image to VM dir" && mv "${INPUT}" "${VM_PATH}/disk.qcow2"
|
||||||
|
CUSTOM_IMAGE_TYPE="qcow2"
|
||||||
|
else
|
||||||
|
echo "ERROR! Only ISO,IMG and QCOW2 file types are supported for --create-config"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Creating custom VM config for ${INPUT##*/}."
|
||||||
|
case "${INPUT,,}" in
|
||||||
|
*windows-server*) CUSTOM_OS="windows-server";;
|
||||||
|
*windows*)
|
||||||
|
CUSTOM_OS="windows"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*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
|
||||||
|
make_vm_config "${INPUT}"
|
||||||
|
}
|
||||||
|
|
||||||
# Use command -v command to check if quickemu is in the system's PATH and
|
# Use command -v command to check if quickemu is in the system's PATH and
|
||||||
# fallback to checking if quickemu is in the current directory.
|
# fallback to checking if quickemu is in the current directory.
|
||||||
function resolve_quickemu() {
|
function resolve_quickemu() {
|
||||||
|
|
Loading…
Reference in New Issue