-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-gobyte.sh
executable file
·121 lines (104 loc) · 3.77 KB
/
install-gobyte.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
#!/bin/sh
#Version 0.1.1
#Info: Installs GoByte daemon, Masternode based on privkey.
#GoByte Version 0.1.12.1 or above
#Tested OS: Ubuntu 17.04, 16.04, and 14.04
#TODO: make script less "ubuntu" or add other linux flavors
#TODO: remove dependency on sudo user account to run script (i.e. run as root and specifiy gobyte user so gobyte user does not require sudo privileges)
#TODO: add specific dependencies depending on build option (i.e. gui requires QT4)
noflags() {
echo "=-=-=-=-=-=-=-=-=-=-="
echo "Usage: install-gobyte"
echo "Example: install-gobyte"
echo "=-=-=-=-=-=-=-=-=-=-="
exit 1
}
message() {
echo "==============================>>>"
echo "| $1"
echo "==============================<<<"
}
error() {
message "An error occured, you must fix it to continue!"
exit 1
}
prepdependencies() { #TODO: add error detection
message "Installing dependencies..."
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
sudo apt-get install automake curl libdb++-dev build-essential libtool autotools-dev autoconf pkg-config libssl-dev libboost-all-dev libminiupnpc-dev git software-properties-common python-software-properties g++ bsdmainutils libevent-dev -y
sudo add-apt-repository ppa:bitcoin/bitcoin -y
sudo apt-get update
sudo apt-get install libdb4.8-dev libdb4.8++-dev -y
}
createswap() { #TODO: add error detection
message "Creating 2GB temporary swap file...this may take a few minutes..."
sudo dd if=/dev/zero of=/swapfile bs=1M count=2000
sudo mkswap /swapfile
sudo chown root:root /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile
#make swap permanent
sudo echo "/swapfile none swap sw 0 0" >> /etc/fstab
}
clonerepo() { #TODO: add error detection
message "Cloning from github repository..."
cd ~/
git clone https://github.com/gobytecoin/gobyte
}
compile() {
cd gobyte #TODO: squash relative path
message "Preparing to build..."
./autogen.sh
if [ $? -ne 0 ]; then error; fi
message "Configuring build options..."
./configure $1 --disable-tests
if [ $? -ne 0 ]; then error; fi
message "Building GoByte...this may take a few minutes..."
make
if [ $? -ne 0 ]; then error; fi
message "Installing GoByte..."
sudo make install
if [ $? -ne 0 ]; then error; fi
}
createconf() {
#TODO: Can check for flag and skip this
#TODO: Random generate the user and password
message "Creating gobyte.conf..."
MNPRIVKEY="7dyTEWm6gdfb5XJXDRaCnX3iNU44waN1K7BY5KQh9wUDPwhuNG5"
CONFDIR=~/.gobytecore
CONFILE=$CONFDIR/gobyte.conf
if [ ! -d "$CONFDIR" ]; then mkdir $CONFDIR; fi
if [ $? -ne 0 ]; then error; fi
mnip=$(curl -s https://api.ipify.org)
rpcuser=$(date +%s | sha256sum | base64 | head -c 10 ; echo)
rpcpass=$(openssl rand -base64 32)
printf "%s\n" "rpcuser=$rpcuser" "rpcpassword=$rpcpass" "rpcallowip=127.0.0.1" "listen=1" "server=1" "daemon=1" "maxconnections=256" "rpcport=12454" "externalip=$mnip" "masternode=1" "masternodeprivkey=$MNPRIVKEY" > $CONFILE
gobyted
message "Wait 10 seconds for daemon to load..."
sleep 20s
MNPRIVKEY=$(gobyte-cli masternode genkey)
gobyte-cli stop
message "wait 10 seconds for deamon to stop..."
sleep 10s
sudo rm $CONFILE
message "Updating gobyte.conf..."
printf "%s\n" "rpcuser=$rpcuser" "rpcpassword=$rpcpass" "rpcallowip=127.0.0.1" "listen=1" "server=1" "daemon=1" "maxconnections=256" "rpcport=12454" "externalip=$mnip" "masternode=1" "masternodeprivkey=$MNPRIVKEY" > $CONFILE
}
success() {
gobyted
message "SUCCESS! Your gobyted has started. Masternode.conf setting below..."
message "MN $mnip:12455 $MNPRIVKEY TXHASH INDEX"
exit 0
}
install() {
prepdependencies
createswap
clonerepo
compile $1
createconf
success
}
#main
#default to --without-gui
install --without-gui