-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
61 lines (50 loc) · 1.74 KB
/
run.sh
File metadata and controls
61 lines (50 loc) · 1.74 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
#!/bin/bash
chown www-data:www-data /app -R
if [ "$ALLOW_OVERRIDE" = "**False**" ]; then
unset ALLOW_OVERRIDE
else
sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf
a2enmod rewrite
fi
# Wait for MySQL to come up (http://stackoverflow.com/questions/6118948/bash-loop-ping-successful)
((count = 100000)) # Maximum number to try.
while [[ $count -ne 0 ]] ; do
nc -v mysql 3306 # Try once.
rc=$?
if [[ $rc -eq 0 ]] ; then
((count = 1)) # If okay, flag to exit loop.
fi
((count = count - 1)) # So we don't go forever.
done
if [[ $rc -eq 0 ]] ; then # Make final determination.
echo 'The MySQL server is up.'
else
echo 'Timeout waiting for MySQL server.'
fi
# Delete all contents of the log and tmp directories
#rm -rfv ./app/log/*
rm -rfv /app/tmp/*
# Create required cache subdirectories
mkdir -p /app/tmp/cache
mkdir -p /app/tmp/cache/models
mkdir -p /app/tmp/cache/persistent
mkdir -p /app/tmp/cache/views
mkdir -p /app/tmp/sessions
mkdir -p /app/tmp/tests
mkdir -p /app/tmp/logs
chmod -R 777 /app/tmp/*
echo "### Updating db schema"
cake -app /app schema update -s 1 -y
export MYSQL_STATUS=$(php /app/check_db.php)
echo "MySQL Status: $MYSQL_STATUS"
if [ "$MYSQL_STATUS" -eq 0 ]; then
echo "### Creating initial db schema and populating seed data";
cake -app /app schema create -s 1 -y;
cake -app /app schema create sessions -y;
fi
export MYSQL_STATUS=$(php /app/check_db.php)
echo "MySQL Status: $MYSQL_STATUS"
chmod 777 /app/Vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer
source /etc/apache2/envvars
tail -F /var/log/apache2/* &
exec apache2 -D FOREGROUND