mirror of
https://github.com/dockur/windows.git
synced 2025-10-29 20:25:49 +00:00
feat: Store base image
This commit is contained in:
parent
47d2d2294c
commit
5869856124
1 changed files with 23 additions and 19 deletions
|
|
@ -20,15 +20,6 @@ hasDisk() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
skipInstall() {
|
|
||||||
|
|
||||||
if hasDisk && [ -f "$STORAGE/windows.boot" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
startInstall() {
|
startInstall() {
|
||||||
|
|
||||||
html "Starting $APP..."
|
html "Starting $APP..."
|
||||||
|
|
@ -55,19 +46,26 @@ startInstall() {
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
skipInstall && return 1
|
if [ -f "$STORAGE/windows.base" ]; then
|
||||||
|
local base previous
|
||||||
|
base=$(basename $iso)
|
||||||
|
previous=$(<"$STORAGE/windows.base")
|
||||||
|
if [ -n "$previous" ]; then
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if hasDisk && [ -f "$STORAGE/windows.boot" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f "$ISO" ] && [ -s "$ISO" ]; then
|
if [ -f "$ISO" ] && [ -s "$ISO" ]; then
|
||||||
|
|
||||||
local magic
|
local magic byte
|
||||||
local auto="16"
|
|
||||||
local manual="17"
|
|
||||||
local byte="$auto"
|
|
||||||
[[ "$MANUAL" == [Yy1]* ]] && byte="$manual"
|
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
if [[ "$magic" == "$byte" ]]; then
|
if [[ "$magic" == "$byte" ]]; then
|
||||||
if [ -z "$CUSTOM" ] || [ -n "$ORIGINAL" ]; then
|
if [ -z "$CUSTOM" ] || [ -n "$ORIGINAL" ]; then
|
||||||
|
|
@ -112,26 +110,32 @@ finishInstall() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local aborted="$2"
|
local aborted="$2"
|
||||||
|
local base byte
|
||||||
|
|
||||||
if [ ! -s "$iso" ] || [ ! -f "$iso" ]; then
|
if [ ! -s "$iso" ] || [ ! -f "$iso" ]; then
|
||||||
error "Failed to find ISO file: $iso" && return 1
|
error "Failed to find ISO file: $iso" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -w "$iso" ] && [[ "$aborted" != [Yy1]* ]]; then
|
if [[ "$aborted" != [Yy1]* ]]; then
|
||||||
# Mark ISO as prepared via magic byte
|
# Mark ISO as prepared via magic byte
|
||||||
local byte="16"
|
byte="16" && [[ "$MANUAL" == [Yy1]* ]] && byte="17"
|
||||||
[[ "$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
|
error "Failed to set magic byte in ISO file: $iso" && return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "$STORAGE/windows.old"
|
rm -f "$STORAGE/windows.old"
|
||||||
|
rm -f "$STORAGE/windows.base"
|
||||||
rm -f "$STORAGE/windows.boot"
|
rm -f "$STORAGE/windows.boot"
|
||||||
rm -f "$STORAGE/windows.mode"
|
rm -f "$STORAGE/windows.mode"
|
||||||
|
|
||||||
cp -f /run/version "$STORAGE/windows.ver"
|
cp -f /run/version "$STORAGE/windows.ver"
|
||||||
|
|
||||||
|
if [[ "$iso" == "$STORAGE/"* ]]; then
|
||||||
|
base=$(basename $iso)
|
||||||
|
echo "$base" > "$STORAGE/windows.base"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
||||||
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
|
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
|
||||||
echo "$BOOT_MODE" > "$STORAGE/windows.mode"
|
echo "$BOOT_MODE" > "$STORAGE/windows.mode"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue