diff --git a/src/define.sh b/src/define.sh index 9ce9b00..63075c5 100644 --- a/src/define.sh +++ b/src/define.sh @@ -1287,7 +1287,7 @@ isMido() { local lang="$2" local sum - [[ "${MIDO:-}" == [Nn]* ]] && return 1 + disabled "${MIDO:-}" && return 1 sum=$(getMido "$id" "en" "sum") [ -n "$sum" ] && return 0 @@ -1300,7 +1300,7 @@ isESD() { local id="$1" local lang="$2" - [[ "${ESD:-}" == [Nn]* ]] && return 1 + disabled "${ESD:-}" && return 1 case "${id,,}" in "win11${PLATFORM,,}" | "win10${PLATFORM,,}" ) diff --git a/src/entry.sh b/src/entry.sh index 2a35133..e5ba630 100644 --- a/src/entry.sh +++ b/src/entry.sh @@ -46,7 +46,7 @@ sed -u \ -e 's/failed to load Boot/skipped Boot/g' \ -e 's/0): Not Found/0)/g' & -if [[ "$SHUTDOWN" != [Yy1]* ]]; then +if ! enabled "$SHUTDOWN"; then exec "${cmd[@]}" ${ARGS:+ $ARGS} >"$pipe" fi diff --git a/src/install.sh b/src/install.sh index 45b2db0..fbc6d11 100644 --- a/src/install.sh +++ b/src/install.sh @@ -110,7 +110,7 @@ skipInstall() { # Check if the ISO was already processed by our script magic=$(dd if="$iso" bs=1 count=1 status=none | tr -d '\000') magic="$(printf '%s' "$magic" | od -A n -t x1 -v | tr -d ' \n')" - byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17" + byte="16" && enabled "$MANUAL" && byte="17" if [[ "$magic" != "$byte" ]]; then @@ -215,7 +215,7 @@ finishInstall() { if [[ "$aborted" != [Yy1]* ]]; then # Mark ISO as prepared via magic byte - byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17" + byte="16" && enabled "$MANUAL" && byte="17" if ! printf '%b' "\x$byte" | dd of="$iso" bs=1 seek=0 count=1 conv=notrunc status=none; then warn "failed to set magic byte in ISO file: $iso" fi @@ -243,7 +243,7 @@ finishInstall() { fi else # Enable secure boot + TPM on manual installs as Win11 requires - if [[ "$MANUAL" == [Yy1]* || "$aborted" == [Yy1]* ]]; then + if enabled "$MANUAL" || [[ "$aborted" == [Yy1]* ]]; then if [[ "${DETECTED,,}" == "win11"* ]]; then BOOT_MODE="windows_secure" file="$STORAGE/windows.mode" @@ -296,7 +296,7 @@ abortInstall() { local efi [[ "${iso,,}" == *".esd" ]] && exit 60 - [[ "${UNPACK:-}" == [Yy1]* ]] && exit 60 + enabled "${UNPACK:-}" && exit 60 efi=$(find "$dir" -maxdepth 1 -type d -iname efi -print -quit) @@ -556,7 +556,7 @@ extractImage() { fKill "progress.sh" - if [[ "${UNPACK:-}" != [Yy1]* ]]; then + if ! enabled "${UNPACK:-}"; then LABEL=$(isoinfo -d -i "$iso" | sed -n 's/Volume id: //p') @@ -739,7 +739,7 @@ detectImage() { skipVersion "${DETECTED,,}" && return 0 - if ! setXML "" && [[ "$MANUAL" != [Yy1]* ]]; then + if ! setXML "" && ! enabled "$MANUAL"; then MANUAL="Y" desc=$(printEdition "$DETECTED" "this version") warn "the answer file for $desc was not found ($DETECTED.xml), $FB." @@ -776,7 +776,7 @@ detectImage() { if [ -z "$DETECTED" ]; then msg="Failed to determine Windows version from image" - if setXML "" || [[ "$MANUAL" == [Yy1]* ]]; then + if setXML "" || enabled "$MANUAL"; then info "${msg}!" else MANUAL="Y" @@ -803,8 +803,8 @@ detectImage() { msg="the answer file for $desc was not found ($DETECTED.xml)" local fallback="/run/assets/${DETECTED%%-*}.xml" - if setXML "$fallback" || [[ "$MANUAL" == [Yy1]* ]]; then - [[ "$MANUAL" != [Yy1]* ]] && warn "${msg}." + if setXML "$fallback" || enabled "$MANUAL"; then + ! enabled "$MANUAL" && warn "${msg}." else MANUAL="Y" warn "${msg}, $FB." @@ -1047,7 +1047,7 @@ updateImage() { if [ ! -s "$asset" ] || [ ! -f "$asset" ]; then asset="" - if [[ "$MANUAL" != [Yy1]* ]]; then + if ! enabled "$MANUAL"; then MANUAL="Y" warn "no answer file provided, $FB." fi @@ -1093,7 +1093,7 @@ updateImage() { fi fi - if [[ "$MANUAL" != [Yy1]* ]]; then + if ! enabled "$MANUAL"; then xml=$(basename "$asset") info "Adding $xml for automatic installation..." @@ -1111,7 +1111,7 @@ updateImage() { fi - if [[ "$MANUAL" == [Yy1]* ]]; then + if enabled "$MANUAL"; then wimlib-imagex update "$wim" "$index" --command "delete --force /$file" > /dev/null || true @@ -1124,11 +1124,11 @@ updateImage() { fi local find="$file" - [[ "$MANUAL" == [Yy1]* ]] && find="$org" + enabled "$MANUAL" && find="$org" path=$(find "$dir" -maxdepth 1 -type f -iname "$find" -print -quit) if [ -f "$path" ]; then - if [[ "$MANUAL" != [Yy1]* ]]; then + if ! enabled "$MANUAL"; then mv -f "$path" "${path%.*}.org" else mv -f "$path" "${path%.*}.xml" diff --git a/src/mido.sh b/src/mido.sh index eeef986..79835ae 100644 --- a/src/mido.sh +++ b/src/mido.sh @@ -90,15 +90,15 @@ download_windows() { # This is the *only* request we make that Fido doesn't. Fido manually maintains a list of all the Windows release/edition product edition IDs in its script (see: $WindowsVersions array). This is helpful for downloading older releases (e.g. Windows 10 1909, 21H1, etc.) but we always want to get the newest release which is why we get this value dynamically # Also, keeping a "$WindowsVersions" array like Fido does would be way too much of a maintenance burden # Remove "Accept" header that curl sends by default - [[ "$DEBUG" == [Yy1]* ]] && echo "Parsing download page: ${url}" + enabled "$DEBUG" && echo "Parsing download page: ${url}" download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --header "Accept:" --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || { handle_curl_error "$?" "Microsoft" return $? } - [[ "$DEBUG" == [Yy1]* ]] && echo -n "Getting Product edition ID: " + enabled "$DEBUG" && echo -n "Getting Product edition ID: " product_edition_id=$(echo "$download_page_html" | grep -Eo '