mirror of
https://github.com/dockur/windows.git
synced 2026-08-03 12:37:20 +01:00
feat: Assign HOST as the Windows computer name (#1897)
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@ An empty default means the variable is unset and its value is determined automat
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `NETWORK` | | Network mode, such as `nat`, `user`, or `N` to disable networking. |
|
| `NETWORK` | | Network mode, such as `nat`, `user`, or `N` to disable networking. |
|
||||||
| `DHCP` | `N` | Enables macvtap networking so Windows receives an address from the external LAN through DHCP. |
|
| `DHCP` | `N` | Enables macvtap networking so Windows receives an address from the external LAN through DHCP. |
|
||||||
| `HOST` | `Windows` | Hostname assigned to Windows. |
|
| `HOST` | `Windows` | Computer name assigned to Windows and advertised on the network. |
|
||||||
| `IP` | | Overrides the automatically selected guest IPv4 address. |
|
| `IP` | | Overrides the automatically selected guest IPv4 address. |
|
||||||
| `MAC` | | Guest network adapter MAC address. |
|
| `MAC` | | Guest network adapter MAC address. |
|
||||||
| `ADAPTER` | `virtio-net-pci` | QEMU network adapter model. |
|
| `ADAPTER` | `virtio-net-pci` | QEMU network adapter model. |
|
||||||
|
|||||||
+33
-2
@@ -2,6 +2,7 @@
|
|||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
: "${KEY:=""}"
|
: "${KEY:=""}"
|
||||||
|
: "${HOST:=""}"
|
||||||
: "${WIDTH:=""}"
|
: "${WIDTH:=""}"
|
||||||
: "${HEIGHT:=""}"
|
: "${HEIGHT:=""}"
|
||||||
: "${VERIFY:=""}"
|
: "${VERIFY:=""}"
|
||||||
@@ -20,6 +21,7 @@ set -Eeuo pipefail
|
|||||||
|
|
||||||
# Sanitize variables
|
# Sanitize variables
|
||||||
KEY=$(strip "$KEY")
|
KEY=$(strip "$KEY")
|
||||||
|
HOST=$(strip "$HOST")
|
||||||
WIDTH=$(strip "$WIDTH")
|
WIDTH=$(strip "$WIDTH")
|
||||||
HEIGHT=$(strip "$HEIGHT")
|
HEIGHT=$(strip "$HEIGHT")
|
||||||
DOMAIN=$(strip "$DOMAIN")
|
DOMAIN=$(strip "$DOMAIN")
|
||||||
@@ -1380,6 +1382,33 @@ validateProductKey() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateComputerName() {
|
||||||
|
|
||||||
|
local value="$1"
|
||||||
|
|
||||||
|
if [ -z "$value" ]; then
|
||||||
|
value="$APP"
|
||||||
|
HOST="$value"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${#value}" -gt 15 ]; then
|
||||||
|
error "The HOST variable cannot contain more than 15 characters!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "$value" =~ ^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?$ ]]; then
|
||||||
|
error "The HOST variable may only contain letters, digits, and hyphens, and cannot start or end with a hyphen!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$value" =~ ^[0-9]+$ ]]; then
|
||||||
|
error "The HOST variable cannot contain only digits!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
validateLegacyText() {
|
validateLegacyText() {
|
||||||
|
|
||||||
local name="$1"
|
local name="$1"
|
||||||
@@ -1719,6 +1748,7 @@ prepareInstall() {
|
|||||||
|
|
||||||
validateResolution "WIDTH" "$WIDTH" 320 || return 1
|
validateResolution "WIDTH" "$WIDTH" 320 || return 1
|
||||||
validateResolution "HEIGHT" "$HEIGHT" 200 || return 1
|
validateResolution "HEIGHT" "$HEIGHT" 200 || return 1
|
||||||
|
validateComputerName "$HOST" || return 1
|
||||||
validateLegacyText "APP" "$APP" "$desc" || return 1
|
validateLegacyText "APP" "$APP" "$desc" || return 1
|
||||||
validateLegacyText "ENGINE" "$ENGINE" "$desc" || return 1
|
validateLegacyText "ENGINE" "$ENGINE" "$desc" || return 1
|
||||||
|
|
||||||
@@ -1727,12 +1757,13 @@ prepareInstall() {
|
|||||||
|
|
||||||
local username="${USERNAME:-Docker}"
|
local username="${USERNAME:-Docker}"
|
||||||
local password="${PASSWORD:-admin}"
|
local password="${PASSWORD:-admin}"
|
||||||
local sifUsername sifPassword sifOrganization
|
local sifHost sifUsername sifPassword sifOrganization
|
||||||
local regUsername regPassword
|
local regUsername regPassword
|
||||||
|
|
||||||
validateLegacyUsername "$username" "$desc" || return 1
|
validateLegacyUsername "$username" "$desc" || return 1
|
||||||
validateLegacyPassword "$password" "$desc" || return 1
|
validateLegacyPassword "$password" "$desc" || return 1
|
||||||
|
|
||||||
|
sifHost=$(escapeSIFValue "$HOST") || return 1
|
||||||
sifUsername=$(escapeSIFValue "$username") || return 1
|
sifUsername=$(escapeSIFValue "$username") || return 1
|
||||||
sifPassword=$(escapeSIFValue "$password") || return 1
|
sifPassword=$(escapeSIFValue "$password") || return 1
|
||||||
sifOrganization=$(escapeSIFValue "$APP for $ENGINE") || return 1
|
sifOrganization=$(escapeSIFValue "$APP for $ENGINE") || return 1
|
||||||
@@ -1774,7 +1805,7 @@ prepareInstall() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "[UserData]"
|
echo "[UserData]"
|
||||||
echo " FullName=\"$sifUsername\""
|
echo " FullName=\"$sifUsername\""
|
||||||
echo " ComputerName=\"*\""
|
echo " ComputerName=\"$sifHost\""
|
||||||
echo " OrgName=\"$sifOrganization\""
|
echo " OrgName=\"$sifOrganization\""
|
||||||
echo " $product"
|
echo " $product"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
+4
-1
@@ -1027,19 +1027,22 @@ updateXML() {
|
|||||||
local language="$2"
|
local language="$2"
|
||||||
local app value culture region keyboard edition key
|
local app value culture region keyboard edition key
|
||||||
local user raw_user user_xml auth_user safe_user
|
local user raw_user user_xml auth_user safe_user
|
||||||
local admin pass pw domain qualifier
|
local admin pass pw domain qualifier host
|
||||||
|
|
||||||
[ -z "$WIDTH" ] && WIDTH="1280"
|
[ -z "$WIDTH" ] && WIDTH="1280"
|
||||||
[ -z "$HEIGHT" ] && HEIGHT="720"
|
[ -z "$HEIGHT" ] && HEIGHT="720"
|
||||||
|
|
||||||
validateResolution "WIDTH" "$WIDTH" 320 || return 1
|
validateResolution "WIDTH" "$WIDTH" 320 || return 1
|
||||||
validateResolution "HEIGHT" "$HEIGHT" 200 || return 1
|
validateResolution "HEIGHT" "$HEIGHT" 200 || return 1
|
||||||
|
validateComputerName "$HOST" || return 1
|
||||||
validateProductKey "$KEY" || return 1
|
validateProductKey "$KEY" || return 1
|
||||||
validatePassword "$PASSWORD" || return 1
|
validatePassword "$PASSWORD" || return 1
|
||||||
|
|
||||||
app=$(escapeXMLSed "$APP for $ENGINE") || return 1
|
app=$(escapeXMLSed "$APP for $ENGINE") || return 1
|
||||||
|
host=$(escapeXMLSed "$HOST") || return 1
|
||||||
|
|
||||||
sed -i "s|>Windows for Docker<|>$app<|g" "$asset" || return 1
|
sed -i "s|>Windows for Docker<|>$app<|g" "$asset" || return 1
|
||||||
|
sed -i -E "s|<ComputerName>[^<]*</ComputerName>|<ComputerName>$host</ComputerName>|g" "$asset" || return 1
|
||||||
sed -i "s|<VerticalResolution>1080</VerticalResolution>|<VerticalResolution>$HEIGHT</VerticalResolution>|g" "$asset" || return 1
|
sed -i "s|<VerticalResolution>1080</VerticalResolution>|<VerticalResolution>$HEIGHT</VerticalResolution>|g" "$asset" || return 1
|
||||||
sed -i "s|<HorizontalResolution>1920</HorizontalResolution>|<HorizontalResolution>$WIDTH</HorizontalResolution>|g" "$asset" || return 1
|
sed -i "s|<HorizontalResolution>1920</HorizontalResolution>|<HorizontalResolution>$WIDTH</HorizontalResolution>|g" "$asset" || return 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user