bootstrap 13.3 KB
Newer Older
Laurence Field's avatar
Laurence Field committed
1
#!/bin/bash
Laurence Field's avatar
Laurence Field committed
2 3 4 5 6 7 8 9 10 11
#
#  Copyright (c) CERN 2016
#
#  Licensed under the Apache License, Version 2.0
#
#  Author: Laurence Field
#

printf "\033c" & # Clears the console 

Laurence Field's avatar
Laurence Field committed
12 13 14 15 16 17
logging_functions="/cvmfs/grid.cern.ch/vc/bin/logging_functions"
if [ -e ${logging_functions} ]; then
    . ${logging_functions}
else
    echo "ERROR Could not source logging functions from ${logging_functions}." 1>&2
fi
Laurence Field's avatar
Laurence Field committed
18 19

log_info "Mounting the shared directory"
Laurence Field's avatar
Laurence Field committed
20
shared_dir="/var/lib/boinc/shared"
Laurence Field's avatar
Laurence Field committed
21
mkdir -p ${shared_dir}
Laurence Field's avatar
Laurence Field committed
22
mount -t vboxsf -ouid=500,gid=486 shared ${shared_dir} 2>/dev/null
Laurence Field's avatar
Laurence Field committed
23
if mount | grep ${shared_dir} > /dev/null; then
Laurence Field's avatar
Laurence Field committed
24
    log_info "Shared directory mounted, enabling vboxmonitor"
Laurence Field's avatar
Laurence Field committed
25
    ln -sf /cvmfs/grid.cern.ch/vc/sbin/vboxmonitor_26086_$(uname -i)-pc-linux-gnu /sbin/vboxmonitor
Laurence Field's avatar
Laurence Field committed
26 27
    sed -i 's/^# %wheel/%wheel/' /etc/sudoers
    sed -i '/^Defaults *requiretty$/d' /etc/sudoers
28
    sed -i 's/#.%users *localhost.*/nobody ALL=(ALL) NOPASSWD:\/sbin\/vboxmonitor/' /etc/sudoers
Laurence Field's avatar
Laurence Field committed
29 30
else
    log_warning "Shared directory not mounted, assuming VM deployment"
Laurence Field's avatar
Laurence Field committed
31 32
fi

Laurence Field's avatar
Laurence Field committed
33 34 35 36 37 38
if [ ! -e ${shared_dir}/init_data.xml ]; then
    boinc-shutdown 206 "File init_data.xml not found in ${shared_dir}"
    exit 1
fi

# Remove domain_name from xml due to character encoding issue
39
sed '/<host_info>/,/<\/host_info>/ d' -i ${shared_dir}/init_data.xml
Laurence Field's avatar
Laurence Field committed
40

Laurence Field's avatar
Laurence Field committed
41
log_debug "Testing network connection to cern.ch on port 80"
Laurence Field's avatar
Laurence Field committed
42
nc -z -v -w 30 cern.ch 80 >/tmp/stdout 2>/tmp/stderr
Laurence Field's avatar
Laurence Field committed
43 44 45
result=$?
log_debug "$(cat /tmp/stdout /tmp/stderr)"
log_debug "$result"
Laurence Field's avatar
Laurence Field committed
46
if [ ! ${result} -eq 0 ]; then
Laurence Field's avatar
Laurence Field committed
47 48 49
    boinc-shutdown -203 "Could not connect to cern.ch on port 80"
    exit 1
fi
Laurence Field's avatar
Laurence Field committed
50 51
log_debug "Testing VCCS connection to vccs.cern.ch on port 443"
nc -z -v -w 30 vccs.cern.ch 443  >/tmp/stdout 2>/tmp/stderr
Laurence Field's avatar
Laurence Field committed
52 53 54 55
result=$?
log_debug "$(cat /tmp/stdout /tmp/stderr)"
log_debug "$result"
if [ ! ${result} -eq 0 ]; then
Laurence Field's avatar
Laurence Field committed
56
    boinc-shutdown -152 "Could not connect to vccs.cern.ch on port 443"
