View difference between Paste ID: sPFJdpDi and iggH4B75
SHOW: | | - or go back to the newest paste.
1
# Quarkcoin All-In-One EZ Setup Script
2
# Hacked together by GigaWatt
3
# Donations welcome!
4
#   BTC: 1E2egHUcLDAmcxcqZqpL18TPLx9Xj1akcV
5
#   XPM: AWHJbwoM67Ez12SHH4pH5DnJKPoMSdvLz2
6
# Last Update: 27 August, 2013
7
8
{
9
# PUT YOUR SETTINGS HERE
10-
QUARK_USERNAME=""
10+
QUARK_USERNAME="mmboulhosa"
11
12
13
# Build swapfile
14
if [[ ! -f /swapfile ]]; then
15
    echo "Building swapfile..."
16
    sudo dd if=/dev/zero of=/swapfile bs=64M count=16
17
    sudo mkswap /swapfile
18
    sudo swapon /swapfile
19
    
20
    # Mount on reboot
21
    if [[ -z "$(cat /etc/fstab | grep swapfile)" ]]; then
22
        echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab > /dev/null 2>&1
23
    fi
24
fi
25
26
# Auto reboot on kernel panic
27
if [[ -z "$(cat /etc/sysctl.conf | grep '^kernel.panic')" ]]; then
28
    echo "kernel.panic=3" | sudo tee /etc/sysctl.conf >/dev/null 2>&1
29
fi
30
31
32
echo "Installing libraries..."
33
sudo apt-get update
34
sudo apt-get install build-essential bc curl fail2ban git haveged libboost-all-dev libdb++-dev libminiupnpc-dev libssl-dev m4 nano -y
35
36
# Install GMP
37
cd ~/
38
rm -rf gmp-5.1.2.tar.bz2 gmp-5.1.2
39
wget http://mirrors.kernel.org/gnu/gmp/gmp-5.1.2.tar.bz2
40
tar xjvf gmp-5.1.2.tar.bz2
41
cd gmp-5.1.2
42
./configure --enable-cxx
43
make
44
sudo make install
45
rm -rf gmp-5.1.2.tar.bz2 gmp-5.1.2
46
cd ~/
47
48
# Enable HAVEGED for entropy
49
sudo update-rc.d haveged defaults
50
sudo service haveged restart
51
52
53
echo "Downloading and building quark..."
54
cat << "SCRIPT" > ~/build-quarkcoin
55
#!/bin/bash
56
[[ -f ~/stop-quarkcoind ]] && ./stop-quarkcoind
57
if [[ -d ~/quark ]]; then
58
    cd ~/quark
59
    git pull
60
    cd ~/quark/src
61
    make -f makefile.unix clean
62
else
63
    cd ~
64
    git clone https://github.com/MaxGuevara/quark.git
65
fi
66
cd ~/quark/src 
67
make -f makefile.unix USE_UPNP=- DEBUGFLAGS=""
68
sudo cp quarkcoind /usr/local/bin/
69
SCRIPT
70
chmod +x ~/build-quarkcoin
71
~/build-quarkcoin
72
73
74
echo "Building settings and scripts..."
75
mkdir ~/.quarkcoin
76
echo "rpcusername=${QUARKCOIN_USERNAME}
77
rpcpassword=$(cat /dev/urandom | tr -cd '[:alnum:]' | head -c32)
78
gen=1
79
genproclimit=-1" > ~/.quarkcoin/quarkcoin.conf
80
81
82
# Notification scripts
83
cat << "SCRIPT" > ~/notify-block
84
#!/bin/bash
85
# YOUR SCRIPT HERE
86
SCRIPT
87
chmod +x ~/notify-block
88
89
cat << "SCRIPT" > ~/notify-wallet
90
#!/bin/bash
91
# YOUR SCRIPT HERE
92
cp ~/.quarkcoin/wallet.dat ~/${HOSTNAME}.bak
93
SCRIPT
94
chmod +x ~/notify-wallet
95
96
97
# Watchdog runner
98
cat << "SCRIPT" > ~/start-quarkcoind
99
#!/bin/bash
100
export PATH="/usr/local/bin:$PATH"
101
echo Starting quarkcoind
102
[[ -n "$(pidof quarkcoind)" ]] && killall --older-than 60s -q start-quarkcoind quarkcoind
103
function background_loop
104
    while :; do
105
        quarkcoind -blocknotify="~/notify-block" -walletnotify="~/notify-wallet" >/dev/null 2>&1
106
        sleep 5
107
        date >> ~/crash.log
108
    done
109
background_loop &
110
SCRIPT
111
chmod +x ~/start-quarkcoind
112
~/start-quarkcoind
113
114
115
# Add to startup
116
mkdir /var/spool/cron/crontabs/ > /dev/null 2>&1
117
echo "@reboot ${HOME}/start-quarkcoind" | sudo tee    /var/spool/cron/crontabs/$(whoami) > /dev/null 2>&1
118
echo ""                                 | sudo tee -a /var/spool/cron/crontabs/$(whoami) > /dev/null 2>&1
119
sudo chmod 0600 /var/spool/cron/crontabs/$(whoami)
120
sudo update-rc.d cron defaults
121
122
123
# Watchdog stopper
124
cat << "SCRIPT" > ~/stop-quarkcoind
125
#!/bin/bash
126
killall -q start-quarkcoind
127
quarkcoind stop
128
sleep 3
129
[[ -n "$(pidof quarkcoind)" ]] && killall quarkcoind
130
SCRIPT
131
chmod +x ~/stop-quarkcoind
132
133
# Watchdog restarter
134
cat << "SCRIPT" > ~/restart-quarkcoind
135
#!/bin/bash
136
~/stop-quarkcoind
137
~/start-quarkcoind
138
SCRIPT
139
chmod +x ~/restart-quarkcoind
140
141
# Peek at status
142
cat << "SCRIPT" > ~/peek
143
#!/bin/bash
144
conf=$(quarkcoind getbalance)
145
unconf=$(quarkcoind getbalance '' 1)
146
immature=$(echo "scale=4;${unconf} - ${conf}" | bc)
147
echo "Stats: $(quarkcoind getmininginfo)"
148
echo "Confirmed Balance:  ${conf}"
149
echo "Immature Balance:   ${immature}"
150
echo "Immature TX: $(quarkcoind listtransactions | grep immature | wc -l)"
151
echo "Connections: $(quarkcoind getconnectioncount)"
152
SCRIPT
153
chmod +x ~/peek
154
155
156
# Dump address info
157
cat << "SCRIPT" > ~/myinfo
158
#!/bin/bash
159
for addr in $(quarkcoind listtransactions "" 99999 | grep -C 1 '"generate"\|"receive"' | grep --color=never -o "\b[A-Za-z0-9]\{33,36\}\b" | sort -u); do
160
    echo Address: ${addr}
161
    echo PrivKey: $(quarkcoind dumpprivkey ${addr})
162
    echo
163
done
164
SCRIPT
165
chmod +x ~/myinfo
166
167
168
# Edit quarkcoin config file
169
cat << "SCRIPT" > ~/config
170
#!/bin/bash
171
nano ~/.quarkcoin/quarkcoin.conf
172
~/stop-quarkcoind
173
~/start-quarkcoind
174
SCRIPT
175
chmod +x ~/config
176
177
178
echo
179
echo
180
echo '=========================================================='
181
echo 'All Done!'
182
echo 'quarkcoind should be up and running'
183
echo
184
echo 'Run ~/start-quarkcoind  to start quarkcoind and begin mining'
185
echo 'Run ~/stop-quarkcoind   to stop quarkcoind and stop mining'
186
echo 'Run ~/build-quarkcoin   to update and rebuild quarkcoind'
187
echo 'Run ~/config            to modify your quarkcoind config file'
188
echo 'Run ~/peek              to check on your mining status'
189
echo 'Run ~/myinfo            to view your quarkcoin address and privkey'
190
}