-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrontend.sh
More file actions
61 lines (44 loc) · 1.43 KB
/
frontend.sh
File metadata and controls
61 lines (44 loc) · 1.43 KB
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
#!/bin/bash
USERID=$(id -u)
R="\e[31m"
G="\e[32m"
Y="\e[33m"
N="\e[0m"
LOGS_FOLDER="/var/log/shell-roboshop"
SCRIPT_NAME=$( echo $0 | cut -d "." -f1 )
SCRIPT_DIR=$PWD
MONGODB_HOST=mongodb.jayani23.fun
LOG_FILE="$LOGS_FOLDER/$SCRIPT_NAME.log" # /var/log/shell-script/16-logs.log
mkdir -p $LOGS_FOLDER
echo "Script started executed at: $(date)" | tee -a $LOG_FILE
if [ $USERID -ne 0 ]; then
echo "ERROR:: Please run this script with root privelege"
exit 1 # failure is other than 0
fi
VALIDATE(){ # functions receive inputs through args just like shell script args
if [ $1 -ne 0 ]; then
echo -e "$2 ... $R FAILURE $N" | tee -a $LOG_FILE
exit 1
else
echo -e "$2 ... $G SUCCESS $N" | tee -a $LOG_FILE
fi
}
dnf module disable nginx -y &>>$LOG_FILE
VALIDATE $? "Disabling nginx"
dnf module enable nginx:1.24 -y &>>$LOG_FILE
VALIDATE $? "Enable nginx version1.24"
dnf install nginx -y &>>$LOG_FILE
VALIDATE $? "Installing nginx"
systemctl enable nginx &>>$LOG_FILE
systemctl start nginx
VALIDATE $? "Starting nginx"
rm -rf /usr/share/nginx/html/*
curl -o /tmp/frontend.zip https://roboshop-artifacts.s3.amazonaws.com/frontend-v3.zip &>>$LOG_FILE
cd /usr/share/nginx/html
unzip /tmp/frontend.zip &>>$LOG_FILE
VALIDATE $? "Downloading frontend"
rm -rf /etc/nginx/nginx.conf
cp $SCRIPT_DIR/nginx.conf /etc/nginx/nginx.conf
VALIDATE $? "Copying nginx.conf"
systemctl restart nginx
VALIDATE $? "restarting nginx"