Laurence Field's avatar
Laurence Field committed
57 58
    exit 1
fi
Laurence Field's avatar
Laurence Field committed
59
log_debug "Testing connection to Condor server on port 9618"
Laurence Field's avatar
Laurence Field committed
60
for run in {1..3}; do
Laurence Field's avatar
Laurence Field committed
61
    nc -z -v -w 30 vocms0840.cern.ch 9618 >/tmp/stdout 2>/tmp/stderr
Laurence Field's avatar
Laurence Field committed
62 63 64 65 66 67 68 69 70 71 72 73
    result=$?
    log_debug "$(cat /tmp/stdout /tmp/stderr)"
    log_debug "$result"
    if [ ! ${result} -eq 0 ]; then
	if [ $run -eq 3 ]; then
	    boinc-shutdown -152 "Could not connect to Condor server on port 9618"
	    exit 1
	fi
    else
	break
    fi
done
Laurence Field's avatar
Laurence Field committed
74

lfield's avatar
lfield committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
# A local wpad file must be created
local_wpad_file="/var/www/html/wpad.dat"
wget -q http://lhchomeproxy.cern.ch/wpad.dat -O ${local_wpad_file}

if [ ${?} -ne 0 ]
then
    wget -q http://lhchomeproxy.fnal.gov/wpad.dat -O ${local_wpad_file}

    if [ ${?} -ne 0 ]
    then
        # Basic configuration if lhchomeproxy can't be reached
        echo -e "function FindProxyForURL(url, host) {\n    return \"DIRECT\";\n}" > ${local_wpad_file}
    fi
    
fi

# Modify the wpad file if a local http proxy is configured

lfield's avatar
lfield committed
93 94 95
if xmllint ${shared_dir}/init_data.xml | grep "<use_http_proxy/>" >/dev/null 2>&1
then 
    PROXY_HOST="$(xmllint ${shared_dir}/init_data.xml | grep "<http_server_name" | cut -d ">" -f2 | cut -d "<" -f1)"
Laurence Field's avatar
Laurence Field committed
96
    PROXY_HOST="${PROXY_HOST#"http://"}"    # remove the protocol prefix if it exists.
lfield's avatar
lfield committed
97 98 99 100
    PROXY_PORT="$(xmllint ${shared_dir}/init_data.xml | grep "<http_server_port" | cut -d ">" -f2 | cut -d "<" -f1)"
    
    if [ -n "${PROXY_HOST}" ] && [ -n "${PROXY_PORT}" ]
    then
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
        log_debug "Detected local proxy http://${PROXY_HOST}:${PROXY_PORT} in init_data.xml"
        log_debug "Testing connection to ${PROXY_HOST} on port ${PROXY_PORT}"
        nc -z -v -w 3 ${PROXY_HOST} ${PROXY_PORT} >/tmp/stdout 2>/tmp/stderr
        result=$?
        log_debug "$(cat /tmp/stdout /tmp/stderr)"
        log_debug "$result"

        if [ ${result} -eq 0 ]
        then
            echo -e "function FindProxyForURL(url, host) {\n    return \"PROXY http://${PROXY_HOST}:${PROXY_PORT}; DIRECT\";\n}" >${local_wpad_file}
        else
            log_debug "Local proxy can't be contacted and will be ignored"
            unset PROXY_HOST
            unset PROXY_PORT
        fi
Laurence Field's avatar
Laurence Field committed
116 117
    fi
fi
lfield's avatar
testing  
lfield committed
118

lfield's avatar
lfield committed
119 120 121 122 123 124 125 126 127
# Setup the Web server
if [ -f /sbin/vboxmonitor ]; then
    cp /cvmfs/grid.cern.ch/vc/etc/html/index.html /var/www/html/
    service httpd start
fi

