Skip to content

Commit 418dc50

Browse files
authored
Merge pull request #7 from Goose-Tech/patch-1
Create vpsprep.sh
2 parents f8d0d02 + a24ef60 commit 418dc50

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

debian/vpsprep-gn.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
# This script will prepare your VPS for the installation of an ethoFS node
3+
# Note: This script does not install the ethoFS node. It run all the prelimiary commands to get the VPS ready.
4+
# To execute you either need to log in as root or run by prepending the "sudo" command.
5+
# You will then need to logoff as root and login as "ether1node" user and run the node installation script
6+
# to complete the installation.
7+
# Example: sudo ./vpsprep-gn.sh
8+
# Version VPSprep v1.0
9+
10+
# Variables
11+
#PORT22="$(sudo lsof -i tcp:22 -s tcp:listen)"
12+
PORT80="$(sudo lsof -i tcp:80 -s tcp:listen)"
13+
PORT4001="$(sudo lsof -i tcp:4001 -s tcp:listen)"
14+
PORT30305="$(sudo lsof -i tcp:30305 -s tcp:listen)"
15+
16+
# Color Codes
17+
YELLOW='\033[1;33m'
18+
BLUE='\033[1;34m'
19+
GREEN='\033[1;32m'
20+
CYAN='\033[1;36m'
21+
NC='\033[0m'
22+
STOP='\e[0m'
23+
24+
#countdown "00:00:30" is a 30 second countdown
25+
countdown()
26+
(
27+
IFS=:
28+
set -- $*
29+
secs=$(( ${1#0} * 3600 + ${2#0} * 60 + ${3#0} ))
30+
while [ $secs -gt 0 ]
31+
do
32+
sleep 1 &
33+
printf "\r%02d:%02d:%02d" $((secs/3600)) $(( (secs/60)%60)) $((secs%60))
34+
secs=$(( $secs - 1 ))
35+
wait
36+
done
37+
echo -e "\033[1K"
38+
)
39+
40+
clear
41+
echo -e "${YELLOW}==========================================================="
42+
echo -e "Ether-1 VPS Prep, v1.0"
43+
echo -e "${YELLOW}===========================================================${NC}"
44+
echo -e "${BLUE}2 Dec 2019, by Goose-Tech${NC}"
45+
echo -e
46+
echo -e "${CYAN}VPS preparation starting, press [CTRL-C] to cancel.${NC}"
47+
countdown "00:00:04"
48+
echo -e
49+
50+
# Verify necessary ports are available
51+
echo -e "${GREEN}Verifying all necessary ports are available...${NC}"
52+
if [ -z "${PORT80}" ] && [ -z "${PORT4001}" ] && [ -z "${PORT30305}" ]; then
53+
echo -e "${YELLOW}All ports are available.${NC}"
54+
else
55+
echo -e "${CYAN}One or more ports are in use by another process.\nPlease disable any processes on ports listed below.\n\n${NC}"
56+
echo -e "${GREEN}Output from port check:${NC}"
57+
echo -e "${GREEN}Port 80:${NC}\n${PORT80}"
58+
echo -e "${GREEN}Port 4001:${NC}\n${PORT4001}"
59+
echo -e "${GREEN}Port 30305:${NC}\n${PORT30305}"
60+
exit
61+
fi
62+
63+
# Distro upgrade
64+
echo -e "${GREEN}Updating OS...${NC}"
65+
apt-get update
66+
apt-get dist-upgrade -y
67+
68+
# Install & Configure Fail2Ban
69+
echo -e "${GREEN}Setting up Fail2Ban...${NC}"
70+
mkdir /var/run/fail2ban
71+
apt-get install sudo ufw fail2ban nano -y
72+
cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
73+
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
74+
systemctl restart fail2ban
75+
countdown "00:00:04"
76+
fail2ban-client status
77+
78+
# Create ether2node user
79+
echo -e "${GREEN}Creating new user called ${YELLOW}ether1node${GREEN}.\nWhen prompted, please set a secure password.${NC}"
80+
adduser ether1node
81+
adduser ether1node sudo
82+
adduser ether1node systemd-journal
83+
84+
# Setting up Firewall
85+
#ufw reset
86+
#ufw allow 22/tcp
87+
#ufw allow 80/tcp
88+
#ufw allow 4001/tcp
89+
#ufw allow 30305/tcp
90+
#ufw allow 30305/udp
91+
#ufw enable
92+
93+
# Download & prepare for ethoFS setup
94+
echo -e "${GREEN}Downloading ethoFS installation script...\n${NC}"
95+
mkdir -p /tmp/ether1 && cd /tmp/ether1
96+
rm -rf setupETHOFS.sh && wget https://raw.githubusercontent.com/Ether1Project/ether1-node-scripts/master/debian/setupETHOFS.sh
97+
chmod +x setupETHOFS.sh
98+
echo -e "${YELLOW}Preparation complete. Please logoff and login as ${CYAN}ether1node${YELLOW}.\nThen type the following commands to complete installation.\n${NC}"
99+
echo -e "${CYAN}/tmp/ether1/setupETHOFS.sh -gatewaynode${NC}"

0 commit comments

Comments
 (0)