#!/usr/bin/bash echo " " echo "################################################################################" echo "#" echo "# Copyright 2009 Sun Microsystems, Inc. All rights reserved." echo "#" echo "# Sun Microsystems, Inc. has intellectual property rights relating to" echo "# technology embodied in the product that is described in this document. In" echo "# particular, and without limitation, these intellectual property rights may" echo "# include one or more of the U.S. patents listed at http://www.sun.com/patents and" echo "# one or more additional patents or pending patent applications in the U.S. and in" echo "# other countries." echo "#" echo "# U.S. Government Rights - Commercial software. Government users are subject" echo "# to the Sun Microsystems, Inc. standard license agreement and applicable" echo "# provisions of the FAR and its supplements." echo "#" echo "# Use is subject to license terms. Sun, Sun Microsystems, the Sun logo," echo "# Solaris and Project OpenSolaris Dynamic Service Containers are trademarks or" echo "# registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries." echo "#" echo "################################################################################" function pause(){ read -p "$*" } function myexit(){ ifconfig vnic893 unplumb &>/dev/null ifconfig vnic894 unplumb &>/dev/null dladm delete-vnic vnic893 &>/dev/null dladm delete-vnic vnic894 &>/dev/null exit 1 } sleep 3 echo " " echo " " echo "DSC 2.0 Workload node installer" echo " " echo " " echo "This installer will" echo " 1) only run on OpenSolaris 2009.06." echo " 2) expects to be able to get to http://pkg.opensolaris.org in order to install extra/non-base functionality." echo " 3) must be run by root" echo " 4) nic0 & nic1 on the machine (e1000g0/nge0 etc.) need to have a static IP address " echo " " echo " " echo "Before you continue you should make esure you have at least 40G of" echo "free swap " echo "# swap -sh" echo "will tell you. If you need to add more swap please " echo "see http://wikis.sun.com/display/DSC/How+to+add+more+swap " echo " " echo " " echo "We also strongly recommend before you install you create /dsc" echo "in a ZFS pool for best performance (often 10x over UFS)" echo " " echo " " pause 'Press key to continue (^C to exit) ....' echo " " echo "=---------------------------=" echo "Setting up for install.." echo "=---------------------------=" regpassword=dsc reguser=dsc reghost=10.2.0.100 regdb=dsc MNIC="$( dladm show-phys|awk 'NR==2 {print}'|awk '{print $1}' )" WNIC="$( dladm show-phys|awk 'NR==3 {print}'|awk '{print $1}' )" dscpool="$( zfs list | grep " /dsc" |awk '{print $1}' )" dhcp="$( ifconfig -a |grep $MNIC| grep 'DHCP' |wc -l )" dhcp1="$( ifconfig -a |grep $WNIC| grep 'DHCP' |wc -l )" netmasktest="$( grep 10.2.0.0 /etc/netmasks | wc -l )" zfsdsc="$( zfs list | grep /dsc |wc -l )" WGET="$(which wget)" MYSQL="$(which mysql)" ID="$( id )" swap="$( swap -s | awk '{as=split($0,T," "); st=sprintf("%s", T[as-1]); print st; }' | sed 's/[A-Za-z]*//g' )" DIR=/usr/local/dsc # cleanup from older (unsucessful installs ?) echo "Cleanup first.." ifconfig vnic893 unplumb &>/dev/null ifconfig vnic894 unplumb &>/dev/null dladm delete-vnic vnic893 &>/dev/null dladm delete-vnic vnic894 &>/dev/null #pkg uninstall amp SUNWmysql5jdbc SUNWPython26 SUNWPython26-extra SUNWpython26-setuptools SUNWmysql-python echo"" echo "=---------------------------=" echo "Checking it's ok to install.." echo "=---------------------------=" # declare -i regalive osversion="$(cat /etc/release |grep OpenSolaris)" if [ "${osversion:25:32}" != "OpenSolaris 2009.06 snv_111b X86" ]; then echo "This installer is designed to run on OpenSolaris 2009.06 ONLY." echo "Please install OpenSolaris 2009.06 from http://opensolaris.org and try again." exit 1 fi # this script needs to be run as root if [ "$ID" != "uid=0(root) gid=0(root)" ]; then echo "You need to run this installer as root, sorry ..." echo "Exiting ....." exit 1 fi if [ "$dhcp" -gt "0" ]; then echo "network interface 0 is using DHCP " echo "Exiting ....." #exit 1 fi if [ "$dhcp1" -gt "0" ]; then echo "network interface 1 is using DHCP " echo "Exiting ....." #exit 1 fi if [ "$zfsdsc" -gt "0" ]; then zfs create -o mountpoint=/dsc rpool/dsc zfs create rpool/dsc/zones else zfs create $dscpool/zones fi #if [ "$swap" -lt "40000000" ]; then if [ "$swap" -lt "400" ]; then echo "You need to have at least 40G of free swap space " echo "See http://wikis.sun.com/display/DSC/How+to+add+more+swap " echo "For help on how to add more swap....." exit 1 fi # # # echo"" echo "=---------------------------------------------=" echo "Starting node install.." echo "=----------------------------------------------=" # create the dsc directory echo "Create the directories for dsc.." mkdir -p /usr/local/ #mkdir -p /dsc &>/dev/null # going to assume /usr/local/dsc for the moment # # install mysql 5.1, php5, apache2 # even if it's already been installed this will exit ok echo "Install Amp, python, jdbc etc... " pkg install amp SUNWmysql5jdbc SUNWPython26 SUNWPython26-extra SUNWpython26-setuptools SUNWmysql-python mv /etc/php/5.2/php.ini /etc/php/5.2/php.ini.old &>/dev/null # #set up a temporary vnic so that I can get a permanent (unique) IP to talk to the registry and repository # echo "Set up the DSC specific network interfaces.. " dladm create-vnic -l $MNIC vnic893 ifconfig vnic893 plumb ifconfig vnic893 10.2.0.98 netmask 255.255.0.0 up # # Can I see the reigstry regalive="$(ping $reghost 2 |grep alive | wc -l)" if [ "$regalive" -lt "1" ]; then echo "I can't see a registry - it needs to be installed before any nodes" echo "Exiting ....." myexit fi # echo "Get and lock a unique IP for this zonehost.." declare -i number number=$RANDOM LOCK=$($MYSQL -h$reghost -u$reguser -p$regpassword -D $regdb -sN -e "update ipaddr set iphost='zonehost.$number' where iphost='zonehost' limit 1") ZHLIP=$($MYSQL -h$reghost -u$reguser -p$regpassword -D $regdb -sN -e "select lzip from ipaddr where iphost='zonehost.$number' limit 1") ZHMIP=$($MYSQL -h$reghost -u$reguser -p$regpassword -D $regdb -sN -e "select mip from ipaddr where iphost='zonehost.$number' limit 1") echo "Drop the temporary nic/IP for this zonehost.." ifconfig vnic893 unplumb &>/dev/null ifconfig vnic894 unplumb &>/dev/null dladm delete-vnic vnic893 &>/dev/null dladm delete-vnic vnic894 &>/dev/null # echo "Set up the permanent DSC network interfaces.. " dladm create-vnic -l $MNIC vnic893 echo $ZHMIP > /etc/hostname.vnic893 ifconfig vnic893 plumb ifconfig vnic893 $ZHMIP netmask 255.255.0.0 up dladm create-vnic -l $WNIC vnic894 echo $ZHLIP > /etc/hostname.vnic894 ifconfig vnic894 plumb ifconfig vnic894 $ZHLIP netmask 255.255.0.0 up # echo "find, get install the DSC code.." SWLocation=$($MYSQL -h$reghost -u$reguser -p$regpassword -D $regdb -sN -e "select value from cpolicy where policy='DSCSwLocation' limit 1") echo "DSC SW location = $SWLocation" echo "Install.." cd /var/tmp rm -rf payload mkdir -p payload cd payload $WGET $SWLocation cd /var/tmp/payload tar xfp *.tar rm -rf /usr/local/dsc.old &>/dev/null mv /usr/local/dsc /usr/local/dsc.old &>/dev/null mv dsc /usr/local/dsc &>/dev/null echo "Does this machine type exist in the DSC host policy table ?.." myplatform="$(prtdiag |head -n 1|awk '{ print $(NF-3), $(NF-2), $(NF-1), $NF }')" # inhpolicy=$($MYSQL -h$reghost -u$reguser -p$regpassword -D $regdb -sN -e "select type from hpolicy where type='$myplatform' limit 1") if [ "$inhpolicy" != "$myplatform" ]; then echo "This host type not found in the host policy table in the registry " echo "- adding it with number of zones = 4 ..." insert=$($MYSQL -h$reghost -u$reguser -p$regpassword -D $regdb -sN -e "insert into hpolicy set type='$myplatform', id='$number', numberofzones='4' ") else zonecount=$($MYSQL -h$reghost -u$reguser -p$regpassword -D $regdb -sN -e "select numberofzones from hpolicy where type='$myplatform' limit 1") echo "yes and zonecount = $zonecount ..." fi # if [ "$netmasktest" -gt "0" ]; then echo "adding entries to /etc/netmask.." echo "10.2.0.0 255.255.0.0" >>/etc/netmask echo "10.1.0.0 255.255.0.0" >>/etc/netmask fi echo " " echo "=--------------------------------------=" echo "Starting ntp.." echo "=--------------------------------------=" cp /etc/inet/ntp.client /etc/inet/ntp.conf svcadm enable ntp echo " " echo "=--------------------------------------=" echo "Configuring dsc_include.sh.." echo "=--------------------------------------=" echo " " /usr/gnu/bin/sed -i -e 's/IP=10.2.0.100/IP='"$ZHMIP"'/' /usr/local/dsc/dsc_include.sh echo " " echo "=---------------------------=" echo "Starting....." echo "=---------------------------=" echo " " echo " " sleep 3 /usr/local/dsc/bin/stop.sh &>/dev/null /usr/local/dsc/bin/start.sh echo "# svcs | grep dsc" echo "will show the services starting and running" echo " " echo "the logfiles are /var/svc/log/*dsc*" echo " " echo " # zoneadm list -vc" echo "will show zones as they are created etc." echo " " echo "For more help or info goto http://wikis.sun.com/dsc " echo "Thankyou "