-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.sh
87 lines (54 loc) · 1.65 KB
/
user.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/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
}
curl -sL https://rpm.nodesource.com/setup_lts.x | bash &>>$LOGFILE
VALIDATE $? "Setting up NPM source"
yum install nodejs -y &>>$LOGFILE
VALIDATE $? "installing nodejs"
useradd roboshop &>>$LOGFILE
mkdir /app &>>$LOGFILE
curl -o /tmp/user.zip https://roboshop-builds.s3.amazonaws.com/user.zip &>>$LOGFILE
VALIDATE $? "downloading user artifact"
cd /app &>>$LOGFILE
VALIDATE $? "moving to app directory"
unzip /tmp/user.zip &>>$LOGFILE
VALIDATE $? "unzipping the user.zip"
cd /app &>>$LOGFILE
VALIDATE $? "moving to app directory"
npm install &>>$LOGFILE
VALIDATE $? "installing dependencies"
cp /root/roboshop-shell/user.service /etc/systemd/system/user.service &>>$LOGFILE
VALIDATE $? "copying user.service"
systemctl daemon-reload &>>$LOGFILE
VALIDATE $? "daemon reload"
systemctl enable user &>>$LOGFILE
VALIDATE $? "enabling user"
systemctl start user &>>$LOGFILE
VALIDATE $? "starting the user"
cp /root/roboshop-shell/mongo.repo /etc/yum.repos.d/mongo.repo &>>$LOGFILE
VALIDATE $? "copying user.repo"
yum install mongodb-org-shell -y &>>$LOGFILE
VALIDATE $? "installing mongodb client"
mongo --host mongodb.vignanspace.online </app/schema/user.js &>>$LOGFILE
VALIDATE $? "loading the user data into mongodb"