-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathinstall.sh
More file actions
120 lines (98 loc) · 3.55 KB
/
install.sh
File metadata and controls
120 lines (98 loc) · 3.55 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# install.sh
# Installs smartnode on Ubuntu 16.04 LTS x64
# ATTENTION: The anti-ddos part will disable http, https and dns ports.
if [ "$(whoami)" != "root" ]; then
echo "Script must be run as user: root"
exit -1
fi
while true; do
if [ -d ~/.smartcash ]; then
printf "~/.smartcash/ already exists! The installer will delete this folder. Continue anyway?(Y/n)"
read REPLY
if [ ${REPLY} == "Y" ]; then
pID=$(ps -ef | grep smartcashd | awk '{print $2}')
kill ${pID}
rm -r ~/.smartcash/
break
else
if [ ${REPLY} == "n" ]; then
exit
fi
fi
else
break
fi
done
# Warning that the script will reboot the server
echo "WARNING: This script will reboot the server when it's finished."
printf "Press Ctrl+C to cancel or Enter to continue: "
read IGNORE
cd
# Changing the SSH Port to a custom number is a good security measure against DDOS attacks
printf "Custom SSH Port(Enter to ignore): "
read VARIABLE
_sshPortNumber=${VARIABLE:-22}
# Get a new privatekey by going to console >> debug and typing smartnode genkey
printf "SmartNode GenKey: "
read _nodePrivateKey
# The RPC node will only accept connections from your localhost
_rpcUserName=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 12 ; echo '')
# Choose a random and secure password for the RPC
_rpcPassword=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32 ; echo '')
# Get the IP address of your vps which will be hosting the smartnode
_nodeIpAddress=$(ip route get 1 | awk '{print $NF;exit}')
# Make a new directory for smartcash daemon
mkdir ~/.smartcash/
touch ~/.smartcash/smartcash.conf
# Change the directory to ~/.smartcash
cd ~/.smartcash/
# Create the initial smartcash.conf file
echo "rpcuser=${_rpcUserName}
rpcpassword=${_rpcPassword}
rpcallowip=127.0.0.1
listen=1
server=1
daemon=1
logtimestamps=1
maxconnections=64
txindex=1
smartnode=1
externalip=${_nodeIpAddress}:9678
smartnodeprivkey=${_nodePrivateKey}
" > smartcash.conf
cd
# Install smartcashd using apt-get
apt-get update -y
apt-get install software-properties-common
add-apt-repository ppa:smartcash/ppa -y && apt update && apt install smartcashd -y && smartcashd
# Create a directory for smartnode's cronjobs and the anti-ddos script
rm -r smartnode
mkdir smartnode
# Change the directory to ~/smartnode/
cd ~/smartnode/
# Download the appropriate scripts
wget https://raw.githubusercontent.com/msg768/smartnode/master/anti-ddos.sh
wget https://raw.githubusercontent.com/msg768/smartnode/master/makerun.sh
wget https://raw.githubusercontent.com/msg768/smartnode/master/checkdaemon.sh
wget https://raw.githubusercontent.com/msg768/smartnode/master/upgrade.sh
wget https://raw.githubusercontent.com/msg768/smartnode/master/clearlog.sh
# Create a cronjob for making sure smartcashd is always running
(crontab -l ; echo "*/1 * * * * ~/smartnode/makerun.sh") | crontab -
chmod 0700 ./makerun.sh
# Create a cronjob for making sure the daemon is never stuck
(crontab -l ; echo "*/30 * * * * ~/smartnode/checkdaemon.sh") | crontab -
chmod 0700 ./checkdaemon.sh
# Create a cronjob for making sure smartcashd is always up-to-date
(crontab -l ; echo "*/120 * * * * ~/smartnode/upgrade.sh") | crontab -
chmod 0700 ./upgrade.sh
# Create a cronjob for clearing the log file
(crontab -l ; echo "0 0 */2 * * ~/smartnode/clearlog.sh") | crontab -
chmod 0700 ./clearlog.sh
# Change the SSH port
sed -i "s/[#]\{0,1\}[ ]\{0,1\}Port [0-9]\{2,\}/Port ${_sshPortNumber}/g" /etc/ssh/sshd_config
sed -i "s/14855/${_sshPortNumber}/g" ~/smartnode/anti-ddos.sh
# Run the anti-ddos script
bash ./anti-ddos.sh
# Reboot the server
reboot