forked from deskpro/deskpro-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·48 lines (36 loc) · 1.14 KB
/
update.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
#!/bin/bash
set -eo pipefail
declare -A cmd=(
[apache]='apache2-foreground'
[fpm]='php-fpm'
)
travisEnv=
for variant in apache fpm; do
# Create the variant directory with a Dockerfile.
mkdir -p "$variant"
template="Dockerfile.template"
cp "$template" "$variant/Dockerfile"
echo "updating $variant"
# Replace the variables.
sed -ri -e '
s/%%VARIANT%%/'"$variant"'/g;
s/%%CMD%%/'"${cmd[$variant]}"'/g;
' "$variant/Dockerfile"
# Remove Apache commands if we're not an Apache variant.
if [ "$variant" != "apache" ]; then
sed -ri -e '/a2enmod/d' "$variant/Dockerfile"
fi
# Copy executables
cp docker-entrypoint.sh deskpro-docker-cron "$variant/"
# Copy php config
cp php.ini "$variant/php.ini"
# Copy apache config (gets copied into fpm image, although it is not used
# by the container)
cp deskpro.conf "$variant/deskpro.conf"
travisEnv='\n - VARIANT='"$variant$travisEnv"
done
# update .travis.yml
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml
# remove duplicate entries
echo "$(awk '!NF || !seen[$0]++' .travis.yml)" > .travis.yml