1# Common shell functions and variables that all pounder scripts can use.
2
3# Copyright (C) 2003-2006 IBM
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License as
7# published by the Free Software Foundation; either version 2 of the
8# License, or (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18# 02111-1307, USA.
19
20# Start by setting environment variables...
21export DATE=`date +%Y%h%d-%H%M%S`
22
23export DEFAULT_SCHEDPACK=default
24export TESTS=`/bin/ls test_scripts/`
25export BUILDS=`/bin/ls build_scripts/`
26export POUNDER_HOME=`pwd`
27export POUNDER_PIDFILE="$POUNDER_HOME/pounder.pid"
28export POUNDER_LOGLOCAL="$POUNDER_HOME/log"
29export POUNDER_LOGDIR="$POUNDER_LOGLOCAL/$DATE/"
30export POUNDER_TMPDIR="$POUNDER_HOME/tmp/"
31export POUNDER_OPTDIR="$POUNDER_HOME/opt/"
32export POUNDER_SRCDIR="$POUNDER_HOME/src/"
33export POUNDER_VERSION=`head -1 "$POUNDER_HOME/README" | awk -F " " '{print $3}' | sed -e 's/\.//g'`
34export NR_CPUS=`getconf _NPROCESSORS_ONLN`
35export NFS_LOGLOCAL="`echo "$HOSTNAME" | sed -e 's/\..*//g'`/`uname -r`-`uname -m`"
36
37if [ -e "$POUNDER_HOME/config" ]; then
38	source "$POUNDER_HOME/config"
39fi
40
41function get_from_sourceforge {
42	PROGNAME=$1
43	TARNAME=$2
44
45	# Correct arguments?
46	if [ -z "$1" -o -z "$2" ]; then
47		echo "get_from_sourceforge: Called with empty arguments."
48		exit
49	fi
50
51	# File already exists?
52	if [ -f "$TARNAME" ]; then
53		echo "get_from_sourceforge: Target file already exists."
54		exit
55	fi
56
57	# Else try download...
58	for SERVER in voxel.dl.sourceforge.net easynews.dl.sourceforge.net umn.dl.sourceforge.net; do
59		wget -t 1 --timeout=15 "http://$SERVER/sourceforge/$PROGNAME/$TARNAME"
60
61		if [ -f "$TARNAME" ]; then
62			break
63		fi
64	done
65}
66