forked from hauptmedia/docker-mailcatcher
-
Notifications
You must be signed in to change notification settings - Fork 3
/
apache-conf.sh
56 lines (45 loc) · 3.12 KB
/
apache-conf.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
#!/bin/bash
# APACHE defaults
if [ -z ${APACHE_MIN_CHILDS+x} ]; then APACHE_MIN_CHILDS=1; fi
if [ -z ${APACHE_MAX_CHILDS+x} ]; then APACHE_MAX_CHILDS=50; fi
if [ -z ${APACHE_MIN_CHILDS_SPARE+x} ]; then APACHE_MIN_CHILDS_SPARE=1; fi
if [ -z ${APACHE_MAX_CHILDS_SPARE+x} ]; then APACHE_MAX_CHILDS_SPARE=5; fi
if [ -z ${APACHE_SERVER_NAME+x} ]; then APACHE_SERVER_NAME=rainloop.loc; fi
if [ -z ${APACHE_SERVER_ADMIN+x} ]; then [email protected]; fi
# PHP defaults
if [ -z ${PHP_MAX_POST_SIZE+x} ]; then PHP_MAX_POST=20M; fi
if [ -z ${PHP_MAX_UPLOAD_SIZE+x} ]; then PHP_MAX_UPLOAD_SIZE=8M; fi
if [ -z ${PHP_MAX_UPLOADS+x} ]; then PHP_MAX_POST=20; fi
if [ -z ${PHP_MAX_EXECUTION_ZIME+x} ]; then PHP_MAX_EXECUTION_ZIME=30; fi
# RAINLOOP defaults
if [ -z ${RAINLOOP_ADMIN_LOGIN+x} ]; then RAINLOOP_ADMIN_LOGIN=admin; fi
if [ -z ${RAINLOOP_ADMIN_PASSWORD+x} ]; then RAINLOOP_ADMIN_PASSWORD=12345; fi
sed "s/StartServers.*=.*/StartServers = $APACHE_MIN_CHILDS/g" -i /etc/apache2/mods-available/mpm_prefork.conf
sed "s/MaxRequestWorkers.*=.*/MaxRequestWorkers = $APACHE_MAX_CHILDS/g" -i /etc/apache2/mods-available/mpm_prefork.conf
sed "s/MinSpareServers.*=.*/MinSpareServers = $APACHE_MIN_CHILDS_SPARE/g" -i /etc/apache2/mods-available/mpm_prefork.conf
sed "s/MaxSpareServers.*=.*/MaxSpareServers = $APACHE_MAX_CHILDS_SPARE/g" -i /etc/apache2/mods-available/mpm_prefork.conf
sed "s/ServerName .*/ServerName $APACHE_SERVER_NAME/g" -i /etc/apache2/sites-available/000-default.conf
sed "s/ServerAdmin .*/ServerAdmin $APACHE_SERVER_ADMIN/g" -i /etc/apache2/sites-available/000-default.conf
echo "ServerName $APACHE_SERVER_NAME" > /etc/apache2/conf-enabled/servername.conf
sed "s/post_max_size.*=.*/post_max_size = $PHP_MAX_POST/g" -i /etc/php/8.*/apache2/php.ini
sed "s/upload_max_filesize.*=.*/upload_max_filesize = $PHP_MAX_UPLOAD_SIZE/g" -i /etc/php/8.*/apache2/php.ini
sed "s/max_file_uploads.*=.*/max_file_uploads = $PHP_MAX_POST/g" -i /etc/php/8.*/apache2/php.ini
sed "s/max_execution_time.*=.*/max_execution_time = $PHP_MAX_EXECUTION_ZIME/g" -i /etc/php/8.*/apache2/php.ini
if [ -f /var/www/html/data/SALT.php ]; then
SALT=$(cat /var/www/html/data/SALT.php)
else
SALT=$(date +'%s')
echo -n $SALT > /var/www/html/data/SALT.php
fi
APP_SALT=$(echo -n ${SALT}_default_${SALT} | md5sum | awk '{ print $1 }')
ADMIN_PASS_HASH=$(echo -n ${APP_SALT}${RAINLOOP_ADMIN_PASSWORD}${APP_SALT} | md5sum | awk '{ print $1 }')
if [ -f /var/www/html/data/_data_/_default_/configs/application.ini ]; then
sed "s/admin_login.*=.*/admin_login = \"$RAINLOOP_ADMIN_LOGIN\"/g" -i /var/www/html/data/_data_/_default_/configs/application.ini
sed "s/admin_password.*=.*/admin_password = \"$ADMIN_PASS_HASH\"/g" -i /var/www/html/data/_data_/_default_/configs/application.ini
else
mkdir -p /var/www/html/data/_data_/_default_/configs/
echo "[security]" >> /var/www/html/data/_data_/_default_/configs/application.ini
echo "admin_login = $RAINLOOP_ADMIN_LOGIN" >> /var/www/html/data/_data_/_default_/configs/application.ini
echo "admin_password = $ADMIN_PASS_HASH" >> /var/www/html/data/_data_/_default_/configs/application.ini
fi
chown -R www-data.www-data /var/www/html/data