1#!/bin/sh
2#
3# Create the sed file for configuring everything
4#
5
6BAREOS_SOURCE=`cd .. && pwd`
7
8cwd=`pwd`
9. ${cwd}/scripts/functions
10mkdir -p ${bin}
11mkdir -p ${tmp}
12out="${tmp}/sed_tmp"
13
14# set ports and other default parameters
15BASEPORT=${BASEPORT:-8101}
16AUTOCHANGER_SCRIPT=${AUTOCHANGER_SCRIPT:-mtx-changer}
17LIBDBI=${LIBDBI:-}
18libdbi=${LIBDBI}
19srcdir=${BAREOS_SOURCE}
20dirport=${BASEPORT}
21fdport=`expr ${BASEPORT} '+' 1`
22sdport=`expr ${BASEPORT} '+' 2`
23sdport2=`expr ${BASEPORT} '+' 3`
24db_type=${DBTYPE:-"postgresql"}
25db_name=${db_name:-"regress"}
26db_user=${db_user:-"regress"}
27db_password=${db_password:-""}
28os=`uname -s`
29# Drop Linux or FreeBSD from OS to shorten name
30if test ${os} = "Linux" -o ${os} = "FreeBSD"; then
31  os=`./scripts/get-os`
32else
33  os=${os}-`./scripts/get-os`
34fi
35if [ -r ${srcdir}/core/src/include/version.h ]; then
36  bversion=`sed -n -e 's/^.*VERSION.*"\(.*\)"$/\1/p' ${srcdir}/core/src/include/version.h`
37  bdate=`sed -n -e 's/^.*LSMDATE.*"\(.*\)"$/\1/p' ${srcdir}/core/src/include/version.h`
38fi
39
40if git --version >/dev/null; then
41   cd  ${srcdir}
42   gitbranch=`git rev-parse --abbrev-ref HEAD`
43   gitrev=`git rev-parse --short HEAD`
44   cd -
45   regress_gitbranch=`git rev-parse --abbrev-ref HEAD`
46   regress_gitrev=`git rev-parse --short HEAD`
47fi
48
49builddir="${src}"
50hostname="${hostname:-$HOST}"
51
52# get git info
53regress_gitrev=""
54bareos_gitrev=""
55
56cd $cwd
57regress_gitrev=`git show -s --format=%h HEAD`
58cd -
59
60cd ${BAREOS_SOURCE}
61bareos_gitrev=`git show -s --format=%h HEAD`
62cd -
63
64GCOV=`which gcov`
65PERL=`which perl`
66
67. ./config
68
69# Create sed command script
70>${out}
71echo "s%@bareos_gitrev@%${bareos_gitrev}%g" >>${out}
72echo "s%@regress_gitrev@%${regress_gitrev}%g" >>${out}
73echo "s%@archivedir@%${tmp}%g" >>${out}
74echo "s%@bindir@%${bin}%g" >>${out}
75echo "s%@sbindir@%${bin}%g" >>${out}
76echo "s%@scriptdir@%${scripts}%g" >>${out}
77echo "s%@scripts@%${scripts}%g" >>${out}
78echo "s%@rscripts@%${rscripts}%g" >>${out}
79echo "s%@plugindir@%${plugindir}%g" >>${out}
80echo "s%@plugindirtmp@%${plugindirtmp}%g" >>${out}
81echo "s%@working_dir@%${working}%g" >>${out}
82echo "s%@piddir@%${working}%g" >>${out}
83echo "s%@job_email@%${EMAIL}%g" >>${out}
84echo "s%@tape_drive@%${TAPE_DRIVE}%g" >>${out}
85echo "s%@autochanger@%${AUTOCHANGER}%g" >>${out}
86echo "s%@changer_script@%${AUTOCHANGER_SCRIPT}%g" >>${out}
87echo "s%@tmpdir@%${tmp}%g" >>${out}
88echo "s%@logdir@%${tmp}%g" >>${out}
89echo "s%@changer_path@%${AUTOCHANGER_PATH}%g" >>${out}
90echo "s%@tape_drive1@%${TAPE_DRIVE1}%g" >>${out}
91echo "s%@smtp_host@%${SMTP_HOST}%g" >>${out}
92echo "s%@disk_drive@%${tmp}/disk-changer%g" >>${out}
93echo "s%@basename@%${HOST}%g" >>${out}
94echo "s%@hostname@%${hostname}%g" >>${out}
95echo "s%@hostname1@%${hostname1}%g" >>${out}
96echo "s%@hostname2@%${hostname2}%g" >>${out}
97echo "s%@hostname3@%${hostname3}%g" >>${out}
98echo "s%@hostname_files@%${hostname_files}%g" >>${out}
99echo "s%@hostname1_files@%${hostname1_files}%g" >>${out}
100echo "s%@hostname2_files@%${hostname2_files}%g" >>${out}
101echo "s%@hostname3_files@%${hostname3_files}%g" >>${out}
102echo "s%@hostname1_password@%${hostname1_password}%g" >>${out}
103echo "s%@hostname2_password@%${hostname2_password}%g" >>${out}
104echo "s%@hostname3_password@%${hostname3_password}%g" >>${out}
105echo "s%@dirport@%${dirport}%g" >>${out}
106echo "s%@dir_port@%${dirport}%g" >>${out}
107echo "s%@sdport@%${sdport}%g" >>${out}
108echo "s%@sdport2@%${sdport2}%g" >>${out}
109echo "s%@fdport@%${fdport}%g" >>${out}
110echo "s%@regressdir@%${cwd}%g" >>${out}
111echo "s%@webuidir@%${BAREOS_SOURCE}/webui%g" >>${out}
112echo "s%@srcdir@%${srcdir}%g" >>${out}
113echo "s%@sitename@%${SITE_NAME}%g" >>${out}
114echo "s%@os@%${os}%g" >>${out}
115echo "s%@bversion@%${bversion}%g" >>${out}
116echo "s%@bdate@%${bdate}%g" >>${out}
117echo "s%@libdbi@%${libdbi}%g" >>${out}
118echo "s%@win32_client@%${WIN32_CLIENT}%g" >>${out}
119echo "s%@win32_addr@%${WIN32_ADDR}%g" >>${out}
120echo "s%@win32_store_addr@%${WIN32_STORE_ADDR}%g" >>${out}
121echo "s%@win32_file@%${WIN32_FILE}%g" >>${out}
122echo "s%@win32_port@%${WIN32_PORT}%g" >>${out}
123echo "s%@win32_password@%${WIN32_PASSWORD}%g" >>${out}
124echo "s%@db_type@%${DBTYPE}%g" >>${out}
125echo "s%@db_name@%${db_name}%g" >>${out}
126echo "s%@db_user@%${db_user}%g" >>${out}
127echo "s%@db_password@%${db_password}%g" >>${out}
128echo "s%@builddir@%${builddir}%g" >>${out}
129echo "s%@BUILD_DIR@%${builddir}%g" >>${out}
130echo "s%@confdir@%${confdir}%g" >>${out}
131echo "s%@uncomment_dbi@%#%g" >>${out}
132echo "s%@gitbranch@%${gitbranch}%g" >>${out}
133echo "s%@gitrev@%${gitrev}%g" >>${out}
134echo "s%@regress_gitbranch@%${regress_gitbranch}%g" >>${out}
135echo "s%@regress_gitrev@%${regress_gitrev}%g" >>${out}
136echo "s%@GCOV@%${GCOV}%g" >>${out}
137echo "s%@PERL@%${PERL}%g" >>${out}
138
139if [ -n "${TRAYMON}" ] ; then
140  echo "s%#ADD_TEST(disk:tray-monitor-connection-test-cleartext%ADD_TEST(disk:tray-monitor-connection-test-cleartext%g" >> ${out}
141  echo "s%#ADD_TEST(disk:tray-monitor-connection-test-tls-psk%ADD_TEST(disk:tray-monitor-connection-test-tls-psk%g" >> ${out}
142fi
143