* Change the /etc/fstab
* Set network interfaces
* Clear root password
* Run a getty on hvc0

Also added a couple of necessary packages to EXTRA_PKGS in
p2v-target.conf.in.

Signed-off-by: Ben Lipton <[email protected]>
---
 instance-p2v-target/defaults                  |   63 ------------------------
 instance-p2v-target/examples/hooks/grub       |   59 -----------------------
 instance-p2v-target/examples/hooks/interfaces |   53 --------------------
 instance-p2v-target/hooks/clear-root-password |   21 ++++++++
 instance-p2v-target/hooks/interfaces          |   53 ++++++++++++++++++++
 instance-p2v-target/hooks/ramboot             |   40 +++++++++++++++
 instance-p2v-target/hooks/xen-hvc0            |   24 +++++++++
 instance-p2v-target/p2v-target.conf.in        |   64 +++++++++++++++++++++++++
 8 files changed, 202 insertions(+), 175 deletions(-)
 delete mode 100644 instance-p2v-target/defaults
 delete mode 100755 instance-p2v-target/examples/hooks/grub
 delete mode 100755 instance-p2v-target/examples/hooks/interfaces
 create mode 100644 instance-p2v-target/hooks/clear-root-password
 create mode 100755 instance-p2v-target/hooks/interfaces
 create mode 100755 instance-p2v-target/hooks/ramboot
 create mode 100644 instance-p2v-target/hooks/xen-hvc0
 create mode 100644 instance-p2v-target/p2v-target.conf.in