# Configure CVMFS to prefer the local wpad file and keep lhchomeproxy as fallback
sed -e "s#CVMFS_HTTP_PROXY=.*#CVMFS_HTTP_PROXY=\"auto\"#" -i /etc/cvmfs/default.local
sed -e "s#CVMFS_PAC_URLS=.*#CVMFS_PAC_URLS=\"http://localhost/wpad.dat;http://lhchomeproxy.cern.ch/wpad.dat;http://lhchomeproxy.fnal.gov/wpad.dat\"#" -i /etc/cvmfs/default.local
Laurence Field's avatar
Laurence Field committed
128
echo "CVMFS_SEND_INFO_HEADER=yes" >> /etc/cvmfs/default.local
Laurence Field's avatar
Laurence Field committed
129 130
# CVMFS might be more patient on slow or overloaded home networks
echo "CVMFS_MAX_RETRIES=3" >> /etc/cvmfs/default.local
lfield's avatar
lfield committed
131

Laurence Field's avatar
Laurence Field committed
132
# Update CVMFS servers
Laurence Field's avatar
Laurence Field committed
133 134
echo 'CVMFS_SERVER_URL="http://s1cern-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1fnal-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1ihep-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1ral-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1bnl-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1unl-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1asgc-cvmfs.openhtc.io:8080/cvmfs/@fqrn@"' >> /etc/cvmfs/domain.d/cern.ch.local
echo 'CVMFS_SERVER_URL="http://s1nikhef-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1fnal-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1ihep-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1ral-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1bnl-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1unl-cvmfs.openhtc.io/cvmfs/@fqrn@;http://s1asgc-cvmfs.openhtc.io:8080/cvmfs/@fqrn@"' >> /etc/cvmfs/domain.d/opensciencegrid.org.local
Laurence Field's avatar
Laurence Field committed
135 136


137 138 139 140 141 142 143 144
# Add app specific repositories
case ${BOINC_APPNAME} in
    'CMS')
    sed -i "s/^CVMFS_REPOSITORIES=.*/CVMFS_REPOSITORIES=grid,cms,singularity.opensciencegrid.org,oasis.opensciencegrid.org/" /etc/cvmfs/default.local
    ;;
esac


lfield's avatar
lfield committed
145 146 147 148
# activate the new CVMFS configuration
cvmfs_config reload


Laurence Field's avatar
Laurence Field committed
149 150 151 152
log_debug "Probing CVMFS ..."
cvmfs_config probe grid.cern.ch 2>&1 | sudo /sbin/vboxmonitor
cvmfs_config stat grid.cern.ch 2>&1 | sudo /sbin/vboxmonitor

Laurence Field's avatar
Laurence Field committed
153
# Add some commands
Laurence Field's avatar
Laurence Field committed
154 155 156 157 158
/bin/cp /cvmfs/grid.cern.ch/vc/bin/gfal-copy /usr/bin/
/bin/cp /cvmfs/grid.cern.ch/vc/bin/gfal-rm /usr/bin/
/bin/cp /cvmfs/grid.cern.ch/vc/bin/boinc-proxy /usr/bin/
/bin/cp /cvmfs/grid.cern.ch/vc/sbin/boinc-shutdown /usr/sbin/
/bin/cp /cvmfs/grid.cern.ch/vc/bin/dumbq-logcat /usr/bin/
Laurence Field's avatar
Laurence Field committed
159

