-
Notifications
You must be signed in to change notification settings - Fork 0
/
daemon_script.sh
138 lines (124 loc) · 3 KB
/
daemon_script.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
#!/bin/bash
# Will install Syscoin Daemon with Testnet Config
# to run script simply paste
# bash <(curl -sL https://raw.githubusercontent.com/bigpoppa-sys/sys-testnet/master/daemon_script.sh)
# syscoin conf file
SYSCOIN_CONF=$(cat <<EOF
#rpc config
testnet=1
[test]
listen=1
daemon=1
server=1
port=18369
rpcport=18370
gethtestnet=1
addnode=54.190.239.153
addnode=52.40.171.92
rpcuser=u
rpcpassword=p
assetindex=1
EOF
)
pause(){
echo ""
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'
clear
}
update_system(){
echo "Updating System"
# update package and upgrade Ubuntu
sudo DEBIAN_FRONTEND=noninteractive apt -y update
sudo DEBIAN_FRONTEND=noninteractive apt -y upgrade
sudo DEBIAN_FRONTEND=noninteractive apt -y autoremove
clear
}
maybe_prompt_for_swap_file(){
# Create swapfile if less than 8GB memory
MEMORY_RAM=$(free -m | awk '/^Mem:/{print $2}')
MEMORY_SWAP=$(free -m | awk '/^Swap:/{print $2}')
MEMORY_TOTAL=$(($MEMORY_RAM + $MEMORY_SWAP))
if [ $MEMORY_RAM -lt 3800 ]; then
echo "You need to upgrade your server to 4 GB RAM."
exit 1
fi
if [ $MEMORY_TOTAL -lt 7700 ]; then
CREATE_SWAP="Y";
fi
}
maybe_create_swap_file(){
if [ "$CREATE_SWAP" = "Y" ]; then
echo "Creating a 4GB swapfile..."
sudo swapoff -a
sudo dd if=/dev/zero of=/swap.img bs=1M count=4096
sudo chmod 600 /swap.img
sudo mkswap /swap.img
sudo swapon /swap.img
echo '/swap.img none swap sw 0 0' | sudo tee --append /etc/fstab > /dev/null
sudo mount -a
echo "Swapfile created."
clear
fi
}
install_ufw(){
echo "Installing UFW"
sudo apt-get install ufw -y
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 18369/tcp
sudo ufw allow 30303/tcp
yes | sudo ufw enable
clear
}
install_dependencies(){
echo "Installing Dependencies"
# build tools
sudo apt install -y build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3 software-properties-common
# boost
sudo apt install -y libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev libboost-iostreams-dev
# bdb 4.8
sudo add-apt-repository -y ppa:bitcoin/bitcoin
sudo apt update -y
sudo apt install -y libdb4.8-dev libdb4.8++-dev
# zmq
sudo apt install -y libzmq3-dev
# git
sudo apt install -y git
# virtualenv python
sudo apt install -y python-virtualenv
clear
}
build_syscoin(){
echo "Build"
git clone http://www.github.com/syscoin/syscoin
cd syscoin
git checkout dev-4.x
git pull
./autogen.sh
./configure
make -j$(nproc)
clear
}
create_conf(){
echo "Creating Conf"
sudo mkdir ~/.syscoin
echo "$SYSCOIN_CONF" > ~/.syscoin/syscoin.conf
clear
}
start_syscoind(){
cd ~/syscoin/src
./syscoind
}
pause
#system updates
update_system
maybe_prompt_for_swap_file
maybe_create_swap_file
install_ufw
install_dependencies
#install syscoin
build_syscoin
create_conf
#run
start_syscoind