-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblake_install.sh
1272 lines (1178 loc) · 38.1 KB
/
blake_install.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#Global varables
#Config settings - change to suit needs
MAXCONNECTIONS='maxconnections=20'
RPCALLOWIP='rpcallowip=127.0.0.1'
GEN='gen=0'
LISTEN='listen=1'
DAEMON='daemon=1'
SERVER='server=1'
TXINDEX='txindex=0'
#For Script
FTP='https://bootstrap.specminer.com'
USER=$(whoami)
USERDIR=$(eval echo ~$user)
STRAP='bootstrap.dat'
COIN_PATH='/usr/local/bin'
SWAP="$(swapon --show)"
cols="$(tput cols)"
BBlue='\033[1;34m'
RED='\033[0;31m'
GREEN='\033[0;32m'
WHITE='\033[1;97m'
YELLOW='\033[0;93m'
UYellow='\033[4;33m'
NC='\033[0m'
HEART=' \u2665'
#For Menu
ERROR=" "
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec &> >(tee setup.log) 2>&1
# Everything below will go to the file 'setup.log':
clear
repeat(){
for ((i=0; i<cols; i++));do printf "="; done; echo
}
function native() {
#Menu option Native Daemon Instller
options[0]="Pre-Built"
options[1]="Build Locally"
options[2]="Create swapfile"
#Menu function
function MENU {
echo -e "${WHITE}Blakestream Daemon Install${NC}"
for NUM in ${!options[@]}; do
echo -e "${WHITE}[${NC}"${RED}"${choices[NUM]:- }""""${WHITE}]${NC}"$(( NUM+1 ))"-> ${options[NUM]}${NC}"
done
echo -e "${WHITE}Daemons pulled from Github unless *Build Locally* is selected${NC}"
repeat ; echo -e ${UYellow}'\nCurrent SwapFile'${NC}
echo "$SWAP"
repeat ;
echo "$ERROR"
}
#Menu loop
while MENU && read -e -p "Select the desired options using their number (again to uncheck, ENTER when done): " -n1 SELECTION && [[ -n "$SELECTION" ]]; do
clear
if [[ "$SELECTION" == *[[:digit:]]* && $SELECTION -ge 1 && $SELECTION -le ${#options[@]} ]]; then
(( SELECTION-- ))
if [[ "${choices[SELECTION]}" == "+" ]]; then
choices[SELECTION]=""
else
choices[SELECTION]="+"
fi
ERROR=" "
else
ERROR="Invalid option: $SELECTION"
fi
done
{
#Selection
if [[ ${choices[0]} ]]; then
echo "- Pre-Built"
pre_built='Y'
bld='Pre-Built'
fi
if [[ ${choices[1]} ]]; then
echo "- Build Locally"
local='Y'
bld='Local Built'
fi
if [[ ${choices[2]} ]]; then
echo "- Create Swap File"
swp='Y'
fi
}
}
function menu_check() {
if [[ $pre_built == "Y" ]] && [[ $local == "Y" ]]; then
clear
echo -e "${WHITE}Choose \u1F63nly Pre-Built OR Build Locally${NC}"
exit 1
fi
if [[ $pre_built == "Y" ]]; then
clear
#echo "Installing Pre-Built BlakeStream Daemons"
if [[ $swp == "Y" ]]; then
clear
echo "Create Swapfile for Daemon Install"
swapsz ;
swap ;
fi
elif [[ $local == "Y" ]]; then
clear
#echo "Installing local built Daemons"
if [[ $swp == "Y" ]]; then
clear
echo "Create Swapfile for Daemon Install"
swapsz ;
swap ;
fi
elif [[ $swp == "Y" ]]; then
clear
echo -e "Create Swapfile - No Daemon Install"
swapsz ;
swap ;
exit 1
else
clear
echo -e "${WHITE}No Install option Selected${NC}"
echo $pre_built
echo $local
exit 1
fi
sleep 2
}
swapsz(){
#Set size of swapfile in megabytes
repeat ; echo -e ${WHITE}Size of swapfile in megabytes${NC}
echo -e "500mb= 512 - 1gb= 1024 - 2gb= 2048"
echo -e " 3gb= 3072 - 4gb= 4096 - 5gb= 5120"
repeat ;
read -p "Enter swapfile size: " swapsize
read -p "Continue with $swapsize swapfile? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
}
swap(){
#checking for swapfile
if [ $(free | awk '/^Swap:/ {exit !$2}') ] || [ ! -f "/blake_swap.img" ]; then
echo "Creating a Swap file"
rm -f /blake_swap.img
dd if=/dev/zero of=/blake_swap.img bs=1024k count="$swapsize"
chmod 0600 /blake_swap.img
mkswap /blake_swap.img
swapon /blake_swap.img
echo '/blake_swap.img none swap sw 0 0' | tee -a /etc/fstab
echo 'vm.swappiness=10' | tee -a /etc/sysctl.conf
echo 'vm.vfs_cache_pressure=50' | tee -a /etc/sysctl.conf
clear
else
echo "A Swap File aready exist"
sleep 1
fi
}
function wallet_select() {
unset SELECTION
unset choices
clear
#Menu option for coin selection
options[0]="All BlakeStream Coins"
options[1]="Blakecoin"
options[2]="Photon"
options[3]="BlakeBitcoin"
options[4]="Electron"
options[5]="Universal Molecule"
options[6]="Lithium"
options[7]="Download bootstraps for selected Daemons"
options[8]="Install bootstrap removal script"
#Menu function
function COIN {
echo -e "${WHITE}Blakestream "$bld" Daemon Install${NC}"
for NUM in ${!options[@]}; do
echo -e "${WHITE}[${NC}"${RED}"${choices[NUM]:- }""""${WHITE}]${NC}"$(( NUM+1 ))"-> ${options[NUM]}${NC}"
done
echo "$ERROR"
}
#Menu loop
while COIN && read -e -p "Select the desired options using their number (again to uncheck, ENTER when done): " -n1 SELECTION && [[ -n "$SELECTION" ]]; do
clear
if [[ "$SELECTION" == *[[:digit:]]* && $SELECTION -ge 1 && $SELECTION -le ${#options[@]} ]]; then
(( SELECTION-- ))
if [[ "${choices[SELECTION]}" == "+" ]]; then
choices[SELECTION]=""
else
choices[SELECTION]="+"
fi
ERROR=" "
else
ERROR="Invalid option: $SELECTION"
fi
done
{
#Selection
echo " "
echo "================="
echo "Selected Options"
echo "================="
if [[ ${choices[0]} ]]; then
#Option 1 selected
echo "- All Blakestream Daemons"
ALL='Y'
fi
if [[ ${choices[1]} ]]; then
#Option 2 selected
echo "- Blakecoin"
BLC='Y'
fi
if [[ ${choices[2]} ]]; then
#Option 3 selected
echo "- Photon"
PHO='Y'
fi
if [[ ${choices[3]} ]]; then
#Option 4 selected
echo "- BlakeBitcoin"
BBTC='Y'
fi
if [[ ${choices[4]} ]]; then
#Option 5 selected
echo "- Electron"
ELT='Y'
fi
if [[ ${choices[5]} ]]; then
#Option 6 selected
echo "- Universal Molecule"
UMO='Y'
fi
if [[ ${choices[6]} ]]; then
#Option 7 selected
echo "- Lithium"
LIT='Y'
fi
if [[ ${choices[7]} ]]; then
#Option 8 selected
echo "- Download Boostrap for selected Daemons"
BSTRP='Y'
fi
if [[ ${choices[8]} ]]; then
#Option 8 selected
echo "- Install bootstrap removal script"
BOOT='Y'
fi
sleep 2
}
}
function depend_native() {
clear
if [[ $(lsb_release -d) = *16.04* ]]; then
echo -e "${WHITE}Installing Dependancies for Ubuntu 16.04${NC}"
apt-get update
sleep 1
apt install --no-install-recommends -y software-properties-common
apt-add-repository -y ppa:bitcoin/bitcoin
apt-get update
apt install --no-install-recommends -y wget git curl build-essential libssl-dev libboost-all-dev libminiupnpc-dev libdb4.8-dev libdb4.8++-dev
clone='git clone -b 16.04'
pre_com='16.04'
USRDIR='/usr/local/bin/'
elif [[ $(lsb_release -d) = *18.04* ]]; then
echo -e "${WHITE}Installing Dependancies for Ubuntu 18.04${NC}"
apt-get update
sleep 1
apt install --no-install-recommends -y software-properties-common
apt-add-repository -y ppa:bitcoin/bitcoin
apt-get update
apt install --no-install-recommends -y wget git curl build-essential libssl-dev libboost-all-dev libminiupnpc-dev libdb4.8-dev libdb4.8++-dev
clone='git clone -b 16.04'
pre_com='18.04'
USRDIR='/usr/local/bin/'
elif [[ $(lsb_release -d) = *20.04* ]]; then
echo -e "${WHITE}Installing Dependancies for Ubuntu 20.04${NC}"
apt-get update
sleep 1
apt install --no-install-recommends -y software-properties-common
wget --no-check-certificate -O $USERDIR/BitcoinPPA.key 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xc70ef1f0305a1adb9986dbd8d46f45428842ce5e'
apt-key add $USERDIR/BitcoinPPA.key
echo "deb http://ppa.launchpad.net/bitcoin/bitcoin/ubuntu/ bionic main" | sudo tee -a /etc/apt/sources.list
apt-get update
apt install --no-install-recommends -y wget git curl build-essential libssl-dev libboost-all-dev libminiupnpc-dev libdb4.8-dev libdb4.8++-dev
clone='git clone'
pre_com='20.04'
else
echo -e "${RED}No Compatable Ubuntu version installed${NC}"
fi
}
progressfilt ()
{
local flag=false c count cr=$'\r' nl=$'\n'
while IFS='' read -d '' -rn 1 c
do
if $flag
then
printf '%s' "$c"
else
if [[ $c != $cr && $c != $nl ]]
then
count=0
else
((count++))
if ((count > 1))
then
flag=true
fi
fi
fi
done
}
function blc_native() {
clear
if [ -f "$USERDIR/$BLC_CONFIGFOLDER/peers.dat" ]; then
echo "$BLC_COIN_NAME already installed skipping"
elif [[ $BLC == Y || $ALL == Y ]]; then
#BlakeCoin Variables
BLC_REPO='https://github.com/BlueDragon747/Blakecoin.git'
BLC_DAEMON='https://github.com/SidGrip/BlakeStream-Nodes/releases/download'
BLC_CONFIG_FILE='blakecoin.conf'
BLC_CONFIGFOLDER='.blakecoin'
BLC_COIN_DAEMON='blakecoind'
BLC_COIN_NAME='Blakecoin'
BLC_RPC_PORT='8772'
BLC_P2P_PORT='8773'
echo "Setting up $BLC_COIN_NAME Daemon"
sleep 2
if [[ $local == Y ]]; then
echo -e "${WHITE}Compiling wallet locally${NC}"
$clone $BLC_REPO /tmp/$BLC_COIN_NAME
chmod +x /tmp/$BLC_COIN_NAME/src/leveldb/build_detect_platform
cd /tmp/$BLC_COIN_NAME/src
make -f makefile.unix
strip $BLC_COIN_DAEMON
mv $BLC_COIN_DAEMON $COIN_PATH
blc_setup ;
blc_service ;
fi
if [[ $pre_built == Y ]]; then
wget --progress=bar:force -O $COIN_PATH/$BLC_COIN_DAEMON $BLC_DAEMON/$pre_com/$BLC_COIN_DAEMON 2>&1 | progressfilt;
sleep 2
chmod +x $COIN_PATH/$BLC_COIN_DAEMON
clear
blc_setup ;
blc_service ;
fi
else
echo "$BLC_COIN_NAME option not chosen"
fi
}
blc_setup(){
#Setup Firewall
echo -e "Opening port# ${GREEN}$BLC_P2P_PORT${NC}"
ufw allow $BLC_P2P_PORT/tcp comment "$BLC_COIN_NAME" >/dev/null
#Make Coin Directory
mkdir $USERDIR/$BLC_CONFIGFOLDER >/dev/null 2>&1
#Create Config File
echo -e "Creating $BLC_COIN_NAME config file"
# get list of curent active nodes from chainz block explorer sort and save to var
NODES=$(curl -s https://chainz.cryptoid.info/blc/api.dws?q=nodes)
BLC_PEERS=$(grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' <<< "$NODES" | sed -e 's/^/addnode=/')
RPCUSER=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w10 | head -n1)
RPCPASSWORD=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w22 | head -n1)
cat << EOF > $USERDIR/$BLC_CONFIGFOLDER/$BLC_CONFIG_FILE
$MAXCONNECTIONS
rpcuser=$RPCUSER
rpcpassword=$RPCPASSWORD
$RPCALLOWIP
rpcport=$BLC_RPC_PORT
port=$BLC_P2P_PORT
$GEN
$LISTEN
$DAEMON
$SERVER
$TXINDEX
$BLC_PEERS
EOF
#Downloading Bootstrap
if [[ $BSTRP == Y ]]; then
echo "Downloading $BLC_COIN_NAME $STRAP to $USERDIR/$BLC_CONFIGFOLDER"
wget --progress=bar:force -O $USERDIR/$BLC_CONFIGFOLDER/$STRAP $FTP/$BLC_COIN_NAME/$STRAP 2>&1 | progressfilt;
else
echo "$BLC_COIN_NAME Boostrap not selected"
fi
}
blc_service(){
#Create system servivce
cat << EOF > /etc/systemd/system/$BLC_COIN_NAME.service
[Unit]
Description=$BLC_COIN_NAME service
After=network.target
[Service]
User=root
Group=root
Type=forking
#PIDFile=$USERDIR/$BLC_CONFIGFOLDER/$BLC_COIN_NAME.pid
ExecStart=$USRDIR$BLC_COIN_DAEMON -daemon -conf=$USERDIR/$BLC_CONFIGFOLDER/$BLC_CONFIG_FILE -datadir=$USERDIR/$BLC_CONFIGFOLDER
ExecStop=$USRDIR$BLC_COIN_DAEMON -conf=$USERDIR/$BLC_CONFIGFOLDER/$BLC_CONFIG_FILE -datadir=$USERDIR/$BLC_CONFIGFOLDER stop
Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=10s
StartLimitInterval=120s
StartLimitBurst=2
CPUQuota=60%
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
sleep 4
systemctl start $BLC_COIN_NAME.service
systemctl enable $BLC_COIN_NAME.service >/dev/null 2>&1
if [[ -z "$(ps axo cmd:100 | egrep $BLC_COIN_DAEMON)" ]]; then
echo -e "${RED}$BLC_COIN_NAME is not running${NC}, please investigate. You should start by running the following commands as root:"
echo -e "${GREEN}systemctl start $BLC_COIN_NAME.service"
echo -e "systemctl status $BLC_COIN_NAME.service"
echo -e "less /var/log/syslog${NC}"
exit 1
fi
sleep 2
echo -e "Starting $BLC_COIN_NAME Daemon"
sleep 4
rm $USERDIR/$BLC_CONFIGFOLDER/debug.log
}
function pho_native() {
clear
if [ -f "$USERDIR/$PHO_CONFIGFOLDER/peers.dat" ]; then
echo "$PHO_COIN_NAME already installed skipping"
elif [[ $PHO == Y || $ALL == Y ]]; then
#PhotonCoin Variables
PHO_REPO='https://github.com/photonproject/photon.git'
PHO_DAEMON='https://github.com/SidGrip/BlakeStream-Nodes/releases/download'
PHO_CONFIG_FILE='photon.conf'
PHO_CONFIGFOLDER='.photon'
PHO_COIN_DAEMON='photond'
PHO_COIN_NAME='Photon'
PHO_RPC_PORT='8984'
PHO_P2P_PORT='35556'
echo "Setting up $PHO_COIN_NAME Daemon"
sleep 2
if [[ $local == Y ]]; then
echo -e "${WHITE}Compiling wallet locally${NC}"
$clone $PHO_REPO /tmp/$PHO_COIN_NAME
chmod +x /tmp/$PHO_COIN_NAME/src/leveldb/build_detect_platform
cd /tmp/$PHO_COIN_NAME/src
make -f makefile.unix
strip $PHO_COIN_DAEMON
mv $PHO_COIN_DAEMON $COIN_PATH
pho_setup ;
pho_service ;
fi
if [[ $pre_built == Y ]]; then
wget --progress=bar:force -O $COIN_PATH/$PHO_COIN_DAEMON $PHO_DAEMON/$pre_com/$PHO_COIN_DAEMON 2>&1 | progressfilt;
sleep 2
chmod +x $COIN_PATH/$PHO_COIN_DAEMON
clear
pho_setup ;
pho_service ;
fi
else
echo "$PHO_COIN_NAME option not chosen"
fi
}
pho_setup(){
#Setup Firewall
echo -e "Opening port# ${GREEN}$PHO_P2P_PORT${NC}"
ufw allow $PHO_P2P_PORT/tcp comment "$PHO_COIN_NAME" >/dev/null
#Make Coin Directory
mkdir $USERDIR/$PHO_CONFIGFOLDER >/dev/null 2>&1
#Create Config File
echo -e "Creating $PHO_COIN_NAME config file"
# get list of curent active nodes from chainz block explorer sort and save to var
NODES=$(curl -s https://chainz.cryptoid.info/pho/api.dws?q=nodes)
PHO_PEERS=$(grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' <<< "$NODES" | sed -e 's/^/addnode=/')
RPCUSER=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w10 | head -n1)
RPCPASSWORD=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w22 | head -n1)
cat << EOF > $USERDIR/$PHO_CONFIGFOLDER/$PHO_CONFIG_FILE
$MAXCONNECTIONS
rpcuser=$RPCUSER
rpcpassword=$RPCPASSWORD
$RPCALLOWIP
rpcport=$PHO_RPC_PORT
port=$PHO_P2P_PORT
$GEN
$LISTEN
$DAEMON
$SERVER
$TXINDEX
$PHO_PEERS
EOF
#Downloading Bootstrap
if [[ $BSTRP == Y ]]; then
echo "Downloading $PHO_COIN_NAME $STRAP to $USERDIR/$PHO_CONFIGFOLDER"
wget --progress=bar:force -O $USERDIR/$PHO_CONFIGFOLDER/$STRAP $FTP/$PHO_COIN_NAME/$STRAP 2>&1 | progressfilt;
else
echo "$PHO_COIN_NAME Boostrap not selected"
fi
}
pho_service(){
#Create system servivce
cat << EOF > /etc/systemd/system/$PHO_COIN_NAME.service
[Unit]
Description=$PHO_COIN_NAME service
After=network.target
[Service]
User=root
Group=root
Type=forking
#PIDFile=$USERDIR/$PHO_CONFIGFOLDER/$PHO_COIN_NAME.pid
ExecStart=$USRDIR$PHO_COIN_DAEMON -daemon -conf=$USERDIR/$PHO_CONFIGFOLDER/$PHO_CONFIG_FILE -datadir=$USERDIR/$PHO_CONFIGFOLDER
ExecStop=$USRDIR$PHO_COIN_DAEMON -conf=$USERDIR/$PHO_CONFIGFOLDER/$PHO_CONFIG_FILE -datadir=$USERDIR/$PHO_CONFIGFOLDER stop
Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=10s
StartLimitInterval=120s
StartLimitBurst=2
CPUQuota=60%
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
sleep 4
systemctl start $PHO_COIN_NAME.service
systemctl enable $PHO_COIN_NAME.service >/dev/null 2>&1
if [[ -z "$(ps axo cmd:100 | egrep $PHO_COIN_DAEMON)" ]]; then
echo -e "${RED}$PHO_COIN_NAME is not running${NC}, please investigate. You should start by running the following commands as root:"
echo -e "${GREEN}systemctl start $PHO_COIN_NAME.service"
echo -e "systemctl status $PHO_COIN_NAME.service"
echo -e "less /var/log/syslog${NC}"
exit 1
fi
sleep 2
echo -e "Starting $PHO_COIN_NAME Daemon"
sleep 4
rm $USERDIR/$PHO_CONFIGFOLDER/debug.log
}
function bbtc_native() {
clear
if [ -f "$USERDIR/$BBTC_CONFIGFOLDER/peers.dat" ]; then
echo "$BBTC_COIN_NAME already installed skipping"
elif [[ $BBTC == Y || $ALL == Y ]]; then
#BlakeBitcoin Variables
BBTC_REPO='https://github.com/BlakeBitcoin/BlakeBitcoin.git'
BBTC_DAEMON='https://github.com/SidGrip/BlakeStream-Nodes/releases/download'
BBTC_CONFIG_FILE='blakebitcoin.conf'
BBTC_CONFIGFOLDER='.blakebitcoin'
BBTC_COIN_DAEMON='blakebitcoind'
BBTC_COIN_NAME='BlakeBitcoin'
BBTC_RPC_PORT='243'
BBTC_P2P_PORT='356'
echo "Setting up $BBTC_COIN_NAME Daemon"
sleep 2
if [[ $local == Y ]]; then
echo -e "${WHITE}Compiling wallet locally${NC}"
$clone $BBTC_REPO /tmp/$BBTC_COIN_NAME
chmod +x /tmp/$BBTC_COIN_NAME/src/leveldb/build_detect_platform
cd /tmp/$BBTC_COIN_NAME/src
make -f makefile.unix
strip $BBTC_COIN_DAEMON
mv $BBTC_COIN_DAEMON $COIN_PATH
bbtc_setup ;
bbtc_service ;
fi
if [[ $pre_built == Y ]]; then
wget --progress=bar:force -O $COIN_PATH/$BBTC_COIN_DAEMON $BBTC_DAEMON/$pre_com/$BBTC_COIN_DAEMON 2>&1 | progressfilt;
sleep 2
chmod +x $COIN_PATH/$BBTC_COIN_DAEMON
clear
bbtc_setup ;
bbtc_service ;
fi
else
echo "$BBTC_COIN_NAME option not chosen"
fi
}
bbtc_setup(){
#Setup Firewall
echo -e "Opening port# ${GREEN}$BBTC_P2P_PORT${NC}"
ufw allow $BBTC_P2P_PORT/tcp comment "$BBTC_COIN_NAME" >/dev/null
#Make Coin Directory
mkdir $USERDIR/$BBTC_CONFIGFOLDER >/dev/null 2>&1
#Create Config File
echo -e "Creating $BBTC_COIN_NAME config file"
# get list of curent active nodes from chainz block explorer sort and save to var
NODES=$(curl -s https://chainz.cryptoid.info/bbtc/api.dws?q=nodes)
BBTC_PEERS=$(grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' <<< "$NODES" | sed -e 's/^/addnode=/')
RPCUSER=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w10 | head -n1)
RPCPASSWORD=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w22 | head -n1)
cat << EOF > $USERDIR/$BBTC_CONFIGFOLDER/$BBTC_CONFIG_FILE
$MAXCONNECTIONS
rpcuser=$RPCUSER
rpcpassword=$RPCPASSWORD
$RPCALLOWIP
rpcport=$BBTC_RPC_PORT
port=$BBTC_P2P_PORT
$GEN
$LISTEN
$DAEMON
$SERVER
$TXINDEX
$BBTC_PEERS
EOF
#Downloading Bootstrap
if [[ $BSTRP == Y ]]; then
echo "Downloading $BBTC_COIN_NAME $STRAP to $USERDIR/$BBTC_CONFIGFOLDER"
wget --progress=bar:force -O $USERDIR/$BBTC_CONFIGFOLDER/$STRAP $FTP/$BBTC_COIN_NAME/$STRAP 2>&1 | progressfilt;
else
echo "$BBTC_COIN_NAME Boostrap not selected"
fi
}
bbtc_service(){
#Create system servivce
cat << EOF > /etc/systemd/system/$BBTC_COIN_NAME.service
[Unit]
Description=$BBTC_COIN_NAME service
After=network.target
[Service]
User=root
Group=root
Type=forking
#PIDFile=$USERDIR/$BBTC_CONFIGFOLDER/$BBTC_COIN_NAME.pid
ExecStart=$USRDIR$BBTC_COIN_DAEMON -daemon -conf=$USERDIR/$BBTC_CONFIGFOLDER/$BBTC_CONFIG_FILE -datadir=$USERDIR/$BBTC_CONFIGFOLDER
ExecStop=$USRDIR$BBTC_COIN_DAEMON -conf=$USERDIR/$BBTC_CONFIGFOLDER/$BBTC_CONFIG_FILE -datadir=$USERDIR/$BBTC_CONFIGFOLDER stop
Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=10s
StartLimitInterval=120s
StartLimitBurst=2
CPUQuota=60%
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
sleep 4
systemctl start $BBTC_COIN_NAME.service
systemctl enable $BBTC_COIN_NAME.service >/dev/null 2>&1
if [[ -z "$(ps axo cmd:100 | egrep $BBTC_COIN_DAEMON)" ]]; then
echo -e "${RED}$BBTC_COIN_NAME is not running${NC}, please investigate. You should start by running the following commands as root:"
echo -e "${GREEN}systemctl start $BBTC_COIN_NAME.service"
echo -e "systemctl status $BBTC_COIN_NAME.service"
echo -e "less /var/log/syslog${NC}"
exit 1
fi
sleep 2
echo -e "Starting $BBTC_COIN_NAME Daemon"
sleep 4
rm $USERDIR/$BBTC_CONFIGFOLDER/debug.log
}
function elt_native() {
clear
if [ -f "$USERDIR/$ELT_CONFIGFOLDER/peers.dat" ]; then
echo "$ELT_COIN_NAME already installed skipping"
elif [[ $ELT == Y || $ALL == Y ]]; then
#ElectronCoin Variables
ELT_REPO='https://github.com/BlueDragon747/Electron-ELT.git'
ELT_DAEMON='https://github.com/SidGrip/BlakeStream-Nodes/releases/download'
ELT_CONFIG_FILE='electron.conf'
ELT_CONFIGFOLDER='.electron'
ELT_COIN_DAEMON='electrond'
ELT_COIN_NAME='Electron'
ELT_RPC_PORT='6852'
ELT_P2P_PORT='6853'
echo "Setting up $ELT_COIN_NAME Daemon"
sleep 2
if [[ $local == Y ]]; then
echo -e "${WHITE}Compiling wallet locally${NC}"
$clone $ELT_REPO /tmp/$ELT_COIN_NAME
chmod +x /tmp/$ELT_COIN_NAME/src/leveldb/build_detect_platform
cd /tmp/$ELT_COIN_NAME/src
make -f makefile.unix
strip $ELT_COIN_DAEMON
mv $ELT_COIN_DAEMON $COIN_PATH
elt_setup ;
elt_service ;
fi
if [[ $pre_built == Y ]]; then
wget --progress=bar:force -O $COIN_PATH/$ELT_COIN_DAEMON $ELT_DAEMON/$pre_com/$ELT_COIN_DAEMON 2>&1 | progressfilt;
sleep 2
chmod +x $COIN_PATH/$ELT_COIN_DAEMON
clear
elt_setup ;
elt_service ;
fi
else
echo "$ELT_COIN_NAME option not chosen"
fi
}
elt_setup(){
#Setup Firewall
echo -e "Opening port# ${GREEN}$ELT_P2P_PORT${NC}"
ufw allow $ELT_P2P_PORT/tcp comment "$ELT_COIN_NAME" >/dev/null
#Make Coin Directory
mkdir $USERDIR/$ELT_CONFIGFOLDER >/dev/null 2>&1
#Create Config File
echo -e "Creating $ELT_COIN_NAME config file"
# get list of curent active nodes from chainz block explorer sort and save to var
NODES=$(curl -s https://chainz.cryptoid.info/bbtc/api.dws?q=nodes)
ELT_PEERS=$(grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' <<< "$NODES" | sed -e 's/^/addnode=/')
RPCUSER=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w10 | head -n1)
RPCPASSWORD=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w22 | head -n1)
cat << EOF > $USERDIR/$ELT_CONFIGFOLDER/$ELT_CONFIG_FILE
$MAXCONNECTIONS
rpcuser=$RPCUSER
rpcpassword=$RPCPASSWORD
$RPCALLOWIP
rpcport=$ELT_RPC_PORT
port=$ELT_P2P_PORT
$GEN
$LISTEN
$DAEMON
$SERVER
$TXINDEX
$ELT_PEERS
EOF
#Downloading Bootstrap
if [[ $BSTRP == Y ]]; then
echo "Downloading $ELT_COIN_NAME $STRAP to $USERDIR/$ELT_CONFIGFOLDER"
wget --progress=bar:force -O $USERDIR/$ELT_CONFIGFOLDER/$STRAP $FTP/$ELT_COIN_NAME/$STRAP 2>&1 | progressfilt;
else
echo "$ELT_COIN_NAME Boostrap not selected"
fi
}
elt_service(){
#Create system servivce
cat << EOF > /etc/systemd/system/$ELT_COIN_NAME.service
[Unit]
Description=$ELT_COIN_NAME service
After=network.target
[Service]
User=root
Group=root
Type=forking
#PIDFile=$USERDIR/$ELT_CONFIGFOLDER/$ELT_COIN_NAME.pid
ExecStart=$USRDIR$ELT_COIN_DAEMON -daemon -conf=$USERDIR/$ELT_CONFIGFOLDER/$ELT_CONFIG_FILE -datadir=$USERDIR/$ELT_CONFIGFOLDER
ExecStop=$USRDIR$ELT_COIN_DAEMON -conf=$USERDIR/$ELT_CONFIGFOLDER/$ELT_CONFIG_FILE -datadir=$USERDIR/$ELT_CONFIGFOLDER stop
Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=10s
StartLimitInterval=120s
StartLimitBurst=2
CPUQuota=60%
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
sleep 4
systemctl start $ELT_COIN_NAME.service
systemctl enable $ELT_COIN_NAME.service >/dev/null 2>&1
if [[ -z "$(ps axo cmd:100 | egrep $ELT_COIN_DAEMON)" ]]; then
echo -e "${RED}$ELT_COIN_NAME is not running${NC}, please investigate. You should start by running the following commands as root:"
echo -e "${GREEN}systemctl start $ELT_COIN_NAME.service"
echo -e "systemctl status $ELT_COIN_NAME.service"
echo -e "less /var/log/syslog${NC}"
exit 1
fi
sleep 2
echo -e "Starting $ELT_COIN_NAME Daemon"
sleep 4
rm $USERDIR/$ELT_CONFIGFOLDER/debug.log
}
function umo_native() {
clear
if [ -f "$USERDIR/$UMO_CONFIGFOLDER/peers.dat" ]; then
echo "$UMO_COIN_NAME already installed skipping"
elif [[ $UMO == Y || $ALL == Y ]]; then
#Universalmolecule Variables
UMO_REPO='https://github.com/BlueDragon747/universalmol.git'
UMO_DAEMON='https://github.com/SidGrip/BlakeStream-Nodes/releases/download'
UMO_CONFIG_FILE='universalmolecule.conf'
UMO_CONFIGFOLDER='.universalmolecule'
UMO_COIN_DAEMON='universalmoleculed'
UMO_COIN_NAME='UniversalMolecule'
UMO_RPC_PORT='19738'
UMO_P2P_PORT='24785'
echo "Setting up $UMO_COIN_NAME Daemon"
sleep 2
if [[ $local == Y ]]; then
echo -e "${WHITE}Compiling wallet locally${NC}"
$clone $UMO_REPO /tmp/$UMO_COIN_NAME
chmod +x /tmp/$UMO_COIN_NAME/src/leveldb/build_detect_platform
cd /tmp/$UMO_COIN_NAME/src
make -f makefile.unix
strip $UMO_COIN_DAEMON
mv $UMO_COIN_DAEMON $COIN_PATH
umo_setup ;
umo_service ;
fi
if [[ $pre_built == Y ]]; then
wget --progress=bar:force -O $COIN_PATH/$UMO_COIN_DAEMON $UMO_DAEMON/$pre_com/$UMO_COIN_DAEMON 2>&1 | progressfilt;
sleep 2
chmod +x $COIN_PATH/$UMO_COIN_DAEMON
clear
umo_setup ;
umo_service ;
fi
else
echo "$UMO_COIN_NAME option not chosen"
fi
}
umo_setup(){
#Setup Firewall
echo -e "Opening port# ${GREEN}$UMO_P2P_PORT${NC}"
ufw allow $UMO_P2P_PORT/tcp comment "$UMO_COIN_NAME" >/dev/null
#Make Coin Directory
mkdir $USERDIR/$UMO_CONFIGFOLDER >/dev/null 2>&1
#Create Config File
echo -e "Creating $UMO_COIN_NAME config file"
# get list of curent active nodes from chainz block explorer sort and save to var
NODES=$(curl -s https://chainz.cryptoid.info/bbtc/api.dws?q=nodes)
UMO_PEERS=$(grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' <<< "$NODES" | sed -e 's/^/addnode=/')
RPCUSER=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w10 | head -n1)
RPCPASSWORD=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w22 | head -n1)
cat << EOF > $USERDIR/$UMO_CONFIGFOLDER/$UMO_CONFIG_FILE
$MAXCONNECTIONS
rpcuser=$RPCUSER
rpcpassword=$RPCPASSWORD
$RPCALLOWIP
rpcport=$UMO_RPC_PORT
port=$UMO_P2P_PORT
$GEN
$LISTEN
$DAEMON
$SERVER
$TXINDEX
$UMO_PEERS
EOF
#Downloading Bootstrap
if [[ $BSTRP == Y ]]; then
echo "Downloading $UMO_COIN_NAME $STRAP to $USERDIR/$UMO_CONFIGFOLDER"
wget --progress=bar:force -O $USERDIR/$UMO_CONFIGFOLDER/$STRAP $FTP/$UMO_COIN_NAME/$STRAP 2>&1 | progressfilt;
else
echo "$UMO_COIN_NAME Boostrap not selected"
fi
}
umo_service() {
#Create system servivce
cat << EOF > /etc/systemd/system/$UMO_COIN_NAME.service
[Unit]
Description=$UMO_COIN_NAME service
After=network.target
[Service]
User=root
Group=root
Type=forking
#PIDFile=$USERDIR/$UMO_CONFIGFOLDER/$UMO_COIN_NAME.pid
ExecStart=$USRDIR$UMO_COIN_DAEMON -daemon -conf=$USERDIR/$UMO_CONFIGFOLDER/$UMO_CONFIG_FILE -datadir=$USERDIR/$UMO_CONFIGFOLDER
ExecStop=$USRDIR$UMO_COIN_DAEMON -conf=$USERDIR/$UMO_CONFIGFOLDER/$UMO_CONFIG_FILE -datadir=$USERDIR/$UMO_CONFIGFOLDER stop
Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=10s
StartLimitInterval=120s
StartLimitBurst=2
CPUQuota=60%
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
sleep 4
systemctl start $UMO_COIN_NAME.service
systemctl enable $UMO_COIN_NAME.service >/dev/null 2>&1
if [[ -z "$(ps axo cmd:100 | egrep $UMO_COIN_DAEMON)" ]]; then
echo -e "${RED}$UMO_COIN_NAME is not running${NC}, please investigate. You should start by running the following commands as root:"
echo -e "${GREEN}systemctl start $UMO_COIN_NAME.service"
echo -e "systemctl status $UMO_COIN_NAME.service"
echo -e "less /var/log/syslog${NC}"
exit 1
fi
sleep 2
echo -e "Starting $UMO_COIN_NAME Daemon"
sleep 4
rm $USERDIR/$UMO_CONFIGFOLDER/debug.log
}
function lit_native() {
clear
if [ -f "$USERDIR/$LIT_CONFIGFOLDER/peers.dat" ]; then
echo "$LIT_COIN_NAME already installed skipping"
elif [[ $LIT == Y || $ALL == Y ]]; then
#LithiumCoin Variables
LIT_REPO='https://github.com/lithiumcoin/lithium.git'
LIT_DAEMON='https://github.com/SidGrip/BlakeStream-Nodes/releases/download'
LIT_CONFIG_FILE='lithium.conf'
LIT_CONFIGFOLDER='.lithium'
LIT_COIN_DAEMON='lithiumd'
LIT_COIN_NAME='Lithium'
LIT_RPC_PORT='12345'
LIT_P2P_PORT='12007'
echo "Setting up $LIT_COIN_NAME Daemon"
sleep 2
if [[ $local == Y ]]; then
echo -e "${WHITE}Compiling wallet locally${NC}"
$clone $LIT_REPO /tmp/$LIT_COIN_NAME
chmod +x /tmp/$LIT_COIN_NAME/src/leveldb/build_detect_platform
cd /tmp/$LIT_COIN_NAME/src
make -f makefile.unix
strip $LIT_COIN_DAEMON
mv $LIT_COIN_DAEMON $COIN_PATH
lit_setup ;
lit_service ;
fi
if [[ $pre_built == Y ]]; then
wget --progress=bar:force -O $COIN_PATH/$LIT_COIN_DAEMON $LIT_DAEMON/$pre_com/$LIT_COIN_DAEMON 2>&1 | progressfilt;
sleep 2
chmod +x $COIN_PATH/$LIT_COIN_DAEMON
clear
lit_setup ;
lit_service ;
fi
else
echo "$LIT_COIN_NAME option not chosen"
fi
}
lit_setup(){
#Setup Firewall
echo -e "Opening port# ${GREEN}$LIT_P2P_PORT${NC}"
ufw allow $LIT_P2P_PORT/tcp comment "$LIT_COIN_NAME" >/dev/null
#Make Coin Directory
mkdir $USERDIR/$LIT_CONFIGFOLDER >/dev/null 2>&1
#Create Config File
echo -e "Creating $LIT_COIN_NAME config file"
# get list of curent active nodes from chainz block explorer sort and save to var
NODES=$(curl -s https://chainz.cryptoid.info/bbtc/api.dws?q=nodes)
LIT_PEERS=$(grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' <<< "$NODES" | sed -e 's/^/addnode=/')