feat: Improved installation

This commit is contained in:
Kroese 2024-05-12 13:01:19 +02:00 committed by GitHub
parent e1f4eef7a2
commit 17e87904ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,8 +31,8 @@ skipInstall() {
previous="$STORAGE/$previous" previous="$STORAGE/$previous"
if [[ "${previous,,}" != "${iso,,}" ]]; then if [[ "${previous,,}" != "${iso,,}" ]]; then
if [ -f "$boot" ] && hasDisk; then if [ -f "$boot" ] && hasDisk; then
info "Detected that the version was changed, but Windows is already installed." info "Detected that the version was changed, but ignoring this because Windows is already installed."
info "Please clear the /storage folder first, if you want to install this new version." info "Please start with an empty /storage folder, if you want to install a different version of Windows."
return 0 return 0
fi fi
[ -f "$previous" ] && rm -f "$previous" || true [ -f "$previous" ] && rm -f "$previous" || true
@ -45,7 +45,6 @@ skipInstall() {
[ ! -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')
@ -53,7 +52,7 @@ skipInstall() {
byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17" byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17"
if [[ "$magic" != "$byte" ]]; then if [[ "$magic" != "$byte" ]]; then
info "The ISO will be processed again because of a configuration change..." info "The ISO will be processed again because the configuration was changed..."
return 1 return 1
fi fi
@ -64,11 +63,7 @@ startInstall() {
html "Starting $APP..." html "Starting $APP..."
if [ -n "$CUSTOM" ]; then if [ -z "$CUSTOM" ]; then
ISO="$CUSTOM"
else
local file="${VERSION/\//}.iso" local file="${VERSION/\//}.iso"
@ -80,39 +75,26 @@ startInstall() {
fi fi
ISO="$STORAGE/$file" BOOT="$STORAGE/$file"
! migrateFiles "$ISO" "$VERSION" && error "Migration failed!" && exit 57 ! migrateFiles "$BOOT" "$VERSION" && error "Migration failed!" && exit 57
fi fi
skipInstall "$ISO" && return 1 skipInstall "$BOOT" && return 1
rm -rf "$TMP" rm -rf "$TMP"
mkdir -p "$TMP" mkdir -p "$TMP"
if [ -z "$CUSTOM" ]; then if [ -z "$CUSTOM" ]; then
BOOT="$ISO" ISO=$(basename "$BOOT")
ISO=$(basename "$ISO")
ISO="$TMP/$ISO" ISO="$TMP/$ISO"
if [ -f "$BOOT" ] && [ -s "$BOOT" ]; then if [ -f "$BOOT" ] && [ -s "$BOOT" ]; then
mv -f "$BOOT" "$ISO" mv -f "$BOOT" "$ISO"
fi fi
else
if [ -n "$ORIGINAL" ]; then
rm -f "$ISO"
ISO="$ORIGINAL"
CUSTOM="$ISO"
fi
local size
size="$(stat -c%s "$ISO")"
BOOT="$STORAGE/windows.$size.iso"
fi fi
rm -f "$BOOT" rm -f "$BOOT"
@ -199,7 +181,6 @@ detectCustom() {
local size base local size base
CUSTOM="" CUSTOM=""
ORIGINAL=""
if [[ "${VERSION,,}" != "http"* ]]; then if [[ "${VERSION,,}" != "http"* ]]; then
base="${VERSION/\/storage\//}" base="${VERSION/\/storage\//}"
@ -221,15 +202,9 @@ detectCustom() {
size="$(stat -c%s "$file")" size="$(stat -c%s "$file")"
[ -z "$size" ] || [[ "$size" == "0" ]] && return 0 [ -z "$size" ] || [[ "$size" == "0" ]] && return 0
base="$STORAGE/windows.$size.iso" ISO="$file"
CUSTOM="$ISO"
if [ -f "$base" ] && [ -s "$base" ]; then BOOT="$STORAGE/windows.$size.iso"
CUSTOM="$base"
ORIGINAL="$file"
else
rm -f "$base"
CUSTOM="$file"
fi
return 0 return 0
} }
@ -1064,13 +1039,11 @@ bootWindows() {
rm -rf "$TMP" rm -rf "$TMP"
if [ ! -f "$ISO" ] || [ ! -s "$ISO" ]; then if [ ! -f "$BOOT" ] || [ ! -s "$BOOT" ]; then
ISO="/custom.iso" BOOT="/custom.iso"
[ ! -f "$ISO" ] && ISO="${STORAGE}$ISO" [ ! -f "$BOOT" ] && BOOT="${STORAGE}$BOOT"
fi fi
BOOT="$ISO"
[[ "${PLATFORM,,}" == "arm64" ]] && VGA="virtio-gpu" [[ "${PLATFORM,,}" == "arm64" ]] && VGA="virtio-gpu"
if [ -s "$STORAGE/windows.mode" ] && [ -f "$STORAGE/windows.mode" ]; then if [ -s "$STORAGE/windows.mode" ] && [ -f "$STORAGE/windows.mode" ]; then