#!/bin/bash # $Id: pocinstall-r2,v 1.35 2007/04/02 21:49:14 dennisvd Exp $ # PoC R2 Installer # (Skip to section main to see where the script starts its work) ###################################################################### # Section: variables ###################################################################### pocversion=2 pocbuild=38 yaim_version=3.0.0-38 apt_version=0.5.15cnc6-4.SL.i386 # Options and parameters which can be overriden on the command line CMD_NO_YAIM=0 CMD_FORCE_YAIM=0 MIRROR=http://poc.vl-e.nl/distribution/$pocversion # for DVD installations DVDINSTALL=0 MOUNTPOINT=/mnt/cdrom CMD_SITE_INFO_DEF= CMD_NODETYPE= DRYRUN=0 ASSUME_YES=0 dryprefix= YAIMINSTALL=1 ERROR_STATE=OK # did we detect a problem along the way? INSTALLDIR= CONFDIR=/etc/opt/vl-e POC_CONF=$CONFDIR/poc.conf SITE_INFO_DEF=$CONFDIR/site-info.def # base os assumptions - do not change UYKWYD READLINK=/usr/bin/readlink RPM=/bin/rpm CP=/bin/cp RM=/bin/rm GPG=/usr/bin/gpg WGET=/usr/bin/wget YUM=/usr/bin/yum # base os prerequisite software BASEOSLIST="4Suite gcc-c++ gcc-g77 gnupg gnuplot ImageMagick lapack less libmng libtool-libs openssh passwd perl-libxml-enno rh-postgresql tcl tcp_wrappers tcsh wget " # RPM's that we know conflict with lcg/vl-e software CONFLICTING_RPMS="lam-6.5.9 rh-postgresql-devel" # Sanitize the PATH before we do anything else PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH export PATH ###################################################################### # Section: Functions ###################################################################### # send to the screen and the log function say() { echo "$@" echo "$@" >&2 } function say_n() { echo -n "$@" echo "$@" >&2 } # echo just to the log function log() { echo $dryprefix "$@" >&2 } function die() { say "FAILED" exec 2>&3 echo "Error: $1" >&2 echo "Tail of the log file follows ($LOGFILE):" >&2 echo "----------------------------------------------------------------------" >&2 echo " ..." >&2 tail $LOGFILE >&2 echo "----------------------------------------------------------------------" >&2 echo "Exiting." trap exit builtin exit 1 } function fail() { echo "$@" exit 1 } # This function will evaluate its arguments if DRYRUN=0; # Otherwise it will just echo them. function really() { if (( $DRYRUN )) then log "$@" else "$@" fi } function usage() { cat < Install from a mirror --no-yaim Skip the YAIM installation (just install PoC middleware) --force-yaim (EXPERT USE) Force a YAIM re-installation --site-info-file= (EXPERT USE) Use this site-info.def file instead of the default --nodetype= (EXPERT USE) specify the gLite node type; default is UI. --yes | -y (EXPERT USE) Assume yes on all queries. --help This text. --dry-run Don't do anything, just show what would be done. --version Display the version of the PoC Installer ----------------------------------------------------------------------------- EOF } # Parse command-line options function parse_options() { while [ $# -gt 0 ]; do case $1 in (--dvd=*) DVDINSTALL=1 MOUNTPOINT=${1#*=} ;; (--dvd) DVDINSTALL=1 MOUNTPOINT=$(awk '/cdrom/ { print $2 }' /etc/fstab) [ -n $MOUNPOINT ] || \ fail "Could not guess the moint point of the DVD-ROM; please specify --dvd=[mount point]" ;; (--mirror=*) MIRROR=${1#*=} # remove trailing slashes MIRROR=${MIRROR%%/} ;; (--no-yaim) CMD_NO_YAIM=1 ;; (--force-yaim) CMD_FORCE_YAIM=1 ;; (--site-info-file=*) CMD_SITE_INFO_DEF=${1#*=} ;; (--nodetype=*) CMD_NODETYPE=${1#*=} ;; (--yes|-y) ASSUME_YES=1 ;; (--help) usage exit 1 ;; (--dry-run) DRYRUN=1 dryprefix="(dryrun) " ;; (--version) echo "PoC Installer for PoC $pocversion, rev. $pocbuild." exit 0 ;; (*) echo "Illegal option: $1" usage exit 1 ;; esac shift done } function prepare_installdir() { # Create an install dir and log file (and report it to the user later) INSTALLDIR=$(mktemp -td pocinstall.XXXXXXXXXX) || \ fail "Failed to create installation directory...bummer." LOGFILE=$INSTALLDIR/install.log # "Changing working directory to $INSTALLDIR..." } # These checks occur _before_ the log file is opened. That is # why 'say' should not be used here, because it gets printed twice. # For the same reason 'really' should not be used. function sanity_checks() { [ -x $RPM ] || fail "$RPM not found! Quitting..." [ -x $READLINK ] || fail "$READLINK not found! Quitting..." # test if we are root if (( $UID > 0 && ! $DRYRUN )); then echo "Only root can run the PoC Installer." bailout 1 fi # Check for conflicting request if (( $CMD_NO_YAIM && $CMD_FORCE_YAIM )); then echo "Both --no-yaim and --force-yaim were given." echo "Please make up your mind." usage bailout 1 fi # check for existing site-info.def if [ -n "$CMD_SITE_INFO_DEF" ]; then if [ ! -r $CMD_SITE_INFO_DEF ]; then echo "Can't read file $CMD_SITE_INFO_DEF." echo "Sorry, but I can't go on." bailout 1 fi fi # If a DVD installation is done, check if the proper DVD is # mounted or mountable. if (( $DVDINSTALL )); then grep -q $MOUNTPOINT /etc/mtab || mount $MOUNTPOINT || \ fail "Could not mount $MOUNTPOINT, is the DVD in the drive?" test "$(cat $MOUNTPOINT/.disk/info)" = "VL-e PoC R2 distribution DVD" || \ fail "The VL-e PoC R2 distribution DVD is not in the drive." fi } function install_wget() { say_n \ "Checking wget ....................................................... " if [ -x $WGET ]; then say OK return 0 fi say "NO" say_n \ "Installing wget ..................................................... " if [ ! -x $YUM ]; then say "FAILED" say say "$WGET is not installed, nor is $YUM. I don't know how to" say "install wget so please fix this before running pocinstall." say fail "Quitting..." else really $YUM -y install wget >&2 if [ $? -eq 0 ]; then say OK else die "Failed to install wget! Quitting..." fi fi } # Function goodbye is called automatically on exit during the normal # operation of the PoC installer... function goodbye() { echo "Goodbye." echo "Log file is $LOGFILE" log "PoC Installer finished on `date`" } # ...but bailout escapes immediately by using the ejection seat. function bailout() { if [ -n "$INSTALLDIR" -a -d "$INSTALLDIR" ]; then $RM -rf $INSTALLDIR fi trap EXIT exit $1 } function log_output() { # Send all further errors to the logfile # save old stderr in FD 3, stdout in FD 4 # send all output to the logfile as well #exec 3>&2 2> $LOGFILE 1> >(tee --append $LOGFILE) echo "Logging details to $LOGFILE" exec 3>&2 2> $LOGFILE trap goodbye EXIT } # sometimes we need to toggle stderr, because of select menu input. function error_to_log() { exec 2>> $LOGFILE } function error_to_screen() { exec 2>&3 } function check_update() { echo -n \ "Checking for newer version of pocinstall ............................ " INSTALL_NEW=0 POCAVAIL=`$WGET $MIRROR/extra/pocinstall -O- -o /dev/null | awk -F= '/^pocbuild=/ { print $2 }' ` || { echo "FAILED" log "Couldn't get $MIRROR/extra/pocinstall" return } if [ -n "$POCAVAIL" ] && [ "$POCAVAIL" -gt "$pocbuild" ]; then echo "Found build $POCAVAIL" echo "A newer version of the PoC installer is available" echo "Do you want to download it?" if (( $ASSUME_YES )) then echo "(Assuming yes)" INSTALL_NEW=1 else export PS3="Please select a number from 1-4 : " select ans in "yes" "no" "help" "quit" do case $ans in (yes) INSTALL_NEW=1 break ;; (no) echo "OK, proceeding with the old installer." # exit 0 break ;; (quit) echo "OK, quitting." bailout 1 ;; (*) cat < $INSTALLDIR/missing-packages < /dev/null; then conflicting_rpms="$conflicting_rpms $p" fi done if [ -z "$conflicting_rpms" ]; then say OK else say FAILED cat << EOF Some packages are installed which are known to conflict with other EGEE/gLite or VL-e packages. These packages need to be removed before installation can continue. The following package(s) can cause conflicts: $conflicting_rpms EOF say "I can remove these packages for you." (( $DRYRUN )) && return say "Should I do this?" if (( $ASSUME_YES )) then echo "(Assuming yes)" REMOVE_CONFLICTS=1 else error_to_screen export PS3="Please select a number from 1-4 : " select ans in "yes" "no" "help" "quit" do case $ans in (yes) REMOVE_CONFLICTS=1 break ;; (no) error_to_log say "Please resolve the conflicting packages before continuing" exit 0 break ;; (quit) echo "OK, quitting." bailout 1 ;; (*) cat <&2 else # adding a little more robustness; if wget is not yet installed # try rpm anyway. if [ -x $WGET ]; then $WGET $1 -O $INSTALLDIR/$(basename $1) >&2 $RPM -i $INSTALLDIR/$(basename $1) >&2 else log "wget is not (yet) installed, trying $RPM." $RPM -i $1 >&2 fi fi } # Check the flavour and version of the distribution function check_distro() { say_n \ "Checking OS distribution ............................................ " if [ ! -f /etc/redhat-release ]; then # this is not a RHEL compatible distribution DISTRO=unk else OSVERSION=$(sed -e 's/.* \([0-9]\).*/\1/' /etc/redhat-release) if [ -z $OSVERSION -o $OSVERSION -lt 3 -o $OSVERSION -gt 4 ]; then OSVERSIONMISMATCH=1 fi if grep -q "Red Hat Enterprise Linux" /etc/redhat-release; then DISTRO=rhel detect="Detected Red Hat Enterprise Linux, release $OSVERSION" elif grep -q "CentOS" /etc/redhat-release; then DISTRO=centos detect="Detected CentOS release $OSVERSION" elif grep -q "Scientific Linux" /etc/redhat-release; then DISTRO=sl detect="Detected Scientific Linux release $OSVERSION" else DISTRO=unk fi fi if [ $DISTRO = "unk" ] || (( $OSVERSIONMISMATCH )); then say "FAILED" say say "I could not determine the kind of Linux distribution of this system." say "This installer only works on Red Hat Enterprise Linux compatible" say "systems, such as CentOS and Scientific Linux; what shall we do?" say "Please choose which flavour closest matches your system, and" say "keep your fingers crossed." error_to_screen select distro in "CentOS 3" "Scientific Linux 3" "Red Hat Enterprise Linux 3" \ "CentOS 4" "Scientific Linux 4" "Red Hat Enterprise Linux 4" "help" quit; do case $distro in ("CentOS 3") DISTRO=centos OSVERSION=4 break ;; ("CentOS 4") DISTRO=centos OSVERSION=4 break ;; ("Scientific Linux 3") DISTRO=sl OSVERSION=3 break ;; ("Scientific Linux 4") DISTRO=sl OSVERSION=4 break ;; ("Red Hat Enterprise Linux 3") DISTRO=rhel OSVERSION=3 break ;; ("Red Hat Enterprise Linux 4") DISTRO=rhel OSVERSION=4 break ;; (quit) echo "OK, quitting." bailout 1 ;; (*) echo "Choose the distribution that you believe matches your system." ;; esac done error_to_log else say "OK" log $detect fi } # This function determines which earlier installations exist on # the system, both vl-e PoC and YAIM. # The rationale is that any sort of pre-existing installation # will prevent installation of the gLite middleware, unless # the user forces the issue. function check_previous_installation() { # See if the VL-e PoC and/or UI are already installed. # Set key variables VLE_PKG_VERSION= VLE_PKG_RELEASE= HAVE_POC_CONF=0 VLE_WN=0 LCG_YAIM=0 LCG_UI=0 GLITE_YAIM=0 PREVIOUS_INSTALLATION=0 POC1=0 POC2=0 log "Checking whether we're doing an upgrade or a fresh installation." if $RPM -q vl-e > /dev/null 2>&1 ; then eval $($RPM -q --qf 'VLE_PKG_VERSION="%{VERSION}" VLE_PKG_RELEASE="%{RELEASE}"' vl-e) log "Found VL-e PoC $VLE_PKG_VERSION, build $VLE_PKG_RELEASE." POC1=1 PREVIOUS_INSTALLATION=1 fi if $RPM -q vle2 > /dev/null 2>&1 ; then eval $($RPM -q --qf 'VLE_PKG_VERSION="%{VERSION}" VLE_PKG_RELEASE="%{RELEASE}"' vle2) log "Found VL-e PoC R2 $VLE_PKG_VERSION, build $VLE_PKG_RELEASE." POC2=1 PREVIOUS_INSTALLATION=1 fi if $RPM -q vl-e-wn > /dev/null 2>&1 ; then VLE_WN=1 fi if $RPM -q lcg-yaim > /dev/null 2>&1 ; then LCG_YAIM=1 PREVIOUS_INSTALLATION=1 fi if $RPM -q glite-yaim > /dev/null 2>&1 ; then GLITE_YAIM=1 PREVIOUS_INSTALLATION=1 fi if $RPM -q lcg-UI > /dev/null 2>&1 ; then LCG_UI=1 fi if $RPM -q glite-UI > /dev/null 2>&1 ; then GLITE_UI=1 fi # prefix values from poc.conf by PC_ if [ -r $POC_CONF ]; then HAVE_POC_CONF=1 for i in yaim sitefile vofile nodetype configure_ui_on_update; do val=$(sed -n -e "s/[[:space:]]*${i}[[:space:]]*=[[:space:]]*//p" $POC_CONF) eval PC_$i=\"$val\" done fi } # This function sets the action plan based on all the information # gathered from the user and the system. # Any decisions about what to do go here! # The logic is as follows: # 1. any previous installation, poc or yaim, will prevent # installing yaim. In other words: # YAIM is only installed on a pristine system. # 2. The PoC is always installed. (Hey, that is why this program # is called pocinstall!) # 3. The nodetype of the PoC is UI, unless --nodetype=WN is given # OR /etc/opt/vl-e/poc.conf has nodetype=WN. # 4. The YAIM install can be forced by --force-yaim, or barred # with --no-yaim. # 5. Currently, RHEL4 type systems will NOT run yaim (but force # overrides). # # The outcome is YAIMINSTALL (1 or 0) and VLE_METAPACKAGE # (vle2-ui or vle2-wn) and YAIM (path of YAIM) and # WRITE_POC_CONF (1 or 0) function determine_action() { # scrob some files of PoC R1 CLEAN_R1=0 if (( $POC1 && ! $POC2 )); then CLEAN_R1=1 fi # location of site-info.def SITE_INFO_DEF=${PC_sitefile:-$SITE_INFO_DEF} # determine YAIM YAIM=${PC_yaim:-/opt/glite/yaim} if (( $PREVIOUS_INSTALLATION )); then YAIMINSTALL=0 fi # YAIM installations don't work yet with RHEL4 if [ $OSVERSION -eq 4 ]; then YAIMINSTALL=0 log "not installing YAIM on RHEL4 compatibles" fi # default nodetype is UI, but a previous vl-e-wn installation # makes this a wn NODETYPE=UI if (( $VLE_WN )); then NODETYPE=WN fi # the value in poc.conf has a higher weight if [ -n "$PC_nodetype" ]; then NODETYPE=$PC_nodetype fi # command-line overrides if (( $CMD_FORCE_YAIM )); then log "YAIM install forced on command line" YAIMINSTALL=1 YAIM=/opt/glite/yaim fi if (( $CMD_NO_YAIM )); then log "YAIM install prohibited on command line" YAIMINSTALL=0 fi if [ -n "$CMD_NODETYPE" ]; then log "Nodetype override on command line" NODETYPE=$CMD_NODETYPE fi if [ "$NODETYPE" = WN ]; then log "WN nodetype: vle2 metapackage to be installed is vle2-wn" VLE_METAPACKAGE=vle2-wn else log "non-WN nodetype: vle2 metapackage to be installed is vle2-ui" VLE_METAPACKAGE=vle2-ui fi GET_SITE_INFO_DEF=0 DOWNLOAD_SITE_INFO_DEF=0 if [ -n "$CMD_SITE_INFO_DEF" ]; then GET_SITE_INFO_DEF=1 elif [ ! -f $SITE_INFO_DEF ]; then DOWNLOAD_SITE_INFO_DEF=1 fi # Did we change poc.conf? if (( $HAVE_POC_CONF )) && \ [ $PC_yaim = $YAIM -a \ $PC_sitefile = $SITE_INFO_DEF -a \ "$PC_nodetype" = "$NODETYPE" ]; then log "poc.conf did not change" WRITE_POC_CONF=0 else WRITE_POC_CONF=1 fi } function clean_r1() { say_n \ "Scrobbing /etc/profile.d/ files from PoC R1 ......................... " for i in fsl vle nimrod gat gt4 vtk mpitb; do really mv /etc/profile.d/$i.sh /etc/profile.d/$i.sh-shoo >&2 really mv /etc/profile.d/$i.csh /etc/profile.d/$i.csh-shoo >&2 done say OK } function write_poc_conf() { # NB: if this is a previous ui installation without a conf # file, create one now. if (( $WRITE_POC_CONF )); then really mkdir -p $CONFDIR if (( $DRYRUN )); then log "Create $CONFDIR/poc.conf" else cat > $CONFDIR/poc.conf <&2 if really apt-get install gnupg >&2; then say "OK" else say "FAILED" die "Could not install gnupg; try to install gnupg yourself first." fi } # This function adds an apt source list in a generic way. # arguments: list name, vendor, base url, branch, repositories. # A grep is performed to see if the base url is already present. function add_apt_list() { listname=$1 vendor=$2 baseurl=$3 branch=$4 shift 4 if ! grep -q -F "$baseurl $branch" /etc/apt/sources.list.d/$listname.list ; then if (( $DRYRUN )); then log "Add rpm $vendor $baseurl $branch $* to /etc/apt/sources.list.d/$listname.list" else cat >| /etc/apt/sources.list.d/$listname.list <&2 say "Going to install from DVD-ROM." fi if [ $DISTRO = centos ]; then if [ $OSVERSION -eq 3 ]; then add_apt_list centos "" http://www.dutchgrid.nl/mirror/apt/centos 3/i386 \ os updates contrib addons centosplus elif [ $OSVERSION -eq 4 ]; then add_apt_list centos "" http://www.dutchgrid.nl/mirror/apt/centos 4/i386 \ os updates contrib addons centosplus fi elif [ $DISTRO = sl ]; then if [ $OSVERSION -eq 3 ]; then add_apt_list sl "" ftp://linuxsoft.cern.ch/scientific/ 30x/i386/apt-rpm \ os updates contrib elif [ $OSVERSION -eq 4 ]; then add_apt_list sl "" ftp://linuxsoft.cern.ch/scientific/ 4x/i386/apt \ os updates contrib fi fi vleuri=$(echo $MIRROR | sed 's,\(.*\)/\([^/]*\),\1,') vlerelease=$(echo $MIRROR | sed 's,\(.*\)/\([^/]*\),\2,') add_apt_list vle2 '[VL-e]' $vleuri $vlerelease/rhel${OSVERSION} vle updates externals contrib # remove original jpackage.list, if any if [ -f /etc/apt/sources.list.d/jpackage.list ]; then really mv /etc/apt/sources.list.d/jpackage.list /etc/apt/sources.list.d/jpackage.old fi add_apt_list jpackage-generic '[JPackage]' http://www.dutchgrid.nl/mirror/jpackage \ 1.6/generic free add_apt_list jpackage-rhel3 '[JPackage]' http://www.dutchgrid.nl/mirror/jpackage \ 1.6/redhat-el-3.0 free } # Because we can install from the network or from DVD, first get # the installation files from the $MIRROR/extra directory to the # local installation directory. All the remaining actions thereby # become network independent. extra_install_files="RPM-GPG-KEY-vle \ jpackage.asc \ RPM-GPG-KEY-CentOS-3 \ apt_preferences_centos \ apt_preferences_jp \ centos.list \ jpackage.list \ site-info.def \ vendors.list" function get_install_files() { say_n \ "Preparing installation .............................................. " if (( $DVDINSTALL )); then for i in $extra_install_files ; do really $CP $MOUNTPOINT/extra/$i $INSTALLDIR/ done else for i in $extra_install_files ; do really $WGET $MIRROR/extra/$i -O \ $INSTALLDIR/$i >&2 || \ die "Couldn't get $MIRROR/extra/$i" done fi say OK } # This function will import the necessary gpg keys into apt (gpg) and rpm. # The following keys are needed: # 1. jpackage # 2. vl-e # 3. Base OS: either CentOS 3 or 4 or SL 3 or 4. function import_gpg_keys() { # fix for error on first use of gnupg. say_n \ "Importing gpg keys .................................................. " [ -d ${HOME}/.gnupg ] || really mkdir -p ${HOME}/.gnupg [ -f ${HOME}/.gnupg/secring.gpg ] || \ really touch ${HOME}/.gnupg/secring.gpg keynames= log "Importing JPackage.org public key into RPM and GPG ... " keynames=jpackage.asc log "Importing PoC Release Manager's public key into RPM and GPG ... " keynames="$keynames RPM-GPG-KEY-vle" if [ $DISTRO = centos ]; then if [ $OSVERSION -eq 3 ]; then log "Importing CentOS 3 GPG key..." keynames="$keynames RPM-GPG-KEY-CentOS-3" elif [ $OSVERSION -eq 4 ]; then log "Importing CentOS 4 GPG key..." keynames="$keynames RPM-GPG-KEY-centos4" fi elif [ $DISTRO = sl ]; then log "Importing all sorts of keys for scientific linux..." # What a hotchpotch! keynames="$keynames RPM-GPG-KEY-csieh RPM-GPG-KEY-dawson RPM-GPG-KEY-jpolok RPM-GPG-KEY.linux-ink" if [ $OSVERSION -eq 4 ]; then log "Importing CentOS 4 GPG key, FOR SCIENTIFIC LINUX! Yes!" keynames="$keynames RPM-GPG-KEY-centos4" fi fi for k in $keynames; do if [ -f $INSTALLDIR/$k ]; then log "Importing $k into RPM and GPG ... " really $RPM --import $INSTALLDIR/$k >&2 || \ die "Couldn't import $k into rpm" really $GPG --import $INSTALLDIR/$k >&2 || \ die "Couldn't import $k into gpg" else log "$k not included, skipping." fi done say OK } function set_vendorlist() { if ! grep -q 'VL-e' /etc/apt/vendors.list; then log "Importing vendors.list for apt ... " if (( $DRYRUN )); then log "cat (HEREDOC) >> /etc/apt/vendors.list" else cat >> /etc/apt/vendors.list <"; } simple-key "VL-e" { Fingerprint "7CB8BF1DDD50687A2212EFF017685BD0E38D518D"; Name "VL-e PoC Release Managers (P4, Scaling & Validation) "; } EOF fi fi } function apt_get_update() { say_n \ "Doing apt-get update ................................................ " really apt-get update >&2 if [ $? -eq 0 ]; then say OK else say "FAILED" say "I detected a problem with apt-get update, but it's" say "Too hard to say what may have caused the problem." say "Sometimes errors like these are harmless, but you" say "should really inspect $LOGFILE to make sure." ERROR_STATE=error fi } function apt_get_fix() { say_n \ "Doing apt-get -f install ............................................ " really apt-get -y -f install >&2 if [ $? -eq 0 ]; then say OK else say "FAILED" say "I detected a problem with apt-get -f install, but it's" say "Too hard to say what may have caused the problem." say "Sometimes errors like these are harmless, but you" say "should really inspect $LOGFILE to make sure." ERROR_STATE=error fi } function update_upgrade() { say_n \ "Doing apt-get upgrade ............................................... " really apt-get -y upgrade >&2 if [ $? -eq 0 ]; then say OK else say "FAILED" say "I detected a problem with apt-get upgrade, but it's" say "too hard to say what may have caused the problem." say "Sometimes errors like these are harmless, but you" say "should really inspect $LOGFILE to make sure." ERROR_STATE=error fi } function clean_ant() { # remove the default ant # TODO: better checking if ant wasn't installed in the # first place, and if it can be safely removed (no dependencies # from other packages). # TODO: find out why we can't just live with an upgrade to the JPP # version of ant. log "Checking if we should remove ant..." if rpm -q --queryformat='%{VERSION}\n' ant | grep -q '^1\.5'; then cat <&2 The version of ant shipped with this system (1.5) is certifiably broken. It is going to be replaced with a 1.6 version that works (provided by JPackage.org). EOF say_n \ "Removing defective ant .............................................. " really $RPM --verbose -e ant ant-libs >&2 if [ $? -eq 0 ]; then say OK else say "FAILED (ignored)" cat >&2 <&2 ; then say "FAILED" log "Dumping dependency information:" apt-cache unmet >&2 say say "Something went wrong. Please check the logfile, and report" say "this to the VL-e P4 team (vle-pfour-team@lists.vl-e.nl)." say exit 1 else say "OK" fi } ###################################################################### # Section: Yaim # ###################################################################### function apt_pin_slc() { log "Pinning apt SL priority." say_n \ "Replacing /etc/apt/preferences ...................................... " really mv /etc/apt/preferences /etc/apt/preferences.O if (( $DRYRUN )) ; then log "writing to /etc/apt/preferences" else cat >> /etc/apt/preferences <&2 ); then say OK else say NO say_n \ "Installing YAIM ..................................................... " if really apt-get -y install glite-yaim 1>&2; then say "OK" else die "Failed to install package glite-yaim." fi fi if [ $DISTRO != sl ]; then # extra sources list needed for gLite. YUK! Protect this with pin-priority! add_apt_list sl "" ftp://linuxsoft.cern.ch/scientific 30x/i386/apt-rpm os updates contrib apt_pin_slc fi } # This function will install the site-info.def file as # given on the command-line. # arguments: src target function cp_site_info_def() { say_n \ "Installing site-info.def ............................................ " if [ ! -d $(dirname $2) ]; then really mkdir -p $(dirname $2) >&2 || \ die "Could not create directory $(dirname $2)." fi really $CP $1 $2 >&2 || \ die "Couldn't copy $1 to $2." say OK } # This funcion will fetch the default site-info def file function install_site_info_def() { say_n \ "Installing site-info.def ............................................ " really mkdir -p $CONFDIR >&2 || \ die "Could not create directory $CONFDIR." really cp $INSTALLDIR/site-info.def $CONFDIR/ || \ die "Could not copy $INSTALLDIR/site-info.def to $CONFDIR." say OK } function set_java_home() { # retrieve JDK install directory from RPM package JAVA_HOME=`rpm -q --qf '%{DIRNAMES}\n' j2sdk | sort | tail -1` || fail "j2sdk rpm is not installed." # remove trailing slash export JAVA_HOME=${JAVA_HOME%/} export PATH=${JAVA_HOME}/bin:${PATH} log "Using Java SDK from ${JAVA_HOME}" # TODO: move this to the postinstall of the vl-e rpm? Define # these as %config files of vl-e? if (( $DRY_RUN )); then log "Create /etc/profile.d/java.{c,}sh" else cat < /etc/profile.d/java.sh export JAVA_HOME=${JAVA_HOME} # tomcat wants this export JAVA_INSTALL_PATH=\${JAVA_HOME} # edg wants this export PATH=\${JAVA_HOME}/bin:\${PATH} EOF cat < /etc/profile.d/java.csh setenv JAVA_HOME ${JAVA_HOME} # tomcat wants this setenv JAVA_INSTALL_PATH \${JAVA_HOME} # edg wants this setenv PATH \${JAVA_HOME}/bin:\${PATH} EOF fi } # nodetypes vs. metapackages WN_nodetype=WN_torque WN_packages="glite-WN glite-torque-client-config" CE_nodetype=CE_torque CE_packages="lcg-CE_torque" SE_nodetype=SE_classic SE_packages=glite-SE_classic BDII_nodetype=BDII BDII_packages=glite-BDII RB_nodetype=RB RB_packages=lcg-RB UI_nodetype=UI UI_packages=glite-UI VOBOX_nodetype=VOBOX VOBOX_packages=glite-VOBOX # This function calls yaim's install_node. All decision points have already # passed, see determine_action. function yaim_install_node() { say_n \ "Installing EGEE/gLite node (this will take a while) ................. " # translate nodetype to metapackage packages= for i in $NODETYPE; do packagevar=${i}_packages packages="$packages ${!packagevar}" done log "Running install_node ${packages}." really /opt/glite/yaim/scripts/install_node $SITE_INFO_DEF $packages >&2 || \ die "Could not install EGGE/gLite middleware" say OK } function yaim_configure_node() { say_n \ "Configuring EGEE/gLite node (hold on) ............................... " nodetypes= for i in $NODETYPE; do nodevar=${i}_nodetype nodetypes="$nodetypes ${!nodevar}" done log "Running configure_node ${nodetypes}." really /opt/glite/yaim/scripts/configure_node $SITE_INFO_DEF ${nodetypes} >&2 || \ die "Could not configure EGEE/gLite middleware" log "Cleaning up after YAIM" log " - fixing ldconfig warnings" bad_libs="\ /opt/lcg/lib/liblcg-info-api-ldap.so \ /opt/glite/externals/lib/libswigpy.so \ /opt/glite/externals/lib/libswigpl.so \ /opt/glite/externals/lib/libswigtcl8.so " for i in $bad_libs do if [ ! -r $i.0.0.0 ] then log "$i.0.0.0 not found; skipping" else if [ ! -L $i ] then log "$i is not a symlink; correcting" really $RM $i (cd ${i%/*} ; really $RM $i ; really ln -fs ${i##*/}.0.0.0 $i) fi if [ ! -L $i.0 ] then log "$i.0 is not a symlink; correcting" really $RM $i.0 (cd ${i%/*} ; really $RM $i.0 ; really ln -fs ${i##*/}.0.0.0 $i.0) fi fi done say OK } function cleanup_after_yaim() { say_n \ "Cleaning up after YAIM .............................................. " log " - fixing ldconfig warnings" bad_libs="\ /opt/lcg/lib/liblcg-info-api-ldap.so \ /opt/glite/externals/lib/libswigpy.so \ /opt/glite/externals/lib/libswigpl.so \ /opt/glite/externals/lib/libswigtcl8.so " for i in $bad_libs do if [ ! -r $i.0.0.0 ] then log "$i.0.0.0 not found; skipping" else if [ ! -L $i ] then log "$i is not a symlink; correcting" really $RM $i (cd ${i%/*} ; really $RM $i ; really ln -fs ${i##*/}.0.0.0 $i) fi if [ ! -L $i.0 ] then log "$i.0 is not a symlink; correcting" really $RM $i.0 (cd ${i%/*} ; really $RM $i.0 ; really ln -fs ${i##*/}.0.0.0 $i.0) fi fi done log " - installing correct /etc/java/java.conf file" (( $DRYRUN )) || cat < /etc/java/java.conf # System-wide Java configuration file # # JPackage Project # Location of jar files on the system JAVA_LIBDIR=/usr/share/java # Location of arch-specific jar files on the system JNI_LIBDIR=/usr/lib/java # Root of all JVM installations JVM_ROOT=/usr/lib/jvm # You can define a system-wide JVM root here if you're not using the default one JAVA_HOME=${JAVA_HOME} # Options to pass to the java interpreter JAVACMD_OPTS= EOF say OK } function install_vle_mw() { say_n \ "Installing VL-e meta package (this will take a while) ............... " if ! really apt-get -y install $VLE_METAPACKAGE >&2 ; then say "FAILED" log "Dumping dependency information:" apt-cache unmet >&2 say say "Something went wrong. Please check the logfile, and report" say "this to the VL-e P4 team (vle-pfour-team@lists.vl-e.nl)." say exit 1 else say "OK" fi } function install_vo_support() { say_n \ "Installing the vle-vo-support package ............................... " if ! really apt-get -y install vle-vo-support >&2 ; then die "installing of vle-vo-support failed." else say "OK" fi } ###################################################################### # Section: main ###################################################################### # the order of calling these functions is very delicate; # some of them need variables or programs that are provided by # others. parse_options "$@" sanity_checks test $DVDINSTALL -eq 0 && check_update $0 "$@" prepare_installdir oldwd=`pwd` cd $INSTALLDIR log_output log "PoC installer started on `date`" log "Invocation was: $0 $*" check_distro check_previous_installation determine_action write_poc_conf # Install the PoC middleware (( $YAIMINSTALL )) && check_conflicting_software clean_ant # is this really necessary? YES install_wget install_apt get_install_files # requires wget configure_apt_sources set_vendorlist install_gpg # requires apt import_gpg_keys # requires install files, gpg apt_get_update apt_get_fix install_java update_upgrade install_vle_mw (( $CLEAN_R1 )) && clean_r1 # Install gLite middleware set_java_home (( $YAIMINSTALL )) && { (( $DOWNLOAD_SITE_INFO_DEF )) && install_site_info_def (( $GET_SITE_INFO_DEF )) && \ cp_site_info_def $oldwd/$CMD_SITE_INFO_DEF $SITE_INFO_DEF install_yaim yaim_install_node yaim_configure_node } cleanup_after_yaim install_vo_support # inspect error state. if [ "$ERROR_STATE" == "OK" ]; then # we're fine say say "Installation completed." exit 0 else say say "We're DONE, but errors occurred along the way." say "Please inspect the log file." exit 1 fi