Statistiques
| Révision :

root / trunk / shell / create-front-end @ 36

Historique | Voir | Annoter | Télécharger (2,41 ko)

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