Browse Source

now using config/info files

#146
rootzoll 6 years ago
parent
commit
843042b8f7
  1. 16
      home.admin/00infoBlitz.sh
  2. 8
      home.admin/00infoLCD.sh
  3. 17
      home.admin/00mainMenu.sh
  4. 14
      home.admin/20initDialog.sh
  5. 3
      home.admin/30initHDD.sh
  6. 4
      home.admin/40addHDD.sh
  7. 4
      home.admin/50copyHDD.sh
  8. 4
      home.admin/50downloadHDD.sh
  9. 4
      home.admin/50syncHDD.sh
  10. 4
      home.admin/50torrentHDD.old.sh
  11. 4
      home.admin/50torrentHDD.sh
  12. 4
      home.admin/60finishHDD.sh
  13. 11
      home.admin/70initLND.sh
  14. 7
      home.admin/80scanLND.sh
  15. 29
      home.admin/90finishSetup.sh
  16. 125
      home.admin/95switchMainTest.sh
  17. 13
      home.admin/97addMobileWalletShango.sh
  18. 13
      home.admin/97addMobileWalletZap.sh
  19. 4
      home.admin/XXdebugLogs.sh
  20. 89
      home.admin/_bootstrap.migration.sh
  21. 124
      home.admin/_bootstrap.sh
  22. 4
      home.admin/assets/bitcoin.conf
  23. 4
      home.admin/assets/litecoin.conf

16
home.admin/00infoBlitz.sh

