-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.sh
55 lines (45 loc) · 1.55 KB
/
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
#!/bin/bash
if [ ! -f /scripts/.mysql_setup ]; then
echo "setting up mysql................................................."
mysql_install_db --user=mysql
fi
su - mysql << EOF
echo "Starting database server to accept connections.................."
mysqld >/dev/null 2>&1 &
EOF
timeout=30
if [ ! -f /scripts/.mysql_setup ]; then
echo "Waiting for database server to accept connections.................."
while ! mysqladmin -u root status >/dev/null 2>&1
do
timeout=$(($timeout - 1))
if [ $timeout -eq 0 ]; then
echo -e "\nCould not connect to database server. Aborting..."
exit 1
fi
echo -n "."
sleep 1
done
echo "setting up mysql................................................."
mysqladmin -u root password letmein
mysql -u root -pletmein -e "create database vanilla_data character set utf8 collate utf8_general_ci"
mysql -u root -pletmein -e "create user 'vanilla_user'@'localhost' identified by 'letmein';"
mysql -u root -pletmein -e "grant all privileges on vanilla_data.* to 'vanilla_user'@'localhost'"
mysql -u root -pletmein -e "flush privileges"
touch /scripts/.mysql_setup
fi
echo "Waiting for database server to accept connections.................."
while ! mysqladmin -u root -pletmein status >/dev/null 2>&1
do
timeout=$(($timeout - 1))
if [ $timeout -eq 0 ]; then
echo -e "\nCould not connect to database server. Aborting..."
exit 1
fi
echo -n "."
sleep 1
done
echo "Starting apache.................."
apachectl
# stop container quitting
/bin/bash