Statistiques
| Révision :

root / trunk / shell / create-start-front-end @ 34

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

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