feat: Improved installation

This commit is contained in:
Kroese 2024-05-12 00:22:18 +02:00 committed by GitHub
parent 4da3a90463
commit e1f4eef7a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,6 +22,7 @@ skipInstall() {
local iso="$1" local iso="$1"
local magic byte local magic byte
local boot="$STORAGE/windows.boot"
local previous="$STORAGE/windows.base" local previous="$STORAGE/windows.base"
if [ -f "$previous" ]; then if [ -f "$previous" ]; then
@ -29,26 +30,32 @@ skipInstall() {
if [ -n "$previous" ]; then if [ -n "$previous" ]; then
previous="$STORAGE/$previous" previous="$STORAGE/$previous"
if [[ "${previous,,}" != "${iso,,}" ]]; then if [[ "${previous,,}" != "${iso,,}" ]]; then
if [ -f "$boot" ] && hasDisk; then
fi info "Detected that the version was changed, but Windows is already installed."
if [ -f "$previous" ]; then info "Please clear the /storage folder first, if you want to install this new version."
rm -f "$previous" || true return 0
fi
[ -f "$previous" ] && rm -f "$previous" || true
return 1
fi fi
fi fi
fi fi
[ -f "$STORAGE/windows.boot" ] && hasDisk && return 0 [ -f "$boot" ] && hasDisk && return 0
[ ! -f "$iso" ] && return 1 [ ! -f "$iso" ] && return 1
[ ! -s "$iso" ] && return 1 [ ! -s "$iso" ] && return 1
[ -n "$CUSTOM" ] && [ -z "$ORIGINAL" ] && return 1
# Check if the ISO was already processed by our script # Check if the ISO was already processed by our script
magic=$(dd if="$iso" seek=0 bs=1 count=1 status=none | tr -d '\000') magic=$(dd if="$iso" seek=0 bs=1 count=1 status=none | tr -d '\000')
magic="$(printf '%s' "$magic" | od -A n -t x1 -v | tr -d ' \n')" magic="$(printf '%s' "$magic" | od -A n -t x1 -v | tr -d ' \n')"
byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17" byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17"
[[ "$magic" != "$byte" ]] && return 1 if [[ "$magic" != "$byte" ]]; then
[ -n "$CUSTOM" ] && [ -z "$ORIGINAL" ] && return 1 info "The ISO will be processed again because of a configuration change..."
return 1
fi
return 0 return 0
} }
@ -126,7 +133,7 @@ finishInstall() {
# Mark ISO as prepared via magic byte # Mark ISO as prepared via magic byte
byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17" byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17"
if ! printf '%b' "\x$byte" | dd of="$iso" bs=1 seek=0 count=1 conv=notrunc status=none; then if ! printf '%b' "\x$byte" | dd of="$iso" bs=1 seek=0 count=1 conv=notrunc status=none; then
error "Failed to set magic byte in ISO file: $iso" && return 1 warn "failed to set magic byte in ISO file: $iso"
fi fi
fi fi