root / trunk / shell / generate-hosts-file @ 23
Historique | Voir | Annoter | Télécharger (1,84 ko)
1 | 3 | storres | #! /bin/bash |
---|---|---|---|
2 | 3 | storres | # |
3 | 3 | storres | # Generate a /etc/hosts files that will be use |
4 | 3 | storres | # by dnsmasq on the front end. |
5 | 3 | storres | # |
6 | 3 | storres | # |
7 | 3 | storres | # Get the directory of the script. |
8 | 3 | storres | SCRIPT_PATH=`dirname $0` |
9 | 3 | storres | # Get the script name. |
10 | 3 | storres | SCRIPT_NAME=`basename $0` |
11 | 3 | storres | # Source the common configuration variables. |
12 | 3 | storres | . $SCRIPT_PATH/c-i-a-b.common |
13 | 3 | storres | # Clean up the file |
14 | 3 | storres | HOSTS_FILE="${SCRIPT_PATH}/${TEMPLATES_DIR}/etc/${HOSTS_FILE_BASENAME}" |
15 | 3 | storres | rm -f $HOSTS_FILE |
16 | 3 | storres | # Local host static entry |
17 | 3 | storres | echo 127.0.0.1 localhost >> $HOSTS_FILE |
18 | 3 | storres | # Compute the file entries for the compute nodes. |
19 | 3 | storres | for i in `seq 1 $COMPUTE_NODE_MAX_NUM` |
20 | 3 | storres | do |
21 | 3 | storres | NODE_NUMBER=$i |
22 | 3 | storres | NODE_NUMBER_STRING=$NODE_NUMBER |
23 | 3 | storres | # Normalize the node numbers for the node names on 3 characters. |
24 | 3 | storres | while [ ${#NODE_NUMBER_STRING} -lt 3 ] |
25 | 3 | storres | do |
26 | 3 | storres | NODE_NUMBER_STRING="0$NODE_NUMBER_STRING" |
27 | 3 | storres | done |
28 | 3 | storres | COMPUTE_NODE_NAME="${COMPUTE_NODE_NAME_PREFIX}${NODE_NUMBER_STRING}" |
29 | 3 | storres | echo -n "${COMPUTE_NODE_STATIC_NETWORK_PREFIX}.${NODE_NUMBER} " >> $HOSTS_FILE |
30 | 3 | storres | echo -n "${COMPUTE_NODE_NAME}.$CLUSTER_DOMAIN_NAME " >> $HOSTS_FILE |
31 | 3 | storres | echo "${COMPUTE_NODE_NAME}" >> $HOSTS_FILE |
32 | 3 | storres | |
33 | 3 | storres | done |
34 | 3 | storres | # More static entries |
35 | 3 | storres | echo -n "${COMPUTE_NODE_STATIC_NETWORK_PREFIX}.$FRONT_END_STATIC_NETWORK_POSTFIX " >> $HOSTS_FILE |
36 | 3 | storres | echo -n "$FRONT_END_NAME.$CLUSTER_DOMAIN_NAME " >> $HOSTS_FILE |
37 | 3 | storres | echo $FRONT_END_NAME >> $HOSTS_FILE |
38 | 3 | storres | echo -n "${COMPUTE_NODE_STATIC_NETWORK_PREFIX}.$COMPUTE_NODE_MODEL_STATIC_NETWORK_POSTFIX " >> $HOSTS_FILE |
39 | 3 | storres | echo -n "$COMPUTE_NODE_MODEL_NAME.$CLUSTER_DOMAIN_NAME " >> $HOSTS_FILE |
40 | 3 | storres | echo $COMPUTE_NODE_MODEL_NAME >> $HOSTS_FILE |
41 | 3 | storres | echo \# The following lines are desirable for IPv6 capable hosts >> $HOSTS_FILE |
42 | 3 | storres | echo ::1 ip6-localhost ip6-loopback >> $HOSTS_FILE |
43 | 3 | storres | echo fe00::0 ip6-localnet >> $HOSTS_FILE |
44 | 3 | storres | echo ff00::0 ip6-mcastprefix >> $HOSTS_FILE |
45 | 3 | storres | echo ff02::1 ip6-allnodes >> $HOSTS_FILE |
46 | 3 | storres | echo ff02::2 ip6-allrouters >> $HOSTS_FILE |
47 | 3 | storres | echo |
48 | 3 | storres | echo Copy the \"$HOSTS_FILE\" file to the frontend. |
49 | 3 | storres | echo |
50 | 3 | storres | exit 0 |