#!/bin/bash # $Id: pocinstall,v 1.31 2006/10/03 10:22:57 dennisvd Exp $ # (Skip to section main to see where the script starts its work) ###################################################################### # Section: variables ###################################################################### pocversion=1 yaim_version=2.7.0-5 apt_version=0.5.15cnc6-4.SL.i386 # overriden on command line NETINSTALL=1 DVDINSTALL=0 YAIMINSTALL=1 FORCE_YAIM=0 MOUNTPOINT= MIRROR=http://poc.vl-e.nl/distribution/$pocversion SITE_INFO_DEF=/etc/opt/vl-e/site-info.def DRYRUN=0 dryprefix= ERROR_STATE=OK # did we detect a problem along the way? INSTALLDIR= # J2SDK 1.4.2 LATEST_JAVA_RPM_RELEASE=12 # 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" # 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 } function goodbye() { echo "Goodbye." echo "Log file is $LOGFILE." log "PoC Installer finished on `date`" } function bailout() { if [ -n "$INSTALLDIR" -a -d "$INSTALLDIR" ]; then $RM -rf $INSTALLDIR fi trap EXIT 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 < 0 && ! $DRYRUN )); then echo "Only root can run the PoC Installer." bailout 1 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 1.0 distribution DVD" || \ fail "The VL-e PoC 1.0 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 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 } # Test if the minimal set of rpms is installed. If not, # offer to download them for the host OS (if possible). # For a netinstall, RHEL3 has the issue that we can't # download base os RPMs function please_install_missing() { cat > $INSTALLDIR/missing-packages <&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 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 add_centos_apt_sources() { log "Installing CentOS apt sources." if (( $DRYRUN )); then log "Create /etc/apt/sources.list.d/centos.list" else cat < /etc/apt/sources.list.d/centos.list rpm http://www.dutchgrid.nl/mirror/apt/centos 3/i386 os updates contrib EOF fi } function add_sl_apt_sources() { log "Installing SL 305 apt sources." if (( $DRYRUN )); then log "Create /etc/apt/sources.list.d/sl.list" else cat < /etc/apt/sources.list.d/sl.list rpm ftp://ftp.scientificlinux.org/linux/scientific/ 305/i386/apt-rpm os updates contrib EOF fi } # add the apt.sources.list file for the base OS function addbaseosaptlist() { log "Adding apt sources for the base OS distribution." really mkdir -p /etc/apt/sources.list.d if (( $SL3 )); then add_sl_apt_sources elif (( $CENTOS3 )); then add_centos_apt_sources else log "I don't know any apt sources for your distribution" please_install_missing exit 1 fi } function check_required_software() { say_n \ "Checking required software .......................................... " missing= complete=1 for p in $BASEOSLIST; do if ! $RPM -q $p > /dev/null; then complete=0 missing="$missing $p" fi done if (( $complete )); then say "OK" else if (( $RHEL3 )); then say "FAILED" say say "Some important packages are missing." please_install_missing elif (( $DVDINSTALL )); then say "FAILED" say say "I could try to download the missing packages from a known repository." say "Should I do this?" error_to_screen select ans in "yes" "no" "quit" "help"; do case $ans in (yes) error_to_log addbaseosaptlist break ;; (no) error_to_log please_install_missing break ;; (quit) echo "OK, quitting." bailout 1 ;; (*) cat < /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/LCG 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?" error_to_screen select ans in "yes" "no" "quit" "help"; do case $ans in (yes) error_to_log really rpm -e $conflicting_rpms 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 } # We should test the mountpoint before trying to install # from CD-ROM. Also, I'm unsure how to go about adding # cdrom methods to the sources list. apt-cdrom is tricky... # We *may* get away by manipulating /var/state/apt/cdroms.list # ourselves, but it's risky. The other, safer but slightly # less user-friendly is to let the user switch CD's and # running apt-cdrom on the entire set. # A network installation is fairly straightforward, as # long as connectivity is not a problem. Maybe we should # ask the user if a network proxy is required. function check_distro() { say_n \ "Checking OS distribution ............................................ " RHEL3=0 CENTOS3=0 SL3=0 if grep -q "Red Hat Enterprise Linux.*release 3" /etc/redhat-release; then RHEL3=1 detect="Detected Red Hat Enterprise Linux, release 3" elif grep -q "CentOS release 3" /etc/redhat-release; then CENTOS3=1 detect="Detected CentOS release 3" elif grep -q "Scientific Linux.*release 3" /etc/redhat-release; then SL3=1 detect="Detected Scientific Linux release 3" fi OTHERDISTRO=0 if ! (( $RHEL3 || $CENTOS3 || $SL3 )); then say "FAILED" say say "Are you pulling my leg ?! This doesn't even look like a" say "Red Hat Enterprise Linux 3 compatible distribution!" OTHERDISTRO=1 else say "OK" log $detect fi if (( $OTHERDISTRO || $RHEL3 )); then say "PLease choose for which distribution you want to install apt sources." say "If you have Red Hat EL, choose Scientific Linux." error_to_screen select distro in "CentOS 3" "Scientific Linux 3" "help" quit; do case $distro in ("CentOS 3") CENTOS3=1 break ;; ("Scientific Linux 3") SL3=1 break ;; (quit) echo "OK, quitting." bailout 1 ;; (*) echo "Choose the distribution that matches your system." echo "I will install apt sources in /etc/apt/sources.list.d/ that" echo "match your choice. If you run Red Hat EL 3, you'd better" echo "Choose Scientific Linux." ;; esac done error_to_log fi } 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= VLE_UI=0 POC_CONF=0 LCG_YAIM=0 LCG_UI=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) YAIMINSTALL=0 say "Upgrading from VL-e PoC $VLE_PKG_VERSION, build $VLE_PKG_RELEASE." else log "VL-e PoC not found; doing a fresh installation." fi if $RPM -q vl-e-ui > /dev/null 2>&1 ; then VLE_UI=1 fi if $RPM -q lcg-yaim > /dev/null 2>&1 ; then LCG_YAIM=1 fi if $RPM -q lcg-UI > /dev/null 2>&1 ; then LCG_UI=1 fi if [ -r /etc/opt/vl-e/poc.conf ]; then POC_CONF=1 fi # NB: if this is a previous ui installation without a conf # file, create one now. if (( ! $POC_CONF )); then really mkdir -p /etc/opt/vl-e if (( $DRYRUN )); then log "Create /etc/opt/vl-e/poc.conf" else cat > /etc/opt/vl-e/poc.conf <&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 "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 "OK" else die "Could not install gnupg; try to install gnupg yourself first." fi } function install_yaim() { # Install yaim say_n \ "Searching for YAIM .................................................. " if YAIM=$($RPM -q lcg-yaim >&2 ); then say OK else say NO say_n \ "Installing YAIM ..................................................... " if really rpmi $MIRROR/extra/lcg-yaim-${yaim_version}.noarch.rpm 1>&2; then say "OK" else die "Failed to install package $MIRROR/extra/lcg-yaim-${yaim_version}.noarch.rpm" fi fi } function vle_apt_sources() { if [ -f /etc/apt/sources.list.d/vle.list ]; then # move out of the way really mv /etc/apt/sources.list.d/vle.list \ /etc/apt/sources.list.d/vle.list.O fi really $CP $INSTALLDIR/vle.list /etc/apt/sources.list.d/vle.list || \ { say "Couldn't copy $INSTALLDIR/vle.list to "\ "/etc/apt/sources.list.d/vle.list" ERROR_STATE=error } } # For the DVD installation, most of the apt sources stuff is unnecessary. # We do an apt-cdrom call and be done with it. Getting all the prerequisite # software for the base os is up to the admin. function configure_apt_sources() { if (( $DVDINSTALL )); then really apt-cdrom --cdrom=$MOUNTPOINT -m add >&2 say "Going to install from DVD-ROM." else log "Going to install from the Internet." # We need the SL sources since some packages are only available on SL. if (( ! $SL3 )); then add_sl_apt_sources fi # For CentOS, we have an apt repository which we prefer over # SL. Manage this by apt pinning. if (( $CENTOS3 )); then add_centos_apt_sources if ! grep -q 'ftp\.scientificlinux\.org' /etc/apt/preferences; then log "Setting apt to prefer CentOS over Scientific Linux..." really $WGET $MIRROR/extra/apt_preferences_centos \ -O $INSTALLDIR/apt_preferences_centos || \ die "Could not get $MIRROR/extra/apt_preferences_centos" if (( $DRYRUN )); then log "cat $INSTALLDIR/apt_preferences_centos >> /etc/apt/preferences" else cat $INSTALLDIR/apt_preferences_centos >> /etc/apt/preferences fi fi fi vle_apt_sources really $WGET -nv $MIRROR/extra/jpackage.list -O /etc/apt/sources.list.d/jpackage.list >&2 || \ die "Couldn't get $MIRROR/extra/jpackage.list" fi # if (( ! DVDINSTALL )) } function get_install_files() { # Get some prerequisites say_n \ "Preparing installation .............................................. " if (( $DVDINSTALL )); then really $CP $MIRROR/extra/vendors.list $INSTALLDIR/ really $CP $MIRROR/extra/jpackage.asc $INSTALLDIR/ really $CP $MIRROR/RPM-GPG-KEY-vle $INSTALLDIR/ really $CP $MIRROR/extra/site-info.def $INSTALLDIR/ really $CP $MIRROR/extra/RPM-GPG-KEY-CentOS-3 $INSTALLDIR/ really cat > $INSTALLDIR/vle.list <&2 || \ die "Couldn't get $MIRROR/extra/vendors.list" really $WGET $MIRROR/extra/jpackage.asc -O \ $INSTALLDIR/jpackage.asc >&2 || \ die "Couldn't get $MIRROR/extra/jpackage.asc" really $WGET $MIRROR/RPM-GPG-KEY-vle -O \ $INSTALLDIR/RPM-GPG-KEY-vle >&2 || \ die "Couldn't get $MIRROR/RPM-GPG-KEY-vle" really $WGET $MIRROR/extra/site-info.def -O \ $INSTALLDIR/site-info.def >&2 || \ die "Couldn't get $MIRROR/extra/site-info.def" really $WGET $MIRROR/extra/RPM-GPG-KEY-CentOS-3 -O \ $INSTALLDIR/RPM-GPG-KEY-CentOS-3 >&2 || \ die "Couldn't get $MIRROR/extra/RPM-GPG-KEY-CentOS-3" really $WGET $MIRROR/extra/vle.list -O \ $INSTALLDIR/vle.list >&2 || \ die "Couldn't get $MIRROR/extra/vle.list" fi if [ ! -a $SITE_INFO_DEF ]; then mkdir -p $(dirname $SITE_INFO_DEF) really $CP $INSTALLDIR/site-info.def $SITE_INFO_DEF fi say OK } 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 log "Importing PoC Release Manager's public key into RPM and GPG ... " really $RPM --import $INSTALLDIR/RPM-GPG-KEY-vle >&2 || \ die "Couldn't import RPM-GPG-KEY-vle into rpm" really $GPG --import $INSTALLDIR/RPM-GPG-KEY-vle >&2 || \ die "Couldn't import RPM-GPG-KEY-vle into gpg" log "Importing JPackage.org public key into RPM and GPG ... " really $RPM --import $INSTALLDIR/jpackage.asc >&2 || \ die "Couldn't import JPackage key into rpm" really $GPG --import $INSTALLDIR/jpackage.asc >&2 || \ die "Couldn't import JPackage key into gpg" if (( $CENTOS3 )); then log "Importing CentOS-3 public key into RPM and GPG ... " really $RPM --import $INSTALLDIR/RPM-GPG-KEY-CentOS-3 >&2 || \ die "Couldn't import CentOS-3 key into rpm" really $GPG --import $INSTALLDIR/RPM-GPG-KEY-CentOS-3 >&2 || \ die "Couldn't import CentOS-3 key into gpg" say OK fi } function set_vendorlist() { if ! grep -q 'VL-e' /etc/apt/vendors.list; then log "Importing vendors.list for apt ... " if (( $DRYRUN )); then log "cat $INSTALLDIR/vendors.list >> /etc/apt/vendors.list" else cat $INSTALLDIR/vendors.list >> /etc/apt/vendors.list fi fi } function detect_java() { LATEST_J2SDK=j2sdk-1_4_2_$LATEST_JAVA_RPM_RELEASE # latest version of the 1.4.2 SDK HAVE_JAVAC=0 # The java compiler is found in the path HAVE_JAVA=0 # The java runtime is found in the path HAVE_GOOD_JAVA=0 # Version 1.4.2 of java is installed HAVE_JAVA_HOME=0 # JAVA_HOME is set HAVE_GOOD_JAVA_HOME=0 # JAVA_HOME is set and points to a 1.4.2 SDK JAVA_HOME_MATCH=0 # javac in the path is the same as javac of JAVA_HOME HAVE_JAVA_RPM=0 # java sdk is installed from RPM HAVE_GOOD_JAVA_RPM=0 # java sdk 1.4.2 is installed from RPM HAVE_LATEST_JAVA_RPM=0 # the latest version of the j2sdk is installed from RPM say_n \ "Looking for Java .................................................... " JAVAC=$(which javac 2> /dev/null) && HAVE_JAVAC=1 JAVA=$(which java 2> /dev/null) && HAVE_JAVA=1 if (( $HAVE_JAVAC )); then JAVA_VERSION=$($JAVA -version 2>&1 | head -1) echo $JAVA_VERSION | grep -q '1\.4\.2' && HAVE_GOOD_JAVA=1 fi [ ! -z $JAVA_HOME ] && HAVE_JAVA_HOME=1 if (( $HAVE_JAVA_HOME )) && [ -x $JAVA_HOME/bin/java ]; then JAVA_HOME_VERSION=$($JAVA_HOME/bin/java -version 2>&1 | head -1) echo $JAVA_HOME_VERSION | grep -q '1\.4\.2' && HAVE_GOOD_JAVA_HOME=1 fi (( $HAVE_GOOD_JAVA_HOME && $HAVE_GOOD_JAVA )) && \ [ $($READLINK -f $JAVAC) == $JAVA_HOME/bin/javac ] && JAVA_HOME_MATCH=1 JAVA_RPM=$($RPM -q --qf '%{VERSION}\n' j2sdk 2> /dev/null) && HAVE_JAVA_RPM=1 JAVA_GOOD_RPM=$($RPM -q --qf '%{VERSION}\n' j2sdk-1.4.2\* 2> /dev/null) && HAVE_GOOD_JAVA_RPM=1 if (( $HAVE_GOOD_JAVA_RPM )); then say OK JAVA_RPM_RELEASE=$(echo $JAVA_GOOD_RPM | sed 's/.*1\.4\.2_\([0-9]*\).*/\1/') if [ $JAVA_RPM_RELEASE -ge $LATEST_JAVA_RPM_RELEASE ]; then HAVE_LATEST_JAVA_RPM=1 fi else say NO fi } function install_java() { # 3. Install java # Installing java goes like this: 1. find out if java is already there # 2a If so, we're done 2b If not, install it from an RPM. It is # allowed to redistribute the J2SDK under the provisions stated in the # LICENSE and README files of the java distribution from Sun; I think # we're OK. Specifically, the SUPPLEMENTAL LICENSE TERMS of the # LICENSE file, terms A and B. I don't know what they mean by # 'reproduce internally' in therm A ('Software Internal Use and # Development License Grant') but I suspect it may mean 'internally # within the computer' instead of 'internally within the # organisation'. But then, term B ('License to Distribute Software') # allows us to distribute the RPM for the purpose of running the PoC. # There are three situations to handle: # 1. The java installation is fine, the RPM is there, JAVA_HOME is there and javac is in the path. # We don't need to do anything here, except compliment the user on the fine shape of his system # and maybe advise about the existence of a newer version of the RPM. # 2. There is no java whatsoever. This is fine, too, since we will install it ourselves # and leave the system in a working state. # 3. Some java stuff is found, but it is not all OK. It's the wrong version, the compiler is # missing, or JAVA_HOME is missing. Report as much as we can on the matter, and leave # it up to the user to fix his/her installation. INSTALLJAVA=0 DONEWITHJAVA=0 if (( ! $DVDINSTALL && ! $HAVE_GOOD_JAVA_RPM )); then say "Download the j2sdk rpm from SUN and install manually!" say "We can't distribute it publicly due to license restrictions." exit 1 fi if (( $HAVE_GOOD_JAVA && $HAVE_GOOD_JAVA_HOME && $JAVA_HOME_MATCH )); then log "Here is the result of my analysis:" log "JAVA_HOME = $JAVA_HOME" log "Java compiler = $JAVAC" if (( $HAVE_GOOD_JAVA_RPM )); then log "Java RPM: $JAVA_GOOD_RPM" log "Congratulations, your Java installation is in good shape!" if (( ! $HAVE_LATEST_JAVA_RPM )); then log "(Be advised that there is a newer version of the JAVA 2 SDK 1.4.2 RPM" log "available: version $LATEST_J2SDK; you may want to upgrade manually.)" fi DONEWITHJAVA=1 else log "Although you seem to have the right version of Java installed," log "you do not have the j2sdk RPM which is required by the PoC." log "You can resolve the issue by letting me install the RPM;" log "it is usually OK to have multiple versions of Java installed" log "simultaneously." INSTALLJAVA=1 fi DONEWITHJAVA=1 fi if (( ! $HAVE_JAVAC && ! $HAVE_JAVA && ! $HAVE_JAVA_HOME )); then INSTALLJAVA=1 DONEWITHJAVA=1 fi # all other cases if (( ! $DONEWITHJAVA )); then log "Here is the result of my analysis." (( $HAVE_JAVAC )) && log "Java compiler: $JAVAC" (( $HAVE_JAVA )) && log "Java runtime: $JAVA" (( $HAVE_JAVA_HOME )) && log "JAVA_HOME = $JAVA_HOME" (( ! $HAVE_JAVA_HOME )) && log "JAVA_HOME is not set!" (( $HAVE_JAVAC && $HAVE_JAVA_HOME && ! $JAVA_HOME_MATCH )) && \ log "JAVA_HOME/bin/javac is not the same as $JAVAC!" if (( $HAVE_JAVAC && ! $HAVE_GOOD_JAVA )); then log "Java reports the wrong version:" log $JAVA_VERSION fi if (( $HAVE_JAVA_HOME && ! $HAVE_GOOD_JAVA_HOME )); then log "JAVA_HOME/bin/javac reports the wrong version:" log $JAVA_HOME_VERSION fi if (( ! $HAVE_GOOD_JAVA_RPM )); then log "The 1.4.2 version of the j2sdk RPM is not installed." if (( $HAVE_JAVA_RPM )); then log "The installed version is: $JAVA_RPM" fi log "The PoC software requires version 1.4.2 of the JAVA 2 SDK." INSTALLJAVA=1 DONEWITHJAVA=1 else log "The 1.4.2 version of the j2sdk RPM is installed." log "The installed version is: $JAVA_RPM" if (( ! $HAVE_LATEST_JAVA_RPM )); then log "However, there is a newer version available ($LATEST_J2SDK)." log "You may consider upgrading manually." fi fi fi # TODO: where to get Java if we're not doing a DVD installation??? if (( $INSTALLJAVA )); then say_n \ "Installing $LATEST_J2SDK RPM ........................................ " really $RPM -i $MIRROR/extra/${LATEST_J2SDK}-linux-i586.rpm >&2 || \ die "Could not find $MIRROR/extra/${LATEST_J2SDK}-linux-i586.rpm." say OK fi } 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 } function yaim_install_node() { # It's hard to find out if/when yaim has been run, but since it # leaves files in /etc/sysconfig, we check there. if (( ! $FORCE_YAIM )) && [ -f /etc/sysconfig/lcg ]; then log "Skipping YAIM UI installation and configuration because /etc/sysconfig/lcg exists." log "I assume that yaim has already been run, so I won't tread on your installation." log log "Run yaim manually or use --force-yaim." return fi say_n \ "Installing EGEE/LCG UI (this will take a while) ..................... " really /opt/lcg/yaim/scripts/install_node $SITE_INFO_DEF UI >&2 || \ die "Could not install EGGE/LCG middleware" say OK } function yaim_configure_node() { say_n \ "Configuring EGEE/LCG UI (hold on) ................................... " really /opt/lcg/yaim/scripts/configure_node $SITE_INFO_DEF UI >&2 || \ die "Could not configure EGEE/LCG 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 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_ui() { say_n \ "Installing VL-e meta package (this will take a while) ............... " if ! really apt-get -y install vl-e-ui >&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 prepare_installdir log_output log "PoC installer started on `date`" install_wget check_distro check_previous_installation # The following actions are idempotent, so harmless on existing # installations install_apt check_required_software # requires apt check_conflicting_software install_gpg # requires apt get_install_files # requires wget import_gpg_keys # requires install files, gpg set_vendorlist configure_apt_sources apt_get_update detect_java install_java set_java_home clean_ant # is this really necessary? # If this is an existing installation, just update the software if [ -n "$VLE_PKG_VERSION" ]; then update_upgrade install_vo_support # new package (( $FORCE_YAIM )) && { install_yaim yaim_install_node yaim_configure_node } else install_vle_ui install_vo_support (( $YAIMINSTALL )) && { install_yaim yaim_install_node yaim_configure_node } fi # 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