Commit c6c27147 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Add default sysprep.inf file.

If a windows-legacy image does not host a sysprep.inf file, then add
one during the deployment. The default one is hosted by snf-image-host
and is passed to snf-image-helper through the configuration floppy. The
same mechanism is used for unattend.xml, where the default file is moved
to snf-image-host.
parent d8587aa0
......@@ -10,7 +10,7 @@ dist_doc_DATA = COPYING AUTHORS CONTRIBUTORS
dist_bin_SCRIPTS = snf-image-helper
dist_scripts_SCRIPTS= hashpwd.py inject-files.py decode-properties.py \
disklabel.py handle-ini-file.py
dist_common_DATA = common.sh unattend.xml
dist_common_DATA = common.sh
edit = sed \
-e 's|@commondir[@]|$(commondir)|g' \
......
#!/bin/bash
# Copyright (C) 2011-2015 GRNET S.A.
# Copyright (C) 2011-2016 GRNET S.A.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -84,6 +84,14 @@ export SNF_IMAGE_DEV=${SNF_IMAGE_DEV_0}
if [ -f "$rules/unattend.xml" ]; then
export SNF_IMAGE_UNATTEND="$rules/unattend.xml"
else
log_error "unattend.xml file missing from the device hosting the rules"
fi
if [ -f "$rules/sysprep.inf" ]; then
export SNF_IMAGE_SYSPREPINF="$rules/sysprep.inf"
else
log_error "sysprep.inf file missing from the device hosting the rules"
fi
if [ -n "$SNF_IMAGE_PROPERTIES" ]; then
......
#! /bin/bash
# Copyright (C) 2011, 2015 GRNET S.A. and individual contributors
# Copyright (C) 2011-2016 GRNET S.A. and individual contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -44,10 +44,6 @@ if [[ ! "$SNF_IMAGE_PROPERTY_OSFAMILY" =~ ^windows ]]; then
exit 0
fi
if [ ! -f "@commondir@/unattend.xml" ]; then
log_error "File \`@commondir@/unattend.xml' is missing."
fi
target=$SNF_IMAGE_TARGET
arch=$(get_windows_architecture "$target")
if [ -z "$arch" ]; then
......@@ -89,17 +85,8 @@ if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = windows ]; then
warn "Using the Unattend.xml file found in the image"
else
rm -f "$unattend"
if [ -n "$SNF_IMAGE_UNATTEND" ]; then
echo "Installing custom Unattend.xml file..."
if [ -f "$SNF_IMAGE_UNATTEND" ]; then
cat "$SNF_IMAGE_UNATTEND" > "$target/Unattend.xml"
else
log_error "Custom unattend file: \`"$SNF_IMAGE_UNATTEND"' is missing"
fi
else
cat "@commondir@/unattend.xml" > "$target/Unattend.xml"
fi
unattend="$target/Unattend.xml"
cat "$SNF_IMAGE_UNATTEND" > "$target/unattend.xml"
unattend="$target/unattend.xml"
fi
# FIXME: There is no guarantee the answer file is actually named
......@@ -151,46 +138,52 @@ elif [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "windows-legacy" ]; then
# ensure C:\SnfScripts\SetupComplete.cmd is executed via CmdLines.txt
# which must be installed in the InstalledfilesPath from SYSPREP.INF.
sysprepinf=$(get_sysprepinf "$target")
if [ -n "$sysprepinf" ]; then
h=@scriptsdir@/handle-ini-file.py
installfilespath=$($h "$sysprepinf" get Unattended InstallFilesPath)
if [ -z "$installfilespath" ]; then
# Set InstallFilesPath to C:\SYSPREP\i386 explicitly, if missing
$h "$sysprepinf" set Unattended InstallFilesPath 'C:\SYSPREP\i386'
installfilespath=$($h "$sysprepinf" get Unattended InstallFilesPath)
fi
if [ -z "$installfilespath" ]; then
log_error "Failed to get value of InstallFilesPath in SYSPREP.INF"
fi
installfilespath=${installfilespath,,}
if [[ ! "$installfilespath" == 'c:\sysprep\'* ]]; then
log_error "InstallFilesPath from SYSPREP.INF not under C:\\SYSPREP\\"
fi
installfilespath=${installfilespath#c:\\sysprep\\}
installfilespath=${installfilespath//\\//}
# Ensure final location for InstallFilesPath is still under $target
oemdir="$target/sysprep/$installfilespath"/'$OEM$'
if ! readlink -f "$oemdir"|grep -q "^$target"; then
log_error "Invalid value for InstallFilesPath in SYSPREP.INF"
fi
mkdir -p "$oemdir"
cmdlinestxt="$oemdir/CmdLines.txt"
touch "$cmdlinestxt"
if ! egrep '^[[:space:]]*\[Commands\][[:space:]]*$' "$cmdlinestxt" >/dev/null; then
echo "[Commands]" >> "$cmdlinestxt"
fi
echo '"C:\Windows\SnfScripts\ChangeAdminPassword.cmd"' >>"$cmdlinestxt"
echo '"C:\Windows\Setup\Scripts\SetupComplete.cmd"' >>"$cmdlinestxt"
#Install a product key if defined
if [ -n "${SNF_IMAGE_OS_PRODUCT_KEY+dummy}" ]; then
$h "$sysprepinf" set UserData ProductKey "$SNF_IMAGE_OS_PRODUCT_KEY"
fi
if test -n "$sysprepinf" && ! check_yes_no SNF_IMAGE_PROPERTY_IGNORE_UNATTEND; then
warn "Using the sysprep.inf file found in the image"
else
rm -f "$sysprepinf"
mkdir -p "$target/sysprep"
cat "$SNF_IMAGE_SYSPREPINF" > "$target/sysprep/sysprep.inf"
fi
infedit="@scriptsdir@/handle-ini-file.py"
installfilespath=$($infedit "$sysprepinf" get Unattended InstallFilesPath)
if [ -z "$installfilespath" ]; then
# Set InstallFilesPath to C:\SYSPREP\i386 explicitly, if missing
"$infedit" "$sysprepinf" set Unattended InstallFilesPath 'C:\SYSPREP\i386'
installfilespath=$("$infedit" "$sysprepinf" get Unattended InstallFilesPath)
fi
if [ -z "$installfilespath" ]; then
log_error "Failed to get value of InstallFilesPath in SYSPREP.INF"
fi
installfilespath=${installfilespath,,}
if [[ ! "$installfilespath" == 'c:\sysprep\'* ]]; then
log_error "InstallFilesPath from SYSPREP.INF not under C:\\SYSPREP\\"
fi
installfilespath=${installfilespath#c:\\sysprep\\}
installfilespath=${installfilespath//\\//}
# Ensure final location for InstallFilesPath is still under $target
oemdir="$target/sysprep/$installfilespath"/'$OEM$'
if ! readlink -f "$oemdir"|grep -q "^$target"; then
log_error "Invalid value for InstallFilesPath in SYSPREP.INF"
fi
mkdir -p "$oemdir"
cmdlinestxt="$oemdir/CmdLines.txt"
touch "$cmdlinestxt"
if ! egrep '^[[:space:]]*\[Commands\][[:space:]]*$' "$cmdlinestxt" >/dev/null; then
echo "[Commands]" >> "$cmdlinestxt"
fi
echo '"C:\Windows\SnfScripts\ChangeAdminPassword.cmd"' >>"$cmdlinestxt"
echo '"C:\Windows\Setup\Scripts\SetupComplete.cmd"' >>"$cmdlinestxt"
#Install a product key if defined
if [ -n "${SNF_IMAGE_OS_PRODUCT_KEY+dummy}" ]; then
"$infedit" "$sysprepinf" set UserData ProductKey "$SNF_IMAGE_OS_PRODUCT_KEY"
fi
fi
......
......@@ -12,7 +12,8 @@ dist_os_SCRIPTS = ${srcdir}/create ${srcdir}/import ${srcdir}/export \
dist_os_DATA = ${srcdir}/ganeti_api_version ${srcdir}/parameters.list \
${srcdir}/variants.list ${srcdir}/xen-common.sh \
${srcdir}/kvm-common.sh
${srcdir}/kvm-common.sh ${srcdir}/unattend.xml \
${srcdir}/sysprep.inf
dist_xenscripts_SCRIPTS = ${srcdir}/vif-snf-image
......
# Copyright (C) 2011-2014 GRNET S.A.
# Copyright (C) 2011-2016 GRNET S.A.
# Copyright (C) 2007, 2008, 2009 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
......@@ -229,7 +229,11 @@ create_floppy() {
log_error "Unattend file: \`"$UNATTEND"' does not exist"
exit 1
fi
else
cat unattend.xml > "$target/unattend.xml"
fi
cat sysprep.inf > "$target/sysprep.inf"
# Put all the NIC info in the floppy
set | egrep ^NIC_ | sed -e 's/^/export SNF_IMAGE_/' >> "$target/rules"
umount "$target"
......
;SetupMgrTag
[Unattended]
OemSkipEula=Yes
InstallFilesPath=C:\sysprep\i386
[GuiUnattended]
OEMSkipRegional=1
TimeZone=130
OemSkipWelcome=1
[UserData]
FullName=User
OrgName=GRNET
ComputerName=*
[SetupMgr]
DistFolder=C:\windist
DistShare=windist
[Identification]
JoinWorkgroup=WORKGROUP
[Networking]
InstallDefaultComponents=Yes
[sysprepcleanup]
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