feat: Improved installation (#99)
This commit is contained in:
parent
348930051e
commit
aaffc9535b
6 changed files with 215 additions and 169 deletions
|
@ -1,5 +1,5 @@
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=qemux/qemu-arm:1.19 / /
|
COPY --from=qemux/qemu-arm:1.20 / /
|
||||||
|
|
||||||
ARG DEBCONF_NOWARNINGS "yes"
|
ARG DEBCONF_NOWARNINGS "yes"
|
||||||
ARG DEBIAN_FRONTEND "noninteractive"
|
ARG DEBIAN_FRONTEND "noninteractive"
|
||||||
|
|
21
readme.md
21
readme.md
|
@ -111,9 +111,14 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
|
||||||
|
|
||||||
* ### How do I share files with the host?
|
* ### How do I share files with the host?
|
||||||
|
|
||||||
Open 'File Explorer' and click on the 'Network' section, you will see a computer called `host.lan`, double-click it and it will show a folder called `Data`.
|
Open 'File Explorer' and click on the 'Network' section, you will see a computer called `host.lan`. Double-click it and it will show a folder called `Data`, which can be binded to any folder on your host via the compose file:
|
||||||
|
|
||||||
Inside this folder you can access any files that are placed in `/storage/shared` (see above) on the host. You can optionally map it to a drive letter, for easy access.
|
```yaml
|
||||||
|
volumes:
|
||||||
|
- /home/user/example:/shared
|
||||||
|
```
|
||||||
|
|
||||||
|
The example folder `/home/user/example` will be available as ` \\host.lan\Data`. You can optionally map this path to a drive letter in Windows, for easier access.
|
||||||
|
|
||||||
* ### How do I install a custom image?
|
* ### How do I install a custom image?
|
||||||
|
|
||||||
|
@ -128,7 +133,7 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
volumes:
|
volumes:
|
||||||
- /home/user/example.iso:/storage/custom.iso
|
- /home/user/example.iso:/custom.iso
|
||||||
```
|
```
|
||||||
|
|
||||||
Replace the example path `/home/user/example.iso` with the filename of your desired ISO file. The value of `VERSION` will be ignored in this case.
|
Replace the example path `/home/user/example.iso` with the filename of your desired ISO file. The value of `VERSION` will be ignored in this case.
|
||||||
|
@ -141,7 +146,7 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
volumes:
|
volumes:
|
||||||
- /home/user/example.xml:/storage/custom.xml
|
- /home/user/example.xml:/custom.xml
|
||||||
```
|
```
|
||||||
|
|
||||||
Replace the example path `/home/user/example.xml` with the filename of the modified XML file.
|
Replace the example path `/home/user/example.xml` with the filename of the modified XML file.
|
||||||
|
@ -152,7 +157,7 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
volumes:
|
volumes:
|
||||||
- /home/user/example:/storage/oem
|
- /home/user/example:/oem
|
||||||
```
|
```
|
||||||
|
|
||||||
The example folder `/home/user/example` will be copied to `C:\OEM` during installation and the containing `install.bat` will be executed during the last step.
|
The example folder `/home/user/example` will be copied to `C:\OEM` during installation and the containing `install.bat` will be executed during the last step.
|
||||||
|
@ -247,11 +252,11 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
devices:
|
devices:
|
||||||
- /dev/sdb:/dev/disk1
|
- /dev/sdb:/disk1
|
||||||
- /dev/sdc:/dev/disk2
|
- /dev/sdc:/disk2
|
||||||
```
|
```
|
||||||
|
|
||||||
Use `/dev/disk1` if you want it to become your main drive, and use `/dev/disk2` and higher to add them as secondary drives.
|
Use `/disk1` if you want it to become your main drive, and use `/disk2` and higher to add them as secondary drives.
|
||||||
|
|
||||||
* ### How do I pass-through a USB device?
|
* ### How do I pass-through a USB device?
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ set -Eeuo pipefail
|
||||||
|
|
||||||
: "${VERIFY:=""}"
|
: "${VERIFY:=""}"
|
||||||
: "${MANUAL:=""}"
|
: "${MANUAL:=""}"
|
||||||
|
: "${REMOVE:=""}"
|
||||||
: "${VERSION:=""}"
|
: "${VERSION:=""}"
|
||||||
: "${DETECTED:=""}"
|
: "${DETECTED:=""}"
|
||||||
: "${PLATFORM:="ARM64"}"
|
: "${PLATFORM:="ARM64"}"
|
||||||
|
@ -11,17 +12,19 @@ MIRRORS=2
|
||||||
|
|
||||||
parseVersion() {
|
parseVersion() {
|
||||||
|
|
||||||
[ -z "$VERSION" ] && VERSION="win11"
|
VERSION="${VERSION/\//}"
|
||||||
|
|
||||||
if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
|
if [[ "${VERSION}" == \"*\" || "${VERSION}" == \'*\' ]]; then
|
||||||
VERSION="${VERSION:1:-1}"
|
VERSION="${VERSION:1:-1}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ -z "$VERSION" ] && VERSION="win11"
|
||||||
|
|
||||||
case "${VERSION,,}" in
|
case "${VERSION,,}" in
|
||||||
"11" | "win11" | "windows11" | "windows 11" )
|
"11" | "11p" | "win11" | "win11p" | "windows11" | "windows 11" )
|
||||||
VERSION="win11${PLATFORM,,}"
|
VERSION="win11${PLATFORM,,}"
|
||||||
;;
|
;;
|
||||||
"10" | "win10" | "windows10" | "windows 10" )
|
"10" | "10p" | "win10" | "win10p" | "windows10" | "windows 10" )
|
||||||
VERSION="win10${PLATFORM,,}"
|
VERSION="win10${PLATFORM,,}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -125,20 +128,35 @@ switchEdition() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
isESD() {
|
getCatalog() {
|
||||||
|
|
||||||
local id="$1"
|
local id="$1"
|
||||||
|
local ret="$2"
|
||||||
|
local url=""
|
||||||
|
local name=""
|
||||||
|
local edition=""
|
||||||
|
|
||||||
case "${id,,}" in
|
case "${id,,}" in
|
||||||
"win11${PLATFORM,,}" ) return 0 ;;
|
"win11${PLATFORM,,}" )
|
||||||
"win10${PLATFORM,,}" ) return 0 ;;
|
edition="Professional"
|
||||||
|
name="Windows 11 Pro"
|
||||||
|
url="https://go.microsoft.com/fwlink?linkid=2156292"
|
||||||
|
;;
|
||||||
|
"win10${PLATFORM,,}" )
|
||||||
|
edition="Professional"
|
||||||
|
name="Windows 10 Pro"
|
||||||
|
url="https://go.microsoft.com/fwlink/?LinkId=841361"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
return 1
|
case "${ret,,}" in
|
||||||
}
|
"url" ) echo "$url" ;;
|
||||||
|
"name" ) echo "$name" ;;
|
||||||
|
"edition" ) echo "$edition" ;;
|
||||||
|
*) echo "";;
|
||||||
|
esac
|
||||||
|
|
||||||
isMido() {
|
return 0
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getLink1() {
|
getLink1() {
|
||||||
|
@ -249,12 +267,28 @@ getSize() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isMido() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
isESD() {
|
||||||
|
|
||||||
|
local id="$1"
|
||||||
|
local url
|
||||||
|
|
||||||
|
url=$(getCatalog "$id" "url")
|
||||||
|
[ -n "$url" ] && return 0
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
validVersion() {
|
validVersion() {
|
||||||
|
|
||||||
local id="$1"
|
local id="$1"
|
||||||
local url
|
local url
|
||||||
|
|
||||||
isESD "$id" && return 0
|
isESD "$id" && return 0
|
||||||
|
isMido "$id" && return 0
|
||||||
|
|
||||||
for ((i=1;i<=MIRRORS;i++)); do
|
for ((i=1;i<=MIRRORS;i++)); do
|
||||||
|
|
||||||
|
@ -266,4 +300,8 @@ validVersion() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
migrateFiles() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
280
src/install.sh
280
src/install.sh
|
@ -9,6 +9,8 @@ EFISYS="efi/microsoft/boot/efisys_noprompt.bin"
|
||||||
|
|
||||||
hasDisk() {
|
hasDisk() {
|
||||||
|
|
||||||
|
[ -b "/disk1" ] && return 0
|
||||||
|
[ -b "/dev/disk1" ] && return 0
|
||||||
[ -b "${DEVICE:-}" ] && return 0
|
[ -b "${DEVICE:-}" ] && return 0
|
||||||
|
|
||||||
if [ -s "$STORAGE/data.img" ] || [ -s "$STORAGE/data.qcow2" ]; then
|
if [ -s "$STORAGE/data.img" ] || [ -s "$STORAGE/data.qcow2" ]; then
|
||||||
|
@ -33,69 +35,63 @@ startInstall() {
|
||||||
|
|
||||||
[ -z "$MANUAL" ] && MANUAL="N"
|
[ -z "$MANUAL" ] && MANUAL="N"
|
||||||
|
|
||||||
if [ -f "$STORAGE/$CUSTOM" ]; then
|
if [ -n "$CUSTOM" ]; then
|
||||||
|
|
||||||
BASE="$CUSTOM"
|
ISO="$CUSTOM"
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
CUSTOM=""
|
local file="${VERSION/\//}.iso"
|
||||||
|
|
||||||
if [[ "${VERSION,,}" != "http"* ]]; then
|
if [[ "${VERSION,,}" == "http"* ]]; then
|
||||||
|
|
||||||
BASE="$VERSION.iso"
|
file=$(basename "${VERSION%%\?*}")
|
||||||
|
: "${file//+/ }"; printf -v file '%b' "${_//%/\\x}"
|
||||||
else
|
file=$(echo "$file" | sed -e 's/[^A-Za-z0-9._-]/_/g')
|
||||||
|
|
||||||
BASE=$(basename "${VERSION%%\?*}")
|
|
||||||
: "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}"
|
|
||||||
BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g')
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ISO="$STORAGE/$file"
|
||||||
|
|
||||||
|
! migrateFiles "$ISO" "$VERSION" && error "Migration failed!" && exit 57
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
skipInstall && return 1
|
||||||
! migrateFiles "$BASE" "$VERSION" && error "Migration failed!" && exit 57
|
|
||||||
fi
|
|
||||||
|
|
||||||
if skipInstall; then
|
if [ -f "$ISO" ] && [ -s "$ISO" ]; then
|
||||||
if [ ! -f "$STORAGE/$BASE" ]; then
|
|
||||||
BASE="custom.iso"
|
|
||||||
[ ! -f "$STORAGE/$BASE" ] && BASE=""
|
|
||||||
fi
|
|
||||||
[[ "${PLATFORM,,}" == "arm64" ]] && VGA="virtio-gpu"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$STORAGE/$BASE" ]; then
|
|
||||||
|
|
||||||
# Check if the ISO was already processed by our script
|
# Check if the ISO was already processed by our script
|
||||||
local magic=""
|
local magic=""
|
||||||
magic=$(dd if="$STORAGE/$BASE" 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')"
|
||||||
|
[[ "$magic" == "16" ]] && return 1
|
||||||
|
|
||||||
if [[ "$magic" == "16" ]]; then
|
fi
|
||||||
|
|
||||||
if hasDisk || [[ "$MANUAL" == [Yy1]* ]]; then
|
if [ -z "$CUSTOM" ]; then
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
BOOT="$ISO"
|
||||||
|
ISO=$(basename "$ISO")
|
||||||
|
ISO="$TMP/$ISO"
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
if [ -n "$ORIGINAL" ]; then
|
||||||
|
rm -f "$ISO"
|
||||||
|
ISO="$ORIGINAL"
|
||||||
|
CUSTOM="$ISO"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CUSTOM="$BASE"
|
local size
|
||||||
|
size="$(stat -c%s "$ISO")"
|
||||||
|
BOOT="$STORAGE/windows.$size.iso"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rm -f "$BOOT"
|
||||||
rm -rf "$TMP"
|
rm -rf "$TMP"
|
||||||
mkdir -p "$TMP"
|
mkdir -p "$TMP"
|
||||||
|
|
||||||
if [ ! -f "$STORAGE/$CUSTOM" ]; then
|
|
||||||
CUSTOM=""
|
|
||||||
ISO="$TMP/$BASE"
|
|
||||||
else
|
|
||||||
ISO="$STORAGE/$CUSTOM"
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +116,6 @@ finishInstall() {
|
||||||
rm -f "$STORAGE/windows.mode"
|
rm -f "$STORAGE/windows.mode"
|
||||||
|
|
||||||
cp /run/version "$STORAGE/windows.ver"
|
cp /run/version "$STORAGE/windows.ver"
|
||||||
echo "$BASE" > "$STORAGE/windows.base"
|
|
||||||
|
|
||||||
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
if [[ "${PLATFORM,,}" == "x64" ]]; then
|
||||||
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
|
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
|
||||||
|
@ -147,43 +142,62 @@ abortInstall() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
|
|
||||||
if [[ "$iso" != "$STORAGE/$BASE" ]]; then
|
[[ "${iso,,}" == *".esd" ]] && exit 60
|
||||||
if ! mv -f "$iso" "$STORAGE/$BASE"; then
|
|
||||||
error "Failed to move ISO file: $iso" && return 1
|
if [ -n "$CUSTOM" ]; then
|
||||||
|
BOOT="$iso"
|
||||||
|
REMOVE="N"
|
||||||
|
else
|
||||||
|
if [[ "$iso" != "$BOOT" ]]; then
|
||||||
|
if ! mv -f "$iso" "$BOOT"; then
|
||||||
|
error "Failed to move ISO file: $iso" && return 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
finishInstall "$STORAGE/$BASE" "Y" && return 0
|
finishInstall "$BOOT" "Y" && return 0
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
detectCustom() {
|
detectCustom() {
|
||||||
|
|
||||||
|
local file=""
|
||||||
|
local size base
|
||||||
|
|
||||||
CUSTOM=""
|
CUSTOM=""
|
||||||
local file size
|
ORIGINAL=""
|
||||||
|
|
||||||
if [[ "${VERSION,,}" != "http"* ]]; then
|
if [[ "${VERSION,,}" != "http"* ]]; then
|
||||||
file="${VERSION/\/storage\//}"
|
base="${VERSION/\/storage\//}"
|
||||||
[[ "$file" == "."* ]] && file="${file:1}"
|
[[ "$base" == "."* ]] && base="${file:1}"
|
||||||
[[ "$file" == *"/"* ]] && file=""
|
[[ "$base" == *"/"* ]] && base=""
|
||||||
[ -n "$file" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname "$file" -printf "%f\n" | head -n 1)
|
[ -n "$base" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname "$base" -printf "%f\n" | head -n 1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.iso -printf "%f\n" | head -n 1)
|
[ -z "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.iso -printf "%f\n" | head -n 1)
|
||||||
[ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.img -printf "%f\n" | head -n 1)
|
[ -z "$file" ] && file=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.img -printf "%f\n" | head -n 1)
|
||||||
[ -z "$CUSTOM" ] && return 0
|
[ -n "$file" ] && file="$STORAGE/$file"
|
||||||
|
|
||||||
size="$(stat -c%s "$STORAGE/$CUSTOM")"
|
base="/custom.iso"
|
||||||
|
[ -f "$base" ] && [ -s "$base" ] && file="$base"
|
||||||
|
|
||||||
if [ -z "$size" ] || [[ "$size" == "0" ]]; then
|
[ -z "$file" ] && return 0
|
||||||
CUSTOM=""
|
[ ! -f "$file" ] && return 0
|
||||||
return 0
|
[ ! -s "$file" ] && return 0
|
||||||
|
|
||||||
|
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
|
||||||
|
CUSTOM="$file"
|
||||||
|
rm -f "$base"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
file="windows.$size.iso"
|
|
||||||
[ -s "$STORAGE/$file" ] && CUSTOM="$file"
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,13 +205,15 @@ getESD() {
|
||||||
|
|
||||||
local dir="$1"
|
local dir="$1"
|
||||||
local version="$2"
|
local version="$2"
|
||||||
|
local editionName
|
||||||
local winCatalog size
|
local winCatalog size
|
||||||
|
|
||||||
case "${version,,}" in
|
if ! isESD "${version,,}"; then
|
||||||
"win11${PLATFORM,,}" ) winCatalog="https://go.microsoft.com/fwlink?linkid=2156292" ;;
|
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
|
||||||
"win10${PLATFORM,,}" ) winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361" ;;
|
fi
|
||||||
*) error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1 ;;
|
|
||||||
esac
|
winCatalog=$(getCatalog "$version" "url")
|
||||||
|
editionName=$(getCatalog "$version" "edition")
|
||||||
|
|
||||||
local msg="Downloading product information from Microsoft..."
|
local msg="Downloading product information from Microsoft..."
|
||||||
info "$msg" && html "$msg"
|
info "$msg" && html "$msg"
|
||||||
|
@ -227,7 +243,6 @@ getESD() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local esdLang="en-us"
|
local esdLang="en-us"
|
||||||
local editionName="Professional"
|
|
||||||
local edQuery='//File[Architecture="'${PLATFORM}'"][Edition="'${editionName}'"]'
|
local edQuery='//File[Architecture="'${PLATFORM}'"][Edition="'${editionName}'"]'
|
||||||
|
|
||||||
echo -e '<Catalog>' > "$dir/$fFile"
|
echo -e '<Catalog>' > "$dir/$fFile"
|
||||||
|
@ -256,47 +271,15 @@ getESD() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
doMido() {
|
|
||||||
|
|
||||||
local iso="$1"
|
|
||||||
local version="$2"
|
|
||||||
local desc="$3"
|
|
||||||
local rc
|
|
||||||
|
|
||||||
rm -f "$iso"
|
|
||||||
rm -f "$iso.PART"
|
|
||||||
|
|
||||||
local msg="Downloading $desc..."
|
|
||||||
info "$msg" && html "$msg"
|
|
||||||
/run/progress.sh "$iso.PART" "" "Downloading $desc ([P])..." &
|
|
||||||
|
|
||||||
cd "$TMP"
|
|
||||||
{ /run/mido.sh "${version,,}"; rc=$?; } || :
|
|
||||||
cd /run
|
|
||||||
|
|
||||||
fKill "progress.sh"
|
|
||||||
|
|
||||||
if (( rc == 0 )) && [ -f "$iso" ]; then
|
|
||||||
if [ "$(stat -c%s "$iso")" -gt 100000000 ]; then
|
|
||||||
html "Download finished successfully..." && return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -f "$iso"
|
|
||||||
rm -f "$iso.PART"
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
verifyFile() {
|
verifyFile() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local size="$2"
|
local size="$2"
|
||||||
local total="$3"
|
local total="$3"
|
||||||
local check="$4"
|
local check="$4"
|
||||||
|
|
||||||
if [ -n "$size" ] && [[ "$total" != "$size" ]]; then
|
if [ -n "$size" ] && [[ "$total" != "$size" ]] && [[ "$size" != "0" ]]; then
|
||||||
[[ "$size" != "0" ]] && warn "The download file has an unexpected size: $total"
|
warn "The downloaded file has an invalid size: $total bytes, while expected value was: $size bytes. Please report this at $SUPPORT/issues"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local hash=""
|
local hash=""
|
||||||
|
@ -316,10 +299,10 @@ verifyFile() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$hash" == "$check" ]]; then
|
if [[ "$hash" == "$check" ]]; then
|
||||||
info "Succesfully verified that the checksum was correct!" && return 0
|
info "Succesfully verified ISO!" && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
error "Invalid $algo checksum: $hash , but expected value is: $check ! Please report this at $SUPPORT/issues"
|
error "The downloaded file has an invalid $algo checksum: $hash , while expected value was: $check. Please report this at $SUPPORT/issues"
|
||||||
|
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
return 1
|
return 1
|
||||||
|
@ -380,10 +363,11 @@ downloadImage() {
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
local version="$2"
|
local version="$2"
|
||||||
local tried="n"
|
local tried="n"
|
||||||
local url sum size desc
|
local url sum size base desc
|
||||||
|
|
||||||
if [[ "${version,,}" == "http"* ]]; then
|
if [[ "${version,,}" == "http"* ]]; then
|
||||||
desc=$(fromFile "$BASE")
|
base=$(basename "$iso")
|
||||||
|
desc=$(fromFile "$base")
|
||||||
downloadFile "$iso" "$version" "" "" "$desc" && return 0
|
downloadFile "$iso" "$version" "" "" "$desc" && return 0
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -410,9 +394,10 @@ downloadImage() {
|
||||||
tried="y"
|
tried="y"
|
||||||
|
|
||||||
if getESD "$TMP/esd" "$version"; then
|
if getESD "$TMP/esd" "$version"; then
|
||||||
ISO="$TMP/$version.esd"
|
local prev="$ISO"
|
||||||
|
ISO="${ISO%.*}.esd"
|
||||||
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$desc" && return 0
|
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$desc" && return 0
|
||||||
ISO="$TMP/$BASE"
|
ISO="$prev"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -436,6 +421,17 @@ downloadImage() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeDownload() {
|
||||||
|
|
||||||
|
local iso="$1"
|
||||||
|
|
||||||
|
[ ! -f "$iso" ] && return 0
|
||||||
|
[ -n "$CUSTOM" ] && return 0
|
||||||
|
! rm -f "$iso" 2> /dev/null && warn "failed to remove $iso !"
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
extractESD() {
|
extractESD() {
|
||||||
|
|
||||||
local iso="$1"
|
local iso="$1"
|
||||||
|
@ -500,16 +496,15 @@ extractESD() {
|
||||||
info "$msg" && html "$msg"
|
info "$msg" && html "$msg"
|
||||||
|
|
||||||
local edition imageIndex imageEdition
|
local edition imageIndex imageEdition
|
||||||
|
edition=$(getCatalog "$version" "name")
|
||||||
|
|
||||||
case "${version,,}" in
|
if [ -z "$edition" ]; then
|
||||||
"win11${PLATFORM,,}" ) edition="11 pro" ;;
|
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
|
||||||
"win10${PLATFORM,,}" ) edition="10 pro" ;;
|
fi
|
||||||
*) error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
for (( imageIndex=4; imageIndex<=esdImageCount; imageIndex++ )); do
|
for (( imageIndex=4; imageIndex<=esdImageCount; imageIndex++ )); do
|
||||||
imageEdition=$(wimlib-imagex info "${iso}" ${imageIndex} | grep '^Description:' | sed 's/Description:[ \t]*//')
|
imageEdition=$(wimlib-imagex info "${iso}" ${imageIndex} | grep '^Description:' | sed 's/Description:[ \t]*//')
|
||||||
[[ "${imageEdition,,}" != *"$edition"* ]] && continue
|
[[ "${imageEdition,,}" != "${edition,,}" ]] && continue
|
||||||
wimlib-imagex export "${iso}" ${imageIndex} "${installWimFile}" --compress=LZMS --chunk-size 128K --quiet || {
|
wimlib-imagex export "${iso}" ${imageIndex} "${installWimFile}" --compress=LZMS --chunk-size 128K --quiet || {
|
||||||
retVal=$?
|
retVal=$?
|
||||||
error "Addition of ${imageIndex} to the $desc image failed" && return $retVal
|
error "Addition of ${imageIndex} to the $desc image failed" && return $retVal
|
||||||
|
@ -517,7 +512,7 @@ extractESD() {
|
||||||
return 0
|
return 0
|
||||||
done
|
done
|
||||||
|
|
||||||
error "Failed to find product in install.wim!" && return 1
|
error "Failed to find product '$edition' in install.wim!" && return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
extractImage() {
|
extractImage() {
|
||||||
|
@ -574,7 +569,10 @@ setXML() {
|
||||||
|
|
||||||
[[ "$MANUAL" == [Yy1]* ]] && return 0
|
[[ "$MANUAL" == [Yy1]* ]] && return 0
|
||||||
|
|
||||||
local file="$STORAGE/custom.xml"
|
local file="/custom.xml"
|
||||||
|
[ -f "$file" ] && [ -s "$file" ] && XML="$file" && return 0
|
||||||
|
|
||||||
|
file="$STORAGE/custom.xml"
|
||||||
[ -f "$file" ] && [ -s "$file" ] && XML="$file" && return 0
|
[ -f "$file" ] && [ -s "$file" ] && XML="$file" && return 0
|
||||||
|
|
||||||
file="/run/assets/custom.xml"
|
file="/run/assets/custom.xml"
|
||||||
|
@ -649,12 +647,8 @@ detectImage() {
|
||||||
|
|
||||||
XML=""
|
XML=""
|
||||||
|
|
||||||
if [ -n "$CUSTOM" ]; then
|
if [ -z "$DETECTED" ] && [[ "${version,,}" != "http"* ]]; then
|
||||||
DETECTED=""
|
[ -z "$CUSTOM" ] && DETECTED="$version"
|
||||||
else
|
|
||||||
if [ -z "$DETECTED" ] && [[ "${version,,}" != "http"* ]]; then
|
|
||||||
DETECTED="$version"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$DETECTED" ]; then
|
if [ -n "$DETECTED" ]; then
|
||||||
|
@ -711,7 +705,7 @@ detectImage() {
|
||||||
local fallback="/run/assets/${DETECTED%%-*}.xml"
|
local fallback="/run/assets/${DETECTED%%-*}.xml"
|
||||||
|
|
||||||
setXML "$fallback" && warn "${msg}." && return 0
|
setXML "$fallback" && warn "${msg}." && return 0
|
||||||
|
|
||||||
warn "${msg}, $FB."
|
warn "${msg}, $FB."
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -752,9 +746,8 @@ prepareImage() {
|
||||||
|
|
||||||
updateImage() {
|
updateImage() {
|
||||||
|
|
||||||
local iso="$1"
|
local dir="$1"
|
||||||
local dir="$2"
|
local asset="$2"
|
||||||
local asset="$3"
|
|
||||||
local path src loc xml index result
|
local path src loc xml index result
|
||||||
|
|
||||||
[ ! -s "$asset" ] || [ ! -f "$asset" ] && return 0
|
[ ! -s "$asset" ] || [ ! -f "$asset" ] && return 0
|
||||||
|
@ -801,10 +794,8 @@ copyOEM() {
|
||||||
local src
|
local src
|
||||||
|
|
||||||
[ ! -d "$folder" ] && folder="/OEM"
|
[ ! -d "$folder" ] && folder="/OEM"
|
||||||
|
[ ! -d "$folder" ] && folder="$STORAGE/oem"
|
||||||
[ ! -d "$folder" ] && folder="$STORAGE/OEM"
|
[ ! -d "$folder" ] && folder="$STORAGE/OEM"
|
||||||
[ ! -d "$folder" ] && folder="$STORAGE/OEM"
|
|
||||||
[ ! -d "$folder" ] && folder="$STORAGE/shared/oem"
|
|
||||||
[ ! -d "$folder" ] && folder="$STORAGE/shared/OEM"
|
|
||||||
[ ! -d "$folder" ] && return 0
|
[ ! -d "$folder" ] && return 0
|
||||||
|
|
||||||
local msg="Copying OEM folder to image..."
|
local msg="Copying OEM folder to image..."
|
||||||
|
@ -832,9 +823,14 @@ buildImage() {
|
||||||
local failed="N"
|
local failed="N"
|
||||||
local cat="BOOT.CAT"
|
local cat="BOOT.CAT"
|
||||||
local log="/run/shm/iso.log"
|
local log="/run/shm/iso.log"
|
||||||
local size size_gb space space_gb desc
|
local base size size_gb space space_gb desc
|
||||||
local out="$TMP/${BASE%.*}.tmp"
|
|
||||||
|
|
||||||
|
if [ -f "$BOOT" ]; then
|
||||||
|
error "File $BOOT does already exist?!" && return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
base=$(basename "$BOOT")
|
||||||
|
local out="$TMP/${base%.*}.tmp"
|
||||||
rm -f "$out"
|
rm -f "$out"
|
||||||
|
|
||||||
desc=$(printVersion "$DETECTED" "ISO")
|
desc=$(printVersion "$DETECTED" "ISO")
|
||||||
|
@ -890,11 +886,7 @@ buildImage() {
|
||||||
[ -s "$log" ] && error="$(<"$log")"
|
[ -s "$log" ] && error="$(<"$log")"
|
||||||
[[ "$error" != "$hide" ]] && echo "$error"
|
[[ "$error" != "$hide" ]] && echo "$error"
|
||||||
|
|
||||||
if [ -f "$STORAGE/$BASE" ]; then
|
mv "$out" "$BOOT"
|
||||||
error "File $STORAGE/$BASE does already exist?!" && return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mv "$out" "$STORAGE/$BASE"
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,6 +894,15 @@ bootWindows() {
|
||||||
|
|
||||||
rm -rf "$TMP"
|
rm -rf "$TMP"
|
||||||
|
|
||||||
|
if [ ! -f "$ISO" ] || [ ! -s "$ISO" ]; then
|
||||||
|
ISO="/custom.iso"
|
||||||
|
[ ! -f "$ISO" ] && ISO="${STORAGE}$ISO"
|
||||||
|
fi
|
||||||
|
|
||||||
|
BOOT="$ISO"
|
||||||
|
|
||||||
|
[[ "${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
|
||||||
BOOT_MODE=$(<"$STORAGE/windows.mode")
|
BOOT_MODE=$(<"$STORAGE/windows.mode")
|
||||||
if [ -s "$STORAGE/windows.old" ] && [ -f "$STORAGE/windows.old" ]; then
|
if [ -s "$STORAGE/windows.old" ] && [ -f "$STORAGE/windows.old" ]; then
|
||||||
|
@ -979,16 +980,13 @@ if ! prepareImage "$ISO" "$DIR"; then
|
||||||
exit 60
|
exit 60
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! updateImage "$ISO" "$DIR" "$XML"; then
|
if ! updateImage "$DIR" "$XML"; then
|
||||||
abortInstall "$ISO" && return 0
|
abortInstall "$ISO" && return 0
|
||||||
exit 60
|
exit 60
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! rm -f "$ISO" 2> /dev/null; then
|
if ! removeDownload "$ISO"; then
|
||||||
size="$(stat -c%s "$ISO")"
|
exit 64
|
||||||
BASE="windows.$size.iso"
|
|
||||||
ISO="$STORAGE/$BASE"
|
|
||||||
rm -f "$ISO"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! copyOEM "$DIR"; then
|
if ! copyOEM "$DIR"; then
|
||||||
|
@ -999,7 +997,7 @@ if ! buildImage "$DIR"; then
|
||||||
exit 65
|
exit 65
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! finishInstall "$STORAGE/$BASE" "N"; then
|
if ! finishInstall "$BOOT" "N"; then
|
||||||
exit 69
|
exit 69
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -71,11 +71,12 @@ finish() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$STORAGE/$BASE" ]; then
|
if [ ! -f "$STORAGE/windows.boot" ] && [ -f "$BOOT" ]; then
|
||||||
# Remove CD-ROM ISO after install
|
# Remove CD-ROM ISO after install
|
||||||
if ready; then
|
if ready; then
|
||||||
if rm -f "$STORAGE/$BASE" 2>/dev/null; then
|
touch "$STORAGE/windows.boot"
|
||||||
touch "$STORAGE/windows.boot"
|
if [[ "$REMOVE" != [Nn]* ]]; then
|
||||||
|
rm -f "$BOOT" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
16
src/samba.sh
16
src/samba.sh
|
@ -14,10 +14,14 @@ if [[ "$DHCP" == [Yy1]* ]]; then
|
||||||
interface="$VM_NET_DEV"
|
interface="$VM_NET_DEV"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
share="$STORAGE/shared"
|
share="/shared"
|
||||||
|
|
||||||
|
if [ ! -d "$share" ] && [ -d "$STORAGE/shared" ]; then
|
||||||
|
share="$STORAGE/shared"
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "$share"
|
mkdir -p "$share"
|
||||||
[ -z "$(ls -A "$share")" ] && chmod -R 777 "$share"
|
[ -z "$(ls -A "$share")" ] && chmod 777 "$share"
|
||||||
|
|
||||||
{ echo "[global]"
|
{ echo "[global]"
|
||||||
echo " server string = Dockur"
|
echo " server string = Dockur"
|
||||||
|
@ -53,16 +57,16 @@ mkdir -p "$share"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Using this folder you can share files with the host machine."
|
echo "Using this folder you can share files with the host machine."
|
||||||
echo ""
|
echo ""
|
||||||
echo "To change the storage location, include the following bind mount in your compose file:"
|
echo "To change its location, include the following bind mount in your compose file:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " volumes:"
|
echo " volumes:"
|
||||||
echo " - \"/home/user/example:/storage/shared\""
|
echo " - \"/home/user/example:/shared\""
|
||||||
echo ""
|
echo ""
|
||||||
echo "Or in your run command:"
|
echo "Or in your run command:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -v \"/home/user/example:/storage/shared\""
|
echo " -v \"/home/user/example:/shared\""
|
||||||
echo ""
|
echo ""
|
||||||
echo "Replace the example path /home/user/example with the desired storage folder."
|
echo "Replace the example path /home/user/example with the desired shared folder."
|
||||||
echo ""
|
echo ""
|
||||||
} | unix2dos > "$share/readme.txt"
|
} | unix2dos > "$share/readme.txt"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue