Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-19 08:00:00

0001 #!/bin/bash
0002 
0003 QUEUENAME=
0004 TOPDIR=
0005 PATH_TO_PROXY=
0006 HARVESTERID=
0007 BATCH_SYSTEM=
0008 PATH_TO_CERTIFICATES=
0009 USERNAME=$(whoami)
0010 GROUPNAME=$(IFS=" " ; set -- $(groups) ; echo $1)
0011 
0012 HARVESTER_REPO="git+git://github.com/PanDAWMS/panda-harvester.git@OLCF_validation"
0013 
0014 usage() { echo -e "Usage: $0 -d <directory_to_install_to> -h <harvester_id> -q <queue_name> -b <batchsystem: e.g. torque|lsf|slurm|condor> -p <path_to_proxy> -c <path_to_certificates>\n\n" 1>&2; exit 1; }
0015 
0016 set -e
0017 
0018 while getopts ":q:d:p:h:b:c:" o; do
0019     case "${o}" in
0020         q)
0021             QUEUENAME=${OPTARG}
0022             ;;
0023         d)
0024             TOPDIR=${OPTARG}
0025             ;;
0026         p)
0027             PATH_TO_PROXY=${OPTARG}
0028             ;;
0029         h)
0030             HARVESTERID=${OPTARG}
0031             ;;
0032         b)
0033             BATCH_SYSTEM=${OPTARG}
0034             ;;
0035         c)
0036             PATH_TO_CERTIFICATES=${OPTARG}
0037             ;;
0038         *)
0039             usage
0040             ;;
0041     esac
0042 done
0043 shift $((OPTIND-1))
0044 
0045 if [ -z "${QUEUENAME}" ] || [ -z "${TOPDIR}" ] || [ -z "${HARVESTERID}" ] || [ -z "${BATCH_SYSTEM}" ]; then
0046     usage
0047     exit 1
0048 fi
0049 
0050 cat << EOF
0051 QUEUENAME=${QUEUENAME}
0052 TOPDIR=${TOPDIR}
0053 PATH_TO_PROXY=${PATH_TO_PROXY}
0054 HARVESTERID=${HARVESTERID}
0055 BATCH_SYSTEM=${BATCH_SYSTEM}
0056 PATH_TO_CERTIFICATES=${PATH_TO_CERTIFICATES}
0057 EOF
0058 
0059 # checking python version
0060 if [ -z "$(python --version 2>&1 | grep 2.7)" ]; then
0061     echo "Python 2.7 is recommended"
0062 fi
0063 
0064 # check for virtualenv
0065 python -c "import virtualenv" 2>/dev/null || (echo "No virtualenv installed, exiting..." ; exit 1 )
0066 
0067 
0068 # check top dir exists, then - writeable
0069 [[ -e "${TOPDIR}" ]] && [[ ! -w "${TOPDIR}" ]] && (echo "Installation directory exists but not writeable, exiting..." ; exit 1)
0070 
0071 # check top dir is writeable
0072 if [ ! -e "${TOPDIR}" ]; then
0073     mkdir -p ${TOPDIR} || (echo "Error creating installation directory, exiting..." ; exit 1 )
0074 fi
0075 
0076 cd ${TOPDIR}
0077 
0078 #virtualenv harvester-venv # or: python -m virtualenv harvester-vens  # or: python -m venv harvester-venv (for python 3)
0079 python -m virtualenv "harvester-${HARVESTERID}"
0080 cd "harvester-${HARVESTERID}"
0081 . bin/activate
0082 
0083 # install additional python packages if missing
0084 pip install pip --upgrade
0085 
0086 # install panda components
0087 # do not run this one: pip install git+git://github.com/PanDAWMS/panda-harvester.git
0088 
0089 pip install ${HARVESTER_REPO}  --upgrade
0090 pip install saga-python backports.ssl-match-hostname
0091 
0092 # copy sample setup and config files
0093 mv etc/sysconfig/panda_harvester.rpmnew.template  etc/sysconfig/panda_harvester
0094 
0095 # mv etc/panda/panda_common.cfg.rpmnew.template etc/panda/panda_common.cfg
0096 # mv etc/panda/panda_harvester.cfg.rpmnew.template etc/panda/panda_harvester.cfg
0097 
0098 mkdir -p var/log/panda var/harvester
0099 
0100 export PANDA_HOME=$VIRTUAL_ENV
0101 export PYTHONPATH=$VIRTUAL_ENV/lib/python2.7/site-packages/pandacommon:$VIRTUAL_ENV/lib/python2.7/site-packages
0102 
0103 # add these values to “activate” script so you do not have to re-enter them every time on virtual env boot
0104 cat << EOF >> ${VIRTUAL_ENV}/bin/activate
0105 export PANDA_HOME=\$VIRTUAL_ENV
0106 export PYTHONPATH=\$VIRTUAL_ENV/lib/python2.7/site-packages/pandacommon:$VIRTUAL_ENV/lib/python2.7/site-packages
0107 EOF
0108 
0109 # copy panda_harvester.cfg , panda_common.cfg , EC2_queueconfig_LQCD.json to $VIRTUAL_ENV/etc/panda/
0110 wget https://www.dropbox.com/s/dcr3rysrtmo1cjs/panda_common.cfg?dl=0 -O etc/panda/panda_common.cfg
0111 wget https://www.dropbox.com/s/2fkakqwgbfhgdxl/panda_harvester.cfg?dl=0 -O etc/panda/panda_harvester.cfg
0112 wget https://www.dropbox.com/s/ijlhb1mpmbdvloo/EC2_queueconfig.json?dl=0 -O etc/panda/EC2_queueconfig.json
0113 
0114 # putting values into configuration
0115 sed -i -e "s#\${BASE_DIR}#$VIRTUAL_ENV#" etc/panda/panda_common.cfg
0116 sed -i -e "s#\${BASE_DIR}#$VIRTUAL_ENV#" etc/panda/panda_harvester.cfg
0117 
0118 # fix “uname” and “gname” items with actual values of username/groupname
0119 sed -i -e "s#\${USERNAME}#$USERNAME#" etc/panda/panda_harvester.cfg
0120 sed -i -e "s#\${GROUPNAME}#$GROUPNAME#" etc/panda/panda_harvester.cfg
0121 sed -i -e "s#\${HARVESTERID}#$HARVESTERID#" etc/panda/panda_harvester.cfg
0122 sed -i -e "s#\${QUEUENAME}#$QUEUENAME#" etc/panda/panda_harvester.cfg
0123 sed -i -e "s#\${PATH_TO_PROXY}#$PATH_TO_PROXY#" etc/panda/panda_harvester.cfg
0124 sed -i -e "s#\${PATH_TO_CERTIFICATES}#$PATH_TO_CERTIFICATES#" etc/panda/panda_harvester.cfg
0125 
0126 # putting values into queue file
0127 sed -i -e "s#\${QUEUENAME}#$QUEUENAME#" etc/panda/EC2_queueconfig.json
0128 sed -i -e "s#\${BATCH_SYSTEM}#$BATCH_SYSTEM#" etc/panda/EC2_queueconfig.json
0129 sed -i -e "s#\${TOP_DIR}#$TOPDIR#" etc/panda/EC2_queueconfig.json
0130 
0131 # update paths to your proxy in items “key_file” , “cert_file” and point “ca_cert” to a right directory with CA certificates, usually it is “/etc/grid-security/certificates"
0132 
0133 mkdir ${VIRTUAL_ENV}/../harvester-messenger \
0134     ${VIRTUAL_ENV}/../harvester-preparator \
0135     ${VIRTUAL_ENV}/../harvester-worker-maker
0136 
0137 # and update the corresponding paths in etc/panda/EC2_queueconfig_LQCD.json
0138 
0139 # copy corresponding attached files to files to locations:
0140 mv ${VIRTUAL_ENV}/lib/python2.7/site-packages/pandaharvester/harvestermonitor/saga_monitor.py ${VIRTUAL_ENV}/lib/python2.7/site-packages/pandaharvester/harvestermonitor/saga_monitor.py.orig
0141 wget https://www.dropbox.com/s/bz3tie6xbug8lpz/saga_monitor.py?dl=0 -O ${VIRTUAL_ENV}/lib/python2.7/site-packages/pandaharvester/harvestermonitor/saga_monitor.py
0142 wget https://www.dropbox.com/s/o9iygiidlj2d7a2/saga_yaml_submitter.py?dl=0 -O ${VIRTUAL_ENV}/lib/python2.7/site-packages/pandaharvester/harvestersubmitter/saga_yaml_submitter.py
0143 
0144 
0145 # copy start_harvester.sh , stop_harvester.sh , clean_logs.sh to ${VIRTUAL_ENV}
0146 cat << EOF > ./start_harvester.sh
0147 #!/bin/bash
0148 python lib/python*/site-packages/pandaharvester/harvesterbody/master.py --pid $PWD/tmp.pid
0149 EOF
0150 
0151 
0152 cat << EOF > ./stop_harvester.sh
0153 #!/bin/bash
0154 kill -USR2 \`cat $PWD/tmp.pid\`
0155 EOF
0156 
0157 
0158 cat << EOF > ./clean_logs.sh
0159 #!/bin/bash
0160 
0161 if [ -z $VIRTUAL_ENV ]; then
0162         exit 0
0163 fi
0164 
0165 rm -f $VIRTUAL_ENV/var/log/panda/*
0166 echo Logs cleaned
0167 EOF
0168 
0169 chmod +x ./start_harvester.sh ./stop_harvester.sh ./clean_logs.sh