-
Notifications
You must be signed in to change notification settings - Fork 4
/
install-cop-bionic.sh
executable file
·76 lines (75 loc) · 2.48 KB
/
install-cop-bionic.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
#!/bin/sh
echo "[*] This script installs the required packages to run cop"
echo " The following packages will be installed: curl, mysql-server,"
echo " mysql-client, mongodb, nodejs, and npm."
echo " You may be prompted to provide your sudo password."
echo ""
echo "[*] Installing to /opt/cop."
echo ""
sudo mkdir /opt/cop
sudo mkdir /opt/cop/mission_files
sudo mkdir /opt/cop/temp_uploads
sudo cp -r * /opt/cop/
sudo groupadd cop
sudo useradd cop -s /bin/false -m -g cop -G cop
sudo chown cop.cop /opt/cop/mission_files
sudo chown cop.cop /opt/cop/temp_uploads
while true; do
read -p "[!] Do you need to install or update packages and dependicies? " yn
case $yn in
[Yy]* ) ans=1; break;;
[Nn]* ) ans=0; break;;
* ) echo "[!] Please select yes or no.";;
esac
done
if [ $ans -eq 1 ]; then
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install curl gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org mongodb-org-tools mongodb-org-shell mongodb-org-server mongodb-org-mongos
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install nodejs
curl https://www.npmjs.com/install.sh | sudo sh
cd /opt/cop
sudo -u cop npm install
sudo systemctl enable mongod.service
sudo systemctl start mongod.service
fi
echo ""
echo "[*] Creating initial admin. Please provide a password for the"
echo " default admin user."
echo ""
while true; do
echo -n "Password: "
read pass
echo -n "Confirm password: "
read cpass
echo ""
if [ "$pass" = "$cpass" ]; then
node support.js $pass
break;
fi
echo "[!] Passwords do not match, please try again."
done
while true; do
read -p "[!] Do you want to enable systemd for the cop? " yn
case $yn in
[Yy]* ) ans=1; break;;
[Nn]* ) ans=0; break;;
* ) echo "[!] Please select yes or no.";;
esac
done
if [ $ans -eq 1 ]; then
sudo cp cop.service /lib/systemd/system/cop.service
sudo systemctl daemon-reload
sudo systemctl start cop
else
echo "[!] To run cop use: node app.js from the cop directory."
echo " Persistent install is possible using systemd."
fi
echo ""
echo "[!] Install completed. Connect to http://<ip>:3000 to login."
echo ""