-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
49 lines (35 loc) · 1.54 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
49 lines (35 loc) · 1.54 KB
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
declare port_http=$PORT_HTTP
declare ports_https=( $PORT_HTTPS )
declare ports_redirect=( $PORT_REDIRECT )
if [ ${#ports_https[*]} -ne ${#ports_redirect[*]} ]; then
echo >&2 error: not equal number of PORT_HTTPS and PORT_REDIRECT mappings
exit 1
fi
# Remove old config
rm -f /etc/apache2/sites-enabled/*
# How many ports do we have
let "count = ${#ports_https[*]} - 1"
# Copy out each config
for i in $(seq 0 $count); do
port_https=${ports_https[$i]}
port_redirect=${ports_redirect[$i]}
# First port, check if we're going to copy out HTTP redirect
if [ $i -eq 0 -a ! -z "$port_http" ]; then
cp /etc/apache2/sites-available/redirect.conf /etc/apache2/sites-enabled/$i-redirect.conf
sed -i "s/%PORT_HTTPS%/$port_https/g" /etc/apache2/sites-enabled/$i-redirect.conf
# Don't extra listening if we don't need it
if [ $port_http -ne 80 -a $port_http -ne 443 ]; then
echo Listen $port_http > /etc/apache2/conf-enabled/listen-${port_http}.conf
fi
fi
# Copy out ssl config and sed to correct ports
cp /etc/apache2/sites-available/ssl.conf /etc/apache2/sites-enabled/$i-ssl.conf
sed -i "s/%PORT_HTTPS%/$port_https/g" /etc/apache2/sites-enabled/$i-ssl.conf
sed -i "s/%PORT_REDIRECT%/$port_redirect/g" /etc/apache2/sites-enabled/$i-ssl.conf
# Don't extra listening if we don't need it
if [ $port_https -ne 80 -a $port_https -ne 443 ]; then
echo Listen $port_https > /etc/apache2/conf-enabled/listen-${port_https}.conf
fi
done
exec $@