1#! /bin/bash
2#
3# Copyright (C) 2010 Igalia S.L. All rights reserved.
4#
5# This library is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Library General Public
7# License as published by the Free Software Foundation; either
8# version 2 of the License, or (at your option) any later version.
9#
10# This library is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13# Library General Public License for more details.
14#
15# You should have received a copy of the GNU Library General Public License
16# along with this library; see the file COPYING.LIB.  If not, write to
17# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18# Boston, MA 02110-1301, USA.
19
20exec 2>&1
21
22: ${BUILDBOT_CONFIG:=/etc/daemontools-buildbot.conf}
23
24# Read configuration file
25[ -r "${BUILDBOT_CONFIG}" ] && . "${BUILDBOT_CONFIG}"
26
27# Expand all "env_*" environment variables
28for varname in ${!env_*} ; do
29	eval "export ${varname#env_}=\${${varname}}"
30done
31
32
33if ! [ "${buildbot_path}" ] ; then
34	echo "No \${buildbot_path} defined! (will sleep for 5 minutes)"
35	sleep 300
36	exit 111
37fi
38
39
40if ! [ "${WEBKIT_TESTFONTS}" ] ; then
41	echo "No \${WEBKIT_TESTFONTS} environment variable! (will sleep for 5 minutes)"
42	sleep 300
43	exit 111
44fi
45
46
47if [ "${coredump_output:=''}" ] ; then
48	# Ensure that the output directory exists.
49	if [[ ! -d ${crashmon_output} ]] ; then
50		mkdir -p "${crashmon_output}"
51	fi
52
53	ulimit -c "${crashmon_max_size:=unlimited}"
54fi
55
56
57if [ "${ccache_path}" ] ; then
58	export PATH="${ccache_path}:${PATH}"
59fi
60
61: ${buildbot_user:=${USER}}
62
63cd "${buildbot_path}"
64exec /usr/bin/env -          \
65		TERM=dumb                 \
66		TZ=PST8PDT                 \
67		PATH="${PATH}"              \
68		SHELL=/bin/bash              \
69		LANG=en_US.UTF-8              \
70		USER="${buildbot_user}"        \
71		LOGNAME="${buildbot_user}"      \
72		HOME="/home/${buildbot_user}"    \
73		DISPLAY="${xvfb_display:-':10'}"  \
74		MAIL="/var/mail/${buildbot_user}"  \
75	/usr/bin/setuidgid "${buildbot_user}" \
76	/usr/bin/twistd -noy buildbot.tac
77
78