-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·157 lines (121 loc) · 3.96 KB
/
entrypoint.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
/etc/init.d/php5-fpm start
chmod a+rwx /var/run/php5-fpm.sock
cat <<EOF
Derived from marvambass/nginx-ssl-secure and marvambass/roundcube containers
IMPORTANT:
IF you use SSL inside your personal NGINX-config,
you should add the Strict-Transport-Security header like:
# only this domain
add_header Strict-Transport-Security "max-age=31536000";
# apply also on subdomains
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
to your config.
After this you should gain a A+ Grade on the Qualys SSL Test
EOF
if [ -z ${DH_SIZE+x} ]
then
>&2 echo ">> no \$DH_SIZE specified using default"
DH_SIZE="2048"
fi
DH="/etc/nginx/external/dh.pem"
if [ ! -e "$DH" ]
then
echo ">> seems like the first start of nginx"
echo ">> doing some preparations..."
echo ""
echo ">> generating $DH with size: $DH_SIZE"
openssl dhparam -out "$DH" $DH_SIZE
fi
if [ ! -e "/etc/nginx/external/cert.pem" ] || [ ! -e "/etc/nginx/external/key.pem" ]
then
echo ">> generating self signed cert"
openssl req -x509 -newkey rsa:4086 \
-subj "/C=XX/ST=XXXX/L=XXXX/O=XXXX/CN=localhost" \
-keyout "/etc/nginx/external/key.pem" \
-out "/etc/nginx/external/cert.pem" \
-days 3650 -nodes -sha256
fi
echo ">> copy /etc/nginx/external/*.conf files to /etc/nginx/conf.d/"
cp /etc/nginx/external/*.conf /etc/nginx/conf.d/ 2> /dev/null > /dev/null
#RC CONFIG
if [ -z ${POSTGRES_USER+x} ] || [ -z ${PGPASSWORD+x} ]
then
>&2 echo ">> no user or password for database specified!"
exit 1
fi
if [ -z ${ROUNDCUBE_IMAP_HOST+x} ]
then
ROUNDCUBE_IMAP_HOST=mail
fi
if [ -z ${ROUNDCUBE_IMAP_PROTO+x} ]
then
ROUNDCUBE_IMAP_PROTO=tls
fi
if [ -z ${ROUNDCUBE_SMTP_HOST+x} ]
then
ROUNDCUBE_SMTP_HOST=mail
fi
if [ -z ${ROUNDCUBE_SMTP_PROTO+x} ]
then
ROUNDCUBE_SMTP_PROTO=tls
fi
if [ -z ${ROUNDCUBE_SMTP_PORT+x} ]
then
ROUNDCUBE_SMTP_PORT=25
fi
if [ -z ${ROUNDCUBE_LANGUAGE+x} ]
then
ROUNDCUBE_LANGUAGE=en_CA
fi
if [ -z ${POSTGRES_PORT_5432_TCP_PORT+x} ]
then
POSTGRES_PORT_5432_TCP_PORT=5432
fi
if [ -z ${PG_DBNAME+x} ]
then
PG_DBNAME=roundcube
fi
if [ -z ${ROUNDCUBE_PHP_DATE_TIMEZONE+x} ]
then
ROUNDCUBE_PHP_DATE_TIMEZONE=America/Montreal
fi
if [ -z ${ROUNDCUBE_RELATIVE_URL_ROOT+x} ]
then
ROUNDCUBE_RELATIVE_URL_ROOT="/"
fi
#Roundcube Webmail
if [ -z ${ROUNDCUBE_NAME+x} ]
then
ROUNDCUBE_NAME=Roundcube Webmail
fi
ROUNDCUBE_RANDOM=`perl -e 'my @chars = ("A".."Z", "a".."z"); my $string; $string .= $chars[rand @chars] for 1..24; print $string;'` # returns exactly 24 random chars
###
# Configuration
###
if [ ! -e "/roundcube/config/TPLconfig.inc.php" ]
then
cp /roundcube/config/config.inc.php /roundcube/config/TPLconfig.inc.php
fi
cp /roundcube/config/TPLconfig.inc.php /roundcube/config/config.inc.php
sed -i "s/PG_USER/$POSTGRES_USER/g" /roundcube/config/config.inc.php
sed -i "s/PG_PASSWORD/$PGPASSWORD/g" /roundcube/config/config.inc.php
sed -i "s/PG_DB/$PG_DBNAME/g" /roundcube/config/config.inc.php
sed -i "s/PG_TCP_ADDR/$POSTGRES_PORT_5432_TCP_ADDR/g" /roundcube/config/config.inc.php
sed -i "s/PG_PORT/$POSTGRES_PORT_5432_TCP_PORT/g" /roundcube/config/config.inc.php
sed -i "s/IMAP_HOST/$ROUNDCUBE_IMAP_HOST/g" /roundcube/config/config.inc.php
sed -i "s/IMAP_PROTOCOL/$ROUNDCUBE_IMAP_PROTO/g" /roundcube/config/config.inc.php
sed -i "s/SMTP_HOST/$ROUNDCUBE_SMTP_HOST/g" /roundcube/config/config.inc.php
sed -i "s/SMTP_PROTOCOL/$ROUNDCUBE_SMTP_PROTO/g" /roundcube/config/config.inc.php
sed -i "s/SMTP_PORT/$ROUNDCUBE_SMTP_PORT/g" /roundcube/config/config.inc.php
sed -i "s/LOCALISATION/$ROUNDCUBE_LANGUAGE/g" /roundcube/config/config.inc.php
sed -i "s/ROUNDCUBE_RANDOM/$ROUNDCUBE_RANDOM/g" /roundcube/config/config.inc.php
sed -i "s/Roundcube Webmail/$ROUNDCUBE_NAME/g" /roundcube/config/config.inc.php
echo ">> set Timezone -> $ROUNDCUBE_PHP_DATE_TIMEZONE"
sed -i "s!;date.timezone =.*!date.timezone = $ROUNDCUBE_PHP_DATE_TIMEZONE!g" /etc/php5/fpm/php.ini
# exec CMD
/opt/startup-roundcube.sh
echo ">> exec docker CMD"
echo "$@"
exec "$@"
#exec nginx