This repository was archived by the owner on May 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmkswap.sh
More file actions
executable file
·100 lines (72 loc) · 2.35 KB
/
mkswap.sh
File metadata and controls
executable file
·100 lines (72 loc) · 2.35 KB
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
#!/bin/bash
#
# Swapfiles and UFW - for Vidulum users #
echo " "
echo " -------------------------------------------------------------"
echo " This script will automatically make a swapfile on your vps. "
echo " Some VPS providers do not allow making swapfiles on their "
echo " servers. It is YOUR Responsibilty to check with the rules. "
echo " Vidulum recommends Vultr, who is fine with it. This will "
echo " allow you to run a node on a $5 VPS as opposed to a $10 one "
echo "--------------------------------------------------------------"
echo " ------------------------------------------------------------ "
echo " Also, this script is going to enable the UFW firewall and "
echo " and configure it for you. This is assuming you are using "
echo " an Ubuntu VPS as recommended. "
echo "--------------------------------------------------------------"
echo " "
echo "Would you like to create a swapfile? (yes/no)"
read -i "yes" SF
if [[ $SF =~ [yY](es)* ]]; then
echo "Do you want a 2GB or 4GB swapfile? (2/4)"
read SIZE
fi
if [ $SIZE == "2" ]; then
SWAP=2048
elif [ $SIZE == "4" ]; then
SWAP=4096
else
exit 1
echo "Would you like a firewall to be installed? (yes/no)"
read -i "yes" FW
if [[ $SF =~ [yY](es)* ]] && [[ $FW =~ [yY](es)* ]]; then
echo " "
echo "Awesome choice, this script will do both!"
echo " "
elif [[ $SF =~ [yY](es) ]] && [[ $FW =~ [nN](o)* ]]; then
echo " "
echo "Then we will setup swapfile, with no firewall."
echo " "
elif [[ $SW =~ [nN](o)* ]] && [[ $FW =~ [yY](es)* ]]; then
echo " "
echo "No swapfile, but we will setup firewall!"
echo " "
else
echo " "
echo "Nothing for you here - exiting script"
exit 1
fi
# Making swapfile
echo " "
echo "Okay, lets prepare to install a swapfile on the VPS."
if [[ -e /root/swapfile ]] || [[ ls / | grep swapfile ]]; then
echo "You already have a swapfile."
exit 1
fi
if [[ ! -e /root/swapfile ]]; then
dd if=/dev/zero of=/swapfile count=${SWAP} bs=1M
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
## Swap done, UFW Firewall next #
if $FW=
then [[ $FW=NP ]]
apt install ufw
ufw allow ssh/tcp
ufw limit ssh/tcp
ufw allow 7676
ufw logging on
ufw enable
ufw status
# UFW Fireawall is good to good #:wq