-
Notifications
You must be signed in to change notification settings - Fork 20
/
install-send.sh
123 lines (106 loc) · 4.37 KB
/
install-send.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
#!/bin/sh
#Version 0.1.1.3
#Info: Installs SocialSend daemon, Masternode, outputs config file entry for masternode.conf..
#SocialSend version 1.0.0.5 or above
#Tested OS: Ubuntu 17.10, 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 chaincoin user so chaincoin user does not require sudo privileges)
#TODO: add specific dependencies depending on build option (i.e. gui requires QT4)
noflags() {
echo "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄"
echo "Usage: install"
echo "Example: install"
echo "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄"
exit 1
}
message() {
echo "════════════════════════════════════════════════════════════════════════════════>>"
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 -y pkg-config
sudo apt-get install automake 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 ~/
sudo git clone https://github.com/SocialSend/SocialSend.git
}
compile() {
cd SocialSend #TODO: squash relative path
sudo chmod +x share/genbuild.sh
sudo chmod +x autogen.sh
sudo chmod 755 src/leveldb/build_detect_platform
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 SocialSend...this may take a few minutes..."
sudo make
if [ $? -ne 0 ]; then error; fi
message "Installing SocialSend..."
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 send.conf..."
CONFDIR=~/.send
CONFILE=$CONFDIR/send.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" > $CONFILE
sendd
message "Wait 10 seconds for daemon to load..."
sleep 20s
MNPRIVKEY=$(send-cli masternode genkey)
send-cli stop
message "wait 10 seconds for deamon to stop..."
sleep 20s
sudo rm $CONFILE
message "Updating send.conf..."
printf "%s\n" "rpcuser=$rpcuser" "rpcpassword=$rpcpass" "rpcallowip=127.0.0.1" "listen=1" "server=1" "daemon=1" "maxconnections=256" "masternode=1" "masternodeprivkey=$MNPRIVKEY" > $CONFILE
}
success() {
sendd
message "SUCCESS! Your sendd has started. Masternode.conf setting below..."
message "MN $mnip:50050 $MNPRIVKEY TXHASH INDEX"
exit 0
}
install() {
prepdependencies
createswap
clonerepo
compile $1
createconf
success
}
#main
#default to --without-gui
install --without-gui