-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql.sh
51 lines (36 loc) · 938 Bytes
/
mysql.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
#!/bin/bash
USERID=$(id -u)
DATE=$(date +%F:%H:%M:%S)
LOG_FILE_DIRECTORY=/tmp
SCRIPT_NAME=$0
LOGFILE=$LOG_FILE_DIRECTORY/$0-$DATE.log
R="\e[31m"
N="\e[0m"
Y="\e[33m"
G="\e[32m"
if [ $USERID -ne 0 ];
then
echo -e "$R ERROR:: Please run this script with root access $N"
exit 1
fi
VALIDATE(){
if [ $1 -ne 0 ]
then
echo -e "$2 ... $R FAILURE $N"
exit 1
else
echo -e "$2 ... $G SUCCESS $N"
fi
}
yum module disable mysql -y &>>$LOGFILE
VALIDATE $? "disbling mysql"
cp /root/roboshop-shell/mysql.repo /etc/yum.repos.d/mysql.repo &>>$LOGFILE
VALIDATE $? "copying mysql repo"
yum install mysql-community-server -y &>>$LOGFILE
VALIDATE $? "installing mysql"
systemctl enable mysqld &>>$LOGFILE
VALIDATE $? "enabling mysqld"
systemctl start mysqld &>>$LOGFILE
VALIDATE $? "starting mysqld"
mysql_secure_installation --set-root-pass RoboShop@1 &>>$LOGFILE
VALIDATE $? "setting password"