#!/bin/bash ##### # ESG SECURITY # This script is intended to be an adjunct to the esg-node / esg-gway scripts # (author: gavin@llnl.gov) #**************************************************************************** #* * #* Organization: Lawrence Livermore National Lab (LLNL) * #* Directorate: Computation * #* Department: Computing Applications and Research * #* Division: S&T Global Security * #* Matrix: Atmospheric, Earth and Energy Division * #* Program: PCMDI * #* Project: Earth Systems Grid (ESG) Data Node Software Stack * #* First Author: Gavin M. Bell (gavin@llnl.gov) * #* * #**************************************************************************** #* * #* Copyright (c) 2009, Lawrence Livermore National Security, LLC. * #* Produced at the Lawrence Livermore National Laboratory * #* Written by: Gavin M. Bell (gavin@llnl.gov) * #* LLNL-CODE-420962 * #* * #* All rights reserved. This file is part of the: * #* Earth System Grid (ESG) Data Node Software Stack, Version 1.0 * #* * #* For details, see http://esg-repo.llnl.gov/esg-node/ * #* Please also read this link * #* http://esg-repo.llnl.gov/LICENSE * #* * #* * Redistribution and use in source and binary forms, with or * #* without modification, are permitted provided that the following * #* conditions are met: * #* * #* * Redistributions of source code must retain the above copyright * #* notice, this list of conditions and the disclaimer below. * #* * #* * Redistributions in binary form must reproduce the above copyright * #* notice, this list of conditions and the disclaimer (as noted below) * #* in the documentation and/or other materials provided with the * #* distribution. * #* * #* Neither the name of the LLNS/LLNL nor the names of its contributors * #* may be used to endorse or promote products derived from this * #* software without specific prior written permission. * #* * #* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * #* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * #* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * #* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE * #* LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR * #* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * #* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * #* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * #* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * #* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * #* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * #* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * #* SUCH DAMAGE. * #* * #**************************************************************************** ###### # Description: Installation of the esgf-drslib submodule. This # file is meant to be sourced by the esg-node # script that has the definition of checked_get(), dedup(), # ${workdir}, etc.... install_logfile=${ESG_INSTALL_LOGFILE:-"/etc/esg.install_log"} date_format=${date_format:-"+%Y_%m_%d_%H%M%S"} drslib_version=${drslib_version:-"0.2.2b1"} cdat_home=${CDAT_HOME:-/usr/local/cdat} #arg (1) - install = 0 [default] # upgrade = 1 setup_drslib() { echo echo "*******************************" echo "Setting up The ESGF DRSLIB Python Module..." echo "*******************************" echo local upgrade=${1:-0} $cdat_home/bin/easy_install --upgrade drslib [ $? != 0 ] && echo "WARNING: drslib did not install successfuly" && checked_done 1 write_drslib_install_log echo "done" return 0 } write_drslib_install_log() { echo "$(date ${date_format}) python->package:esgf_dirslib=${drslib_version} ${module_install_dir}" >> ${install_logfile} dedup ${install_logfile} return 0 } ############################################ # General - Utility Functions ############################################ #These functions are identical to the ones in the esg-node script they are #being copied here in the case where we are not running this script as #a sub process of esg-node. In other words, this allows this script #to be stand-alone. checked_done() { if (($1)); then echo "" echo "Sorry..." echo "This action did not complete successfully" echo "Please re-run this task until successful before continuing further" echo "" exit 1 fi return 0 } dedup() { local infile=${1:-${envfile}} [ ! -w "${infile}" ] && echo "WARNING: dedup() - unable to write to ${infile}" && return 1 local tmp=$(tac ${infile} | awk 'BEGIN {FS="[ =]"} !($2 in a) {a[$2];print $0}' | sort -k2,2) echo "$tmp" > ${infile} }