Laurence Field's avatar
Laurence Field committed
160 161 162 163 164 165
# Copy certificates locally and install the Volunteer CA
rm -rf /etc/grid-security/certificates
mkdir /etc/grid-security/certificates
cp -r /cvmfs/grid.cern.ch/etc/grid-security/certificates/* /etc/grid-security/certificates/
cp -r /cvmfs/grid.cern.ch/vc/etc/grid-security/certificates/* /etc/grid-security/certificates/

Laurence Field's avatar
Laurence Field committed
166
log_info "Reading volunteer information"
Laurence Field's avatar
Laurence Field committed
167 168
boinc_config="/cvmfs/grid.cern.ch/vc/bin/boinc-config"
if [ -e ${boinc_config} ]; then
Laurence Field's avatar
Laurence Field committed
169
    . ${boinc_config}
Laurence Field's avatar
Laurence Field committed
170
    if [ ! $? -eq 0 ]; then
Laurence Field's avatar
Laurence Field committed
171
	boinc-shutdown 206 "Could not get the BOINC configuration values"
Laurence Field's avatar
Laurence Field committed
172 173
	exit 1
    fi
Laurence Field's avatar
Laurence Field committed
174
else
Laurence Field's avatar
Laurence Field committed
175
    boinc-shutdown 206 "BOINC config script ${boinc_config} does not exist."
Laurence Field's avatar
Laurence Field committed
176
    exit 1
Laurence Field's avatar
Laurence Field committed
177 178
fi

179
log_info "Volunteer: ${BOINC_USERNAME} (${BOINC_USERID})"
Laurence Field's avatar
Laurence Field committed
180
if ! [[ ${BOINC_USERID} =~ ^[0-9]+$ ]]; then
Laurence Field's avatar
Laurence Field committed
181
    xmllint ${shared_dir}/init_data.xml 2>/tmp/output
182 183
    log_debug "xmllint returned:"
    log_debug "$(cat /tmp/output)"
Laurence Field's avatar
Laurence Field committed
184
    boinc-shutdown 206 "BOINC_USERID ${BOINC_USERID} is not an integer."
Laurence Field's avatar
Laurence Field committed
185
    exit 1
Laurence Field's avatar
Laurence Field committed
186 187
fi

Laurence Field's avatar
Laurence Field committed
188
# Easter egg for the Kansas City challenge.
189
if [ ${BOINC_TEAMID} -eq 2839 ]; then
Laurence Field's avatar
Laurence Field committed
190 191 192 193
    log_info "Hey! You're from Kansas City."
    log_info "We have something special for you."
fi

Laurence Field's avatar
Laurence Field committed
194 195 196 197 198
export $(cat /etc/cernvm/machine.conf)
log_info "VMID: ${CERNVM_UUID}"

# Set the hostname if needed
if [ -f /sbin/vboxmonitor ]; then
Laurence Field's avatar
Laurence Field committed
199
    HOSTNAME=${BOINC_USERID}-${BOINC_HOSTID}-${RANDOM}
Laurence Field's avatar
Laurence Field committed
200 201 202 203 204
    grep ${HOSTNAME} /etc/hosts >/dev/null 2>&1
    if [ $? = 1 ]; then 
	echo "127.0.0.1    ${HOSTNAME}" 127.0.0.1 >> /etc/hosts
    fi
    hostname ${HOSTNAME}
Laurence Field's avatar
Laurence Field committed
205
fi
Laurence Field's avatar
Laurence Field committed
206

Laurence Field's avatar
Laurence Field committed
207 208
boinc-proxy
if [ $? = 1 ] || [ ! -e /tmp/x509up_u$(id -u) ]; then
Laurence Field's avatar
Laurence Field committed
209
    boinc-shutdown 206 "The x509 proxy creation failed."
Laurence Field's avatar
Laurence Field committed
210
    exit 1
Laurence Field's avatar
Laurence Field committed
211 212
fi

Laurence Field's avatar
Laurence Field committed
213
output_dir="/var/www/html/logs"
Laurence Field's avatar
Laurence Field committed
214
mkdir -p ${output_dir}
Laurence Field's avatar
Laurence Field committed
215

Laurence Field's avatar
Laurence Field committed
216
# Setup the consoles
Laurence Field's avatar
Laurence Field committed
217
bash -c "python /usr/bin/dumbq-logcat ${output_dir}/running.log[white] >/dev/tty2 2>/dev/null" &
Laurence Field's avatar
Laurence Field committed
218
bash -c "top 2>&1 >/dev/tty3 2>/dev/null </dev/tty3" &
Laurence Field's avatar
Laurence Field committed
219 220
bash -c "python /usr/bin/dumbq-logcat ${output_dir}/stdout.log[white] >/dev/tty4 2>/dev/null" &
bash -c "python /usr/bin/dumbq-logcat ${output_dir}/stderr.log[white] >/dev/tty5 2>/dev/null" &
Laurence Field's avatar
Laurence Field committed
221

Laurence Field's avatar
Laurence Field committed
222 223 224 225
echo "Running job output should appear here."  > ${output_dir}/running.log
echo "Output of the job wrapper may appear here."  > ${output_dir}/stdout.log
echo "Error messages may appear here."  > ${output_dir}/stderr.log

Laurence Field's avatar
Laurence Field committed
226 227
chmod -R a+w ${output_dir} # Needs to be here so files above are writeable

Laurence Field's avatar
Laurence Field committed
228
# Setup the heartbeat cron job
229
echo "* * * * * root touch ${shared_dir}/heartbeat " > /etc/cron.d/heartbeat-agent
Laurence Field's avatar
Laurence Field committed
230

Laurence Field's avatar
Laurence Field committed
231 232 233 234
# Setup swap if not found
if [ $(swapon -s | wc -l ) -lt 2 ]; then 
    fallocate -l 1G /mnt/.rw/swapfile
    chmod 0600 /mnt/.rw/swapfile
Laurence Field's avatar
Laurence Field committed
235
    mkswap /mnt/.rw/swapfile >/dev/null 2>/dev/null
Laurence Field's avatar
Laurence Field committed
236
    swapon /mnt/.rw/swapfile >/dev/null
Laurence Field's avatar
Laurence Field committed
237
fi
Laurence Field's avatar
Laurence Field committed
238

Laurence Field's avatar
Laurence Field committed
239 240
chkconfig --del vmcontext_epilog # To avoid starting message. 

Laurence Field's avatar
Laurence Field committed
241
# Special speed test for the Kansas City challenge.
Laurence Field's avatar
Laurence Field committed
242
#if [ ${BOINC_TEAMID} -eq 2839 ]; then
Laurence Field's avatar
Laurence Field committed
243
if [ ${BOINC_TEAMID} -eq -1 ]; then # disabling
Laurence Field's avatar
Laurence Field committed
244 245 246 247
    log_info "Checking conectivity with CERN ..."
    FILE=$(mktemp)
    rm -f ${FILE}
    log_info "Testing Download Speed ..."
Laurence Field's avatar
Laurence Field committed
248
    DOWN=$(/usr/bin/gfal-copy http://data-bridge.cern.ch/myfed/cms-boinc/input/speed-test.dat file://${FILE} | grep Bandwidth | cut -d ":" -f 2 2>/dev/null)
Laurence Field's avatar
Laurence Field committed
249 250 251
    log_info "Download: ${DOWN} B/s"
    log_info "Testing Upload Speed ..."
    NEW="result-${USERID}-${HOSTID}-$(date -u +%s).dat"
Laurence Field's avatar
Laurence Field committed
252
    UP=$(/usr/bin/gfal-copy file://${FILE} https://data-bridge.cern.ch/myfed/cms-boinc/output/speed-test/${NEW} | grep Bandwidth | cut -d ":" -f 2 2> /dev/null)
Laurence Field's avatar
Laurence Field committed
253
    log_info "Upload: ${UP} B/s"
Laurence Field's avatar
Laurence Field committed
254
    /usr/bin/gfal-rm https://data-bridge.cern.ch/myfed/cms-boinc/output/speed-test/${NEW} >/dev/null 2>&1
Laurence Field's avatar
Laurence Field committed
255 256
    rm -f ${FILE}
    cat <<EOF > /etc/condor/config.d/61-bandwidth.conf
Laurence Field's avatar
Laurence Field committed
257 258 259
BANDWIDTH_DOWNLOAD = ${DOWN}
BANDWIDTH_UPLOAD = ${UP}
BOINC_TEAM = "Kansas City"
Laurence Field's avatar
Laurence Field committed
260
STARTD_ATTRS = \$(STARTD_ATTRS), BANDWIDTH_DOWNLOAD, BANDWIDTH_UPLOAD, BOINC_TEAM
Laurence Field's avatar
Laurence Field committed
261
EOF
Laurence Field's avatar
Laurence Field committed
262 263
fi

Laurence Field's avatar
Laurence Field committed
264 265
log_info "Running the fast benchmark."
HEPSPEC06=$(/cvmfs/grid.cern.ch/vc/bin/DIRACbenchmark.py wholenode | cut -d',' -f2|  sed s'/.*: //')
Laurence Field's avatar
Laurence Field committed
266
HEPSPEC06=$(printf "%0.2f" ${HEPSPEC06})
267
log_info "Machine performance ${HEPSPEC06} HEPSPEC06"
Laurence Field's avatar
Laurence Field committed
268 269
echo "HEPSPEC06=${HEPSPEC06}" > /etc/condor/config.d/62-benchmark.conf
echo "STARTD_ATTRS = \$(STARTD_ATTRS), HEPSPEC06" >> /etc/condor/config.d/62-benchmark.conf
Laurence Field's avatar
Laurence Field committed
270

Laurence Field's avatar
Laurence Field committed
271 272 273 274
if [ ${BOINC_APPNAME} = 'vboxwrapper' ]; then
    BOINC_APPNAME='Theory'
fi

Laurence Field's avatar
Laurence Field committed
275 276
log_info "${BOINC_APPNAME} application starting. Check log files."

Laurence Field's avatar
Laurence Field committed
277
case ${BOINC_APPNAME} in
Laurence Field's avatar
Laurence Field committed
278
    'CMS')
Laurence Field's avatar
Laurence Field committed
279
	cp /cvmfs/grid.cern.ch/vc/etc/condor/config.d/35_cms.config /etc/condor/config.d/
Laurence Field's avatar
Laurence Field committed
280 281
	wget https://gitlab.cern.ch/CMSSI/CMSglideinWMSValidation/raw/master/singularity_wrapper.sh -O /usr/local/bin/singularity_wrapper.sh
	chmod +x /usr/local/bin/singularity_wrapper.sh
Laurence Field's avatar
Laurence Field committed
282 283 284
	cp /tmp/x509up_u0 /tmp/x509up_u31961
	chown 31961:1399 /tmp/x509up_u31961 
	sed -i "s/hdfs/hdfs \/tmp/"  /usr/local/bin/singularity_wrapper.sh 
lfield's avatar
lfield committed
285 286
	sed -i "s/^enable overlay =.*/enable overlay = no/" /etc/singularity/singularity.conf
	sed -i "s/^max loop devices =.*/max loop devices = 0/" /etc/singularity/singularity.conf
