-
Notifications
You must be signed in to change notification settings - Fork 1
/
ufw-firewall_install.sh
90 lines (83 loc) · 2.97 KB
/
ufw-firewall_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
#!/bin/bash
# K7ILO's ufw firewall Installer and configurer
if [ "$EUID" -ne 0 ];
then
echo ""
echo " You must be root to run this script!! "
exit 1
fi
if [ ! -e "/etc/debian_version" ]
then
echo ""
echo "This script has been tested on Debian 10 and 11 64-bit repo's only."
exit 0
fi
# Global Parameters -------------------------------------------------------------------------------------------------
VERSION=$(sed 's/\..*//' /etc/debian_version)
DEP="ufw"
sshport=22
# Lets begin --------------------------------------------------------------------------------------------------------
if [ $VERSION = 10 ];
then
echo " Debian 10 (Buster) is detected "
sleep 2
clear
if command -v ufw >/dev/null
then
echo "--------------------------------------------------------------------------"
echo " ufw is already installed. The ports just need to be opened. Moving on! "
echo "--------------------------------------------------------------------------"
else
echo "--------------------------------------------------------------------"
echo " About to download and install ufw and its dependencies. STANDBY!! "
echo "--------------------------------------------------------------------"
apt update && apt install -y $DEP
apt autoremove && apt autoclean
echo ""
echo " Done. Now to open the required ports .... "
fi
elif [ $VERSION = 11 ];
then
echo " Debian 11 (Bullseye) is detected "
sleep 2
clear
if command -v ufw >/dev/null
then
echo "--------------------------------------------------------------------------"
echo " ufw is already installed. The ports just need to be opened. Moving on! "
echo "--------------------------------------------------------------------------"
else
echo "--------------------------------------------------------------------"
echo " About to download and install ufw and its dependencies. STANDBY!! "
echo "--------------------------------------------------------------------"
apt update && apt install -y $DEP
apt autoremove && apt autoclean
echo ""
echo " Done. Now to open the required ports .... "
fi
else
clear
echo "------------------------------------------------------------------------------------------"
echo " Operating system not supported! Please check your configuration or upgrade. Exiting .... "
echo "------------------------------------------------------------------------------------------"
exit 0
fi
sleep 3
echo "------------------------------------------------------------"
echo " Enabling ufw and opening the proper ports for HBlink3 .... "
echo "------------------------------------------------------------"
ufw allow $sshport/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 4321/tcp
ufw allow 9000/tcp
ufw allow 62030:62050/udp
sleep 2
ufw enable
sleep 2
ufw status
echo ""
echo "---------------------------------------------------"
echo " ufw enabled and required ports are opened now and "
echo " All other ports are closed. 73 "
echo "---------------------------------------------------"