refactor: rename $just to $OPERATION

This commit is contained in:
Martin Wimpress 2024-04-28 22:31:27 +01:00 committed by Martin Wimpress
parent 06fbd84f12
commit 8a1eb9d5dc
1 changed files with 18 additions and 18 deletions

View File

@ -1190,7 +1190,7 @@ function check_hash() {
local iso="" local iso=""
local hash="" local hash=""
local hash_algo="" local hash_algo=""
if [ "${just}" == 'download' ]; then if [ "${OPERATION}" == "download" ]; then
iso="${1}" iso="${1}"
else else
iso="${VM_PATH}/${1}" iso="${VM_PATH}/${1}"
@ -1249,14 +1249,14 @@ function web_get() {
done done
# Test mode for ISO # Test mode for ISO
if [ "${just}" == 'show' ]; then if [ "${OPERATION}" == "show" ]; then
show_url_result "${OS}" "${RELEASE}" "${EDITION}" "${URL}" show_url_result "${OS}" "${RELEASE}" "${EDITION}" "${URL}"
exit 0 exit 0
elif [ "${just}" == 'test' ]; then elif [ "${OPERATION}" == "test" ]; then
CHECK=$(web_check "${URL}" && echo 'PASS' || echo 'FAIL') CHECK=$(web_check "${URL}" && echo 'PASS' || echo 'FAIL')
show_test_result "${CHECK}" "${OS}" "${RELEASE}" "${EDITION}" "${URL}" show_test_result "${CHECK}" "${OS}" "${RELEASE}" "${EDITION}" "${URL}"
exit 0 exit 0
elif [ "${just}" == 'download' ]; then elif [ "${OPERATION}" == "download" ]; then
DIR="$(pwd)" DIR="$(pwd)"
fi fi
@ -1323,10 +1323,10 @@ function zsync_get() {
local OUT="" local OUT=""
local URL="${1}" local URL="${1}"
# Test mode for ISO # Test mode for ISO
if [ "${just}" == 'show' ]; then if [ "${OPERATION}" == "show" ]; then
echo "${URL}" echo "${URL}"
exit 0 exit 0
elif [ "${just}" == 'test' ]; then elif [ "${OPERATION}" == "test" ]; then
web_check "${URL}" web_check "${URL}"
exit 0 exit 0
elif command -v zsync &>/dev/null; then elif command -v zsync &>/dev/null; then
@ -1367,7 +1367,7 @@ function make_vm_config() {
local IMAGE_TYPE="" local IMAGE_TYPE=""
local GUEST="" local GUEST=""
local SEC_BOOT="" local SEC_BOOT=""
if [ "${just}" == 'download' ]; then if [ "${OPERATION}" == "download" ]; then
exit 0 exit 0
fi fi
IMAGE_FILE="${1}" IMAGE_FILE="${1}"
@ -2089,14 +2089,14 @@ function get_macos() {
local chunkListLink=$(echo "$info" | grep 'oscdn' | grep 'chunklist') local chunkListLink=$(echo "$info" | grep 'oscdn' | grep 'chunklist')
local chunkListSession=$(echo "$info" | grep 'expires' | grep 'chunklist') local chunkListSession=$(echo "$info" | grep 'expires' | grep 'chunklist')
if [ "${just}" == 'show' ]; then if [ "${OPERATION}" == "show" ]; then
show_url_result "${OS}" "${RELEASE}" "" "${downloadLink}" show_url_result "${OS}" "${RELEASE}" "" "${downloadLink}"
exit 0 exit 0
elif [ "${just}" == 'test' ]; then elif [ "${OPERATION}" == "test" ]; then
local CHECK=$(web_check "${downloadLink}" --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${downloadSession}" && echo 'PASS' || echo 'FAIL') local CHECK=$(web_check "${downloadLink}" --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${downloadSession}" && echo 'PASS' || echo 'FAIL')
show_test_result ${CHECK} "${OS}" "${RELEASE}" "" "${downloadLink}" show_test_result ${CHECK} "${OS}" "${RELEASE}" "" "${downloadLink}"
exit 0 exit 0
elif [ "${just}" == 'download' ]; then elif [ "${OPERATION}" == "download" ]; then
echo "Downloading macOS ${RELEASE} from ${downloadLink}" echo "Downloading macOS ${RELEASE} from ${downloadLink}"
web_get "${downloadLink}" "${VM_PATH}" RecoveryImage.dmg --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${downloadSession}" web_get "${downloadLink}" "${VM_PATH}" RecoveryImage.dmg --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${downloadSession}"
web_get "${chunkListLink}" "${VM_PATH}" RecoveryImage.chunklist --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${chunkListSession}" web_get "${chunkListLink}" "${VM_PATH}" RecoveryImage.chunklist --header "Host: oscdn.apple.com" --header "Connection: close" --header "User-Agent: InternetRecovery/1.0" --header "Cookie: AssetToken=${chunkListSession}"
@ -3273,7 +3273,7 @@ function get_windows() {
download_windows_workstation "${RELEASE}" download_windows_workstation "${RELEASE}"
fi fi
if [ "${just}" == 'download' ]; then if [ "${OPERATION}" == "download" ]; then
exit 0 exit 0
fi fi
@ -3404,7 +3404,7 @@ if ((BASH_VERSINFO[0] < 4)); then
fi fi
LANGS=() LANGS=()
OPERATION=""
CURL=$(command -v curl) CURL=$(command -v curl)
if [ ! -e "${CURL}" ]; then if [ ! -e "${CURL}" ]; then
echo "ERROR! curl not found. Please make install curl" echo "ERROR! curl not found. Please make install curl"
@ -3418,11 +3418,11 @@ case "${1}" in
exit 0 exit 0
;; ;;
'--download'|'-d') '--download'|'-d')
just="download" OPERATION="download"
shift shift
;; ;;
'--create-config'|'-cc') '--create-config'|'-cc')
just="config" OPERATION="config"
shift shift
create_config "${@}" create_config "${@}"
;; ;;
@ -3444,11 +3444,11 @@ case "${1}" in
exit 0 exit 0
;; ;;
'--url'|'-u') '--url'|'-u')
just="show" OPERATION="show"
shift shift
;; ;;
'--url-all'|'-ua') '--url-all'|'-ua')
just="show" OPERATION="show"
shift shift
# if no OS is specified, list all URLs for all supported OSes # if no OS is specified, list all URLs for all supported OSes
if [ -z "${1}" ]; then if [ -z "${1}" ]; then
@ -3460,11 +3460,11 @@ case "${1}" in
fi fi
;; ;;
'--check'|'-c') '--check'|'-c')
just="test" OPERATION="test"
shift shift
;; ;;
'--check-all'|'-ca') '--check-all'|'-ca')
just="test" OPERATION="test"
shift shift
# if no OS is specified, check all URLs for all supported OSes # if no OS is specified, check all URLs for all supported OSes
if [ -z "${1}" ]; then if [ -z "${1}" ]; then