Sophie

Sophie

distrib > Mandriva > 10.2 > x86_64 > by-pkgid > ff3ee324c0567e1c25614ef618e7dd7f > files > 20

clusterautosetup-2.1-5mdk.src.rpm

#!/bin/sh
# 
# version: 1.1 
#

UBIN="/usr/bin"
TMPLOG="/tmp/log"

CONFFILE="/etc/clusterserver.conf"
if  [ ! -f ${CONFFILE} ]; then
        echo "Cant find ${CONFFILE} !"
        exit 1
fi
. ${CONFFILE}

check_domain() {
if [ ${DOMAINNAME} = "localdomain" ]; then
        echo " Strange DOMAIN for a DNS server ?"
        echo " cant configure a DNS server with such a DOMAINNAME !"
        echo " please edit /etc/sysconfig/network"
	echo " and choose a corect DOMAINNAME, then restart your network:"
	echo " ${INFO}service network restart"
        echo ""
	exit 1
fi
}

check_range_ip() {
echo " - Checking IP of SERVER in RANGE IP"
for i in `seq ${STARTNODE} ${FINISHNODE}` ; do
        if [ "$i" = "${IPSERVERREVERSE}" ]; then
        echo " !!!! WARNING !!!!"
        echo " IP of DNS Server found twice in DNS !!"
        echo " change the range ip of nodes in ${CONFFILE}"
        exit 1
        fi
done
if [ "${STARTNODE}" -ge "${FINISHNODE}" ]; then
        echo " FINISHNODE is greater than STARTNODE !!"
        echo " check ${CONFFILE}"
        exit 1
fi
if [ "${FINISHNODE}" -gt "254" ]; then
        echo " Be carefull ! IP out of 1 to 254 RANGE"
        exit 1
fi
}

check_hostname() {
if [ ${NAMEOFSERVER} = "localhost" ]; then
        echo " Strange name for a DNS server ?"
        echo " cant configure a DNS server with such a name !"
        echo " EXITING ! "
        exit 1
fi
}

rm -rf ${TMPLOG}
mkdir -p ${TMPLOG}
rm -rf  /tmp/nocd 

echo " - Stoppping PBS to avoid Problem of ARP"
service openpbs stop
check_hostname
check_range_ip
check_domain

clear
echo ${INFO}
echo " |------------------------------|" 
echo " |   AUTO SETUP CLIC SERVER !   |"
echo " |------------------------------|"
echo 
echo " You can adjust VAR for all scripts in:"
echo " ${CONFFILE}"
echo
echo " This script is going to automaticaly execute in order:"
echo " setup_install_server"
echo " setup_server_clic all"
echo " setup_dns_server"
echo " setup_nis_server"
echo " setup_dhcpdconf_server"
echo " setup_pxe_server build"
echo " setup_add_nodes_to_dhcp -n number_of_nodes"
echo " setup_pbs_server all"
echo " setup_pbs_client $HOSTNAME"
echo " setup_maui"
echo " setup_postfix"
echo
echo "${WARNING} Be sure that the CDROM is present (first launch)"
# eject
echo " (press ENTER when ready)"
read

launch_script() {
	if [ -f /tmp/nocd ]; then break ; exit; fi
	clear
	rm -f ${TMPLOG}/${1}.log
	echo ${INFO}
	echo
	echo "  ---------------------------------"
	echo "   LAUNCH: ${1}"
	echo
	echo "   LOG can be found in:"
	echo "   ${TMPLOG}/${1}.log"
	echo "  ---------------------------------"
	echo 
	sleep 2
	echo ${NORMAL}
	${UBIN}/${1} ${2} ${3} 2> ${TMPLOG}/${1}.log

# test size of the log
SIZELOG=`du -s ${TMPLOG}/${1}.log | awk '{print $1}'`
if [ "${SIZELOG}" -eq "0" ]; then
	rm -f ${TMPLOG}/${1}.log
fi
}


test_script_log() {
if [ -f "${TMPLOG}/${1}.log" ]; then 
	echo ${WARNING}
        echo 
        echo "     ${1} finish with LOG"
        echo "     Look in ${TMPLOG}/${1}.log for more information"
	echo
	echo " (press ENTER key to continue)"
	read
        echo ${NORMAL}
else
	echo ${SUCCESS}
	echo  
	echo " ${1} finish with SUCCESS"
	echo
        echo " (press ENTER key to continue)"
	read
	echo ${NORMAL}
fi
}

echo 
launch_script setup_install_server
test_script_log setup_install_server

launch_script setup_server_clic all
test_script_log setup_server_clic

launch_script setup_dns_server
test_script_log setup_dns_server

launch_script setup_nis_server
test_script_log setup_nis_server

launch_script setup_dhcpdconf_server
test_script_log setup_dhcpdconf_server

launch_script setup_pxe_server build
test_script_log setup_pxe_server 

NUMBER_OF_NODES=`cat /etc/nodes_list | wc -l`
launch_script setup_add_nodes_to_dhcp -n ${NUMBER_OF_NODES}
test_script_log setup_add_nodes_to_dhcp  

launch_script setup_pbs_server all
test_script_log setup_pbs_server

launch_script setup_pbs_client $HOSTNAME
test_script_log setup_pbs_client

launch_script setup_maui
echo " - Please enter maui user password:"
passwd maui
echo
test_script_log setup_maui

launch_script setup_postfix
test_script_log setup_postfix


clear
echo " - Restarting gmond and gmetad on server"
service gmond restart
service gmetad restart


clear
echo ${INFO}
TESTLOG=`ls ${TMPLOG}/ | grep log`
if [ ! -z "${TESTLOG}" ]; then
	echo " found log(s) in ${TMPLOG}:"
	ls ${TMPLOG}/*.log
fi
echo ${WHITE} 
echo
echo " Server ${SUCCESS}READY${WHITE}, now install a client"
echo "${SUCCESS} DONT ${WHITE}forget to ${WARNING}logout and log again${WHITE}"
echo " to be sure that your environement is set correctly,"
echo " Or GEXEC and Clusterit tools will NOT Work !"
echo ${WHITE} 
echo
echo " (press ENTER key to exit)"
read