+++ /dev/null
-#! /bin/sh
-
-# set the environment varialbe AUTO_INSTALL to 1 to do an automatic
-# installation.
-
-rootfs_image="/root/rootfs.i686.ext2.bz2"
-disk_device=/dev/sda
-logfile=/var/log/installer
-
-# execute a command and log it
-r()
-{
- cat <<EOF >>$logfile
-$@
-EOF
- "$@"
-}
-
-# execute dialog and stores its output in the variable d
-d()
-{
- r dialog "$@" 2>out
- ret=$?
- out="$(<out)"
- rm out
- return $ret
-}
-
-# stop the installation because of a failure
-die()
-{
- clear
- echo -e "=== \e[1;31mInstallation failed\e[m ==="
- exit 1
-}
-
-msg_box()
-{
- msg="$1"
- d --msgbox "$msg" 0 0
-}
-
-mixedgauge()
-{
- text="$1"
- percent="$2"
- r d --mixedgauge "$text" 0 0 "$percent"
-}
-
-# return true if enabled
-check_vtx()
-{
- hvm-info | grep '^hvm is enabled$' >/dev/null 2>&1
-}
-
-# return true if enabled
-check_vtd()
-{
- hvm-info | grep '^hvm_directio is enabled$' >/dev/null 2>&1
-}
-
-welcome_screen()
-{
- msg_box "Welcome to XenClient installer."
-}
-
-# return 0 => upgrade
-# return 1 => reinstall
-install_or_upgrade()
-{
- if { vgscan | grep xenclient; } 2>/dev/null; then
- d --yesno "We detected a previous installation of XenClient.
-Choose yes to upgrade and no to wipe the previous install an reinstall XenClient." 0 0
- else
- return 1
- fi
-}
-
-upgrade()
-{
- mixedgauge "Upgrading..." 0
- lvremove -f /dev/xenclient/root-new
- mixedgauge "Upgrading..." 10
- lvcreate --name root-new --size 250M /dev/xenclient
- mixedgauge "Upgrading..." 20
-
- bzcat "$rootfs_image" | dd of=/dev/xenclient/root-new && {
- mixedgauge "Upgrading..." 30
- fsck -a /dev/xenclient/root-new
- mixedgauge "Upgrading..." 40
- resize2fs /dev/xenclient/root-new
- mixedgauge "Upgrading..." 50
- tune2fs -j -C 0 -c 100 /dev/xenclient/root-new
- mixedgauge "Upgrading..." 60
-
- lvremove -f /dev/xenclient/root-old
- mixedgauge "Upgrading..." 70
- lvrename /dev/xenclient/root /dev/xenclient/root-old
- mixedgauge "Upgrading..." 80
- lvrename /dev/xenclient/root-new /dev/xenclient/root
- mixedgauge "Upgrading..." 95
- sync
- mixedgauge "Upgrade successful" 100
- }
-}
-
-info_install_mechanism_screen()
-{
- d --yesno "Information about the install mechanism:
-a. The installer will erase the whole disk.
-b. The installer copies XenClient on the disk.
-
-Do you want to continue." 0 0 || { reboot; exit; }
-}
-
-trash_and_install()
-{
- mixedgauge "Removing previous partitions." 0
- r vgchange -a n || die
- for i in /dev/sda[1-4]
- do
- if [[ -b $i ]] ; then
- r pvremove -ff -y $i >>$logfile 2>>$logfile
- fi
- done
-
- mixedgauge "Creating new partition." 10
- r sfdisk -D $disk_device <<EOF >>$logfile 2>>$logfile || die
-,,
-EOF
- mixedgauge "Activating first partition." 15
- r sfdisk $disk_device -A1 >>$logfile 2>>$logfile || die
- mixedgauge "Installing XenClient." 20
- r /root/install $rootfs_image ${disk_device}1 hd0,1 2>>$logfile | tee >>$logfile || die
- mixedgauge "Updating MBR." 95
- r dd if=/install/mbr of=/dev/sda >>$logfile 2>>$logfile || die
- mixedgauge "Finished." 100
-}
-
-eject_cdrom()
-{
- if grep 'eject_cdrom=1' /proc/cmdline >/dev/null 2>&1 &&
- [[ -b /dev/sr0 ]] ; then
- r eject /dev/sr0
- fi
-}
-
-reboot_screen()
-{
- msg_box "Please press <OK> to reboot." &&
- r reboot
-}
-
-check_capabilities()
-{
- msg=""
- reboot=0
- warning=0
-
- if check_vtx; then
- msg="VTX is enabled."
- else
- msg="VTX is disabled."
- reboot=1
- fi
-
- if check_vtd; then
- msg="$msg
-VTD is enabled."
- else
- msg="$msg
-VTD is disabled."
- warning=1
- fi
-
- if [[ $reboot -eq 1 ]]; then
- msg_box "$msg
-
-You need VTX to be able to install XenClient.
-Press enter to reboot."
- reboot
- exit 1
- elif [[ $warning -eq 1 ]]; then
- msg_box "$msg
-
-You should enable VTD.
-Press enter to continue."
- fi
-}
-
-if [[ "$AUTO_INSTALL" -eq 1 ]]; then
- d(){ :;} # redefine d to nothing so no dialogs are shown
- trash_and_install && reboot
-else
- welcome_screen
- check_capabilities
- if install_or_upgrade; then
- upgrade
- else
- info_install_mechanism_screen
- trash_and_install
- fi
- eject_cdrom
- reboot_screen
-fi
+++ /dev/null
-#! /bin/sh -x
-
-export PATH="/sbin:/bin:/usr/sbin:/usr/bin"
-
-die()
-{
- echo "Failure."
- exit 1
-}
-
-usage()
-{
- echo usage: "$0" root-image device-to-install-lvm default-active-partition
- exit 2
-}
-
-root="$1"
-part="$2"
-previous_activ_partition="$3"
-
-if [ $# -ne 3 ]; then
- usage
-fi
-
-set -e
-pvcreate "$part" || die
-vgcreate xenclient "$part" || die
-lvcreate --name config --size 12M /dev/xenclient || die
-lvcreate --name root --size 250M /dev/xenclient || die
-lvcreate --name storage -l +90%FREE /dev/xenclient || die
-
-vgscan --mknodes || die
-vgchange -a y || die
-
-# detect if the rootfs is compressed or not
-if [ "$root" != "${root%.bz2}" ]
-then
- mycat="bzcat"
-else
- mycat="cat"
-fi
-
-$mycat "$root" | dd of=/dev/xenclient/root || die
-
-fsck -y -f /dev/xenclient/root || true # always return 1...
-resize2fs /dev/xenclient/root || die
-tune2fs -j -C 0 -c 100 /dev/xenclient/root || die
-
-mke2fs -j /dev/xenclient/config || die
-mke2fs -j /dev/xenclient/storage || die
-
-mkdir -p /mnt/xenclient || die
-
-mount /dev/xenclient/root /mnt/xenclient || die
-
-mkdir -p /mnt/xenclient/config || die
-mount /dev/xenclient/config /mnt/xenclient/config || die
-
-mkdir -p /mnt/xenclient/storage || die
-mount /dev/xenclient/storage /mnt/xenclient/storage || die
-
-#install iovm
-if [ -d /root/iovm ]
-then
- mkdir -p /mnt/xenclient/storage/iovm
- cp -r /root/iovm/* /mnt/xenclient/storage/iovm
- td-util create vhd 500 /mnt/xenclient/storage/iovm/iovm.vhd
- disk=`tapdisk2 -n vhd:/mnt/xenclient/storage/iovm/iovm.vhd`
- rootfs=`echo /root/iovm/*root*`
- [ ! ${rootfs} = ${rootfs%.gz} ] && mycat="gzip -c -d"
- [ ! ${rootfs} = ${rootfs%.bz2} ] && mycat="bzcat"
- $mycat "$rootfs" | dd of=$disk || die
- e2fsck -y -f $disk || true # return 1 sometimes
- resize2fs $disk || die
- sync
-
-fi
-
-mount --bind /dev /mnt/xenclient/dev || die
-mount --bind /proc /mnt/xenclient/proc || die
-
-chroot /mnt/xenclient "/usr/share/xenclient/install-bootloader" "$part" "$previous_activ_partition"
-
-# unwind
-umount /mnt/xenclient/dev
-umount /mnt/xenclient/proc
-umount /mnt/xenclient/config
-sync
-for TAP in /sys/class/blktap2/blktap* ; do
- [ ! -e "${TAP}/remove" ] || echo 1 > "${TAP}/remove"
-done
-umount /mnt/xenclient/storage
-umount /mnt/xenclient
-