]> xenbits.xensource.com Git - xenclient/build.git/commitdiff
[host installer] script to enable PXE-only install
authorChristopher Clark <christopher.clark@citrix.com>
Sat, 5 Sep 2009 02:04:41 +0000 (19:04 -0700)
committerChristopher Clark <christopher.clark@citrix.com>
Sat, 5 Sep 2009 02:04:41 +0000 (19:04 -0700)
Tool inserts the repository into the initrd to allow
PXE-only network installation.

target/generic/target_xenclient_installer_skeleton/install/answers/doc/add-repository-to-initrd.sh [new file with mode: 0755]

diff --git a/target/generic/target_xenclient_installer_skeleton/install/answers/doc/add-repository-to-initrd.sh b/target/generic/target_xenclient_installer_skeleton/install/answers/doc/add-repository-to-initrd.sh
new file mode 100755 (executable)
index 0000000..ea70835
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# Script to repack the initrd to include the software repository,
+# to enable PXE-only network installation.
+#
+# Copyright (c) 2009 Citrix Systems
+#
+
+if [ "$#" != 2 ] ; then
+    echo "This script takes a path to the mounted CD as a parameter,">&2
+    echo "and the filename to write out the repacked initrd to.">&2
+    exit 1
+fi
+CDROM="$1"
+OUTPUT="$2"
+
+P_DOT_M="${CDROM}/packages.main"
+if [ ! -d "${P_DOT_M}" ] ; then
+    echo "Error: Could not find the repository at ${P_DOT_M}.">&2
+    exit 2
+fi
+
+INITRD="${CDROM}/isolinux/rootfs.gz"
+if [ ! -r "${INITRD}" ] ; then
+    echo "Error: Could not read the ramdisk filesystem from ${INITRD}.">&2
+    exit 3
+fi
+
+if [ -e "${OUTPUT}" ] ; then
+    echo "Error: output file ${OUTPUT} already exists.">&2
+    exit 4
+fi
+
+STAGING=$(mktemp)
+if [ $? != 0 ] ; then
+    echo "Error: could not create a temporary file.">&2
+    exit 5
+fi
+
+gunzip <"${INITRD}" >"${STAGING}"
+if [ $? != 0 ] ; then
+    echo "Error: could not unzip the initrd.">&2
+    rm "${STAGING}"
+    exit 6
+fi
+
+cd "${CDROM}"
+find packages.main -print | cpio -H newc -A -O "${STAGING}" -o
+if [ $? != 0 ] ; then
+    echo "Error: could not append to the new initrd.">&2
+    rm "${STAGING}"
+    exit 7
+fi
+
+cd -
+gzip <"${STAGING}" >"${OUTPUT}"
+if [ $? != 0 ] ; then
+    echo "Error: could not compress the new initrd.">&2
+    rm "${STAGING}"
+    rm "${OUTPUT}"
+    exit 8
+fi
+rm -f "${STAGING}"
+exit 0