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