/usr/sbin/dtc_setup_vps_disk is in dtc-xen 0.5.17-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | #!/bin/sh
if [ $# -lt 3 ]; then
echo "Usage: $0 <xen id> <hdd size> <swap size> [lvm/vbd]"
exit 64
fi
# Source the configuration in the config file!
if [ -f /etc/dtc-xen/dtc-xen.conf ] ; then
. /etc/dtc-xen/dtc-xen.conf
fi
# Figure out the VPS mount point
if [ -n "$provisioning_mount_point" ]
then
VPSGLOBPATH="$provisioning_mount_point"
else
VPSGLOBPATH="$VPS_MOUNTPOINT"
fi
# Things that most of then time don't change
VPSNUM=$1
VPSNAME=xen${VPSNUM}
VPSHOSTNAME=xen${NODE_NUM}${VPSNUM}
VPSHDD=$2
VPSMEM=$3
IMAGE_TYPE=$4
if [ -z "$IMAGE_TYPE" ] ; then IMAGE_TYPE=lvm ; fi
# Figure out the LVM name from dtc-xen.conf
if [ "$IMAGE_TYPE" = "lvm" ] ; then
LVMNAME=`dtc-xen-volgroup`
if [ -z "$LVMNAME" ] ; then
echo "Could not determine volume group from which to provision the volume" 1>&2
echo "You might want to set provisioning_volgroup in dtc-xen.conf" 1>&2
exit 78
fi
fi
FSTAB_LVMNAME=`echo ${LVMNAME} | sed -e 's/-/--/g'`
# redirect stdout and stderr to log files, so we can see what happened during install
echo "Redirecting standard output to $VPSGLOBPATH/$VPSNUM.stdout..."
echo "Redirecting standard error to $VPSGLOBPATH/$VPSNUM.stderr..."
if [ -e $VPSGLOBPATH/$VPSNUM.setuplvm.stdout ]; then
mv $VPSGLOBPATH/$VPSNUM.setuplvm.stdout $VPSGLOBPATH/$VPSNUM.setuplvm.stdout.old
fi
if [ -e $VPSGLOBPATH/$VPSNUM.setuplvm.stderr ]; then
mv $VPSGLOBPATH/$VPSNUM.setuplvm.stderr $VPSGLOBPATH/$VPSNUM.setuplvm.stderr.old
fi
exec 1>$VPSGLOBPATH/$VPSNUM.setuplvm.stdout
exec 2>$VPSGLOBPATH/$VPSNUM.setuplvm.stderr
if [ -x /sbin/lvcreate -a -x /sbin/lvremove ] ; then
LVCREATE=/sbin/lvcreate
LVREMOVE=/sbin/lvremove
else
if [ -x /usr/sbin/lvcreate -a -x /usr/sbin/lvremove ] ; then
LVCREATE=/usr/sbin/lvcreate
LVREMOVE=/usr/sbin/lvremove
else
echo "Could not find lvcreate and lvremove binaries!" > /dev/stderr
exit 1
fi
fi
MKFS=/sbin/mkfs.ext3
MKDIR=/bin/mkdir
MKSWAP=/sbin/mkswap
echo "Seleted ${VPSNAME}: ${VPSHDD}MB HDD and ${VPSMEM}MB RAM";
echo "Creating disks..."
if [ ""$IMAGE_TYPE = "lvm" ]; then
# Remove existing partitions if they existed
if [ -L /dev/${LVMNAME}/${VPSNAME} ] ; then
$LVREMOVE -f /dev/${LVMNAME}/${VPSNAME}
fi
if [ -L /dev/${LVMNAME}/${VPSNAME}swap ] ; then
$LVREMOVE -f /dev/${LVMNAME}/${VPSNAME}swap
fi
# (re)create the partitions
if [ ! -L /dev/${LVMNAME}/${VPSNAME} ] ; then
$LVCREATE -L${VPSHDD} -n${VPSNAME} ${LVMNAME}
$MKDIR -p ${VPSGLOBPATH}/${VPSNUM}
fi
if [ ! -L /dev/${LVMNAME}/${VPSNAME}swap ] ; then
$LVCREATE -L${VPSMEM} -n${VPSNAME}swap ${LVMNAME}
fi
if grep ${VPSNAME} /etc/fstab >/dev/null ; then
echo "LV already exists in fstab"
else
echo "/dev/mapper/${FSTAB_LVMNAME}-${VPSNAME} ${VPSGLOBPATH}/${VPSNUM} ext3 defaults,noauto 0 0" >>/etc/fstab
fi
else
if [ -e ${VPSGLOBPATH}/${VPSNAME}.img ]; then
umount ${VPSGLOBPATH}/${VPSNAME}.img
rm ${VPSGLOBPATH}/${VPSNAME}.img
fi
if [ -e ${VPSGLOBPATH}/${VPSNAME}.swap.img ]; then
umount ${VPSGLOBPATH}/${VPSNAME}.swap.img
rm ${VPSGLOBPATH}/${VPSNAME}.swap.img
fi
# (re)create the files
dd if=/dev/zero of=$VPSGLOBPATH/${VPSNAME}.img bs=1M count=${VPSHDD}
dd if=/dev/zero of=$VPSGLOBPATH/${VPSNAME}.swap.img bs=1M count=${VPSMEM}
if grep ${VPSNAME} /etc/fstab >/dev/null ; then
echo "LoopMount already exists in fstab: skipping"
else
echo "$VPSGLOBPATH/${VPSNAME}.img ${VPSGLOBPATH}/${VPSNUM} ext3 defaults,noauto,loop 0 0" >>/etc/fstab
fi
fi
|