rootzoll
7 years ago
12 changed files with 222 additions and 111 deletions
@ -1,105 +1,67 @@ |
|||
#!/bin/sh |
|||
echo "" |
|||
|
|||
# *** BITCOIN Torrent *** |
|||
bitcoinTorrent="raspiblitz-hdd-2018-07-16" |
|||
bitcoinTorrentsize=231230512 |
|||
# *** BITCOIN *** |
|||
bitcoinList="" # url to list with other sources |
|||
bitcoinUrl="ftp://anonymous:anonymous@tll9xsfkjht8j26z.myfritz.net/raspiblitz-hdd-2018-07-16" |
|||
bitcoinSize=100 |
|||
|
|||
# *** LITECOIN Torrent *** |
|||
litecoinTorrent="raspiblitz-litecoin-2018-07-28" |
|||
litecoinTorrentsize=100 |
|||
# *** LITECOIN *** |
|||
litecoinList="" # url to list with other sources |
|||
litecoinUrl="ftp://anonymous:anonymous@ftp.rotzoll.de/pub/raspiblitz-litecoin-2018-07-29" |
|||
litecoinSize=19184980 |
|||
|
|||
# load network |
|||
network=`cat .network` |
|||
|
|||
# set torrent based on network |
|||
torrent=$bitcoinTorrent |
|||
torrentsize=$bitcoinTorrentsize |
|||
# settings based on network |
|||
list=$bitcoinList |
|||
url=$bitcoinUrl |
|||
size=$bitcoinSize |
|||
if [ "$network" = "litecoin" ]; then |
|||
torrent=$litecoinTorrent |
|||
torrentsize=$litecoinTorrentsize |
|||
list=$litecoinList |
|||
url=$litecoinUrl |
|||
size=$litecoinSize |
|||
fi |
|||
|
|||
# the path wget will download to |
|||
targetPath=$(echo ${url} | cut -d '@' -f2) |
|||
|
|||
echo "network($network)" |
|||
echo "list($list)" |
|||
echo "url($url)" |
|||
echo "size($size)" |
|||
echo "targetPath($targetPath)" |
|||
|
|||
exit 1 |
|||
|
|||
echo "*** Downloading HDD / FTP ***" |
|||
sudo wget -r -P /mnt/hdd/ -q --show-progress ${url} |
|||
echo "OK" |
|||
echo "" |
|||
echo "*** Checking HDD ***" |
|||
mountOK=$(df | grep -c /mnt/hdd) |
|||
if [ ${mountOK} -eq 1 ]; then |
|||
# HDD is mounted |
|||
if [ -d "/mnt/hdd/${network}" ]; then |
|||
# HDD has already content |
|||
echo "It seems that HDD has already content. Try to continue with ./finishHDD.sh" |
|||
else |
|||
# HDD is empty - download HDD content |
|||
echo "OK - HDD is ready." |
|||
echo "" |
|||
|
|||
downloading=1 |
|||
retry=0 |
|||
while [ $downloading -eq 1 ] |
|||
do |
|||
echo "*** Downloading HDD ***" |
|||
echo "torrentFile: ${torrent}" |
|||
tmpfile=$(mktemp) |
|||
chmod a+x $tmpfile |
|||
echo "killall transmission-cli" > $tmpfile |
|||
sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile |
|||
echo "" |
|||
echo "*** Checking Download ***" |
|||
echo "wait a moment" |
|||
sleep 5 |
|||
downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9') |
|||
if [ ${#downloadsize} -eq 0 ]; then |
|||
echo "*** Checking Download ***" |
|||
downloadsize=$(sudo du -s /mnt/hdd/${targetPath} | awk '{print $1}' | tr -dc '0-9') |
|||
if [ ${#downloadsize} -eq 0 ]; then |
|||
downloadsize=0 |
|||
fi |
|||
# add some tolerance for checking |
|||
torrentsize="$(($torrentsize-1024000))" |
|||
echo "download size is(${downloadsize})" |
|||
if [ ${downloadsize} -lt ${torrentsize} ]; then |
|||
echo "" |
|||
echo "FAIL - download is not ${torrentsize}" |
|||
retry=$(($retry+1)) |
|||
if [ ${retry} -gt 2 ]; then |
|||
echo "All Retry FAILED" |
|||
downloading=0 |
|||
else |
|||
echo "--> RETRY(${retry}) in 10 secs" |
|||
sleep 10 |
|||
echo "" |
|||
fi |
|||
else |
|||
echo "OK - Download is complete" |
|||
downloading=0 |
|||
fi |
|||
done |
|||
if [ ${downloadsize} -lt ${torrentsize} ]; then |
|||
fi |
|||
echo "download size is(${downloadsize}) needs to be minimum(${size}})" |
|||
if [ ${downloadsize} -lt ${size} ]; then |
|||
sleep 3 |
|||
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want to clean all download data before you continue?" 6 57 |
|||
echo -ne '\007' |
|||
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57 |
|||
response=$? |
|||
case $response in |
|||
0) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;; |
|||
1) sudo rm -rf /mnt/hdd/${targetPath} ;; |
|||
esac |
|||
# |
|||
./00mainMenu.sh |
|||
exit 1; |
|||
fi |
|||
echo "" |
|||
|
|||
echo "*** Moving Files ***" |
|||
echo "moving files ..." |
|||
sudo mv /mnt/hdd/$torrent /mnt/hdd/${network} |
|||
echo "" |
|||
|
|||
# set SetupState |
|||
echo "50" > /home/admin/.setup |
|||
|
|||
echo "*** Next Step ***" |
|||
echo "You can now use this HDD as a source to copy the Blockchain during the setup of another RaspiBlitz." |
|||
sleep 4 |
|||
fi |
|||
echo "" |
|||
|
|||
# continue setup |
|||
./60finishHDD.sh |
|||
echo "*** Moving Files ***" |
|||
sudo mv /mnt/hdd/${targetPath} /mnt/hdd/litecoin |
|||
echo "OK" |
|||
|
|||
fi |
|||
else |
|||
# HDD is not available yet |
|||
echo "*** Mount HDD on /mnt/hdd first ***" |
|||
fi |
|||
# continue setup |
|||
./60finishHDD.sh |
@ -0,0 +1,62 @@ |
|||
#!/bin/sh |
|||
|
|||
# *** BITCOIN Torrent *** |
|||
bitcoinTorrent="raspiblitz-hdd-2018-07-16" |
|||
bitcoinTorrentsize=231230512 |
|||
|
|||
# *** LITECOIN Torrent *** |
|||
litecoinTorrent="raspiblitz-litecoin-2018-07-28" |
|||
litecoinTorrentsize=100 |
|||
|
|||
# load network |
|||
network=`cat .network` |
|||
|
|||
# settings based on network |
|||
torrent=$bitcoinTorrent |
|||
torrentsize=$bitcoinTorrentsize |
|||
if [ "$network" = "litecoin" ]; then |
|||
torrent=$litecoinTorrent |
|||
torrentsize=$litecoinTorrentsize |
|||
if |
|||
|
|||
echo "*** Downloading TORRENT ***" |
|||
echo "torrentFile: ${torrent}" |
|||
tmpfile=$(mktemp) |
|||
chmod a+x $tmpfile |
|||
echo "killall transmission-cli" > $tmpfile |
|||
sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile |
|||
echo "OK - Download is complete" |
|||
echo "" |
|||
|
|||
echo "*** Checking TORRENT ***" |
|||
echo "wait a moment" |
|||
sleep 5 |
|||
downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9') |
|||
if [ ${#downloadsize} -eq 0 ]; then |
|||
downloadsize=0 |
|||
fi |
|||
# add some tolerance for checking |
|||
size="$(($size-1024000))" |
|||
echo "download size is(${downloadsize}) needs to be minimum(${size}})" |
|||
if [ ${downloadsize} -lt ${size} ]; then |
|||
sleep 3 |
|||
echo -ne '\007' |
|||
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57 |
|||
response=$? |
|||
case $response in |
|||
1) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;; |
|||
esac |
|||
./00mainMenu.sh |
|||
exit 1; |
|||
fi |
|||
|
|||
echo "*** Moving Files ***" |
|||
echo "moving files ..." |
|||
sudo mv /mnt/hdd/$torrent /mnt/hdd/${network} |
|||
echo "" |
|||
|
|||
# set SetupState |
|||
echo "50" > /home/admin/.setup |
|||
|
|||
# continue setup |
|||
./60finishHDD.sh |
@ -0,0 +1,23 @@ |
|||
# RaspiBlitz: systemd unit for bitcoind |
|||
|
|||
[Unit] |
|||
Description=Bitcoin daemon |
|||
Wants=getpublicip.service |
|||
After=getpublicip.service |
|||
|
|||
# for use with sendmail alert (coming soon) |
|||
#OnFailure=systemd-sendmail@%n |
|||
|
|||
[Service] |
|||
User=bitcoin |
|||
Group=bitcoin |
|||
Type=forking |
|||
PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid |
|||
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid |
|||
KillMode=process |
|||
Restart=always |
|||
TimeoutSec=120 |
|||
RestartSec=30 |
|||
|
|||
[Install] |
|||
WantedBy=multi-user.target |
@ -0,0 +1,20 @@ |
|||
[Unit] |
|||
Description=Bitcoin daemon |
|||
Wants=getpublicip.service |
|||
After=getpublicip.service |
|||
|
|||
# for use with sendmail alert (coming soon) |
|||
#OnFailure=systemd-sendmail@%n |
|||
|
|||
[Service] |
|||
User=bitcoin |
|||
Group=bitcoin |
|||
Type=simple |
|||
ExecStart=/usr/local/bin/litecoind -daemon -conf=/home/bitcoin/.litecoin/litecoin.conf |
|||
KillMode=process |
|||
Restart=always |
|||
TimeoutSec=120 |
|||
RestartSec=30 |
|||
|
|||
[Install] |
|||
WantedBy=multi-user.target |
@ -0,0 +1,27 @@ |
|||
# RaspiBlitz: systemd unit for lnd |
|||
|
|||
[Unit] |
|||
Description=LND Lightning Daemon |
|||
Wants=bitcoind.service |
|||
After=bitcoind.service |
|||
|
|||
# for use with sendmail alert |
|||
#OnFailure=systemd-sendmail@%n |
|||
|
|||
[Service] |
|||
# get var PUBIP from file |
|||
EnvironmentFile=/run/publicip |
|||
|
|||
ExecStart=/usr/local/bin/lnd --externalip=${PUBLICIP} |
|||
PIDFile=/home/bitcoin/.lnd/lnd.pid |
|||
User=bitcoin |
|||
Group=bitcoin |
|||
LimitNOFILE=128000 |
|||
Type=simple |
|||
KillMode=process |
|||
TimeoutSec=180 |
|||
Restart=always |
|||
RestartSec=60 |
|||
|
|||
[Install] |
|||
WantedBy=multi-user.target |
Loading…
Reference in new issue