-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepareEnv.sh
More file actions
125 lines (100 loc) · 4.51 KB
/
prepareEnv.sh
File metadata and controls
125 lines (100 loc) · 4.51 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
<<COMMENT
Description: This automation script prepares the programming environment to complete my ITD-212 assignment
Author: istackz
Note: created this script so that I can quicly set up my environment on a new system/container/vm (RHEL 7/CentOS 7/Rocky 7)
COMMENT
# install nodeJS if it isn't there already
if [[ $(sudo yum list installed | grep -i 'nodejs') ]]
then
# display message
echo -e "\nNodeJS is currently installed in this system";
else
# display message
echo -e "\nNodeJS is not installed on this system\n";
echo -e "\nWill now proceed to install NodeJS\n";
# command to install nodejs
sudo yum install nodejs -y;
if [[ $? == 0 ]]
then
echo -e "\nNodeJS has been installed\n";
else
echo -e "\nError! could not install NodeJS\n";
fi
fi
# install npm package manager (for Javascript/NodeJS)
if [[ $(sudo yum list installed | grep -i 'npm') ]]
then
# display message
echo -e "\nnpm is currently installed in this system";
else
# display message
echo -e "\nnpm is not installed on this system\n";
echo -e "\nWill now proceed to install npm\n";
# command to install npm
sudo yum install npm -y;
if [[ $? == 0 ]]
then
echo -e "\nSuccess!\n";
else
echo -e "\nError! couldn't install npm\n";
fi
fi
# get the mongoDB 3.4.24 server and mongoDB 3.4.24 client shell packages
echo -e "\nWill now download the mongodb server and shell packages";
sudo wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/RPMS/mongodb-org-server-3.4.24-1.el7.x86_64.rpm -P /tmp;
sudo wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/RPMS/mongodb-org-shell-3.4.24-1.el7.x86_64.rpm -P /tmp;
# install both packages on the system
if [[ $(ls -a /tmp | grep -i 'mongodb-org-server') && $(ls -a /tmp | grep -i 'mongodb-org-shell') ]]
then
# command to install both packages
sudo yum localinstall -y /tmp/mongodb-org-server-3.4.24-1.el7.x86_64.rpm /tmp/mongodb-org-shell-3.4.24-1.el7.x86_64.rpm;
if [[ $? == 0 ]]
then
echo -e "\nDone!";
else
echo -e "\nError! could not install the mongodb packages\n";
fi
else
echo -e "\nError! the monogodb-org-server and mongodb-org-shell files are not within /tmp\n";
fi
# create the directory /data/db for mongodb
sudo mkdir -p /data/db;
if [[ $? == 0 ]]
then
echo -e "\nDone! created the directory /data/db\n";
else
echo -e "\nCould not create the directory /data/db\n";
fi
# multi-line comment
<<:
NOTE:
be sure to run --> npm install express body-parser mongodb@2.2.33 <-- when intializing a package for programming assignment 3
Afterwards, go to /data/db run mongodb to start the mongodb server.
in a separate tab run mongo to have the mongodb client connect to the server.
be sure to create the database (use <dbName>) and collection (db.<dbName>.createCollection('<collName>')).
so that when you referenc it in your NodeJS entry point file the code will work.
from the client you can run db.<dbName>.find() to see if the data was stored correctly
:
#############
# my banner #
#############
##########################################################
# source: http://patorjk.com/software/taag/ #
##########################################################
echo -e "\nScript by: ";
echo -e "\n";
echo -e "\e[5;32m";
echo -e " ██▓ ██████▄▄▄█████▓▄▄▄ ▄████▄ ██ ▄█▒███████▒";
echo -e "▓██▒██ ▒▓ ██▒ ▓▒████▄ ▒██▀ ▀█ ██▄█▒▒ ▒ ▒ ▄▀░";
echo -e "▒██░ ▓██▄ ▒ ▓██░ ▒▒██ ▀█▄ ▒▓█ ▄▓███▄░░ ▒ ▄▀▒░ ";
echo -e "░██░ ▒ ██░ ▓██▓ ░░██▄▄▄▄██▒▓▓▄ ▄██▓██ █▄ ▄▀▒ ░";
echo -e "░██▒██████▒▒ ▒██▒ ░ ▓█ ▓██▒ ▓███▀ ▒██▒ █▒███████▒";
echo -e "░▓ ▒ ▒▓▒ ▒ ░ ▒ ░░ ▒▒ ▓▒█░ ░▒ ▒ ▒ ▒▒ ▓░▒▒ ▓░▒░▒";
echo -e " ▒ ░ ░▒ ░ ░ ░ ▒ ▒▒ ░ ░ ▒ ░ ░▒ ▒░░▒ ▒ ░ ▒";
echo -e " ▒ ░ ░ ░ ░ ░ ▒ ░ ░ ░░ ░░ ░ ░ ░ ░";
echo -e " ░ ░ ░ ░ ░ ░ ░ ░ ░ ";
echo -e " ░ ░ ";
echo -e "\e[0m";
echo -e "\n";
###########################################################