forked from RackHD/on-build-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-config
executable file
·104 lines (95 loc) · 3.64 KB
/
build-config
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
102
103
#!/bin/bash -xe
REPO_NAME="$1"
if [ -e "${REPO_NAME}/sonar.properties.in" ]; then
echo "Generating sonar.properties file from template"
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
cat ${REPO_NAME}/sonar.properties.in | sed -f sed.script > sonar.properties
rm sed.script
fi
echo "Generating config.ini file from template"
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
cat config.ini.in | sed -f sed.script > config.ini
chmod oug+x config.ini
rm sed.script
echo "Generating test script file from template"
if [ -e "${REPO_NAME}/test.sh.in" ]; then
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
cat ${REPO_NAME}/test.sh.in | sed -f sed.script > test.sh
chmod oug+x test.sh
rm sed.script
else
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
cat test.sh.in | sed -f sed.script > test.sh
chmod oug+x test.sh
rm sed.script
fi
echo "Generating pre deployment file from template"
if [ -e "${REPO_NAME}/pre-deploy.sh.in" ]; then
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
cat ${REPO_NAME}/pre-deploy.sh.in | sed -f sed.script > pre-deploy.sh
chmod oug+x pre-deploy.sh
rm sed.script
else
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
cat pre-deploy.sh.in | sed -f sed.script > pre-deploy.sh
chmod oug+x pre-deploy.sh
rm sed.script
fi
echo "Generating post deployment file from template"
if [ -e "${REPO_NAME}/post-deploy.sh.in" ]; then
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
cat ${REPO_NAME}/post-deploy.sh.in | sed -f sed.script > post-deploy.sh
chmod oug+x post-deploy.sh
rm sed.script
else
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
cat post-deploy.sh.in | sed -f sed.script > post-deploy.sh
chmod oug+x post-deploy.sh
rm sed.script
fi
echo "Generating nvmrc file from template"
if [ -e "${REPO_NAME}/.nvmrc.in" ]; then
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
cat ${REPO_NAME}/.nvmrc.in | sed -f sed.script > .nvmrc
rm sed.script
else
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
cat .nvmrc.in | sed -f sed.script > .nvmrc
rm sed.script
fi
echo "Generating sol-log script file from template"
#BMC_{DOMAIN}_USER/BMC_{DOMAIN}_PASSWORD config in jenkins build-config-setup job parameters
#This script generate a BMC_ACCOUNT_LIST="u1/p1 u2/p2 ..." according to these parameters.
bmc_var_name_list=`env | grep BMC_ | awk -F '=' '{print $1}' | xargs`
domain_list=""
for var_name in $bmc_var_name_list; do
domain=${var_name%_*}
if [[ "$domain_list" != *"$domain"* ]]; then
user_var_name=$domain"_USER"
password_var_name=$domain"_PASSWORD"
BMC_ACCOUNT_LIST="${!user_var_name}:${!password_var_name} $BMC_ACCOUNT_LIST"
domain_list="$domain $domain_list"
fi
done
export BMC_ACCOUNT_LIST
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
if [ -e "${REPO_NAME}/generate-sol-log.sh.in" ]; then
cat ${REPO_NAME}/generate-sol-log.sh.in | sed -f sed.script > generate-sol-log.sh
chmod oug+x generate-sol-log.sh
rm sed.script
else
cat generate-sol-log.sh.in | sed -f sed.script > generate-sol-log.sh
chmod oug+x generate-sol-log.sh
rm sed.script
fi
echo "Generating vnc record script file from template"
env | sed 's/[\%]/\\&/g;s/\([^=]*\)=\(.*\)/s%${\1}%\2%/' > sed.script
if [ -e "${REPO_NAME}/.sh.in" ]; then
cat ${REPO_NAME}/vnc_record.sh.in | sed -f sed.script > vnc_record.sh
chmod oug+x vnc_record.sh
rm sed.script
else
cat vnc_record.sh.in | sed -f sed.script > vnc_record.sh
chmod oug+x vnc_record.sh
rm sed.script
fi