lfield's avatar
testing  
lfield committed
287 288
	/cvmfs/grid.cern.ch/vc/bin/instant-glidein & >/dev/null 2>&1 </dev/null
	/cvmfs/grid.cern.ch/vc/bin/watch_logs & >/dev/null 2>&1 </dev/null
Laurence Field's avatar
Laurence Field committed
289 290
	;;
    'LHCb')
Laurence Field's avatar
Laurence Field committed
291 292 293 294 295
	# Setup MJF
	mkdir -p /etc/machinefeatures
	expr `date +'%s'` + 86400 > /etc/machinefeatures/shutdowntime
	echo 'export MACHINEFEATURES=/etc/machinefeatures' > /etc/profile.d/mjf.sh
	echo 'setenv MACHINEFEATURES /etc/machinefeatures' > /etc/profile.d/mjf.csh
Laurence Field's avatar
Laurence Field committed
296
	chown nobody:nobody /etc/grid-security/host*.pem
Laurence Field's avatar
Laurence Field committed
297
	cp /cvmfs/grid.cern.ch/vc/etc/condor/config.d/35_lhcb.config /etc/condor/config.d/
lfield's avatar
testing  
lfield committed
298
	#/cvmfs/grid.cern.ch/vc/bin/instant-glidein & >/dev/null 2>&1 </dev/null
