-
Notifications
You must be signed in to change notification settings - Fork 24
/
rabbitmq.sh
59 lines (40 loc) · 1.32 KB
/
rabbitmq.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
#!/bin/bash
ID=$(id -u)
R="\e[31m"
G="\e[32m"
Y="\e[33m"
N="\e[0m"
MONGDB_HOST=mongodb.daws76s.online
TIMESTAMP=$(date +%F-%H-%M-%S)
LOGFILE="/tmp/$0-$TIMESTAMP.log"
echo "script stareted executing at $TIMESTAMP" &>> $LOGFILE
VALIDATE(){
if [ $1 -ne 0 ]
then
echo -e "$2 ... $R FAILED $N"
exit 1
else
echo -e "$2 ... $G SUCCESS $N"
fi
}
if [ $ID -ne 0 ]
then
echo -e "$R ERROR:: Please run this script with root access $N"
exit 1 # you can give other than 0
else
echo "You are root user"
fi # fi means reverse of if, indicating condition end
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | bash &>> $LOGFILE
VALIDATE $? "Downloading erlang script"
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | bash &>> $LOGFILE
VALIDATE $? "Downloading rabbitmq script"
dnf install rabbitmq-server -y &>> $LOGFILE
VALIDATE $? "Installing RabbitMQ server"
systemctl enable rabbitmq-server &>> $LOGFILE
VALIDATE $? "Enabling rabbitmq server"
systemctl start rabbitmq-server &>> $LOGFILE
VALIDATE $? "Starting rabbitmq server"
rabbitmqctl add_user roboshop roboshop123 &>> $LOGFILE
VALIDATE $? "creating user"
rabbitmqctl set_permissions -p / roboshop ".*" ".*" ".*" &>> $LOGFILE
VALIDATE $? "setting permission"