diff --git a/instance-p2v-target/defaults b/instance-p2v-target/defaults
deleted file mode 100644
index 72d41ac..0000000
--- a/instance-p2v-target/defaults
+++ /dev/null
@@ -1,63 +0,0 @@
-# ganeti-instance-debootstrap defaults file
-
-# if you want to change from the default of installing debian stable
-# on the next instance, customize this file before the instance
-# installation
-
-# PROXY: if non-null, use this as an http-proxy in order to speed up
-# non-cached installs; not that if not set, debootstrap might still
-# use a system-wide proxy setting if it is exported in the
-# ganeti-noded daemon environment
-# PROXY="http://proxy.example.com:3128/";
-
-# MIRROR: do not customize MIRROR if you want to be able to install
-# both debian and ubuntu, since they have different defaults; or
-# customize it before each install
-# MIRROR="http://ftp.debian.org/debian";
-
-# ARCH: define ARCH only if you want a different architecture than the
-# current one; the known use case is to install a 32-bit instance on a
-# 64-bit node; choose either "i386" or "amd64":
-# ARCH="i386"
-
-# SUITE: change suite to any of the ones supported by deboostrap; this
-# could be unstable, etch, etc.:
-# SUITE="lenny"
-
-# EXTRA_PKGS: depending on the suite and architecture you are using, different
-# extra packages are needed for different hypervisors. For example:
-#
-# Xen, for etch/lenny i386:
-# EXTRA_PKGS="linux-image-xen-686,libc6-xen"
-# Xen, for etch/lenny amd64:
-# EXTRA_PKGS="linux-image-xen-amd64"
-# KVM, for lenny i386:
-# EXTRA_PKGS="acpi-support-base,console-tools,udev,linux-image-686"
-# KVM, for lenny amd64:
-# EXTRA_PKGS="acpi-support-base,console-tools,udev,linux-image-amd64"
-#
-
-# CUSTOMIZE_DIR: a directory containing scripts to customize the installation.
-# The scripts are executed using run-parts
-# By default /etc/ganeti/instance-debootstrap/hooks
-# CUSTOMIZE_DIR="/etc/ganeti/instance-debootstrap/hooks"
-
-# GENERATE_CACHE: if set to yes (the default), create new cache files;
-# any other value will disable the generation of cache files (but they
-# will still be used if they exist)
-GENERATE_CACHE="yes"
-
-# CLEAN_CACHE: should be set to the number of days after which to
-# clean the cache; the default is 14 (two weeks); to disable cache
-# cleaning, set it to an empty value ("")
-CLEAN_CACHE="14"
-
-# PARTITION_STYLE: whether and how the target device should be partitioned.
-# Allowed values:
-# 'none': just format the device, but don't partition it
-# 'msdos': install an msdos partition table on the device, with a single
-#          partition on it
-# (more styles may be added in the future)
-# The default is "msdos" from ganeti 2.0 onwards, but none if installing under
-# Ganeti 1.2 (os api version 5)
-# PARTITION_STYLE="none"
diff --git a/instance-p2v-target/examples/hooks/grub 
b/instance-p2v-target/examples/hooks/grub
deleted file mode 100755
index c93dcf5..0000000
--- a/instance-p2v-target/examples/hooks/grub
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/bash
-#
-# This is an example script that install and configure grub after installation.
-# To use it put it in your CUSTOMIZE_DIR, make it executable, and edit 
EXTRAPKGS
-# of your $sysconfdir/default/ganeti-instance-debootstrap.
-#
-# Xen, for etch/lenny i386:
-#   EXTRA_PKGS="linux-image-xen-686,libc6-xen"
-# Xen, for etch/lenny amd64:
-#   EXTRA_PKGS="linux-image-xen-amd64"
-# KVM:
-#   no extra packages needed besides the normal suggested ones
-#
-# Do not include grub in EXTRA_PKGS because it will cause error of debootstrap.
-
-set -e
-
-. common.sh
-
-CLEANUP=( )
-
-trap cleanup EXIT
-
-if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
-  echo "Missing target directory"
-  exit 1
-fi
-
-# install grub
-LANG=C
-chroot "$TARGET" apt-get -y --force-yes install grub grub-common
-
-# make /dev/sda
-mknod $TARGET/dev/sda b $(stat -L -c "0x%t 0x%T" $BLOCKDEV)
-CLEANUP+=("rm -f $TARGET/dev/sda")
-
-# make /dev/sda1
-mknod $TARGET/dev/sda1 b $(stat -L -c "0x%t 0x%T" $FSYSDEV)
-CLEANUP+=("rm -f $TARGET/dev/sda1")
-
-# create grub directory
-mkdir -p "$TARGET/boot/grub"
-
-# create device.map
-cat > "$TARGET/boot/grub/device.map" <<EOF
-(hd0) /dev/sda
-EOF
-
-# execute update-grub
-chroot "$TARGET" update-grub
-
-# install grub to the block device
-grub-install --no-floppy --root-directory="$TARGET" "$BLOCKDEV"
-
-# execute cleanups
-cleanup
-trap - EXIT
-
-exit 0
diff --git a/instance-p2v-target/examples/hooks/interfaces 
b/instance-p2v-target/examples/hooks/interfaces
deleted file mode 100755
index 455c396..0000000
--- a/instance-p2v-target/examples/hooks/interfaces
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2009 Google Inc.
-#
-# 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
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-
-# This is an example script that configures you /etc/network/interfaces after
-# installation.  By default its sets up the system to use dhcp. To use it just
-# put it in your CUSTOMIZE_DIR and make it executable.
-
-if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
-  echo "Missing target directory"
-  exit 1
-fi
-
-if [ ! -d "$TARGET/etc/network" ]; then
-  echo "Missing target network directory"
-  exit 1
-fi
-
-if [ -z "$NIC_COUNT" ]; then
-  echo "Missing NIC COUNT"
-  exit 1
-fi
-
-if [ "$NIC_COUNT" -gt 0 ]; then
-
-  cat > $TARGET/etc/network/interfaces <<EOF
-# This file describes the network interfaces available on your system
-# and how to activate them. For more information, see interfaces(5).
-
-auto lo
-iface lo inet loopback
-
-auto eth0
-iface eth0 inet dhcp
-
-EOF
-
-fi
diff --git a/instance-p2v-target/hooks/clear-root-password 
b/instance-p2v-target/hooks/clear-root-password
new file mode 100644
index 0000000..417b62d
--- /dev/null
+++ b/instance-p2v-target/hooks/clear-root-password
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -e
+
+# Make sure we're not working on the root directory
+if [ -z "$TARGET" -o "$TARGET" = "/" ]; then
+    echo "Invalid target directory '$TARGET', aborting." 1>&2
+    exit 1
+fi
+
+if [ "$(mountpoint -d /)" = "$(mountpoint -d "$TARGET")" ]; then
+    echo "The target directory seems to be the root dir, aborting."  1>&2
+    exit 1
+fi
+
+# Disable root's password, as the switch to enable shadow by default
+# has left root with a disabled password, preventing the initial login
+echo "Disabling root's password"
+chroot "$TARGET" passwd -d root
+
+exit 0
diff --git a/instance-p2v-target/hooks/interfaces 
b/instance-p2v-target/hooks/interfaces
new file mode 100755
index 0000000..455c396
--- /dev/null
+++ b/instance-p2v-target/hooks/interfaces
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# Copyright (C) 2009 Google Inc.
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# This is an example script that configures you /etc/network/interfaces after
+# installation.  By default its sets up the system to use dhcp. To use it just
+# put it in your CUSTOMIZE_DIR and make it executable.
+
+if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
+  echo "Missing target directory"
+  exit 1
+fi
+
+if [ ! -d "$TARGET/etc/network" ]; then
+  echo "Missing target network directory"
+  exit 1
+fi
+
+if [ -z "$NIC_COUNT" ]; then
+  echo "Missing NIC COUNT"
+  exit 1
+fi
+
+if [ "$NIC_COUNT" -gt 0 ]; then
+
+  cat > $TARGET/etc/network/interfaces <<EOF
+# This file describes the network interfaces available on your system
+# and how to activate them. For more information, see interfaces(5).
+
+auto lo
+iface lo inet loopback
+
+auto eth0
+iface eth0 inet dhcp
+
+EOF
+
+fi
diff --git a/instance-p2v-target/hooks/ramboot 
b/instance-p2v-target/hooks/ramboot
new file mode 100755
index 0000000..fee3c3e
--- /dev/null
+++ b/instance-p2v-target/hooks/ramboot
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# Copyright (C) 2011 Google Inc.
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# This script modifies the /etc/fstab file of the instance OS to prevent
+# mounting the hard disk over the tmpfs root.
+
+if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
+  echo "Missing target directory"
+  exit 1
+fi
+
+if [ ! -f "$TARGET/etc/fstab" ]; then
+  echo "Missing target /etc/fstab"
+  exit 1
+fi
+
+cat > $TARGET/etc/fstab <<EOF
+# /etc/fstab: static file system information.
+#
+# <file system>   <mount point>   <type>  <options>       <dump>  <pass>
+tmpfs             /               tmpfs   defaults        0       0
+proc              /proc           proc    defaults        0       0
+
+EOF
diff --git a/instance-p2v-target/hooks/xen-hvc0 
b/instance-p2v-target/hooks/xen-hvc0
new file mode 100644
index 0000000..5210767
--- /dev/null
+++ b/instance-p2v-target/hooks/xen-hvc0
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+set -e
+
+# Make sure we're not working on the root directory
+if [ -z "$TARGET" -o "$TARGET" = "/" ]; then
+    echo "Invalid target directory '$TARGET', aborting." 1>&2
+    exit 1
+fi
+
+if [ "$(mountpoint -d /)" = "$(mountpoint -d "$TARGET")" ]; then
+    echo "The target directory seems to be the root dir, aborting."  1>&2
+    exit 1
+fi
+
+# Fix the console information for xen-pvm mode
+if [ "$HYPERVISOR" = "xen-pvm" ]; then
+    echo "xen-pvm hypervisor detected, adding getty on hvc0"
+    cat >> "$TARGET"/etc/inittab <<EOF
+hvc0:2345:respawn:/sbin/getty 38400 hvc0
+EOF
+fi
+
+exit 0
diff --git a/instance-p2v-target/p2v-target.conf.in 
b/instance-p2v-target/p2v-target.conf.in
new file mode 100644
index 0000000..9d0bfa5
--- /dev/null
+++ b/instance-p2v-target/p2v-target.conf.in
@@ -0,0 +1,64 @@
+# ganeti-instance-debootstrap defaults file
+
+# if you want to change from the default of installing debian stable
+# on the next instance, customize this file before the instance
+# installation
+
+# PROXY: if non-null, use this as an http-proxy in order to speed up
+# non-cached installs; not that if not set, debootstrap might still
+# use a system-wide proxy setting if it is exported in the
+# ganeti-noded daemon environment
+# PROXY="http://proxy.example.com:3128/";
+
+# MIRROR: do not customize MIRROR if you want to be able to install
+# both debian and ubuntu, since they have different defaults; or
+# customize it before each install
+# MIRROR="http://ftp.debian.org/debian";
+
+# ARCH: define ARCH only if you want a different architecture than the
+# current one; the known use case is to install a 32-bit instance on a
+# 64-bit node; choose either "i386" or "amd64":
+# ARCH="i386"
+
+# SUITE: change suite to any of the ones supported by deboostrap; this
+# could be unstable, etch, etc.:
+# SUITE="squeeze"
+
+# EXTRA_PKGS: depending on the suite and architecture you are using, different
+# extra packages are needed for different hypervisors. For example:
+#
+# Xen, for etch/lenny i386:
+# EXTRA_PKGS="linux-image-xen-686,libc6-xen"
+# Xen, for etch/lenny amd64:
+EXTRA_PKGS="linux-image-xen-amd64"
+# KVM, for lenny i386:
+# EXTRA_PKGS="acpi-support-base,console-tools,udev,linux-image-686"
+# KVM, for lenny amd64:
+# EXTRA_PKGS="acpi-support-base,console-tools,udev,linux-image-amd64"
+
+# Additional packages required for p2v-target image
+EXTRA_PKGS+=",rsync,openssh-server"
+
+# CUSTOMIZE_DIR: a directory containing scripts to customize the installation.
+# The scripts are executed using run-parts
+# CUSTOMIZE_DIR="@configdir@/hooks"
+
+# GENERATE_CACHE: if set to yes (the default), create new cache files;
+# any other value will disable the generation of cache files (but they
+# will still be used if they exist)
+GENERATE_CACHE="yes"
+
+# CLEAN_CACHE: should be set to the number of days after which to
+# clean the cache; the default is 14 (two weeks); to disable cache
+# cleaning, set it to an empty value ("")
+CLEAN_CACHE="14"
+
+# PARTITION_STYLE: whether and how the target device should be partitioned.
+# Allowed values:
+# 'none': just format the device, but don't partition it
+# 'msdos': install an msdos partition table on the device, with a single
+#          partition on it
+# (more styles may be added in the future)
+# The default is "msdos" from ganeti 2.0 onwards, but none if installing under
+# Ganeti 1.2 (os api version 5)
+# PARTITION_STYLE="none"
-- 
1.7.3.1

Reply via email to