mirror of
https://github.com/dockur/windows.git
synced 2026-08-03 12:37:20 +01:00
fix: Error propagation during image preparation (#1884)
This commit is contained in:
+53
-49
@@ -1358,7 +1358,7 @@ addFolder() {
|
|||||||
cp -Lr "$folder/." "$dest" || return 1
|
cp -Lr "$folder/." "$dest" || return 1
|
||||||
|
|
||||||
local file
|
local file
|
||||||
file=$(find "$dest" -maxdepth 1 -type f -iname install.bat -print -quit)
|
file=$(find "$dest" -maxdepth 1 -type f -iname install.bat -print -quit) || return 1
|
||||||
|
|
||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
if ! unix2dos -q "$file"; then
|
if ! unix2dos -q "$file"; then
|
||||||
@@ -1398,8 +1398,8 @@ prepareInstall() {
|
|||||||
local msg="Adding drivers to image..."
|
local msg="Adding drivers to image..."
|
||||||
info "$msg" && html "$msg"
|
info "$msg" && html "$msg"
|
||||||
|
|
||||||
rm -rf "$drivers"
|
rm -rf "$drivers" || return 1
|
||||||
mkdir -p "$drivers"
|
mkdir -p "$drivers" || return 1
|
||||||
|
|
||||||
if ! bsdtar -xf /var/drivers.txz -C "$drivers"; then
|
if ! bsdtar -xf /var/drivers.txz -C "$drivers"; then
|
||||||
error "Failed to extract drivers!" && return 1
|
error "Failed to extract drivers!" && return 1
|
||||||
@@ -1425,19 +1425,19 @@ prepareInstall() {
|
|||||||
cp -L "$drivers/NetKVM/$driver/$arch/netkvm.inf" "$dir/\$OEM\$/\$1/Drivers/NetKVM" || return 1
|
cp -L "$drivers/NetKVM/$driver/$arch/netkvm.inf" "$dir/\$OEM\$/\$1/Drivers/NetKVM" || return 1
|
||||||
cp -L "$drivers/NetKVM/$driver/$arch/netkvm.sys" "$dir/\$OEM\$/\$1/Drivers/NetKVM" || return 1
|
cp -L "$drivers/NetKVM/$driver/$arch/netkvm.sys" "$dir/\$OEM\$/\$1/Drivers/NetKVM" || return 1
|
||||||
|
|
||||||
file=$(find "$target" -maxdepth 1 -type f -iname TXTSETUP.SIF -print -quit)
|
file=$(find "$target" -maxdepth 1 -type f -iname TXTSETUP.SIF -print -quit) || return 1
|
||||||
|
|
||||||
if [ -z "$file" ]; then
|
if [ -z "$file" ]; then
|
||||||
error "The file TXTSETUP.SIF could not be found!" && return 1
|
error "The file TXTSETUP.SIF could not be found!" && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i '/^\[SCSI.Load\]/s/$/\nviostor=viostor.sys,4/' "$file"
|
sed -i '/^\[SCSI.Load\]/s/$/\nviostor=viostor.sys,4/' "$file" || return 1
|
||||||
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\nviostor.sys=1,,,,,,4_,4,1,,,1,4/' "$file"
|
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\nviostor.sys=1,,,,,,4_,4,1,,,1,4/' "$file" || return 1
|
||||||
sed -i '/^\[SCSI\]/s/$/\nviostor=\"Red Hat VirtIO SCSI Disk Device\"/' "$file"
|
sed -i '/^\[SCSI\]/s/$/\nviostor=\"Red Hat VirtIO SCSI Disk Device\"/' "$file" || return 1
|
||||||
sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00000000=\"viostor\"/' "$file"
|
sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00000000=\"viostor\"/' "$file" || return 1
|
||||||
sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00020000=\"viostor\"/' "$file"
|
sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00020000=\"viostor\"/' "$file" || return 1
|
||||||
sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00021AF4=\"viostor\"/' "$file"
|
sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00021AF4=\"viostor\"/' "$file" || return 1
|
||||||
sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00000000=\"viostor\"/' "$file"
|
sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_1AF4\&DEV_1001\&SUBSYS_00000000=\"viostor\"/' "$file" || return 1
|
||||||
|
|
||||||
if [ ! -d "$drivers/sata/xp/$arch" ]; then
|
if [ ! -d "$drivers/sata/xp/$arch" ]; then
|
||||||
error "Failed to locate required SATA drivers!" && return 1
|
error "Failed to locate required SATA drivers!" && return 1
|
||||||
@@ -1447,32 +1447,32 @@ prepareInstall() {
|
|||||||
cp -Lr "$drivers/sata/xp/$arch/." "$dir/\$OEM\$/\$1/Drivers/sata" || return 1
|
cp -Lr "$drivers/sata/xp/$arch/." "$dir/\$OEM\$/\$1/Drivers/sata" || return 1
|
||||||
cp -Lr "$drivers/sata/xp/$arch/." "$target" || return 1
|
cp -Lr "$drivers/sata/xp/$arch/." "$target" || return 1
|
||||||
|
|
||||||
sed -i '/^\[SCSI.Load\]/s/$/\niaStor=iaStor.sys,4/' "$file"
|
sed -i '/^\[SCSI.Load\]/s/$/\niaStor=iaStor.sys,4/' "$file" || return 1
|
||||||
sed -i '/^\[FileFlags\]/s/$/\niaStor.sys = 16/' "$file"
|
sed -i '/^\[FileFlags\]/s/$/\niaStor.sys = 16/' "$file" || return 1
|
||||||
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.cat = 1,,,,,,,1,0,0/' "$file"
|
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.cat = 1,,,,,,,1,0,0/' "$file" || return 1
|
||||||
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.inf = 1,,,,,,,1,0,0/' "$file"
|
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.inf = 1,,,,,,,1,0,0/' "$file" || return 1
|
||||||
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.sys = 1,,,,,,4_,4,1,,,1,4/' "$file"
|
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.sys = 1,,,,,,4_,4,1,,,1,4/' "$file" || return 1
|
||||||
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.sys = 1,,,,,,,1,0,0/' "$file"
|
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaStor.sys = 1,,,,,,,1,0,0/' "$file" || return 1
|
||||||
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaahci.cat = 1,,,,,,,1,0,0/' "$file"
|
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaahci.cat = 1,,,,,,,1,0,0/' "$file" || return 1
|
||||||
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaAHCI.inf = 1,,,,,,,1,0,0/' "$file"
|
sed -i '/^\[SourceDisksFiles.'"$arch"'\]/s/$/\niaAHCI.inf = 1,,,,,,,1,0,0/' "$file" || return 1
|
||||||
sed -i '/^\[SCSI\]/s/$/\niaStor=\"Intel\(R\) SATA RAID\/AHCI Controller\"/' "$file"
|
sed -i '/^\[SCSI\]/s/$/\niaStor=\"Intel\(R\) SATA RAID\/AHCI Controller\"/' "$file" || return 1
|
||||||
sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_8086\&DEV_2922\&CC_0106=\"iaStor\"/' "$file"
|
sed -i '/^\[HardwareIdsDatabase\]/s/$/\nPCI\\VEN_8086\&DEV_2922\&CC_0106=\"iaStor\"/' "$file" || return 1
|
||||||
|
|
||||||
rm -rf "$drivers"
|
rm -rf "$drivers" || return 1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local key setup
|
local key setup
|
||||||
setup=$(find "$target" -maxdepth 1 -type f -iname setupp.ini -print -quit)
|
setup=$(find "$target" -maxdepth 1 -type f -iname setupp.ini -print -quit) || return 1
|
||||||
|
|
||||||
if [ -n "$setup" ] && [ -z "$KEY" ]; then
|
if [ -n "$setup" ] && [ -z "$KEY" ]; then
|
||||||
|
|
||||||
pid=$(<"$setup")
|
pid=$(<"$setup") || return 1
|
||||||
pid="${pid%$'\r'}"
|
pid="${pid%$'\r'}"
|
||||||
|
|
||||||
if [[ "$driver" == "2k" ]]; then
|
if [[ "$driver" == "2k" ]]; then
|
||||||
|
|
||||||
echo "${pid:0:$((${#pid})) - 3}270" > "$setup"
|
echo "${pid:0:$((${#pid})) - 3}270" > "$setup" || return 1
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@@ -1482,21 +1482,21 @@ prepareInstall() {
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
file=$(find "$target" -maxdepth 1 -type f -iname PID.INF -print -quit)
|
file=$(find "$target" -maxdepth 1 -type f -iname PID.INF -print -quit) || return 1
|
||||||
|
|
||||||
if [ -n "$file" ]; then
|
if [ -n "$file" ]; then
|
||||||
|
|
||||||
if [[ "$driver" == "2k3" ]]; then
|
if [[ "$driver" == "2k3" ]]; then
|
||||||
|
|
||||||
key=$(grep -i -A 2 "StagingKey" "$file" | tail -n 2 | head -n 1)
|
key=$(grep -i -A 2 "StagingKey" "$file" | tail -n 2 | head -n 1) || key=""
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
key="${pid:$((${#pid})) - 8:5}"
|
key="${pid:$((${#pid})) - 8:5}"
|
||||||
if [[ "${pid^^}" == *"OEM" ]]; then
|
if [[ "${pid^^}" == *"OEM" ]]; then
|
||||||
key=$(grep -i -A 2 "$key" "$file" | tail -n 2 | head -n 1)
|
key=$(grep -i -A 2 "$key" "$file" | tail -n 2 | head -n 1) || key=""
|
||||||
else
|
else
|
||||||
key=$(grep -i -m 1 -A 2 "$key" "$file" | tail -n 2 | head -n 1)
|
key=$(grep -i -m 1 -A 2 "$key" "$file" | tail -n 2 | head -n 1) || key=""
|
||||||
fi
|
fi
|
||||||
key="${key#*= }"
|
key="${key#*= }"
|
||||||
|
|
||||||
@@ -1534,7 +1534,7 @@ prepareInstall() {
|
|||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo "${pid:0:$((${#pid})) - 3}000" > "$setup"
|
echo "${pid:0:$((${#pid})) - 3}000" > "$setup" || return 1
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1545,7 +1545,7 @@ prepareInstall() {
|
|||||||
|
|
||||||
[ -n "$KEY" ] && KEY="ProductID=$KEY"
|
[ -n "$KEY" ] && KEY="ProductID=$KEY"
|
||||||
|
|
||||||
mkdir -p "$dir/\$OEM\$"
|
mkdir -p "$dir/\$OEM\$" || return 1
|
||||||
|
|
||||||
if ! addFolder "$dir"; then
|
if ! addFolder "$dir"; then
|
||||||
error "Failed to add OEM folder to image!" && return 1
|
error "Failed to add OEM folder to image!" && return 1
|
||||||
@@ -1558,19 +1558,23 @@ prepareInstall() {
|
|||||||
[ -z "$WIDTH" ] && WIDTH="1280"
|
[ -z "$WIDTH" ] && WIDTH="1280"
|
||||||
[ -z "$HEIGHT" ] && HEIGHT="720"
|
[ -z "$HEIGHT" ] && HEIGHT="720"
|
||||||
|
|
||||||
XHEX=$(printf '%08x\n' "$WIDTH")
|
XHEX=$(printf '%08x\n' "$WIDTH") || return 1
|
||||||
YHEX=$(printf '%08x\n' "$HEIGHT")
|
YHEX=$(printf '%08x\n' "$HEIGHT") || return 1
|
||||||
|
|
||||||
local username=""
|
local username=""
|
||||||
local password=""
|
local password=""
|
||||||
|
|
||||||
[ -n "$USERNAME" ] && username=$(echo "$USERNAME" | sed 's/[^[:alnum:]@!._-]//g')
|
if [ -n "$USERNAME" ]; then
|
||||||
|
username=$(echo "$USERNAME" | sed 's/[^[:alnum:]@!._-]//g') || return 1
|
||||||
|
fi
|
||||||
[ -z "$username" ] && username="Docker"
|
[ -z "$username" ] && username="Docker"
|
||||||
|
|
||||||
[ -n "$PASSWORD" ] && password=$(echo "$PASSWORD" | sed 's/"//g')
|
if [ -n "$PASSWORD" ]; then
|
||||||
|
password=$(echo "$PASSWORD" | sed 's/"//g') || return 1
|
||||||
|
fi
|
||||||
[ -z "$password" ] && password="admin"
|
[ -z "$password" ] && password="admin"
|
||||||
|
|
||||||
find "$target" -maxdepth 1 -type f -iname winnt.sif -exec rm {} \;
|
find "$target" -maxdepth 1 -type f -iname winnt.sif -exec rm {} \; || return 1
|
||||||
|
|
||||||
{ echo "[Data]"
|
{ echo "[Data]"
|
||||||
echo " AutoPartition=1"
|
echo " AutoPartition=1"
|
||||||
@@ -1630,7 +1634,7 @@ prepareInstall() {
|
|||||||
echo "[TerminalServices]"
|
echo "[TerminalServices]"
|
||||||
echo " AllowConnections=1"
|
echo " AllowConnections=1"
|
||||||
echo ""
|
echo ""
|
||||||
} | unix2dos > "$target/WINNT.SIF"
|
} | unix2dos > "$target/WINNT.SIF" || return 1
|
||||||
|
|
||||||
if [[ "$driver" == "2k3" ]]; then
|
if [[ "$driver" == "2k3" ]]; then
|
||||||
{ echo "[Components]"
|
{ echo "[Components]"
|
||||||
@@ -1640,7 +1644,7 @@ prepareInstall() {
|
|||||||
echo " AutoMode=PerServer"
|
echo " AutoMode=PerServer"
|
||||||
echo " AutoUsers=5"
|
echo " AutoUsers=5"
|
||||||
echo ""
|
echo ""
|
||||||
} | unix2dos >> "$target/WINNT.SIF"
|
} | unix2dos >> "$target/WINNT.SIF" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{ echo "Windows Registry Editor Version 5.00"
|
{ echo "Windows Registry Editor Version 5.00"
|
||||||
@@ -1691,13 +1695,13 @@ prepareInstall() {
|
|||||||
echo "\"ScreenSaverOff\"=\"reg add \\\"HKCU\\\\Control Panel\\\\Desktop\\\" /f /v \\\"ScreenSaveActive\\\" /t REG_SZ /d \\\"0\\\"\""
|
echo "\"ScreenSaverOff\"=\"reg add \\\"HKCU\\\\Control Panel\\\\Desktop\\\" /f /v \\\"ScreenSaveActive\\\" /t REG_SZ /d \\\"0\\\"\""
|
||||||
echo "$oem"
|
echo "$oem"
|
||||||
echo ""
|
echo ""
|
||||||
} | unix2dos > "$dir/\$OEM\$/install.reg"
|
} | unix2dos > "$dir/\$OEM\$/install.reg" || return 1
|
||||||
|
|
||||||
if [[ "$driver" == "2k" ]]; then
|
if [[ "$driver" == "2k" ]]; then
|
||||||
{ echo "[HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Runonce]"
|
{ echo "[HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Runonce]"
|
||||||
echo "\"^SetupICWDesktop\"=-"
|
echo "\"^SetupICWDesktop\"=-"
|
||||||
echo ""
|
echo ""
|
||||||
} | unix2dos >> "$dir/\$OEM\$/install.reg"
|
} | unix2dos >> "$dir/\$OEM\$/install.reg" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$driver" == "2k3" ]]; then
|
if [[ "$driver" == "2k3" ]]; then
|
||||||
@@ -1707,7 +1711,7 @@ prepareInstall() {
|
|||||||
echo "[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ServerOOBE\SecurityOOBE]"
|
echo "[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ServerOOBE\SecurityOOBE]"
|
||||||
echo "\"DontLaunchSecurityOOBE\"=dword:00000000"
|
echo "\"DontLaunchSecurityOOBE\"=dword:00000000"
|
||||||
echo ""
|
echo ""
|
||||||
} | unix2dos >> "$dir/\$OEM\$/install.reg"
|
} | unix2dos >> "$dir/\$OEM\$/install.reg" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{ echo "Set WshShell = WScript.CreateObject(\"WScript.Shell\")"
|
{ echo "Set WshShell = WScript.CreateObject(\"WScript.Shell\")"
|
||||||
@@ -1759,13 +1763,13 @@ prepareInstall() {
|
|||||||
echo "End With"
|
echo "End With"
|
||||||
echo "Set oLink = Nothing"
|
echo "Set oLink = Nothing"
|
||||||
echo ""
|
echo ""
|
||||||
} | unix2dos > "$dir/\$OEM\$/install.vbs"
|
} | unix2dos > "$dir/\$OEM\$/install.vbs" || return 1
|
||||||
|
|
||||||
{ echo "[COMMANDS]"
|
{ echo "[COMMANDS]"
|
||||||
echo "\"REGEDIT /s install.reg\""
|
echo "\"REGEDIT /s install.reg\""
|
||||||
echo "\"Wscript install.vbs\""
|
echo "\"Wscript install.vbs\""
|
||||||
echo ""
|
echo ""
|
||||||
} | unix2dos > "$dir/\$OEM\$/cmdlines.txt"
|
} | unix2dos > "$dir/\$OEM\$/cmdlines.txt" || return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -1782,32 +1786,32 @@ prepareLegacy() {
|
|||||||
ETFS="boot.img"
|
ETFS="boot.img"
|
||||||
|
|
||||||
[ -s "$dir/$ETFS" ] && return 0
|
[ -s "$dir/$ETFS" ] && return 0
|
||||||
rm -f "$dir/$ETFS"
|
rm -f "$dir/$ETFS" || return 1
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp" || return 1
|
||||||
|
|
||||||
if ! LC_ALL=C xorriso \
|
if ! LC_ALL=C xorriso \
|
||||||
-no_rc \
|
-no_rc \
|
||||||
-osirrox on \
|
-osirrox on \
|
||||||
-indev "$iso" \
|
-indev "$iso" \
|
||||||
-extract_boot_images "$tmp" >/dev/null 2>&1; then
|
-extract_boot_images "$tmp" >/dev/null 2>&1; then
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp" || true
|
||||||
error "Failed to extract boot image from $desc ISO!"
|
error "Failed to extract boot image from $desc ISO!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -s "$image" ]; then
|
if [ ! -s "$image" ]; then
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp" || true
|
||||||
error "Failed to locate BIOS boot image in $desc ISO!"
|
error "Failed to locate BIOS boot image in $desc ISO!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! mv -f "$image" "$dir/$ETFS"; then
|
if ! mv -f "$image" "$dir/$ETFS"; then
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp" || true
|
||||||
error "Failed to save boot image from $desc ISO!"
|
error "Failed to save boot image from $desc ISO!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp" || return 1
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+33
-33
@@ -902,62 +902,62 @@ updateXML() {
|
|||||||
[ -z "$HEIGHT" ] && HEIGHT="720"
|
[ -z "$HEIGHT" ] && HEIGHT="720"
|
||||||
[ -z "$WIDTH" ] && WIDTH="1280"
|
[ -z "$WIDTH" ] && WIDTH="1280"
|
||||||
|
|
||||||
sed -i "s/>Windows for Docker</>$APP for $ENGINE</g" "$asset"
|
sed -i "s/>Windows for Docker</>$APP for $ENGINE</g" "$asset" || return 1
|
||||||
sed -i "s/<VerticalResolution>1080<\/VerticalResolution>/<VerticalResolution>$HEIGHT<\/VerticalResolution>/g" "$asset"
|
sed -i "s/<VerticalResolution>1080<\/VerticalResolution>/<VerticalResolution>$HEIGHT<\/VerticalResolution>/g" "$asset" || return 1
|
||||||
sed -i "s/<HorizontalResolution>1920<\/HorizontalResolution>/<HorizontalResolution>$WIDTH<\/HorizontalResolution>/g" "$asset"
|
sed -i "s/<HorizontalResolution>1920<\/HorizontalResolution>/<HorizontalResolution>$WIDTH<\/HorizontalResolution>/g" "$asset" || return 1
|
||||||
|
|
||||||
culture=$(getLanguage "$language" "culture")
|
culture=$(getLanguage "$language" "culture") || return 1
|
||||||
|
|
||||||
if [ -n "$culture" ] && [[ "${culture,,}" != "en-us" ]]; then
|
if [ -n "$culture" ] && [[ "${culture,,}" != "en-us" ]]; then
|
||||||
sed -i "s/<UILanguage>en-US<\/UILanguage>/<UILanguage>$culture<\/UILanguage>/g" "$asset"
|
sed -i "s/<UILanguage>en-US<\/UILanguage>/<UILanguage>$culture<\/UILanguage>/g" "$asset" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
region="$REGION"
|
region="$REGION"
|
||||||
[ -z "$region" ] && region="$culture"
|
[ -z "$region" ] && region="$culture"
|
||||||
|
|
||||||
if [ -n "$region" ] && [[ "${region,,}" != "en-us" ]]; then
|
if [ -n "$region" ] && [[ "${region,,}" != "en-us" ]]; then
|
||||||
sed -i "s/<UserLocale>en-US<\/UserLocale>/<UserLocale>$region<\/UserLocale>/g" "$asset"
|
sed -i "s/<UserLocale>en-US<\/UserLocale>/<UserLocale>$region<\/UserLocale>/g" "$asset" || return 1
|
||||||
sed -i "s/<SystemLocale>en-US<\/SystemLocale>/<SystemLocale>$region<\/SystemLocale>/g" "$asset"
|
sed -i "s/<SystemLocale>en-US<\/SystemLocale>/<SystemLocale>$region<\/SystemLocale>/g" "$asset" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
keyboard="$KEYBOARD"
|
keyboard="$KEYBOARD"
|
||||||
[ -z "$keyboard" ] && keyboard="$culture"
|
[ -z "$keyboard" ] && keyboard="$culture"
|
||||||
|
|
||||||
if [ -n "$keyboard" ] && [[ "${keyboard,,}" != "en-us" ]]; then
|
if [ -n "$keyboard" ] && [[ "${keyboard,,}" != "en-us" ]]; then
|
||||||
sed -i "s/<InputLocale>en-US<\/InputLocale>/<InputLocale>$keyboard<\/InputLocale>/g" "$asset"
|
sed -i "s/<InputLocale>en-US<\/InputLocale>/<InputLocale>$keyboard<\/InputLocale>/g" "$asset" || return 1
|
||||||
sed -i "s/<InputLocale>0409:00000409<\/InputLocale>/<InputLocale>$keyboard<\/InputLocale>/g" "$asset"
|
sed -i "s/<InputLocale>0409:00000409<\/InputLocale>/<InputLocale>$keyboard<\/InputLocale>/g" "$asset" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
user=$(echo "$USERNAME" | sed 's/[^[:alnum:]@!._-]//g')
|
user=$(echo "$USERNAME" | sed 's/[^[:alnum:]@!._-]//g') || return 1
|
||||||
|
|
||||||
if [ -n "$user" ]; then
|
if [ -n "$user" ]; then
|
||||||
sed -i "s/-name \"Docker\"/-name \"$user\"/g" "$asset"
|
sed -i "s/-name \"Docker\"/-name \"$user\"/g" "$asset" || return 1
|
||||||
sed -i "s/<Name>Docker<\/Name>/<Name>$user<\/Name>/g" "$asset"
|
sed -i "s/<Name>Docker<\/Name>/<Name>$user<\/Name>/g" "$asset" || return 1
|
||||||
sed -i "s/where name=\"Docker\"/where name=\"$user\"/g" "$asset"
|
sed -i "s/where name=\"Docker\"/where name=\"$user\"/g" "$asset" || return 1
|
||||||
sed -i "s/<FullName>Docker<\/FullName>/<FullName>$user<\/FullName>/g" "$asset"
|
sed -i "s/<FullName>Docker<\/FullName>/<FullName>$user<\/FullName>/g" "$asset" || return 1
|
||||||
sed -i "s/<Username>Docker<\/Username>/<Username>$user<\/Username>/g" "$asset"
|
sed -i "s/<Username>Docker<\/Username>/<Username>$user<\/Username>/g" "$asset" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "$PASSWORD" ] && pass="$PASSWORD" || pass="admin"
|
[ -n "$PASSWORD" ] && pass="$PASSWORD" || pass="admin"
|
||||||
|
|
||||||
pw=$(printf '%s' "${pass}Password" | iconv -f utf-8 -t utf-16le | base64 -w 0)
|
pw=$(printf '%s' "${pass}Password" | iconv -f utf-8 -t utf-16le | base64 -w 0) || return 1
|
||||||
admin=$(printf '%s' "${pass}AdministratorPassword" | iconv -f utf-8 -t utf-16le | base64 -w 0)
|
admin=$(printf '%s' "${pass}AdministratorPassword" | iconv -f utf-8 -t utf-16le | base64 -w 0) || return 1
|
||||||
|
|
||||||
sed -i "s|<Value>password<\/Value>|<Value>$admin<\/Value>|g" "$asset"
|
sed -i "s|<Value>password<\/Value>|<Value>$admin<\/Value>|g" "$asset" || return 1
|
||||||
sed -i "s|<PlainText>true<\/PlainText>|<PlainText>false<\/PlainText>|g" "$asset"
|
sed -i "s|<PlainText>true<\/PlainText>|<PlainText>false<\/PlainText>|g" "$asset" || return 1
|
||||||
sed -i -z "s|<Password>...........<Value \/>|<Password>\n <Value>$pw<\/Value>|g" "$asset"
|
sed -i -z "s|<Password>...........<Value \/>|<Password>\n <Value>$pw<\/Value>|g" "$asset" || return 1
|
||||||
sed -i -z "s|<Password>...............<Value \/>|<Password>\n <Value>$pw<\/Value>|g" "$asset"
|
sed -i -z "s|<Password>...............<Value \/>|<Password>\n <Value>$pw<\/Value>|g" "$asset" || return 1
|
||||||
sed -i -z "s|<AdministratorPassword>...........<Value \/>|<AdministratorPassword>\n <Value>$admin<\/Value>|g" "$asset"
|
sed -i -z "s|<AdministratorPassword>...........<Value \/>|<AdministratorPassword>\n <Value>$admin<\/Value>|g" "$asset" || return 1
|
||||||
sed -i -z "s|<AdministratorPassword>...............<Value \/>|<AdministratorPassword>\n <Value>$admin<\/Value>|g" "$asset"
|
sed -i -z "s|<AdministratorPassword>...............<Value \/>|<AdministratorPassword>\n <Value>$admin<\/Value>|g" "$asset" || return 1
|
||||||
|
|
||||||
if [ -n "$EDITION" ]; then
|
if [ -n "$EDITION" ]; then
|
||||||
[[ "${EDITION^^}" == "CORE" ]] && EDITION="STANDARDCORE"
|
[[ "${EDITION^^}" == "CORE" ]] && EDITION="STANDARDCORE"
|
||||||
sed -i "s/SERVERSTANDARD<\/Value>/SERVER${EDITION^^}<\/Value>/g" "$asset"
|
sed -i "s/SERVERSTANDARD<\/Value>/SERVER${EDITION^^}<\/Value>/g" "$asset" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$KEY" ]; then
|
if [ -n "$KEY" ]; then
|
||||||
sed -i '/<ProductKey>/,/<\/ProductKey>/d' "$asset"
|
sed -i '/<ProductKey>/,/<\/ProductKey>/d' "$asset" || return 1
|
||||||
sed -i "s/<\/UserData>/ <ProductKey>\n <Key>${KEY}<\/Key>\n <WillShowUI>OnError<\/WillShowUI>\n <\/ProductKey>\n <\/UserData>/g" "$asset"
|
sed -i "s/<\/UserData>/ <ProductKey>\n <Key>${KEY}<\/Key>\n <WillShowUI>OnError<\/WillShowUI>\n <\/ProductKey>\n <\/UserData>/g" "$asset" || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -1095,17 +1095,17 @@ updateImage() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp" || return 1
|
||||||
mkdir -p "$tmp"
|
mkdir -p "$tmp" || return 1
|
||||||
|
|
||||||
src=$(find "$dir" -maxdepth 1 -type d -iname sources -print -quit)
|
src=$(find "$dir" -maxdepth 1 -type d -iname sources -print -quit) || return 1
|
||||||
|
|
||||||
if [ ! -d "$src" ]; then
|
if [ ! -d "$src" ]; then
|
||||||
error "failed to locate 'sources' folder in ISO image, $FB"
|
error "failed to locate 'sources' folder in ISO image, $FB"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wim=$(find "$src" -maxdepth 1 -type f \( -iname boot.wim -or -iname boot.esd \) -print -quit)
|
wim=$(find "$src" -maxdepth 1 -type f \( -iname boot.wim -or -iname boot.esd \) -print -quit) || return 1
|
||||||
|
|
||||||
if [ ! -f "$wim" ]; then
|
if [ ! -f "$wim" ]; then
|
||||||
error "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB"
|
error "failed to locate 'boot.wim' or 'boot.esd' in ISO image, $FB"
|
||||||
@@ -1144,7 +1144,7 @@ updateImage() {
|
|||||||
|
|
||||||
if ! enabled "$MANUAL"; then
|
if ! enabled "$MANUAL"; then
|
||||||
|
|
||||||
name=$(basename "$asset")
|
name=$(basename "$asset") || return 1
|
||||||
local answer="$tmp/$name"
|
local answer="$tmp/$name"
|
||||||
|
|
||||||
info "Adding $name for automatic installation..."
|
info "Adding $name for automatic installation..."
|
||||||
@@ -1182,7 +1182,7 @@ updateImage() {
|
|||||||
|
|
||||||
name="$xml"
|
name="$xml"
|
||||||
enabled "$MANUAL" && name="$bak"
|
enabled "$MANUAL" && name="$bak"
|
||||||
path=$(find "$dir" -maxdepth 1 -type f -iname "$name" -print -quit)
|
path=$(find "$dir" -maxdepth 1 -type f -iname "$name" -print -quit) || return 1
|
||||||
|
|
||||||
if [ -f "$path" ]; then
|
if [ -f "$path" ]; then
|
||||||
if ! enabled "$MANUAL"; then
|
if ! enabled "$MANUAL"; then
|
||||||
@@ -1198,7 +1198,7 @@ updateImage() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp" || return 1
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user