blob: 90d49709f4e9524a3fa6b84049fcd7e95bb0d853 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#!/bin/sh
#
# Copyright (C) 2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# This is a "morph deploy" configuration extension to fully configure
# a Mason instance at deployment time. It uses the following variables
# from the environment:
#
# * ARTIFACT_CACHE_SERVER
# * MASON_CLUSTER_MORPHOLOGY
# * MASON_DEFINITIONS_REF
# * MASON_DISTBUILD_ARCH
# * MASON_TEST_HOST
# * TROVE_HOST
# * TROVE_ID
# * CONTROLLERHOST
set -e
ROOT="$1"
if [ "$ARTIFACT_CACHE_SERVER" = "" \
-o "$MASON_CLUSTER_MORPHOLOGY" = "" \
-o "$MASON_DEFINITIONS_REF" = "" \
-o "$MASON_DISTBUILD_ARCH" = "" \
-o "$MASON_TEST_HOST" = "" ]; then
echo Not configuring as Mason, some options not defined
exit 0
fi
##########################################################################
# Functions
##########################################################################
shellescape() {
echo "'$(echo "$1" | sed -e "s/'/'\\''/g")'"
}
##########################################################################
# Generate config variable shell snippet
##########################################################################
MASON_CONFIG="$ROOT"/root/mason.conf
echo "Creating $MASON_CONFIG"
cat >>"$MASON_CONFIG" <<EOF
#################### START OF DEPLOY TIME CONFIGURATION #######################
ARTIFACT_CACHE_SERVER=$(shellescape "$ARTIFACT_CACHE_SERVER")
UPSTREAM_TROVE_ADDRESS=$(shellescape "$TROVE_HOST")
DEFINITIONS_REF=$(shellescape "$MASON_DEFINITIONS_REF")
DISTBUILD_ARCH=$(shellescape "$MASON_DISTBUILD_ARCH")
DISTBUILD_CONTROLLER_ADDRESS=$(shellescape "$CONTROLLERHOST")
TROVE_ID=$(shellescape "$TROVE_ID")
BUILD_CLUSTER_MORPHOLOGY=$(shellescape "$MASON_CLUSTER_MORPHOLOGY")
TEST_VM_HOST_SSH_URL=$(shellescape "$MASON_TEST_HOST")
##################### END OF DEPLOY TIME CONFIGURATION ########################
EOF
##########################################################################
# Copy Mason files into root filesystem
##########################################################################
cp mason/mason.sh "$ROOT"/root/mason.sh
cp mason/mason-report.sh "$ROOT"/root/mason-report.sh
cp mason/mason.timer "$ROOT"/etc/systemd/system/mason.timer
ln -s ../mason.timer "$ROOT"/etc/systemd/system/multi-user.target.wants/mason.timer
cp mason/mason.service "$ROOT"/etc/systemd/system/mason.service
ln -s ../mason.service "$ROOT"/etc/systemd/system/multi-user.target.wants/mason.service
##########################################################################
# Set up httpd web server
##########################################################################
cp mason/httpd.service "$ROOT"/etc/systemd/system/httpd.service
ln -s ../httpd.service "$ROOT"/etc/systemd/system/multi-user.target.wants/httpd.service
mkdir -p "$ROOT"/srv/mason
cat >>"$ROOT"/etc/httpd.conf <<EOF
.log:text/plain
EOF
|