-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.sh
186 lines (161 loc) · 4.62 KB
/
setup.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash
########################################
######### REQUIRED FUNCTIONS ##########
########################################
get_distribution() {
lsb_dist=""
# Every system that we officially support has /etc/os-release
if [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
# Returning an empty string here should be alright since the
# case statements don't act unless you provide an actual value
echo "$lsb_dist"
}
########################################
############# MAIN CODE ##############
########################################
# set time zone
sudo dpkg-reconfigure tzdata
sudo apt update -y
sudo apt upgrade -y
printf "\n"
echo "#####################################"
echo "### INSTALLING NECESSARY PACKAGES ###"
echo "#####################################"
printf "\n"
sudo apt install git nano zip ufw iptables curl openssh-server -y
while true; do
printf "\n"
read -r -p "Do you want to secure ssh ? (Y/N) : " isSSH
case $isSSH in
[Yy]*)
chmod +x ssh.sh
sudo ./ssh.sh
break
;;
[Nn]*) break ;;
*) echo "Please answer y or n." ;;
esac
done
chmod +x fail2ban.sh
./fail2ban.sh
while true; do
printf "\n"
read -r -p "Do you want to install CyberPannel ? (Y/N) : " isCyberPannel
case $isCyberPannel in
[Yy]*)
sudo su - && sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh) && exit
break
;;
[Nn]*) break ;;
*) echo "Please answer y or n." ;;
esac
done
printf "\n"
echo "#####################################"
echo "###### INSTALLING WEB SERVERS ######"
echo "#####################################"
printf "\n"
echo "Available Web Servers"
printf "\n"
printf "[1] Apache\n"
printf "[2] Nginx\n\n"
while true; do
printf "\n"
read -r -p "Select the server type that you want to configure or 0 to skip :" WEBSERVER
case $WEBSERVER in
[1]*)
chmod +x apache.sh
sudo ./apache.sh
break
;;
[2]*)
chmod +x nginx.sh
sudo ./nginx.sh
break ;;
[0]*)
break ;;
*) echo "Invalid Input.Please try again [1/2/0] : " ;;
esac
done
while true; do
printf "\n"
read -r -p "Do you want to enable cloudflare ip blocking ? (Y/N) : " isDocker
case $isDocker in
[Yy]*)
chmod +x cloudflare-iptables.sh
./cloudflare-iptables.sh
break
;;
[Nn]*) break ;;
*) echo "Please answer y or n." ;;
esac
done
while true; do
printf "\n"
read -r -p "Do you want to install nodejs ? (Y/N) : " isNodejs
case $isNodejs in
[Yy]*)
chmod +x nodejs.sh
./nodejs.sh
break
;;
[Nn]*) break ;;
*) echo "Please answer y or n." ;;
esac
done
while true; do
printf "\n"
read -r -p "Do you want to install docker & docker-compose ? (Y/N) : " isDocker
case $isDocker in
[Yy]*)
chmod +x docker.sh
./docker.sh
break
;;
[Nn]*) break ;;
*) echo "Please answer y or n." ;;
esac
done
while true; do
printf "\n"
read -r -p "Do you want to install and configure Open-VPN ? (Y/N) : " isOpenVPN
case $isOpenVPN in
[Yy]*)
chmod +x open-vpn.sh
./open-vpn.sh
printf "\n"
echo "Open Vpn server configured successfully.You can download the configuration file on your home directory [thinkpad.ovpn]"
printf "\n"
break
sudo mv /root/${USER}.ovpn /home/${USER}
sudo chown ${USER} /home/${USER}/${USER}.ovpn
sudo sed -i "s/verb 3/verb 0/" /etc/openvpn/server/server.conf
sudo systemctl restart openvpn-server@server.service
printf "\n"
echo "Open Vpn server configured successfully.You can download the configuration file on your home directory [thinkpad.ovpn]"
printf "\n"
break
;;
[Nn]*) break ;;
*) echo "Please answer y or n." ;;
esac
done
while true; do
printf "\n"
read -r -p "Do you want to install Pi-Hole (Network wide ad-blocker) ? (Y/N) : " isDocker
case $isDocker in
[Yy]*)
printf "\n"
echo "#####################################"
echo "######### INSTALLING PIHOLE #########"
echo "#####################################"
printf "\n"
curl -sSL https://install.pi-hole.net | bash
break
;;
[Nn]*) break ;;
*) echo "Please answer y or n." ;;
esac
done