mirror of
https://github.com/dockur/windows.git
synced 2025-10-27 03:15:49 +00:00
feat; Create backup of previous installation
This commit is contained in:
parent
05330ff64c
commit
5959879b25
1 changed files with 21 additions and 10 deletions
|
|
@ -1,23 +1,23 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
TMP="$STORAGE/tmp"
|
|
||||||
DIR="$TMP/unpack"
|
|
||||||
FB="falling back to manual installation!"
|
|
||||||
ETFS="boot/etfsboot.com"
|
ETFS="boot/etfsboot.com"
|
||||||
|
FB="falling back to manual installation!"
|
||||||
EFISYS="efi/microsoft/boot/efisys_noprompt.bin"
|
EFISYS="efi/microsoft/boot/efisys_noprompt.bin"
|
||||||
|
|
||||||
skipInstall() {
|
skipInstall() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local method=""
|
local method=""
|
||||||
local magic byte
|
local dir magic byte
|
||||||
local boot="$STORAGE/windows.boot"
|
local boot="$STORAGE/windows.boot"
|
||||||
local previous="$STORAGE/windows.base"
|
local previous="$STORAGE/windows.base"
|
||||||
|
|
||||||
if [ -f "$previous" ]; then
|
if [ -f "$previous" ]; then
|
||||||
|
|
||||||
previous=$(<"$previous")
|
previous=$(<"$previous")
|
||||||
previous="${previous//[![:print:]]/}"
|
previous="${previous//[![:print:]]/}"
|
||||||
|
|
||||||
if [ -n "$previous" ]; then
|
if [ -n "$previous" ]; then
|
||||||
if [[ "${STORAGE,,}/${previous,,}" != "${iso,,}" ]]; then
|
if [[ "${STORAGE,,}/${previous,,}" != "${iso,,}" ]]; then
|
||||||
if [ -f "$boot" ] && hasDisk; then
|
if [ -f "$boot" ] && hasDisk; then
|
||||||
|
|
@ -29,15 +29,24 @@ skipInstall() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -n "$method" ]; then
|
if [ -n "$method" ]; then
|
||||||
info "Detected that $method was changed, but ignoring this because Windows is already installed."
|
info "Detected that $method was changed, will create a backup of your previous installation."
|
||||||
info "Please start with an empty /storage folder, if you want to install a different version of Windows."
|
|
||||||
fi
|
fi
|
||||||
|
local i=2
|
||||||
|
dir="${previous%.*}"
|
||||||
|
while [[ $i -le 99 ]] && [ -d "$STORAGE/$dir" ]
|
||||||
|
do
|
||||||
|
dir="${previous%.*}-$i"
|
||||||
|
i=$(expr $i + 1)
|
||||||
|
done
|
||||||
|
mkdir -p "$STORAGE/$dir"
|
||||||
|
find "$STORAGE" -maxdepth 1 -type f -name '*' -exec mv -n {} $STORAGE/$dir/ \;
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
rm -f "$STORAGE/$previous"
|
rm -f "$STORAGE/$previous"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -f "$boot" ] && hasDisk && return 0
|
[ -f "$boot" ] && hasDisk && return 0
|
||||||
|
|
@ -88,9 +97,11 @@ startInstall() {
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
skipInstall "$BOOT" && return 1
|
TMP="$STORAGE/tmp"
|
||||||
|
|
||||||
rm -rf "$TMP"
|
rm -rf "$TMP"
|
||||||
|
|
||||||
|
skipInstall "$BOOT" && return 1
|
||||||
|
|
||||||
mkdir -p "$TMP"
|
mkdir -p "$TMP"
|
||||||
|
|
||||||
if [ -z "$CUSTOM" ]; then
|
if [ -z "$CUSTOM" ]; then
|
||||||
|
|
@ -1076,8 +1087,6 @@ buildImage() {
|
||||||
|
|
||||||
bootWindows() {
|
bootWindows() {
|
||||||
|
|
||||||
rm -rf "$TMP"
|
|
||||||
|
|
||||||
if [ -f "$STORAGE/windows.args" ]; then
|
if [ -f "$STORAGE/windows.args" ]; then
|
||||||
ARGS=$(<"$STORAGE/windows.args")
|
ARGS=$(<"$STORAGE/windows.args")
|
||||||
ARGS="${ARGS//[![:print:]]/}"
|
ARGS="${ARGS//[![:print:]]/}"
|
||||||
|
|
@ -1145,6 +1154,8 @@ if [ ! -s "$ISO" ] || [ ! -f "$ISO" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
DIR="$TMP/unpack"
|
||||||
|
|
||||||
if ! extractImage "$ISO" "$DIR" "$VERSION"; then
|
if ! extractImage "$ISO" "$DIR" "$VERSION"; then
|
||||||
rm -f "$ISO" 2> /dev/null || true
|
rm -f "$ISO" 2> /dev/null || true
|
||||||
exit 62
|
exit 62
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue