forked from Dragontek/octobercms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·53 lines (41 loc) · 1.12 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
49
50
51
52
53
#!/bin/bash
set -euo pipefail
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
phpVersions=( "$@" )
if [ ${#phpVersions[@]} -eq 0 ]; then
phpVersions=( php*.*/ )
fi
phpVersions=( "${phpVersions[@]%/}" )
declare -A variantExtras=(
[apache]='\nRUN a2enmod rewrite expires\n'
[fpm]=''
)
declare -A variantCmds=(
[apache]='apache2-foreground'
[fpm]='php-fpm'
)
travisEnv=
for phpVersion in "${phpVersions[@]}"; do
phpVersionDir="$phpVersion"
phpVersion="${phpVersion#php}"
for variant in apache fpm; do
dir="$phpVersionDir/$variant"
mkdir -p "$dir"
extras="${variantExtras[$variant]}"
cmd="${variantCmds[$variant]}"
(
set -x
sed -r \
-e 's!%%PHP_VERSION%%!'"$phpVersion"'!g' \
-e 's!%%VARIANT%%!'"$variant"'!g' \
-e 's!%%VARIANT_EXTRAS%%!'"$extras"'!g' \
-e 's!%%CMD%%!'"$cmd"'!g' \
Dockerfile.template > "$dir/Dockerfile"
cp -rf docker-entrypoint.sh "$dir/docker-entrypoint.sh"
cp -R config "$dir/"
)
travisEnv+='\n - VARIANT='"$dir"
done
done
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
echo "$travis" > .travis.yml