forked from boredland/horde-docker
-
Notifications
You must be signed in to change notification settings - Fork 3
/
horde-init.sh
executable file
·60 lines (51 loc) · 2.75 KB
/
horde-init.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
#!/bin/bash
[ "${DEBUG:-}" = "yes" ] && set -x
if [[ ! -f "/etc/horde/horde/conf.php" ]]; then
cp -rp /etc/.horde/* /etc/horde/
cp /etc/horde/horde/conf.php.dist /etc/horde/horde/conf.php
cat /etc/horde-base-settings.inc >> /etc/horde/horde/conf.php
chown -R www-data:www-data /etc/horde
fi
if [[ $MYSQL_PORT_3306_TCP_ADDR ]]; then
sed -i "s/^\(.*sql.*hostspec.*=\)\(.*\);/\1 '$MYSQL_PORT_3306_TCP_ADDR';/g" /etc/horde/horde/conf.php
sed -i "s/^\(.*sql.*port.*=\)\(.*\);/\1 '$MYSQL_PORT_3306_TCP_PORT';/g" /etc/horde/horde/conf.php
else
sed -i "s/^\(.*sql.*hostspec.*=\)\(.*\);/\1 '$DB_HOST';/g" /etc/horde/horde/conf.php
sed -i "s/^\(.*sql.*port.*=\)\(.*\);/\1 '$DB_PORT';/g" /etc/horde/horde/conf.php
fi
if [[ $MYSQL_ENV_MYSQL_ROOT_PASSWORD ]]; then
sed -i "s/^\(.*sql.*username.*=\)\(.*\);/\1 'root';/g" /etc/horde/horde/conf.php
sed -i "s/^\(.*sql.*password.*=\)\(.*\);/\1 '$MYSQL_ENV_MYSQL_ROOT_PASSWORD';/g" /etc/horde/horde/conf.php
sed -i "s/^\(.*sql.*database.*=\)\(.*\);/\1 '$DB_NAME';/g" /etc/horde/horde/conf.php
sed -i "s/^\(.*sql.*phptype.*=\)\(.*\);/\1 '$DB_DRIVER';/g" /etc/horde/horde/conf.php
else
sed -i "s/^\(.*sql.*username.*=\)\(.*\);/\1 '$DB_USER';/g" /etc/horde/horde/conf.php
sed -i "s/^\(.*sql.*password.*=\)\(.*\);/\1 '$DB_PASS';/g" /etc/horde/horde/conf.php
sed -i "s/^\(.*sql.*database.*=\)\(.*\);/\1 '$DB_NAME';/g" /etc/horde/horde/conf.php
sed -i "s/^\(.*sql.*phptype.*=\)\(.*\);/\1 '$DB_DRIVER';/g" /etc/horde/horde/conf.php
fi
if [[ $MYSQL_PORT_3306_TCP_ADDR ]]; then
RESULT=`mysql -u root --password=$MYSQL_ENV_MYSQL_ROOT_PASSWORD --port=$MYSQL_PORT_3306_TCP_PORT --host=$MYSQL_PORT_3306_TCP_ADDR --protocol=$DB_PROTOCOL --skip-column-names -e "SHOW DATABASES LIKE '$DB_NAME'"`
if [ "$RESULT" == "$DB_NAME" ]; then
echo "Database exist"
else
echo "Database does not exist"
mysql -u root --password=$MYSQL_ENV_MYSQL_ROOT_PASSWORD --port=$MYSQL_PORT_3306_TCP_PORT --host=$MYSQL_PORT_3306_TCP_ADDR --protocol=$DB_PROTOCOL -e "CREATE DATABASE $DB_NAME"
horde-db-migrate
echo "Database created"
fi
else
RESULT=`mysql -u $DB_USER --password=$DB_PASS --port=$DB_PORT --host=$DB_HOST --protocol=$DB_PROTOCOL --skip-column-names -e "SHOW DATABASES LIKE '$DB_NAME'"`
if [ "$RESULT" == "$DB_NAME" ]; then
echo "Database exist"
else
echo "Database does not exist"
mysql -u $DB_USER --password=$DB_PASS --port=$DB_PORT --host=$DB_HOST --protocol=$DB_PROTOCOL --skip-column-names -e "CREATE DATABASE $DB_NAME"
horde-db-migrate
echo "Database created"
fi
fi
sed -i "s/^\(.*use_ssl.*=\)\(.*\);/\1 0;/g" /etc/horde/horde/conf.php
sed -i "s/^\(.*testdisable.*=\)\(.*\);/\1 $HORDE_TEST_DISABLE;/g" /etc/horde/horde/conf.php
# Fix file/dir permissions
chown -R www-data:www-data /var/cache/horde/