-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
63 lines (50 loc) · 2.12 KB
/
run.sh
File metadata and controls
63 lines (50 loc) · 2.12 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#setting timezone
echo "set timezone to ${RC_TIMEZONE}"
echo "date.timezone = \"${RC_TIMEZONE}\"" >> /etc/php/7.0/fpm/php.ini
#configure nginx
echo "configure nginx"
sed -i "s/{{SERVER_NAME}}/$SRV_NAME/g" default
cp default /etc/nginx/sites-available/default
#roundcube config
echo "configure roundcube"
sed -i "s/{{DB_USER}}/$DB_USR/g" config.inc.php
sed -i "s/{{DB_PASSWORD}}/$DB_PW/g" config.inc.php
sed -i "s/{{DB_HOST}}/$DB_HOST/g" config.inc.php
sed -i "s/{{IMAP_SRV}}/$IMAP_SRV/g" config.inc.php
sed -i "s/{{SMTP_SRV}}/$SMTP_SRV/g" config.inc.php
sed -i "s/{{SUPP_URL}}/$SUPP_URL/g" config.inc.php
DES_KEY=$(< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${1:-24};echo;)
sed -i "s/{{DES_KEY}}/$DES_KEY/g" config.inc.php
sed -i "s/{{MAIL_NAME}}/$MAIL_NAME/g" config.inc.php
sed -i "s/{{LANG}}/$LANG/g" config.inc.php
sed -i "s/{{PASSWORD_PLUGIN}}/${PASSWORD_PLUGIN:+password}/g" config.inc.php
cp config.inc.php /var/www/html/config/config.inc.php
#password config
echo "configure password plugin"
sed -i "s/{{DB_USER}}/$VMAIL_DB_USER/g" password/config.inc.php
sed -i "s/{{DB_PASSWORD}}/$VMAIL_DB_PW/g" password/config.inc.php
sed -i "s/{{DB_HOST}}/$VMAIL_DB_HOST/g" password/config.inc.php
cp password/config.inc.php /var/www/html/plugins/password/config.inc.php
echo "wait for database"
while !(mysqladmin -h $DB_HOST -u root -p$DB_ROOT_PW ping)
do
sleep 1
done
echo "database on"
#database setup
echo "Database Setup"
mysql -u root -p$DB_ROOT_PW -h $DB_HOST -se "CREATE DATABASE IF NOT EXISTS roundcube;"
mysql -u root -p$DB_ROOT_PW -h $DB_HOST -se "DROP USER '${DB_USR}'@'%';"
mysql -u root -p$DB_ROOT_PW -h $DB_HOST -se "CREATE USER IF NOT EXISTS '${DB_USR}'@'%' IDENTIFIED BY '${DB_PW}';"
mysql -u root -p$DB_ROOT_PW -h $DB_HOST -se "GRANT ALL PRIVILEGES ON roundcube.* TO ${DB_USR};"
mysql -u root -p$DB_ROOT_PW -h $DB_HOST -se "FLUSH PRIVILEGES;"
echo "initalize database"
mysql -u root -p$DB_ROOT_PW -h $DB_HOST 'roundcube' < /var/www/html/SQL/mysql.initial.sql
nginx -t
service nginx start
service nginx reload
service php7.0-fpm start
service php7.0-fpm restart
touch /var/www/html/logs/errors
tail -f /var/www/html/logs/errors