root / trunk / shell / front-end-create @ 43
Historique | Voir | Annoter | Télécharger (2,14 ko)
| 1 | 37 | storres | #! /bin/bash -x |
|---|---|---|---|
| 2 | 37 | storres | # |
| 3 | 37 | storres | # ST - 2012-03-09 |
| 4 | 37 | storres | # |
| 5 | 37 | storres | # Create the front end, up to basic system installation. |
| 6 | 37 | storres | # |
| 7 | 37 | storres | # Get the directory of the script. |
| 8 | 37 | storres | SCRIPT_PATH=`dirname $0` |
| 9 | 37 | storres | # Get the script name. |
| 10 | 37 | storres | SCRIPT_NAME=`basename $0` |
| 11 | 37 | storres | # Source the common configuration variables. |
| 12 | 37 | storres | . $SCRIPT_PATH/c-i-a-b.common |
| 13 | 37 | storres | # |
| 14 | 37 | storres | # Check that the front-end virtual machine does not already exist. |
| 15 | 37 | storres | # |
| 16 | 37 | storres | CURRENT_HOST_NAME=$FRONT_END_HOST_NAME |
| 17 | 37 | storres | IS_RUNNING=`xm list | grep $CURRENT_HOST_NAME` |
| 18 | 37 | storres | if [ -n "$IS_RUNNING" ] |
| 19 | 37 | storres | then |
| 20 | 37 | storres | echo |
| 21 | 37 | storres | echo The \"$CURRENT_HOST_NAME\" domU already exists. Aborting! |
| 22 | 37 | storres | echo |
| 23 | 37 | storres | exit 1 |
| 24 | 37 | storres | fi |
| 25 | 37 | storres | |
| 26 | 37 | storres | # Create the front-end system disk. |
| 27 | 37 | storres | lvcreate -L$FRONT_END_SYSTEM_DISK_SIZE \ |
| 28 | 37 | storres | -n $FRONT_END_SYSTEM_DISK \ |
| 29 | 37 | storres | $FRONT_END_SYSTEM_VOLUME_GROUP |
| 30 | 37 | storres | # Create a File System on the front-end system disk. |
| 31 | 37 | storres | mkfs -t $FRONT_END_SYSTEM_DISK_FILE_SYSTEM \ |
| 32 | 37 | storres | $FRONT_END_SYSTEM_VOLUME_GROUP_DEVICE/$FRONT_END_SYSTEM_DISK |
| 33 | 37 | storres | # If necessary, create the swap volume for the front end. |
| 34 | 37 | storres | if [ $FRONT_END_SWAP_DISK_SIZE != $CONST_NULL_DISK_SIZE ] ; then |
| 35 | 37 | storres | lvcreate -L $FRONT_END_SWAP_DISK_SIZE \ |
| 36 | 37 | storres | -n $FRONT_END_SWAP_DISK \ |
| 37 | 37 | storres | $FRONT_END_SWAP_VOLUME_GROUP |
| 38 | 37 | storres | mkswap $FRONT_END_SWAP_VOLUME_GROUP_DEVICE/$FRONT_END_SWAP_DISK |
| 39 | 37 | storres | fi |
| 40 | 37 | storres | # Create the VM home disk. |
| 41 | 37 | storres | lvcreate -L$FRONT_END_HOME_DISK_SIZE \ |
| 42 | 37 | storres | -n $FRONT_END_HOME_DISK \ |
| 43 | 37 | storres | $FRONT_END_HOME_VOLUME_GROUP |
| 44 | 43 | storres | # Create a File System on the front-end home disk. |
| 45 | 37 | storres | mkfs -t $FRONT_END_HOME_DISK_FILE_SYSTEM \ |
| 46 | 37 | storres | $FRONT_END_HOME_VOLUME_GROUP_DEVICE/$FRONT_END_HOME_DISK |
| 47 | 37 | storres | # Mount the system disk to install the system. |
| 48 | 37 | storres | if [ ! -d $FRONT_END_FILE_SYSTEM_MOUNT_POINT ]; then |
| 49 | 37 | storres | mkdir $FRONT_END_FILE_SYSTEM_MOUNT_POINT |
| 50 | 37 | storres | fi |
| 51 | 37 | storres | mount $FRONT_END_SYSTEM_VOLUME_GROUP_DEVICE/$FRONT_END_SYSTEM_DISK \ |
| 52 | 37 | storres | $FRONT_END_FILE_SYSTEM_MOUNT_POINT |
| 53 | 37 | storres | if [ $? -ne 0 ] ; then |
| 54 | 37 | storres | exit 1 |
| 55 | 37 | storres | fi |
| 56 | 37 | storres | # Create the directory for the homes |
| 57 | 37 | storres | if [ ! -d "$FRONT_END_FILE_SYSTEM_MOUNT_POINT/home" ]; then |
| 58 | 37 | storres | mkdir "$FRONT_END_FILE_SYSTEM_MOUNT_POINT/home" |
| 59 | 37 | storres | fi |
| 60 | 37 | storres | mount $FRONT_END_HOME_VOLUME_GROUP_DEVICE/$FRONT_END_HOME_DISK \ |
| 61 | 37 | storres | "$FRONT_END_FILE_SYSTEM_MOUNT_POINT/home" |
| 62 | 37 | storres | # |
| 63 | 37 | storres | # Install the system. |
| 64 | 37 | storres | # |
| 65 | 37 | storres | debootstrap --arch $CONST_DEBIAN_ARCH $CONST_DEBIAN_VERSION \ |
| 66 | 37 | storres | $FRONT_END_FILE_SYSTEM_MOUNT_POINT |
| 67 | 37 | storres | # |
| 68 | 37 | storres | exit 0 |