forked from topix-hackademy/docker-nginx-ssh-mysql-php7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
22 lines (19 loc) · 926 Bytes
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
# mysql setup
if [ ! -f /setup.txt ]; then
#mysql has to be started this way as it doesn't work to call from /etc/init.d
/usr/bin/mysqld_safe &
sleep 10s
# Here we generate random passwords (thank you pwgen!) for mysql users
MYSQL_PASSWORD=`pwgen -c -n -1 12`
#This is so the passwords show up in logs.
echo mysql root password: $MYSQL_PASSWORD
echo $MYSQL_PASSWORD > /mysql-root-pw.txt
echo "SETUPOK" > /setup.txt
mysqladmin -u root password $MYSQL_PASSWORD
mysql -uroot -p$MYSQL_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' WITH GRANT OPTION; FLUSH PRIVILEGES;"
mysql -uroot -p$MYSQL_PASSWORD -e "CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY '$WORDPRESS_PASSWORD'; FLUSH PRIVILEGES;"
killall mysqld
fi
# start all the services
/usr/local/bin/supervisord -n -c /etc/supervisord.conf