Laurence Field's avatar
Laurence Field committed
299 300
	;;
    'Theory')
Laurence Field's avatar
Laurence Field committed
301
	# Test4Theory WebApp
Laurence Field's avatar
Laurence Field committed
302
	T4T_WEBAPP_TGZ="/cvmfs/grid.cern.ch/vc/var/www/t4t-webapp.tgz"
Laurence Field's avatar
Laurence Field committed
303
	T4T_WEBAPP_DST="/var/www/html"
Laurence Field's avatar
Laurence Field committed
304
	chmod a+w /var/www/html
Laurence Field's avatar
Laurence Field committed
305
	/bin/tar zxvf $T4T_WEBAPP_TGZ -C $T4T_WEBAPP_DST > /dev/null 2>&1
306
	chmod a+w -R /var/www/html/job
Laurence Field's avatar
Laurence Field committed
307
	ln -sf /cvmfs/grid.cern.ch/vc/bin/copilot-config /bin/
Laurence Field's avatar
Laurence Field committed
308
	cp /cvmfs/grid.cern.ch/vc/etc/condor/config.d/35_theory.config /etc/condor/config.d/
Laurence Field's avatar
Laurence Field committed
309
	/cvmfs/grid.cern.ch/vc/bin/instant-glidein & >/dev/null 2>&1 </dev/null
