Commit 5a4c92f1 authored by Iustin Pop's avatar Iustin Pop

Imported Upstream version 0.6

parent 393cfd9a
......@@ -4,7 +4,7 @@ osdir=$(OS_DIR)/$(osname)
os_SCRIPTS = create
dist_os_SCRIPTS = import export rename
dist_os_DATA = ganeti_api_version
dist_os_DATA = ganeti_api_version common.sh
dist_doc_DATA = COPYING NEWS README
......
......@@ -147,7 +147,7 @@ osname = $(subst ganeti-instance-,,$(PACKAGE))
osdir = $(OS_DIR)/$(osname)
os_SCRIPTS = create
dist_os_SCRIPTS = import export rename
dist_os_DATA = ganeti_api_version
dist_os_DATA = ganeti_api_version common.sh
dist_doc_DATA = COPYING NEWS README
EXTRA_DIST = create.in defaults
do_subst = sed \
......
Version 0.6
-----------
Support for Ganeti 2.0 (os api 10)
The instance's fstab is now generated with volumes' UUIDs rather than paths.
This makes it more resilient to changes and use under different
hypervisors/drivers.
Init is configured to listen on /dev/console rather than /dev/tty1
Version 0.5
-----------
......
log_error() {
echo "$@" >&2
}
SCRIPT_NAME=$(basename $0)
for dir in /lib/udev /sbin; do
if [ -f $dir/vol_id -a -x $dir/vol_id ]; then
VOL_ID=$dir/vol_id
fi
done
if [ -z "$VOL_ID" ]; then
log_error "vol_id not found, please install udev"
exit 1
fi
get_api5_arguments() {
TEMP=`getopt -o o:n:i:b:s: -n '$0' -- "$@"`
if [ $? != 0 ] ; then log_error "Terminating..."; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true; do
case "$1" in
-i|-n) instance=$2; shift 2;;
-o) old_name=$2; shift 2;;
-b) blockdev=$2; shift 2;;
-s) swapdev=$2; shift 2;;
--) shift; break;;
*) log_error "Internal error!" >&2; exit 1;;
esac
done
if [ -z "$instance" -o -z "$blockdev" ]; then
log_error "Missing OS API Argument (-i, -n, or -b)"
exit 1
fi
if [ "$SCRIPT_NAME" != "export" -a -z "$swapdev" ]; then
log_error "Missing OS API Argument -s (swapdev)"
exit 1
fi
if [ "$SCRIPT_NAME" = "rename" -a -z "$old_name" ]; then
log_error "Missing OS API Argument -o (old_name)"
exit 1
fi
}
get_api10_arguments() {
if [ -z "$INSTANCE_NAME" -o -z "$HYPERVISOR" -o -z "$DISK_COUNT" ]; then
log_error "Missing OS API Variable:"
log_error "(INSTANCE_NAME HYPERVISOR or DISK_COUNT)"
exit 1
fi
instance=$INSTANCE_NAME
if [ $DISK_COUNT -lt 1 -o -z "$DISK_0_PATH" ]; then
log_error "At least one disk is needed"
exit 1
fi
if [ "$SCRIPT_NAME" = "export" ]; then
if [ -z "$EXPORT_DEVICE" ]; then
log_error "Missing OS API Variable EXPORT_DEVICE"
fi
blockdev=$EXPORT_DEVICE
elif [ "$SCRIPT_NAME" = "import" ]; then
if [ -z "$IMPORT_DEVICE" ]; then
log_error "Missing OS API Variable IMPORT_DEVICE"
fi
blockdev=$IMPORT_DEVICE
else
blockdev=$DISK_0_PATH
fi
if [ "$SCRIPT_NAME" = "rename" -a -z "$OLD_INSTANCE_NAME" ]; then
log_error "Missing OS API Variable OLD_INSTANCE_NAME"
fi
old_name=$OLD_INSTANCE_NAME
}
if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then
OS_API_VERSION=5
get_api5_arguments
elif [ "$OS_API_VERSION" = "10" ]; then
get_api10_arguments
else
log_error "Unknown OS API VERSION $OS_API_VERSION"
exit 1
fi
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for ganeti-instance-debootstrap 0.5.
# Generated by GNU Autoconf 2.61 for ganeti-instance-debootstrap 0.6.
#
# Report bugs to <ganeti@googlegroups.com>.
#
......@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='ganeti-instance-debootstrap'
PACKAGE_TARNAME='ganeti-instance-debootstrap'
PACKAGE_VERSION='0.5'
PACKAGE_STRING='ganeti-instance-debootstrap 0.5'
PACKAGE_VERSION='0.6'
PACKAGE_STRING='ganeti-instance-debootstrap 0.6'
PACKAGE_BUGREPORT='ganeti@googlegroups.com'
ac_unique_file="configure"
......@@ -1148,7 +1148,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures ganeti-instance-debootstrap 0.5 to adapt to many kinds of systems.
\`configure' configures ganeti-instance-debootstrap 0.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1214,7 +1214,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of ganeti-instance-debootstrap 0.5:";;
short | recursive ) echo "Configuration of ganeti-instance-debootstrap 0.6:";;
esac
cat <<\_ACEOF
......@@ -1285,7 +1285,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
ganeti-instance-debootstrap configure 0.5
ganeti-instance-debootstrap configure 0.6
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1299,7 +1299,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by ganeti-instance-debootstrap $as_me 0.5, which was
It was created by ganeti-instance-debootstrap $as_me 0.6, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -1992,7 +1992,7 @@ fi
# Define the identity of the package.
PACKAGE='ganeti-instance-debootstrap'
VERSION='0.5'
VERSION='0.6'
cat >>confdefs.h <<_ACEOF
......@@ -2754,7 +2754,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by ganeti-instance-debootstrap $as_me 0.5, which was
This file was extended by ganeti-instance-debootstrap $as_me 0.6, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -2797,7 +2797,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
ganeti-instance-debootstrap config.status 0.5
ganeti-instance-debootstrap config.status 0.6
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
AC_PREREQ(2.59)
AC_INIT(ganeti-instance-debootstrap, 0.5, ganeti@googlegroups.com)
AC_INIT(ganeti-instance-debootstrap, 0.6, ganeti@googlegroups.com)
AC_CONFIG_AUX_DIR(autotools)
AC_CONFIG_SRCDIR(configure)
......
......@@ -19,6 +19,20 @@
set -e
CLEANUP=( )
cleanup() {
if [ ${#CLEANUP[*]} -gt 0 ]; then
LAST_ELEMENT=$((${#CLEANUP[*]}-1))
REVERSE_INDEXES=$(seq ${LAST_ELEMENT} -1 0)
for i in $REVERSE_INDEXES; do
${CLEANUP[$i]}
done
fi
}
trap cleanup EXIT
DEFAULT_FILE="@sysconfdir@/default/ganeti-instance-debootstrap"
if [ -f "$DEFAULT_FILE" ]; then
. "$DEFAULT_FILE"
......@@ -46,43 +60,28 @@ fi
DPKG_ARCH=${ARCH:-`dpkg --print-architecture`}
CACHE_FILE="$CACHE_DIR/cache-${SUITE}-${DPKG_ARCH}.tar"
TEMP=`getopt -o i:b:s: -n '$0' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
. common.sh
while true; do
case "$1" in
-i) instance=$2; shift 2;;
-b) blockdev=$2; shift 2;;
-s) swapdev=$2; shift 2;;
--) shift; break;;
*) echo "Internal error!"; exit 1;;
esac
done
if [ -z "$instance" -o -z "$blockdev" -o -z "$swapdev" ]; then
echo "Missing -i or -b or -s argument!"
exit 1
# If the target device is not a real block device we'll first losetup it.
# This is needed for file disks.
if [ ! -b $blockdev ]; then
ORIGINAL_BLOCKDEV=$blockdev
blockdev=$(losetup -sf $blockdev)
CLEANUP+=("losetup -d $blockdev")
fi
mkswap $swapdev
mke2fs -Fjq $blockdev
root_uuid=$($VOL_ID -u $blockdev )
if [ -n "$swapdev" ]; then
mkswap $swapdev
swap_uuid=$($VOL_ID -u $swapdev )
fi
TMPDIR=`mktemp -d` || exit 1
trap "umount $TMPDIR; rmdir $TMPDIR" EXIT
CLEANUP+=("rmdir $TMPDIR")
# If it's not a block device try to mount it via loopback device.
# This is needed for file disks.
MOUNT_OPTIONS=""
if [ ! -b $blockdev ]; then
MOUNT_OPTIONS="$MOUNT_OPTIONS -o loop"
fi
mount $MOUNT_OPTIONS $blockdev $TMPDIR
mount $blockdev $TMPDIR
CLEANUP+=("umount $TMPDIR")
# remove the cache file if it's old (> 2 weeks) and writable by the owner (the
# default due to the standard umask)
......@@ -129,10 +128,13 @@ echo $instance > $TMPDIR/etc/mailname
cat > $TMPDIR/etc/fstab <<EOF
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda / ext3 defaults 0 1
/dev/sdb swap swap defaults 0 0
proc /proc proc defaults 0 0
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=$root_uuid / ext3 defaults 0 1
proc /proc proc defaults 0 0
EOF
[ -n "$swapdev" ] && cat >> $TMPDIR/etc/fstab <<EOF
UUID=$swap_uuid swap swap defaults 0 0
EOF
cat > $TMPDIR/etc/network/interfaces <<EOF
......@@ -140,8 +142,18 @@ auto lo
iface lo inet loopback
EOF
umount $TMPDIR
rmdir $TMPDIR
if [ -e $TMPDIR/etc/inittab ]; then
cat $TMPDIR/etc/inittab | sed -re 's/\stty1$/ console/' \
> $TMPDIR/etc/inittab.new
mv $TMPDIR/etc/inittab.new $TMPDIR/etc/inittab
elif [ -e $TMPDIR/etc/event.d/tty1 ]; then
cat $TMPDIR/etc/event.d/tty1 | sed -re 's/tty1/console/' \
> $TMPDIR/etc/event.d/console
rm $TMPDIR/etc/event.d/tty1
fi
# execute cleanups
cleanup
trap - EXIT
exit 0
......@@ -24,16 +24,18 @@
# could be unstable, etch, etc.:
# SUITE="lenny"
# EXTRA_PKGS: depending on the suite and architecture you are using,
# different extra packages are needed for Xen support; if you are not
# using Xen, then Xen packages should not be installed and you should
# use a different, if any, value for it
# for etch/lenny i386:
# 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"
# for etch amd64 (lenny doesn't have xen support in amd64):
# 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"
#
# GENERATE_CACHE: if set to yes (the default), create new cache files;
# any other value will disable the generation of cache files (but they
......
......@@ -19,27 +19,11 @@
set -e
TEMP=`getopt -o i:b: -n '$0' -- "$@"`
. common.sh
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
vol_type=$($VOL_ID -t $blockdev)
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true; do
case "$1" in
-i) instance="$2"; shift 2;;
-b) blockdev="$2"; shift 2;;
--) shift; break;;
*) echo "Internal error!"; exit 1;;
esac
done
if [ -z "$blockdev" ]; then
echo "Missing -b argument!"
exit 1
if [ "$vol_type" = "ext3" -o "$vol_type" = "ext2" ]; then
dump -0 -q -f - "$blockdev"
fi
dump -0 -q -f - "$blockdev"
......@@ -19,33 +19,15 @@
set -e
TEMP=`getopt -o i:b:s: -n '$0' -- "$@"`
. common.sh
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true; do
case "$1" in
-i) instance=$2; shift 2;;
-b) blockdev=$2; shift 2;;
-s) swapdev=$2; shift 2;;
--) shift; break;;
*) echo "Internal error!"; exit 1;;
esac
done
if [ -z "$instance" -o -z "$blockdev" -o -z "$swapdev" ]; then
echo "Missing -i or -b or -s argument!"
exit 1
mke2fs -Fjq $blockdev
root_uuid=$($VOL_ID -u $blockdev )
if [ -n "$swapdev" ]; then
mkswap $swapdev
swap_uuid=$($VOL_ID -u $swapdev )
fi
mkswap $swapdev
mke2fs -Fjq $blockdev
TMPDIR=`mktemp -d` || exit 1
trap "umount $TMPDIR; rmdir $TMPDIR" EXIT
......@@ -59,6 +41,24 @@ mount $MOUNT_OPTIONS $blockdev $TMPDIR
( cd $TMPDIR; restore -r -y -f - )
rm -f $TMPDIR/etc/udev/rules.d/z25_persistent-net.rules
# Fix /etc/fstab with the new volumes' UUIDs
if [ -e $TMPDIR/etc/fstab ]; then
ROOT_LINE="UUID=$root_uuid / ext3 defaults 0 1"
if [ -n "$swapdev" ]; then
SWAP_LINE="UUID=$swap_uuid swap swap defaults 0 0"
cat $TMPDIR/etc/fstab | \
sed -re "s#^(/dev/sda|UUID=[a-f0-9-]+)\s+/\s+.*\$#$ROOT_LINE#" \
-re "s#^(/dev/sdb|UUID=[a-f0-9-]+)\s+swap\s+.*\$#$SWAP_LINE#" \
> $TMPDIR/etc/fstab.new
else
cat $TMPDIR/etc/fstab | \
sed -re "s#^(/dev/sda|UUID=[a-f0-9-]+)\s+/\s+.*\$#$ROOT_LINE#" \
> $TMPDIR/etc/fstab.new
fi
mv $TMPDIR/etc/fstab.new $TMPDIR/etc/fstab
fi
umount $TMPDIR
rmdir $TMPDIR
trap - EXIT
......@@ -19,32 +19,7 @@
set -e
TEMP=`getopt -o o:n:b:s: -n '$0' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true; do
case "$1" in
-o) old_name=$2; shift 2;;
-n) new_name=$2; shift 2;;
-b) blockdev=$2; shift 2;;
-s) swapdev=$2; shift 2;;
--) shift; break;;
*) echo "Internal error!"; exit 1;;
esac
done
if [ -z "$old_name" -o -z "$new_name" -o -z "$blockdev" -o -z "$swapdev" ]; then
echo "Missing -o or -n or -b or -s argument!"
exit 1
fi
. common.sh
TMPDIR=`mktemp -d` || exit 1
trap "umount $TMPDIR; rmdir $TMPDIR" EXIT
......@@ -64,17 +39,17 @@ MNAME="$TMPDIR/etc/mailname"
# expect
OLD_HNAME="`cat $HNAME`"
if [ "$OLD_HNAME" = "$old_name" ]; then
echo $new_name > $HNAME
echo $instance > $HNAME
else
echo "Cannot rename from $old_name to $new_name:" 1>&2
echo "Instance has a different hostname ($OLD_HNAME)" 1>&2
log_error "Cannot rename from $old_name to $instance:"
log_error "Instance has a different hostname ($OLD_HNAME)"
exit 1
fi
# for mailname, we rename only if it has the old_name, otherwise we
# for mailname, we rename only if it has the old name, otherwise we
# ignore it (and assumme that it's a customized name)
if [ "`cat $MNAME`" = "$old_name" ]; then
echo $new_name > $MNAME
echo $instance > $MNAME
fi
umount $TMPDIR
......
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