Statistiques
| Révision :

root / trunk / shell / generate-dhcp-hostsfile @ 25

Historique | Voir | Annoter | Télécharger (1,58 ko)

1 3 storres
#! /bin/bash
2 3 storres
#
3 3 storres
# Generate a dhcp-hostsfile for dnsmasq.
4 3 storres
# MAC_address,node_name,IP_address
5 3 storres
#
6 3 storres
# Get the directory of the script.
7 3 storres
SCRIPT_PATH=`dirname $0`
8 3 storres
# Get the script name.
9 3 storres
SCRIPT_NAME=`basename $0`
10 3 storres
# Source the common configuration variables.
11 3 storres
. $SCRIPT_PATH/c-i-a-b.common
12 3 storres
# Clean up the file
13 3 storres
DHCP_HOSTSFILE="${SCRIPT_PATH}/${TEMPLATES_DIR}/etc/${DHCP_HOSTSFILE_BASENAME}"
14 3 storres
rm -f $DHCP_HOSTSFILE
15 25 storres
# Compute the compute nodes file entries.
16 25 storres
# Must start at 1 (0 is the network address).
17 3 storres
for i in `seq 1 $COMPUTE_NODE_MAX_NUM`
18 3 storres
  do
19 3 storres
    NODE_NUMBER=$i
20 3 storres
    NODE_NUMBER_STRING=$NODE_NUMBER
21 3 storres
    # Normalize the node numbers for the node names on 3 characters.
22 3 storres
    while [ ${#NODE_NUMBER_STRING} -lt 3 ]
23 3 storres
      do
24 3 storres
        NODE_NUMBER_STRING="0$NODE_NUMBER_STRING"
25 3 storres
    done
26 3 storres
    # Transform the decimal node number in hexadecimal for the MAC address.
27 3 storres
    NODE_NUMBER_HEXA=`printf "%X" $NODE_NUMBER`
28 3 storres
    while [ ${#NODE_NUMBER_HEXA} -lt 2 ]
29 3 storres
      do
30 3 storres
        NODE_NUMBER_HEXA="0$NODE_NUMBER_HEXA"
31 3 storres
    done
32 25 storres
    MAC_ADDRESS="${CLUSTER_MAC_ADDRESS_PREFIX}:$NODE_NUMBER_HEXA"
33 3 storres
    COMPUTE_NODE_NAME="${COMPUTE_NODE_NAME_PREFIX}${NODE_NUMBER_STRING}"
34 25 storres
    echo "${MAC_ADDRESS},id:*,${CLUSTER_STATIC_NETWORK_PREFIX}.${NODE_NUMBER},${COMPUTE_NODE_NAME}" >> $DHCP_HOSTSFILE
35 3 storres
done
36 25 storres
# Create the entry for the front-end.
37 25 storres
NODE_NUMBER_HEXA=`printf "%X" $FRONT_END_STATIC_NETWORK_POSTFIX`
38 25 storres
MAC_ADDRESS="${CLUSTER_MAC_ADDRESS_PREFIX}:$NODE_NUMBER_HEXA"
39 25 storres
echo "${MAC_ADDRESS},id:*,${CLUSTER_STATIC_NETWORK_PREFIX}.${FRONT_END_STATIC_NETWORK_POSTFIX},$FRONT_END_HOST_NAME" >> $DHCP_HOSTSFILE
40 3 storres
echo
41 3 storres
echo Copy the file to the front end!
42 3 storres
echo
43 3 storres
exit 0