Update define.sh
This commit is contained in:
parent
22b70588b7
commit
dacdd278e4
1 changed files with 142 additions and 49 deletions
185
src/define.sh
185
src/define.sh
|
|
@ -1,11 +1,14 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
: "${VERIFY:=""}"
|
||||||
: "${MANUAL:=""}"
|
: "${MANUAL:=""}"
|
||||||
: "${VERSION:=""}"
|
: "${VERSION:=""}"
|
||||||
: "${DETECTED:=""}"
|
: "${DETECTED:=""}"
|
||||||
: "${PLATFORM:="ARM64"}"
|
: "${PLATFORM:="ARM64"}"
|
||||||
|
|
||||||
|
MIRRORS=2
|
||||||
|
|
||||||
parseVersion() {
|
parseVersion() {
|
||||||
|
|
||||||
[ -z "$VERSION" ] && VERSION="win11"
|
[ -z "$VERSION" ] && VERSION="win11"
|
||||||
|
|
@ -31,44 +34,94 @@ printVersion() {
|
||||||
local id="$1"
|
local id="$1"
|
||||||
local desc="$2"
|
local desc="$2"
|
||||||
|
|
||||||
[[ "$id" == "win10"* ]] && desc="Windows 10"
|
case "${id,,}" in
|
||||||
[[ "$id" == "win11"* ]] && desc="Windows 11"
|
"win10"* ) desc="Windows 10" ;;
|
||||||
|
"win11"* ) desc="Windows 11" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
[ -z "$desc" ] && desc="Windows"
|
if [ -z "$desc" ]; then
|
||||||
|
desc="Windows"
|
||||||
|
[[ "${PLATFORM,,}" != "x64" ]] && desc="$desc for ${PLATFORM}"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$desc for ${PLATFORM}"
|
echo "$desc"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
getName() {
|
printEdition() {
|
||||||
|
|
||||||
local file="$1"
|
local id="$1"
|
||||||
local desc="$2"
|
local desc="$2"
|
||||||
|
local result=""
|
||||||
|
local edition=""
|
||||||
|
|
||||||
[[ "${file,,}" == "win11"* ]] && desc="Windows 11"
|
result=$(printVersion "$id" "x")
|
||||||
[[ "${file,,}" == "win10"* ]] && desc="Windows 10"
|
[[ "$result" == "x" ]] && echo "$desc" && return 0
|
||||||
[[ "${file,,}" == *"windows11"* ]] && desc="Windows 11"
|
|
||||||
[[ "${file,,}" == *"windows10"* ]] && desc="Windows 10"
|
|
||||||
[[ "${file,,}" == *"windows_11"* ]] && desc="Windows 11"
|
|
||||||
[[ "${file,,}" == *"windows_10"* ]] && desc="Windows 10"
|
|
||||||
[[ "${file,,}" == *"windows 11"* ]] && desc="Windows 11"
|
|
||||||
[[ "${file,,}" == *"windows 10"* ]] && desc="Windows 10"
|
|
||||||
|
|
||||||
[ -z "$desc" ] && desc="Windows"
|
case "${id,,}" in
|
||||||
|
"win10"* )
|
||||||
|
edition="Pro"
|
||||||
|
;;
|
||||||
|
"win11"* )
|
||||||
|
edition="Pro"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
echo "$desc for ${PLATFORM}"
|
[ -n "$edition" ] && result="$result $edition"
|
||||||
|
|
||||||
|
echo "$result"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fromFile() {
|
||||||
|
|
||||||
|
local id=""
|
||||||
|
local desc="$1"
|
||||||
|
local file="${1,,}"
|
||||||
|
|
||||||
|
case "${file/ /_}" in
|
||||||
|
"win10"*| "win_10"* | *"windows10"* | *"windows_10"* )
|
||||||
|
id="win10${PLATFORM,,}"
|
||||||
|
;;
|
||||||
|
"win11"* | "win_11"* | *"windows11"* | *"windows_11"* )
|
||||||
|
id="win11${PLATFORM,,}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -n "$id" ]; then
|
||||||
|
desc=$(printVersion "$id" "$desc")
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$desc"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fromName() {
|
||||||
|
|
||||||
|
local id=""
|
||||||
|
local name="$1"
|
||||||
|
|
||||||
|
case "${name,,}" in
|
||||||
|
*"windows 10"* ) id="win10${PLATFORM,,}" ;;
|
||||||
|
*"windows 11"* ) id="win11${PLATFORM,,}" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "$id"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
getVersion() {
|
getVersion() {
|
||||||
|
|
||||||
|
local id
|
||||||
local name="$1"
|
local name="$1"
|
||||||
local detected=""
|
|
||||||
|
|
||||||
[[ "${name,,}" == *"windows 11"* ]] && detected="win11${PLATFORM,,}"
|
id=$(fromName "$name")
|
||||||
[[ "${name,,}" == *"windows 10"* ]] && detected="win10${PLATFORM,,}"
|
|
||||||
|
|
||||||
echo "$detected"
|
echo "$id"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
switchEdition() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,56 +130,92 @@ isESD() {
|
||||||
local id="$1"
|
local id="$1"
|
||||||
|
|
||||||
case "${id,,}" in
|
case "${id,,}" in
|
||||||
"win11${PLATFORM,,}")
|
"win11${PLATFORM,,}" ) return 0 ;;
|
||||||
return 0
|
"win10${PLATFORM,,}" ) return 0 ;;
|
||||||
;;
|
|
||||||
"win10${PLATFORM,,}")
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
getLink() {
|
isMido() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
getLink1() {
|
||||||
|
|
||||||
# Fallbacks for users who cannot connect to the Microsoft servers
|
# Fallbacks for users who cannot connect to the Microsoft servers
|
||||||
|
|
||||||
local id="$1"
|
local id="$1"
|
||||||
|
local ret="$2"
|
||||||
local url=""
|
local url=""
|
||||||
local host="https://dl.bobpony.com"
|
local sum=""
|
||||||
|
local host="https://dl.bobpony.com/windows"
|
||||||
|
|
||||||
case "${id,,}" in
|
case "${id,,}" in
|
||||||
"win11${PLATFORM,,}")
|
"win11${PLATFORM,,}")
|
||||||
|
sum=""
|
||||||
url="$host/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso"
|
url="$host/windows/11/en-us_windows_11_23h2_${PLATFORM,,}.iso"
|
||||||
;;
|
;;
|
||||||
"win10${PLATFORM,,}")
|
"win10${PLATFORM,,}")
|
||||||
|
sum=""
|
||||||
url="$host/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.iso"
|
url="$host/windows/10/en-us_windows_10_22h2_${PLATFORM,,}.iso"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
[ -z "$ret" ] && echo "$url" || echo "$sum"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
getLink2() {
|
||||||
|
|
||||||
|
# Fallbacks for users who cannot connect to the Microsoft servers
|
||||||
|
|
||||||
|
local id="$1"
|
||||||
|
local ret="$2"
|
||||||
|
local url=""
|
||||||
|
local sum=""
|
||||||
|
local host="https://drive.massgrave.dev"
|
||||||
|
|
||||||
|
case "${id,,}" in
|
||||||
|
"win11${PLATFORM,,}")
|
||||||
|
sum=""
|
||||||
|
url="$host/SW_DVD9_Win_Pro_11_23H2.2_Arm64_English_Pro_Ent_EDU_N_MLF_X23-68023.ISO"
|
||||||
|
;;
|
||||||
|
"win10${PLATFORM,,}")
|
||||||
|
sum=""
|
||||||
|
url="$host/SW_DVD9_Win_Pro_10_22H2.15_Arm64_English_Pro_Ent_EDU_N_MLF_X23-67223.ISO"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ -z "$ret" ] && echo "$url" || echo "$sum"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
getLink() {
|
||||||
|
|
||||||
|
local url=""
|
||||||
|
local id="$2"
|
||||||
|
local func="getLink$1"
|
||||||
|
|
||||||
|
if [ "$1" -gt 0 ] && [ "$1" -le "$MIRRORS" ]; then
|
||||||
|
url=$($func "$id" "")
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$url"
|
echo "$url"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
secondLink() {
|
getHash() {
|
||||||
|
|
||||||
# Fallbacks for users who cannot connect to the Microsoft servers
|
local sum=""
|
||||||
|
local id="$2"
|
||||||
|
local func="getLink$1"
|
||||||
|
|
||||||
local id="$1"
|
if [ "$1" -gt 0 ] && [ "$1" -le "$MIRRORS" ]; then
|
||||||
local url=""
|
sum=$($func "$id" "sum")
|
||||||
local host="https://drive.massgrave.dev"
|
fi
|
||||||
|
|
||||||
case "${id,,}" in
|
echo "$sum"
|
||||||
"win11${PLATFORM,,}")
|
|
||||||
url="$host/SW_DVD9_Win_Pro_11_23H2.2_Arm64_English_Pro_Ent_EDU_N_MLF_X23-68023.ISO"
|
|
||||||
;;
|
|
||||||
"win10${PLATFORM,,}")
|
|
||||||
url="$host/SW_DVD9_Win_Pro_10_22H2.15_Arm64_English_Pro_Ent_EDU_N_MLF_X23-67223.ISO"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "$url"
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,12 +225,16 @@ validVersion() {
|
||||||
local url
|
local url
|
||||||
|
|
||||||
isESD "$id" && return 0
|
isESD "$id" && return 0
|
||||||
|
isMido "$id" && return 0
|
||||||
|
|
||||||
url=$(getLink "$id")
|
for ((i=1;i<=MIRRORS;i++)); do
|
||||||
|
|
||||||
|
url=$(getLink "$i" "$id")
|
||||||
[ -n "$url" ] && return 0
|
[ -n "$url" ] && return 0
|
||||||
|
|
||||||
url=$(secondLink "$id")
|
done
|
||||||
[ -n "$url" ] && return 0
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue