forked from chaoabunga/mnscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-chc.sh
100 lines (88 loc) · 3.06 KB
/
install-chc.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
#!/bin/sh
#TODO: add version number to script
#TODO: add chc version dependency to script
#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 proper install path rather than defaulting
#TODO: add specific dependencies depending on build option (i.e. gui requires QT4)
noflags() {
echo "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄"
echo "Usage: install-chc [options]"
echo "Valid options are:"
echo "-gui" #can prolly change this for something more interesting i.e. desktop, master node, etc.
echo "-nogui" #this too
echo "Do not provide more than one option."
echo "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄"
exit 1
}
message() {
echo "╒════════════════════════════════════════════════════════════════════════════════>>"
echo "| $1"
echo "╘════════════════════════════════════════════<<<"
}
error() {
message "An error occured, you must fix it to continue!"
exit 1
}
success() {
message "SUCCESS! You can now run chaincoind"
exit 0
}
prepdependencies() { #TODO: add error detection
message "Installing dependencies..."
sudo apt-get update
sudo apt-get upgrade -y
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
}
clonerepo() { #TODO: add error detection
message "Cloning from github repository..."
cd ~/
git clone https://github.com/chaincoin/chaincoin.git
}
compile() {
cd chaincoin #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 ChainCoin...this may take a few minutes..."
make
if [ $? -ne 0 ]; then error; fi
message "Installing ChainCoin..."
sudo make install
if [ $? -ne 0 ]; then error; fi
}
install() {
prepdependencies
createswap
clonerepo
compile $1
success
}
#main
if [ -z $1 ] || [ $# -gt 1 ]
then
noflags
fi
if [ $1 = "-gui" ]
then
install
elif [ $1 = "-nogui" ]
then
install --without-gui
else
noflags
fi