Commit 2a5be644 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Fix a bug introduced in 9fca5245

AssignHostname task did not search for Unattend.xml in a case
insensitive way.
parent c459a69d
......@@ -340,6 +340,18 @@ get_last_free_sector() {
fi
}
get_unattend() {
local target="$1"
# Workaround to search for $target/Unattend.xml in an case insensitive way.
exists=$(find "$target"/ -maxdepth 1 -iname unattend.xml)
if [ $(wc -l <<< "$exists") -gt 1 ]; then
log_error "Found multiple Unattend.xml files in the image:" $exists
fi
echo "$exists"
}
cleanup() {
# if something fails here, it shouldn't call cleanup again...
trap - EXIT
......
......@@ -45,13 +45,12 @@ fi
target=$SNF_IMAGE_TARGET
mkdir -p "$target/Windows/Setup/Scripts"
# Workaround to search for C:\Unattend.xml in an case insensitive way.
exists=$(find "$target"/ -maxdepth 1 -iname unattend.xml)
unattend=$(get_unattend "$target")
if [ -n "$exists" -a -z "$SNF_IMAGE_PROPERTY_USE_DEFAULT_UNATTEND" ]; then
if [ -n "$unattend" -a -z "$SNF_IMAGE_PROPERTY_USE_DEFAULT_UNATTEND" ]; then
warn "Using the Unattend.xml file found in the image"
else
xargs rm -f <<< "$exists"
rm -f "$unattend"
if [ -n "$SNF_IMAGE_UNATTEND" ]; then
echo "Installing custom Unattend.xml file..."
if [ -f "$SNF_IMAGE_UNATTEND" ]; then
......
......@@ -37,16 +37,21 @@ windows_hostname() {
local target="$1"
local password="$2"
local tmp_unattend=`mktemp` || exit 1
local tmp_unattend=$(mktemp) || exit 1
add_cleanup rm "$tmp_unattend"
echo -n "Assigning new computer name..."
local namespace="urn:schemas-microsoft-com:unattend"
unattend=$(get_unattend "$target")
if [ -z "$unattend" ]; then
log_error "Unattend.xml is missing."
fi
"$XMLSTARLET" ed -N x=$namespace -u "/x:unattend/x:settings/x:component/x:ComputerName" -v "$password" "$target/Unattend.xml" > "$tmp_unattend"
"$XMLSTARLET" ed -N x=$namespace -u "/x:unattend/x:settings/x:component/x:ComputerName" -v "$password" "$unattend" > "$tmp_unattend"
cat "$tmp_unattend" > "$target/Unattend.xml"
cat "$tmp_unattend" > "$unattend"
echo done
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment