-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
install.sh
executable file
·153 lines (131 loc) · 4.63 KB
/
install.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
usageFunction()
{
echo " "
tput setaf 2;
echo "Usage: $0 (-n) (-h)"
echo -e "\t-n Non-interactive installation (Optional)"
echo -e "\t-h Show usage"
exit 1
}
tput setaf 2;
cat web/art/reNgine.txt
tput setaf 1; echo "Before running this script, please make sure Docker is running and you have made changes to .env file."
tput setaf 2; echo "Changing the postgres username & password from .env is highly recommended."
tput setaf 4;
isNonInteractive=false
while getopts nh opt; do
case $opt in
n) isNonInteractive=true ;;
h) usageFunction ;;
?) usageFunction ;;
esac
done
if [ $isNonInteractive = false ]; then
read -p "Are you sure, you made changes to .env file (y/n)? " answer
case ${answer:0:1} in
y|Y|yes|YES|Yes )
echo "Continiuing Installation!"
;;
* )
nano .env
;;
esac
else
echo "Non-interactive installation parameter set. Installation begins."
fi
echo " "
tput setaf 3;
echo "#########################################################################"
echo "Please note that, this installation script is only intended for Linux"
echo "For Mac and Windows, refer to the official guide https://rengine.wiki"
echo "#########################################################################"
echo " "
tput setaf 4;
echo "Installing reNgine and its dependencies"
echo " "
if [ "$EUID" -ne 0 ]
then
tput setaf 1; echo "Error installing reNgine, Please run this script as root!"
tput setaf 1; echo "Example: sudo ./install.sh"
exit
fi
echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing curl..."
echo "#########################################################################"
if [ -x "$(command -v curl)" ]; then
tput setaf 2; echo "CURL already installed, skipping."
else
sudo apt update && sudo apt install curl -y
tput setaf 2; echo "CURL installed!!!"
fi
echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing Docker..."
echo "#########################################################################"
if [ -x "$(command -v docker)" ]; then
tput setaf 2; echo "Docker already installed, skipping."
else
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
tput setaf 2; echo "Docker installed!!!"
fi
echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing Docker Compose"
echo "#########################################################################"
if [ -x "$(command -v docker compose)" ]; then
tput setaf 2; echo "Docker Compose already installed, skipping."
else
curl -L "https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
tput setaf 2; echo "Docker Compose installed!!!"
fi
echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing make"
echo "#########################################################################"
if [ -x "$(command -v make)" ]; then
tput setaf 2; echo "make already installed, skipping."
else
apt install make
fi
echo " "
tput setaf 4;
echo "#########################################################################"
echo "Checking Docker status"
echo "#########################################################################"
if docker info >/dev/null 2>&1; then
tput setaf 4;
echo "Docker is running."
else
tput setaf 1;
echo "Docker is not running. Please run docker and try again."
echo "You can run docker service using sudo systemctl start docker"
exit 1
fi
echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing reNgine"
echo "#########################################################################"
make certs && make build && make up && tput setaf 2 && echo "reNgine is installed!!!" && failed=0 || failed=1
if [ "${failed}" -eq 0 ]; then
sleep 3
echo " "
tput setaf 4;
echo "#########################################################################"
echo "Creating an account"
echo "#########################################################################"
make username isNonInteractive=$isNonInteractive
make migrate
tput setaf 2 && printf "\n%s\n" "Thank you for installing reNgine, happy recon!!"
echo "In case you have unapplied migrations (see above in red), run 'make migrate'"
else
tput setaf 1 && printf "\n%s\n" "reNgine installation failed!!"
fi