Laurence Field's avatar
Laurence Field committed
310
	;;
Laurence Field's avatar
Laurence Field committed
311 312
    'ATLAS')
	cp /cvmfs/grid.cern.ch/vc/etc/condor/config.d/35_atlas.config /etc/condor/config.d/
Laurence Field's avatar
Laurence Field committed
313
	/cvmfs/grid.cern.ch/vc/bin/instant-glidein & >/dev/null 2>&1 </dev/null
314
	;;
Laurence Field's avatar
Laurence Field committed
315 316
    'ALICE')
	cp /cvmfs/grid.cern.ch/vc/etc/condor/config.d/35_alice.config /etc/condor/config.d/
Laurence Field's avatar
Laurence Field committed
317
	/cvmfs/grid.cern.ch/vc/bin/instant-glidein & >/dev/null 2>&1 </dev/null
318
	;;
Laurence Field's avatar
Laurence Field committed
319
    'Benchmark')
Laurence Field's avatar
Laurence Field committed
320 321 322 323 324 325 326 327 328 329 330
	RUN_LOG="/var/www/html/logs/running.log"
	function link_log {
	    while true; do
		if [ -e /tmp/cern-benchmark_root/profiler.sh.out ]; then
		    ln -f /tmp/cern-benchmark_root/profiler.sh.out ${RUN_LOG}
		    break
		fi
		sleep 5
	    done
	}
	link_log &
331 332
	RESULT=$(xmllint ${shared_dir}/init_data.xml | grep "^<result_name" | cut -d ">" -f2 | cut -d "<" -f1)
	
Laurence Field's avatar
Laurence Field committed
333
	export BMK_ROOTDIR="/cvmfs/atlas.cern.ch/repo/benchmarks/cern/current"
334
	/cvmfs/atlas.cern.ch/repo/benchmarks/cern/current/cern-benchmark --benchmarks="kv" --cloud=BOINC --freetext="${RESULT}" --queue_host=dashb-test-mb.cern.ch --queue_port=61113 --username=vmspecprod --password=$(cat /etc/bmkpass) --topic=/topic/vm.spec --uid=${BOINC_USERID}-${BOINC_HOSTID}
Laurence Field's avatar
Laurence Field committed
335 336
	boinc-shutdown 0 "Benchmarking Finished"
	;;
Laurence Field's avatar
Laurence Field committed
337
    *)
Laurence Field's avatar
Laurence Field committed
338
	boinc-shutdown 206 "App ${BOINC_APPNAME} is not supported. Shutting down!"
Laurence Field's avatar
Laurence Field committed
339
	exit 1
Laurence Field's avatar
Laurence Field committed
340 341
	;;
    esac