| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
##### |
| 4 |
# ESG SECURITY |
| 5 |
# This script is intended to be an adjunct to the esg-node / esg-gway scripts |
| 6 |
# (author: [email protected]) |
| 7 |
#**************************************************************************** |
| 8 |
#* * |
| 9 |
#* Organization: Lawrence Livermore National Lab (LLNL) * |
| 10 |
#* Directorate: Computation * |
| 11 |
#* Department: Computing Applications and Research * |
| 12 |
#* Division: S&T Global Security * |
| 13 |
#* Matrix: Atmospheric, Earth and Energy Division * |
| 14 |
#* Program: PCMDI * |
| 15 |
#* Project: Earth Systems Grid (ESG) Data Node Software Stack * |
| 16 |
#* First Author: Gavin M. Bell ([email protected]) * |
| 17 |
#* * |
| 18 |
#**************************************************************************** |
| 19 |
#* * |
| 20 |
#* Copyright (c) 2009, Lawrence Livermore National Security, LLC. * |
| 21 |
#* Produced at the Lawrence Livermore National Laboratory * |
| 22 |
#* Written by: Gavin M. Bell ([email protected]) * |
| 23 |
#* LLNL-CODE-420962 * |
| 24 |
#* * |
| 25 |
#* All rights reserved. This file is part of the: * |
| 26 |
#* Earth System Grid (ESG) Data Node Software Stack, Version 1.0 * |
| 27 |
#* * |
| 28 |
#* For details, see http://esg-repo.llnl.gov/esg-node/ * |
| 29 |
#* Please also read this link * |
| 30 |
#* http://esg-repo.llnl.gov/LICENSE * |
| 31 |
#* * |
| 32 |
#* * Redistribution and use in source and binary forms, with or * |
| 33 |
#* without modification, are permitted provided that the following * |
| 34 |
#* conditions are met: * |
| 35 |
#* * |
| 36 |
#* * Redistributions of source code must retain the above copyright * |
| 37 |
#* notice, this list of conditions and the disclaimer below. * |
| 38 |
#* * |
| 39 |
#* * Redistributions in binary form must reproduce the above copyright * |
| 40 |
#* notice, this list of conditions and the disclaimer (as noted below) * |
| 41 |
#* in the documentation and/or other materials provided with the * |
| 42 |
#* distribution. * |
| 43 |
#* * |
| 44 |
#* Neither the name of the LLNS/LLNL nor the names of its contributors * |
| 45 |
#* may be used to endorse or promote products derived from this * |
| 46 |
#* software without specific prior written permission. * |
| 47 |
#* * |
| 48 |
#* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * |
| 49 |
#* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * |
| 50 |
#* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * |
| 51 |
#* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE * |
| 52 |
#* LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR * |
| 53 |
#* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * |
| 54 |
#* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
| 55 |
#* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * |
| 56 |
#* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * |
| 57 |
#* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * |
| 58 |
#* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * |
| 59 |
#* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * |
| 60 |
#* SUCH DAMAGE. * |
| 61 |
#* * |
| 62 |
#**************************************************************************** |
| 63 |
###### |
| 64 |
|
| 65 |
|
| 66 |
# Description: Installation of the esgf-drslib submodule. This |
| 67 |
# file is meant to be sourced by the esg-node |
| 68 |
# script that has the definition of checked_get(), dedup(), |
| 69 |
# ${workdir}, etc.... |
| 70 |
|
| 71 |
|
| 72 |
install_logfile=${ESG_INSTALL_LOGFILE:-"/etc/esg.install_log"} |
| 73 |
date_format=${date_format:-"+%Y_%m_%d_%H%M%S"} |
| 74 |
drslib_version=${drslib_version:-"0.2.2b1"} |
| 75 |
cdat_home=${CDAT_HOME:-/usr/local/cdat} |
| 76 |
|
| 77 |
#arg (1) - install = 0 [default] |
| 78 |
# upgrade = 1 |
| 79 |
setup_drslib() { |
| 80 |
echo |
| 81 |
echo "*******************************" |
| 82 |
echo "Setting up The ESGF DRSLIB Python Module..." |
| 83 |
echo "*******************************" |
| 84 |
echo |
| 85 |
|
| 86 |
local upgrade=${1:-0} |
| 87 |
|
| 88 |
$cdat_home/bin/easy_install --upgrade drslib |
| 89 |
[ $? != 0 ] && echo "WARNING: drslib did not install successfuly" && checked_done 1 |
| 90 |
|
| 91 |
write_drslib_install_log |
| 92 |
echo "done" |
| 93 |
return 0 |
| 94 |
} |
| 95 |
|
| 96 |
write_drslib_install_log() { |
| 97 |
echo "$(date ${date_format}) python->package:esgf_dirslib=${drslib_version} ${module_install_dir}" >> ${install_logfile} |
| 98 |
dedup ${install_logfile} |
| 99 |
return 0 |
| 100 |
} |
| 101 |
|
| 102 |
############################################ |
| 103 |
# General - Utility Functions |
| 104 |
############################################ |
| 105 |
|
| 106 |
#These functions are identical to the ones in the esg-node script they are |
| 107 |
#being copied here in the case where we are not running this script as |
| 108 |
#a sub process of esg-node. In other words, this allows this script |
| 109 |
#to be stand-alone. |
| 110 |
checked_done() { |
| 111 |
if (($1)); then |
| 112 |
echo "" |
| 113 |
echo "Sorry..." |
| 114 |
echo "This action did not complete successfully" |
| 115 |
echo "Please re-run this task until successful before continuing further" |
| 116 |
echo "" |
| 117 |
exit 1 |
| 118 |
fi |
| 119 |
return 0 |
| 120 |
} |
| 121 |
|
| 122 |
dedup() { |
| 123 |
local infile=${1:-${envfile}} |
| 124 |
[ ! -w "${infile}" ] && echo "WARNING: dedup() - unable to write to ${infile}" && return 1 |
| 125 |
local tmp=$(tac ${infile} | awk 'BEGIN {FS="[ =]"} !($2 in a) {a[$2];print $0}' | sort -k2,2) |
| 126 |
echo "$tmp" > ${infile} |
| 127 |
} |