This repository has been archived by the owner on Nov 21, 2022. It is now read-only.
forked from passbolt/passbolt_install_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_scripts.sh
executable file
·131 lines (109 loc) · 2.72 KB
/
build_scripts.sh
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
#
# Small script that prepares install scripts for distribution
#
# - Concats all the parts in a single script under dist/<os>/
# - Creates a tarball under dist/tar/<os>
# - Checksums tarballs
set -euo pipefail
PROGNAME=$0
help_message() {
cat <<-EOF
usage: $PROGNAME [OPTION] [ARGUMENT]
OPTIONS:
-h This help message
-d DISTRIBUTION_NAME Builds for a specific distribution. Supported values centos/debian/redhat/ubuntu
EOF
}
checksum() {
cd dist/tar/"$1" || exit 1
sha512sum passbolt-ce-installer-"$1"-"$2".tar.gz > SHA512SUMS-$1.txt
cd -
}
compress() {
mkdir -p dist/tar/"$1"
cd dist/"$1" || exit 1
tar cvfz passbolt-ce-installer-"$1"-"$2".tar.gz *
cd -
mv dist/"$1"/passbolt-ce-installer-"$1"-"$2".tar.gz dist/tar/"$1"
}
error() {
echo "$1"
help_message
exit 1
}
build() {
local os=$1
local output=dist/"$os"/passbolt_ce_"$os"_installer.sh
if ! [[ "$os" =~ ^(debian|ubuntu|centos7|centos8|redhat)$ ]]; then
error "Distribution not supported"
fi
mkdir -p dist/"$os"/conf/{nginx,php}
{
cat templates/header.in
cat conf/constants_common.sh
cat "conf/$os/constants.sh"
} >> "$output"
for util in lib/helpers/utils/*.sh; do
cat "$util" >> "$output";
done
for validator in lib/validators/*.sh; do
cat "$validator" >> "$output";
done
for validator in lib/validators/*.sh; do
cat "$validator" >> "$output";
done
for initializer in lib/initializers/*.sh; do
cat "$initializer" >> "$output";
done
if [ "$os" == "centos7" ] || [ "$os" == "redhat" ] || [ "$os" == "centos8" ]; then
for helper in lib/helpers/"$os"/*.sh; do
cat "$helper" >> "$output";
done
fi
if [ "$os" == "ubuntu" ]; then
for helper in lib/helpers/"$os"/*.sh; do
cat "$helper" >> "$output";
done
fi
for helper in lib/helpers/*.sh; do
cat "$helper" >> "$output";
done
cat "lib/main/$os/main.sh" >> "$output"
chmod +x "$output"
cp conf/nginx/*.conf "dist/$os/conf/nginx"
cp conf/php/*.conf "dist/$os/conf/php"
cp "conf/$os/packages.txt" "dist/$os/conf/packages.txt"
if [ "$os" == "redhat" ]; then
sed -i s:-euo:-eo: "$output"
sed -i s:/etc/nginx:/etc/opt/rh/rh-nginx116/nginx: "$output"
fi
}
while getopts "chd:" opt; do
case $opt in
h)
help_message
exit 0
;;
d)
build "$OPTARG"
;;
c)
compress debian 10
checksum debian 10
compress centos 7
checksum centos 7
compress centos 8
checksum centos 8
compress ubuntu 18.04
checksum ubuntu 18.04
compress redhat EXPERIMENTAL
;;
*)
error "No such build option"
;;
esac
done
if [ "$OPTIND" -eq 1 ]; then
error "Please tell me what to build"
fi