-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprovision.sh
66 lines (52 loc) · 2.13 KB
/
provision.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
61
62
63
64
65
66
#!/usr/bin/env bash
if [ "$1" == "" ] ; then
VER="56"
else
VER="$1"
fi
printf "\nInitializing mysql.sh Version ($VER)...\n\n"
# NOTE: EPEL repo must be enabled in base.sh script per missing dependency in Percona repo:
# https://bugs.launchpad.net/percona-xtrabackup/+bug/1526636
if [[ ! -e /etc/yum.repos.d/epel.repo ]]; then yum -y install http://mirror.pnl.gov/epel/6/x86_64/epel-release-6-8.noarch.rpm; fi
# Install Percona MySQL Repo
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm -y
# Install Percona MySQL Server, server headers, toolkit and Xtrabackup
yum install Percona-Server-server-$VER Percona-Server-devel-$VER percona-toolkit percona-xtrabackup -y
# Create mysql dir
if [[ ! -d /storage/db ]]; then mkdir -p /storage/db && ln -s /storage/db/ /db; fi
ln -s /var/lib/mysql/ /storage/db/mysql > /dev/null 2>&1
chown -R mysql:mysql /db/mysql
# Start MySQL Service
if pidof systemd > /dev/null ; then
systemctl enable mysqld
systemctl start mysqld
else
chkconfig --add mysql
service mysql start
fi
if ! grep password ~/.my.cnf > /dev/null 2>&1
then
printf "Configure desired mysql_secure_installation defaults..."
# This is not about local security, it about making sure root can't get attacked remotly easily by guessing no password.
# The password is always initially set here and then populated in the ~/.my.cnf file
mysql --user=root <<- EOF
UPDATE mysql.user SET Password=PASSWORD('Secret1') WHERE User='root';
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DROP DATABASE IF EXISTS test;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
FLUSH PRIVILEGES;
EOF
# ~/.my.cnf should never be there already when this script runs - it always initializes the mysql install
printf "\nSetting up .my.cnf..."
printf "
[client]
password=Secret1" >> ~/.my.cnf
printf "
[client]
password=Secret1" >> /home/vagrant/.my.cnf
printf "Done.\n"
fi
yum install -y httpd
sudo systemctl start httpd.service
echo "You should be able to reach http://localhost:8080/ now (unless the port was redirected.)"