@ -10,18 +10,14 @@ color_yellow='\033[0;33m'
color_gray='\033[0;37m' color_gray='\033[0;37m'
color_purple='\033[0;35m' color_purple='\033[0;35m'
## get basic info (its OK if not set yet) ## get basic info
source /home/admin/raspiblitz.info 2>/dev/null
source /mnt/hdd/raspiblitz.conf 2>/dev/null source /mnt/hdd/raspiblitz.conf 2>/dev/null
# check hostname and get backup if from old config # check hostname
if [ ${#hostname} -eq 0 ]; then if [ ${#hostname} -eq 0 ]; then hostname="raspiblitz"; fi
hostname=`sudo cat /home/admin/.hostname 2>/dev/null`
if [ ${#hostname} -eq 0 ]; then
hostname="raspiblitz"
fi
fi
# check network and get backup if from old config # for oldnodes
if [ ${#network} -eq 0 ]; then if [ ${#network} -eq 0 ]; then
network="bitcoin" network="bitcoin"
litecoinActive=$(sudo ls /mnt/hdd/litecoin/litecoin.conf 2>/dev/null | grep -c 'litecoin.conf') litecoinActive=$(sudo ls /mnt/hdd/litecoin/litecoin.conf 2>/dev/null | grep -c 'litecoin.conf')
@ -35,7 +31,7 @@ if [ ${#network} -eq 0 ]; then
fi fi
fi fi
# check chain and get backup if from system # for oldnodes
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
chain="test" chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c) isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)

8
home.admin/00infoLCD.sh

@ -43,18 +43,20 @@ while :
else else
## get basic info (its OK if not set yet) ## get basic info
source /home/admin/raspiblitz.info 2>/dev/null
source /mnt/hdd/raspiblitz.conf 2>/dev/null source /mnt/hdd/raspiblitz.conf 2>/dev/null
# check hostname and get backup if from old config # check hostname and get backup if from old config
if [ ${#hostname} -eq 0 ]; then if [ ${#hostname} -eq 0 ]; then
# keep for old nodes
hostname=`sudo cat /home/admin/.hostname` hostname=`sudo cat /home/admin/.hostname`
if [ ${#hostname} -eq 0 ]; then if [ ${#hostname} -eq 0 ]; then
hostname="raspiblitz" hostname="raspiblitz"
fi fi
fi fi
# check network and get backup if from old config # for old nodes
if [ ${#network} -eq 0 ]; then if [ ${#network} -eq 0 ]; then
network="bitcoin" network="bitcoin"
litecoinActive=$(sudo ls /mnt/hdd/litecoin/litecoin.conf 2>/dev/null | grep -c 'litecoin.conf') litecoinActive=$(sudo ls /mnt/hdd/litecoin/litecoin.conf 2>/dev/null | grep -c 'litecoin.conf')
@ -68,7 +70,7 @@ while :
fi fi
fi fi
# check chain and get backup if from system # for old nodes
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
chain="test" chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c) isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)

17
home.admin/00mainMenu.sh

@ -54,7 +54,7 @@ source /mnt/hdd/raspiblitz.conf
# check hostname and get backup if from old config # check hostname and get backup if from old config
if [ ${#hostname} -eq 0 ]; then if [ ${#hostname} -eq 0 ]; then
echo "backup info: hostname" echo "backup info for old nodes: hostname"
hostname=`sudo cat /home/admin/.hostname` hostname=`sudo cat /home/admin/.hostname`
if [ ${#hostname} -eq 0 ]; then if [ ${#hostname} -eq 0 ]; then
hostname="raspiblitz" hostname="raspiblitz"
@ -63,22 +63,23 @@ fi
# check network and get backup if from old config # check network and get backup if from old config
if [ ${#network} -eq 0 ]; then if [ ${#network} -eq 0 ]; then
echo "backup info: network" echo "backup info for old nodes: network"
network="bitcoin" network="bitcoin"
litecoinActive=$(sudo ls /mnt/hdd/litecoin/litecoin.conf 2>/dev/null | grep -c 'litecoin.conf') litecoinActive=$(sudo ls /mnt/hdd/litecoin/litecoin.conf 2>/dev/null | grep -c 'litecoin.conf')
if [ ${litecoinActive} -eq 1 ]; then if [ ${litecoinActive} -eq 1 ]; then
network="litecoin" network="litecoin"
else else
network=`sudo cat /home/admin/.network 2>/dev/null` # keep for old nodes
network=`sudo cat /home/admin/.network 2>/dev/null`
fi fi
if [ ${#network} -eq 0 ]; then if [ ${#network} -eq 0 ]; then
network="bitcoin" network="bitcoin"
fi fi
fi fi
# check chain and get backup if from system # for old nodes
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
echo "backup info: chain" echo "backup info for old nodes: chain"
chain="test" chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c) isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then if [ ${isMainChain} -gt 0 ];then
@ -244,12 +245,14 @@ case $CHOICE in
exit 1; exit 1;
;; ;;
BITCOIN) BITCOIN)
echo "bitcoin" > /home/admin/.network sed -i "s/^network=.*/network=bitcoin/g" /home/admin/raspiblitz.info
sed -i "s/^chain=.*/chain=main/g" /home/admin/raspiblitz.info
./10setupBlitz.sh ./10setupBlitz.sh
exit 1; exit 1;
;; ;;
LITECOIN) LITECOIN)
echo "litecoin" > /home/admin/.network sed -i "s/^network=.*/network=litecoin/g" /home/admin/raspiblitz.info
sed -i "s/^chain=.*/chain=main/g" /home/admin/raspiblitz.info
./10setupBlitz.sh ./10setupBlitz.sh
exit 1; exit 1;
;; ;;

14
home.admin/20initDialog.sh

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
_temp="./download/dialog.$$" _temp="./download/dialog.$$"
# load network ## get basic info
network=`cat .network` source /home/admin/raspiblitz.info 2>/dev/null
# welcome and ask for name of RaspiBlitz # welcome and ask for name of RaspiBlitz
result="" result=""
@ -20,7 +20,15 @@ sed -i "s/^alias=.*/alias=${result}/g" /home/admin/assets/lnd.${network}.conf
# store hostname for later - to be set right before the next reboot # store hostname for later - to be set right before the next reboot
# work around - because without a reboot the hostname seems not updates in the whole system # work around - because without a reboot the hostname seems not updates in the whole system
echo $result > /home/admin/.hostname valueExistsInInfoFile=$(sudo cat /home/admin/raspiblitz.info | grep -c "hostname=")
if [ ${valueExistsInInfoFile} -eq 0 ]; then
# update
sed -i "s/^hostname=.*/hostname=${result}/g" /home/admin/raspiblitz.info
else
# add
echo "hostname=${result}" >> /home/admin/raspiblitz.info
fi
passwordValid=0 passwordValid=0
result="" result=""

3
home.admin/30initHDD.sh

@ -47,8 +47,7 @@ if [ ${existsHDD} -eq 1 ]; then
sleep 1 sleep 1
# set SetupState # set SetupState
echo "30" > /home/admin/.setup sudo sed -i "s/^setupStep=.*/setupStep=30/g" /home/admin/raspiblitz.info
sudo sed -i "s/^setupStep=.*/setupStep=30/g" ${infoFile}
# automatically now add the HDD to the system # automatically now add the HDD to the system
./40addHDD.sh ./40addHDD.sh

4
home.admin/40addHDD.sh

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
echo "" echo ""
# load network ## get basic info
network=`cat .network` source /home/admin/raspiblitz.info 2>/dev/null
echo "*** Adding HDD to the System ***" echo "*** Adding HDD to the System ***"
sleep 5 sleep 5

4
home.admin/50copyHDD.sh

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# load network ## get basic info
network=`cat .network` source /home/admin/raspiblitz.info 2>/dev/null
echo "" echo ""
echo "*** Check 1st HDD ***" echo "*** Check 1st HDD ***"

4
home.admin/50downloadHDD.sh

@ -15,8 +15,8 @@ litecoinSize=35000000 # 35021940-tolerance
# NOTE TO GET THE SIZE RIGHT: for new download add 9999999999 as size. Runf download. # NOTE TO GET THE SIZE RIGHT: for new download add 9999999999 as size. Runf download.
# When finished the warning comes up and behind WARNING: copy that number # When finished the warning comes up and behind WARNING: copy that number
# load network ## get basic info
network=`cat .network` source /home/admin/raspiblitz.info 2>/dev/null
# settings based on network # settings based on network
list=$bitcoinList list=$bitcoinList

4
home.admin/50syncHDD.sh

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# load network ## get basic info
network=`cat .network` source /home/admin/raspiblitz.info 2>/dev/null
# only show warning when bitcoin # only show warning when bitcoin
if [ "$network" = "bitcoin" ]; then if [ "$network" = "bitcoin" ]; then

4
home.admin/50torrentHDD.old.sh

@ -11,8 +11,8 @@ bitcoinTorrentsize=259000000
litecoinTorrent="raspiblitz-litecoin-2018-07-29" litecoinTorrent="raspiblitz-litecoin-2018-07-29"
litecoinTorrentsize=10240000 litecoinTorrentsize=10240000
# load network ## get basic info
network=`cat .network` source /home/admin/raspiblitz.info 2>/dev/null
## experimental redirect if bitcoin ## experimental redirect if bitcoin
if [ "$network" = "bitcoin" ]; then if [ "$network" = "bitcoin" ]; then

4
home.admin/50torrentHDD.sh

@ -4,8 +4,8 @@ echo ""
# see background_downloadBlockchain.md for info # see background_downloadBlockchain.md for info
# why there are two torrent files # why there are two torrent files
# load network ## get basic info
network=`cat .network` source /home/admin/raspiblitz.info 2>/dev/null
# make sure rtorrent is available # make sure rtorrent is available
sudo apt-get install rtorrent -y sudo apt-get install rtorrent -y

4
home.admin/60finishHDD.sh

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
echo "" echo ""
# load network ## get basic info
network=`cat .network` source /home/admin/raspiblitz.info 2>/dev/null
echo "*** Checking HDD ***" echo "*** Checking HDD ***"
mountOK=$(df | grep -c /mnt/hdd) mountOK=$(df | grep -c /mnt/hdd)

11
home.admin/70initLND.sh

@ -1,15 +1,8 @@
#!/bin/bash #!/bin/bash
echo "" echo ""
# load network ## get basic info
network=`cat .network` source /home/admin/raspiblitz.info 2>/dev/null
# get chain
chain="test"
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi
# verify that bitcoin is running # verify that bitcoin is running
echo "*** Checking ${network} ***" echo "*** Checking ${network} ***"

7
home.admin/80scanLND.sh

@ -1,8 +1,5 @@
# load network source /home/admin/raspiblitz.info
network=`sudo cat /home/admin/.network` source /mnt/hdd/raspiblitz.conf 2>/dev/null
# load name of Blitz
name=`sudo cat /home/admin/.hostname`
### USER PI AUTOSTART (LCD Display) ### USER PI AUTOSTART (LCD Display)
localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')

29
home.admin/90finishSetup.sh

@ -4,6 +4,12 @@ echo ""
# add bonus scripts # add bonus scripts
./91addBonus.sh ./91addBonus.sh
# load setup config
source /home/admin/raspiblitz.info
# load version
source /home/admin/_version.info
###### SWAP & FS ###### SWAP & FS
echo "*** SWAP file ***" echo "*** SWAP file ***"
swapExists=$(swapon -s | grep -c /mnt/hdd/swapfile) swapExists=$(swapon -s | grep -c /mnt/hdd/swapfile)
@ -84,13 +90,30 @@ dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) "
" 10 42 " 10 42
# set the hostname inputed on initDialog # set the hostname inputed on initDialog
hostname=`cat .hostname` if [ ${#hostname} -gt 0 ]; then
echo "Setting new network hostname '$hostname'" echo "Setting new network hostname '$hostname'"
sudo raspi-config nonint do_hostname ${hostname} sudo raspi-config nonint do_hostname ${hostname}
else
echo "WARN: hostname not set"
fi
# mark setup is done (100%) # mark setup is done (100%)
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
# init the RASPIBLITZ Config
configFile="/mnt/hdd/raspiblitz.conf"
echo "# RASPIBLITZ CONFIG FILE" > $configFile
echo "raspiBlitzVersion='${codeVersion}'" >> $configFile
sudo chmod 777 ${configFile}
# transfer data from SD info file
echo "hostname=${hostname}" >> $configFile
echo "network=${network}" >> $configFile
echo "chain=${chain}" >> $configFile
# let migration/init script do the rest
./_bootstrap.migration.sh
clear clear
echo "Setup done. Rebooting now." echo "Setup done. Rebooting now."
sudo shutdown -r now sudo shutdown -r now

125
home.admin/95switchMainTest.sh

@ -1,125 +0,0 @@
#!/usr/bin/env bash
# based on pull request from vnnkl
# load network
network=`cat .network`
echo ""
echo "*** Switch between Testnet/Mainnet ***"
# allow only on bitcoin network
if [ "${network}" = "bitcoin" ]; then
echo "Bitcoin network can be switched between testnet/mainnet ..."
else
echo "FAIL - Only Bitcoin Network can be switched between man/tast at the moment."
exit 1
fi
NETWORK_CONFIG="/home/bitcoin/.${network}/${network}.conf"
NETWORK_TEMPLATE="/home/admin/assets/${network}.conf"
LND_CONFIG="/home/bitcoin/.lnd/lnd.conf"
LND_TEMPLATE="/home/admin/assets/lnd.${network}.conf"
echo "NETWORK_CONFIG(${NETWORK_CONFIG})"
echo "LND_CONFIG(${LND_CONFIG})"
echo "NETWORK_TEMPLATE(${NETWORK_TEMPLATE})"
echo "LND_TEMPLATE(${LND_TEMPLATE})"
# function to detect main/testnet
function isMainnet(){
grep "^#testnet=1$" -q $NETWORK_CONFIG && return 1
return 0
}
function switchToMainnet {
echo "switching to mainnet"
sed -i "s/^testnet=1/#testnet=1/g" $NETWORK_CONFIG
sed -i "s/^testnet=1/#testnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^#mainnet=1/mainnet=1/g" $NETWORK_CONFIG
sed -i "s/^#mainnet=1/mainnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^${network}.testnet=1/#${network}.testnet=1/g" $LND_CONFIG
sed -i "s/^#${network}.mainnet=1/${network}.mainnet=1/g" $LND_CONFIG
sed -i "s/^${network}.testnet=1/#${network}.testnet=1/g" $LND_TEMPLATE
sed -i "s/^#${network}.mainnet=1/${network}.mainnet=1/g" $LND_TEMPLATE
echo "OK switched to mainnet"
}
function switchToTestnet {
echo "switching to testnet"
sed -i "s/^#testnet=1/testnet=1/g" $NETWORK_CONFIG
sed -i "s/^#testnet=1/testnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^mainnet=1/#mainnet=1/g" $NETWORK_CONFIG
sed -i "s/^mainnet=1/#mainnet=1/g" $NETWORK_TEMPLATE
sed -i "s/^#${network}.testnet=1/${network}.testnet=1/g" $LND_CONFIG
sed -i "s/^${network}.mainnet=1/#${network}.mainnet=1/g" $LND_CONFIG
sed -i "s/^#${network}.testnet=1/${network}.testnet=1/g" $LND_TEMPLATE
sed -i "s/^${network}.mainnet=1/#${network}.mainnet=1/g" $LND_TEMPLATE
echo "OK switched to testnet"
}
# LND Service
lndInstalled=$(systemctl status lnd.service | grep loaded -c)
if [ ${lndInstalled} -gt 0 ]; then
echo "check for open channels"
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c)
if [ ${openChannels} -gt 0 ]; then
echo ""
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - You have still open channels and could loose funds !! - close those first with 'lncli closeallchannels' or main menu option."
echo "!!!!!!!!!!!!!!!!!!!"
exit 1
else
echo "no open channels found"
fi
echo "stopping lnd client"
systemctl stop lnd
sleep 4
else
echo "LND not running"
fi
# NETWORK Service
networkInstalled=$(systemctl status ${network}d.service | grep loaded -c)
if [ ${networkInstalled} -gt 0 ]; then
echo "stopping bitcoind client"
systemctl stop bitcoind
sleep 4
else
echo "Network ${network} not running"
fi
# TURN THE SWITCH
isMainnet
if [ $? -eq 1 ]; then
echo "switching from mainnet to testnet"
switchToTestnet
else
echo "switching from testnet to mainnet"
switchToMainnet
fi
echo "copying over config to admin user"
cp $NETWORK_CONFIG /home/admin/.${network}/
chown admin:admin /home/admin/.${network}/${network}.conf
cp $LND_CONFIG /home/admin/.lnd/
chown admin:admin /home/admin/.lnd/lnd.conf
# restarting network
if [ ${networkInstalled} -gt 0 ]; then
# start network
systemctl start bitcoind
echo "started ${network}d back up, giving it a 120 SECONDS to prepare"
sleep 120
# set setup info again
sudo sed -i "s/^setupStep=.*/setupStep=60/g" /home/admin/raspiblitz.info
# run again the complete LND init procedure
./70initLND.sh
else
echo "No starting of network, because it was not running before"
fi

13
home.admin/97addMobileWalletShango.sh

@ -1,13 +1,10 @@
#!/bin/bash #!/bin/bash
# load network # load raspiblitz config data (with backup from old config)
network=`cat .network` source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi
# get chain if [ ${#chain} -eq 0 ]; then
chain="test" chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi fi
# make sure qrcode-encoder in installed # make sure qrcode-encoder in installed

13
home.admin/97addMobileWalletZap.sh

@ -1,13 +1,10 @@
#!/bin/bash #!/bin/bash
# load network # load raspiblitz config data (with backup from old config)
network=`cat .network` source /mnt/hdd/raspiblitz.conf 2>/dev/null
if [ ${#network} -eq 0 ]; then network=`cat .network`; fi
# get chain if [ ${#chain} -eq 0 ]; then
chain="test" chain=$(${network}-cli getblockchaininfo | jq -r '.chain')
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
if [ ${isMainChain} -gt 0 ];then
chain="main"
fi fi
# make sure qrcode-encoder in installed # make sure qrcode-encoder in installed

4
home.admin/XXdebugLogs.sh

@ -8,7 +8,7 @@ source /home/admin/_version.info
## get basic info (its OK if not set yet) ## get basic info (its OK if not set yet)
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
# check network and get backup if from old config # for old nodes
if [ ${#network} -eq 0 ]; then if [ ${#network} -eq 0 ]; then
echo "backup info: network" echo "backup info: network"
network="bitcoin" network="bitcoin"
@ -19,7 +19,7 @@ if [ ${#network} -eq 0 ]; then
network=`sudo cat /home/admin/.network` network=`sudo cat /home/admin/.network`
fi fi
# check chain and get backup if from system # for old nodes
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
echo "backup info: chain" echo "backup info: chain"
chain="test" chain="test"

89
home.admin/_bootstrap.migration.sh

@ -1,17 +1,96 @@
#!/bin/bash #!/bin/bash
# LOAD DATA & PRECHECK
# path to old or init configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# check if there is a config file
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
if [ ${configExists} -eq 0 ]; then
echo "FAIL: no config file (${configFile}) found to init or upgrade!"
exit 1
fi
# load old or init raspiblitz config
source ${configFile}
# check if config files contains basic: network
if [ ${#network} -eq 0 ]; then
echo "FAIL: missing network in (${configFile})!"
exit 1
fi
# check if config files contains basic: chain
if [ ${#chain} -eq 0 ]; then
echo "FAIL: missing chain in (${configFile})!"
exit 1
fi
# check if config files contains basic: hostname
if [ ${#hostname} -eq 0 ]; then
echo "FAIL: missing hostname in (${configFile})!"
exit 1
fi
# load codeVersion # load codeVersion
source ./_version.info source /home/admin/_version.info
# check if code version was loaded
if [ ${#codeVersion} -eq 0 ]; then
echo "FAIL: no code version (/home/admin/_version.info) found!"
exit 1
fi
# load raspiblitz config # DEFAULT VALUES - MISSING data fields on init or upadte
source /mnt/hdd/raspiblitz.conf
echo "" echo ""
echo "*****************************" echo "*****************************"
echo "Version Migration RaspiBlitz" echo "Default Values"
echo "*****************************"
# AUTOPILOT
# autoPilot=off|on
if [ ${#autoPilot} -eq 0 ]; then
echo "autoPilot=off" >> $configFile
fi
# AUTO NAT DISCOVERY
# autoNatDiscovery=off|on
if [ ${#autoNatDiscovery} -eq 0 ]; then
echo "autoNatDiscovery=off" >> $configFile
fi
# TOR
# runBehindTor=off|on
if [ ${#runBehindTor} -eq 0 ]; then
echo "runBehindTor=off" >> $configFile
fi
# RideTheLightning RTL
# rtlWebinterface=off|on
if [ ${#rtlWebinterface} -eq 0 ]; then
echo "rtlWebinterface=off" >> $configFile
fi
# MIGRATION - DATA CONVERSION when updating config
# this is the place if on a future version change
# a conversion of config data or app data is needed
echo ""
echo "*****************************"
echo "Version Migration Steps"
echo "*****************************" echo "*****************************"
echo "Version Code: ${codeVersion}" echo "Version Code: ${codeVersion}"
echo "Version Data: ${raspiBlitzVersion}" echo "Version Data: ${raspiBlitzVersion}"
echo "TODO: Update Migration check ..." if [ "${raspiBlitzVersion}" != "${codeVersion}" ]; then
echo "detected version change ... starting migration script"
echo "TODO: Update Migration check ... only needed after version 1.0"
else
echo "OK - version of config data is up to date"
fi
echo "" echo ""
exit 0

124
home.admin/_bootstrap.sh

@ -212,123 +212,21 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
fi fi
# EXIT on BOOTSTRAP HERE AT THE MOMENT
echo "DONE BOOTSTRAP (before any configs etc)" >> $logFile
echo "state=ready" > $infoFile
exit 0
################################ ################################
# CONFIGFILE BASICS # INFOFILE BASICS
################################ ################################
# check if there is a config file # init network and chain values if needed with defaults
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf') valueExists=$(sudo cat /home/admin/raspiblitz.info 2>/dev/null | grep -c "network=")
if [ ${configExists} -eq 0 ]; then if [ ${valueExists} -eq 0 ]; then
echo "network=bitcoin" >> /home/admin/raspiblitz.info
# create new config
echo "creating config file: ${configFile}" >> $logFile
echo "# RASPIBLITZ CONFIG FILE" > $configFile
echo "raspiBlitzVersion='${codeVersion}'" >> $configFile
sudo chmod 777 ${configFile}
# the rest will be set under DEFAULT VALUES
else
# load & check config version
source $configFile
echo "codeVersion(${codeVersion})" >> $logFile
echo "configVersion(${raspiBlitzVersion})" >> $logFile
if [ "${raspiBlitzVersion}" != "${codeVersion}" ]; then
echo "detected version change ... starting migration script" >> $logFile
/home/admin/_bootstrap.update.sh
fi
fi
##################################
# DEFAULT VALUES
# check which are not set and add
##################################
# COIN NETWORK
# network=bitcoin|litecoin|undefined
if [ ${#network} -eq 0 ]; then
oldNetworkConfigExists=$(sudo ls /home/admin/.network | grep -c '.network')
if [ ${oldNetworkConfigExists} -eq 1 ]; then
network=`sudo cat /home/admin/.network`
echo "importing old network value: ${network}" >> $logFile
echo "network=${network}" >> $configFile
else
echo "network=undefined" >> $configFile
fi
fi fi
valueExists=$(sudo cat /home/admin/raspiblitz.info 2>/dev/null | grep -c "chain=")
# RUNNING CHAIN if [ ${valueExists} -eq 0 ]; then
# chain=test|main echo "chain=main" >> /home/admin/raspiblitz.info
if [ ${#chain} -eq 0 ]; then
networkConfigExists=$(sudo ls /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep -c '.conf')
if [ ${networkConfigExists} -eq 1 ]; then
source /mnt/hdd/${network}/${network}.conf
if [ ${testnet} -eq 1 ]; then
echo "detecting mainchain" >> $logFile
echo "chain=main" >> $configFile
else
echo "detecting testnet" >> $logFile
echo "chain=test" >> $configFile
fi
else
echo "chain=main" >> $configFile
fi
fi fi
# HOSTNAME # EXIT on BOOTSTRAP HERE AT THE MOMENT
# hostname=ONEWORDSTRING echo "DONE BOOTSTRAP (before any configs etc)" >> $logFile
if [ ${#hostname} -eq 0 ]; then
oldValueExists=$(sudo ls /home/admin/.hostname | grep -c '.hostname')
if [ ${oldValueExists} -eq 1 ]; then
oldValue=`sudo cat /home/admin/.hostname`
echo "importing old hostname: ${oldValue}" >> $logFile
echo "hostname=${oldValue}" >> $configFile
else
echo "hostname=raspiblitz" >> $configFile
fi
fi
# SETUP STEP (ONLY DO ON SD CARD infofile - not configfile)
# setupStep=0-100
# AUTOPILOT
# autoPilot=off|on
if [ ${#autoPilot} -eq 0 ]; then
echo "autoPilot=off" >> $configFile
fi
# AUTO NAT DISCOVERY
# autoNatDiscovery=off|on
if [ ${#autoNatDiscovery} -eq 0 ]; then
echo "autoNatDiscovery=off" >> $configFile
fi
# TOR
# runBehindTor=off|on
if [ ${#runBehindTor} -eq 0 ]; then
echo "runBehindTor=off" >> $configFile
fi
# RideTheLightning RTL
# rtlWebinterface=off|on
if [ ${#rtlWebinterface} -eq 0 ]; then
echo "rtlWebinterface=off" >> $configFile
fi
##################################
# CHECK CONFIG CONSISTENCY
##################################
# after all default values written to config - reload config
source $configFile
echo "" >> $logFile
echo "DONE BOOTSTRAP" >> $logFile
echo "state=ready" > $infoFile echo "state=ready" > $infoFile
exit 0

4
home.admin/assets/bitcoin.conf

@ -1,7 +1,7 @@
# bitcoind configuration # bitcoind configuration
# mainnet/testnet - to switch just comment/uncomment # mainnet/testnet
#testnet=1 testnet=0
# Bitcoind options # Bitcoind options
server=1 server=1

4
home.admin/assets/litecoin.conf

@ -1,7 +1,7 @@
# litecoind configuration # litecoind configuration
# mainnet/testnet - to switch just comment/uncomment # mainnet/testnet
#testnet=1 testnet=1
# litcoind options # litcoind options
server=1 server=1

Loading…
Cancel
Save