From 843042b8f707582e6c2674b7cbe0d55035e4bc4b Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Dec 2018 14:36:02 +0100 Subject: [PATCH] now using config/info files --- home.admin/00infoBlitz.sh | 16 ++-- home.admin/00infoLCD.sh | 8 +- home.admin/00mainMenu.sh | 17 ++-- home.admin/20initDialog.sh | 14 ++- home.admin/30initHDD.sh | 3 +- home.admin/40addHDD.sh | 4 +- home.admin/50copyHDD.sh | 4 +- home.admin/50downloadHDD.sh | 4 +- home.admin/50syncHDD.sh | 4 +- home.admin/50torrentHDD.old.sh | 4 +- home.admin/50torrentHDD.sh | 4 +- home.admin/60finishHDD.sh | 4 +- home.admin/70initLND.sh | 11 +-- home.admin/80scanLND.sh | 7 +- home.admin/90finishSetup.sh | 29 +++++- home.admin/95switchMainTest.sh | 125 ------------------------- home.admin/97addMobileWalletShango.sh | 13 +-- home.admin/97addMobileWalletZap.sh | 13 +-- home.admin/XXdebugLogs.sh | 4 +- home.admin/_bootstrap.migration.sh | 91 +++++++++++++++++-- home.admin/_bootstrap.sh | 126 +++----------------------- home.admin/assets/bitcoin.conf | 4 +- home.admin/assets/litecoin.conf | 4 +- 23 files changed, 190 insertions(+), 323 deletions(-) delete mode 100755 home.admin/95switchMainTest.sh diff --git a/home.admin/00infoBlitz.sh b/home.admin/00infoBlitz.sh index 175a847..10eff7e 100755 --- a/home.admin/00infoBlitz.sh +++ b/home.admin/00infoBlitz.sh @@ -10,18 +10,14 @@ color_yellow='\033[0;33m' color_gray='\033[0;37m' 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 -# check hostname and get backup if from old config -if [ ${#hostname} -eq 0 ]; then - hostname=`sudo cat /home/admin/.hostname 2>/dev/null` - if [ ${#hostname} -eq 0 ]; then - hostname="raspiblitz" - fi -fi +# check hostname +if [ ${#hostname} -eq 0 ]; then hostname="raspiblitz"; fi -# check network and get backup if from old config +# for oldnodes if [ ${#network} -eq 0 ]; then network="bitcoin" 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 -# check chain and get backup if from system +# for oldnodes if [ ${#chain} -eq 0 ]; then chain="test" isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c) diff --git a/home.admin/00infoLCD.sh b/home.admin/00infoLCD.sh index 58a5935..cd63ab5 100755 --- a/home.admin/00infoLCD.sh +++ b/home.admin/00infoLCD.sh @@ -43,18 +43,20 @@ while : 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 # check hostname and get backup if from old config if [ ${#hostname} -eq 0 ]; then + # keep for old nodes hostname=`sudo cat /home/admin/.hostname` if [ ${#hostname} -eq 0 ]; then hostname="raspiblitz" fi fi - # check network and get backup if from old config + # for old nodes if [ ${#network} -eq 0 ]; then network="bitcoin" litecoinActive=$(sudo ls /mnt/hdd/litecoin/litecoin.conf 2>/dev/null | grep -c 'litecoin.conf') @@ -68,7 +70,7 @@ while : fi fi - # check chain and get backup if from system + # for old nodes if [ ${#chain} -eq 0 ]; then chain="test" isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c) diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index efb2dd8..124b753 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -54,7 +54,7 @@ source /mnt/hdd/raspiblitz.conf # check hostname and get backup if from old config if [ ${#hostname} -eq 0 ]; then - echo "backup info: hostname" + echo "backup info for old nodes: hostname" hostname=`sudo cat /home/admin/.hostname` if [ ${#hostname} -eq 0 ]; then hostname="raspiblitz" @@ -63,22 +63,23 @@ fi # check network and get backup if from old config if [ ${#network} -eq 0 ]; then - echo "backup info: network" + echo "backup info for old nodes: network" network="bitcoin" litecoinActive=$(sudo ls /mnt/hdd/litecoin/litecoin.conf 2>/dev/null | grep -c 'litecoin.conf') if [ ${litecoinActive} -eq 1 ]; then network="litecoin" else - network=`sudo cat /home/admin/.network 2>/dev/null` + # keep for old nodes + network=`sudo cat /home/admin/.network 2>/dev/null` fi if [ ${#network} -eq 0 ]; then network="bitcoin" fi fi -# check chain and get backup if from system +# for old nodes if [ ${#chain} -eq 0 ]; then - echo "backup info: chain" + echo "backup info for old nodes: chain" chain="test" isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c) if [ ${isMainChain} -gt 0 ];then @@ -244,12 +245,14 @@ case $CHOICE in exit 1; ;; 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 exit 1; ;; 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 exit 1; ;; diff --git a/home.admin/20initDialog.sh b/home.admin/20initDialog.sh index e1d5f23..ccbca90 100755 --- a/home.admin/20initDialog.sh +++ b/home.admin/20initDialog.sh @@ -1,8 +1,8 @@ #!/bin/bash _temp="./download/dialog.$$" -# load network -network=`cat .network` +## get basic info +source /home/admin/raspiblitz.info 2>/dev/null # welcome and ask for name of RaspiBlitz 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 # 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 result="" diff --git a/home.admin/30initHDD.sh b/home.admin/30initHDD.sh index 8013a93..c0a7c00 100755 --- a/home.admin/30initHDD.sh +++ b/home.admin/30initHDD.sh @@ -47,8 +47,7 @@ if [ ${existsHDD} -eq 1 ]; then sleep 1 # set SetupState - echo "30" > /home/admin/.setup - sudo sed -i "s/^setupStep=.*/setupStep=30/g" ${infoFile} + sudo sed -i "s/^setupStep=.*/setupStep=30/g" /home/admin/raspiblitz.info # automatically now add the HDD to the system ./40addHDD.sh diff --git a/home.admin/40addHDD.sh b/home.admin/40addHDD.sh index a0e4208..aeaf445 100755 --- a/home.admin/40addHDD.sh +++ b/home.admin/40addHDD.sh @@ -1,8 +1,8 @@ #!/bin/bash echo "" -# load network -network=`cat .network` +## get basic info +source /home/admin/raspiblitz.info 2>/dev/null echo "*** Adding HDD to the System ***" sleep 5 diff --git a/home.admin/50copyHDD.sh b/home.admin/50copyHDD.sh index f8f4e3c..69c9a8c 100755 --- a/home.admin/50copyHDD.sh +++ b/home.admin/50copyHDD.sh @@ -1,7 +1,7 @@ #!/bin/bash -# load network -network=`cat .network` +## get basic info +source /home/admin/raspiblitz.info 2>/dev/null echo "" echo "*** Check 1st HDD ***" diff --git a/home.admin/50downloadHDD.sh b/home.admin/50downloadHDD.sh index 7297c4a..62d78df 100755 --- a/home.admin/50downloadHDD.sh +++ b/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. # When finished the warning comes up and behind WARNING: copy that number -# load network -network=`cat .network` +## get basic info +source /home/admin/raspiblitz.info 2>/dev/null # settings based on network list=$bitcoinList diff --git a/home.admin/50syncHDD.sh b/home.admin/50syncHDD.sh index bb094fc..0ae9660 100755 --- a/home.admin/50syncHDD.sh +++ b/home.admin/50syncHDD.sh @@ -1,7 +1,7 @@ #!/bin/bash -# load network -network=`cat .network` +## get basic info +source /home/admin/raspiblitz.info 2>/dev/null # only show warning when bitcoin if [ "$network" = "bitcoin" ]; then diff --git a/home.admin/50torrentHDD.old.sh b/home.admin/50torrentHDD.old.sh index 6b2428b..9c709db 100755 --- a/home.admin/50torrentHDD.old.sh +++ b/home.admin/50torrentHDD.old.sh @@ -11,8 +11,8 @@ bitcoinTorrentsize=259000000 litecoinTorrent="raspiblitz-litecoin-2018-07-29" litecoinTorrentsize=10240000 -# load network -network=`cat .network` +## get basic info +source /home/admin/raspiblitz.info 2>/dev/null ## experimental redirect if bitcoin if [ "$network" = "bitcoin" ]; then diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 0ac6fae..4d0b6ea 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -4,8 +4,8 @@ echo "" # see background_downloadBlockchain.md for info # why there are two torrent files -# load network -network=`cat .network` +## get basic info +source /home/admin/raspiblitz.info 2>/dev/null # make sure rtorrent is available sudo apt-get install rtorrent -y diff --git a/home.admin/60finishHDD.sh b/home.admin/60finishHDD.sh index d850c8f..669e60e 100755 --- a/home.admin/60finishHDD.sh +++ b/home.admin/60finishHDD.sh @@ -1,8 +1,8 @@ #!/bin/bash echo "" -# load network -network=`cat .network` +## get basic info +source /home/admin/raspiblitz.info 2>/dev/null echo "*** Checking HDD ***" mountOK=$(df | grep -c /mnt/hdd) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index f5782c9..7b09e10 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -1,15 +1,8 @@ #!/bin/bash echo "" -# load network -network=`cat .network` - -# 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 +## get basic info +source /home/admin/raspiblitz.info 2>/dev/null # verify that bitcoin is running echo "*** Checking ${network} ***" diff --git a/home.admin/80scanLND.sh b/home.admin/80scanLND.sh index 962676e..99fae62 100755 --- a/home.admin/80scanLND.sh +++ b/home.admin/80scanLND.sh @@ -1,8 +1,5 @@ -# load network -network=`sudo cat /home/admin/.network` - -# load name of Blitz -name=`sudo cat /home/admin/.hostname` +source /home/admin/raspiblitz.info +source /mnt/hdd/raspiblitz.conf 2>/dev/null ### USER PI AUTOSTART (LCD Display) localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') diff --git a/home.admin/90finishSetup.sh b/home.admin/90finishSetup.sh index 05a85aa..4e9e5c0 100755 --- a/home.admin/90finishSetup.sh +++ b/home.admin/90finishSetup.sh @@ -4,6 +4,12 @@ echo "" # add bonus scripts ./91addBonus.sh +# load setup config +source /home/admin/raspiblitz.info + +# load version +source /home/admin/_version.info + ###### SWAP & FS echo "*** SWAP file ***" swapExists=$(swapon -s | grep -c /mnt/hdd/swapfile) @@ -84,13 +90,30 @@ dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " " 10 42 # set the hostname inputed on initDialog -hostname=`cat .hostname` -echo "Setting new network hostname '$hostname'" -sudo raspi-config nonint do_hostname ${hostname} +if [ ${#hostname} -gt 0 ]; then + echo "Setting new network hostname '$hostname'" + sudo raspi-config nonint do_hostname ${hostname} +else + echo "WARN: hostname not set" +fi # mark setup is done (100%) 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 echo "Setup done. Rebooting now." sudo shutdown -r now diff --git a/home.admin/95switchMainTest.sh b/home.admin/95switchMainTest.sh deleted file mode 100755 index d0b0833..0000000 --- a/home.admin/95switchMainTest.sh +++ /dev/null @@ -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 \ No newline at end of file diff --git a/home.admin/97addMobileWalletShango.sh b/home.admin/97addMobileWalletShango.sh index 450c2ac..3385ba7 100644 --- a/home.admin/97addMobileWalletShango.sh +++ b/home.admin/97addMobileWalletShango.sh @@ -1,13 +1,10 @@ #!/bin/bash -# load network -network=`cat .network` - -# 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" +# load raspiblitz config data (with backup from old config) +source /mnt/hdd/raspiblitz.conf 2>/dev/null +if [ ${#network} -eq 0 ]; then network=`cat .network`; fi +if [ ${#chain} -eq 0 ]; then + chain=$(${network}-cli getblockchaininfo | jq -r '.chain') fi # make sure qrcode-encoder in installed diff --git a/home.admin/97addMobileWalletZap.sh b/home.admin/97addMobileWalletZap.sh index db69081..5cfdef7 100755 --- a/home.admin/97addMobileWalletZap.sh +++ b/home.admin/97addMobileWalletZap.sh @@ -1,13 +1,10 @@ #!/bin/bash -# load network -network=`cat .network` - -# 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" +# load raspiblitz config data (with backup from old config) +source /mnt/hdd/raspiblitz.conf 2>/dev/null +if [ ${#network} -eq 0 ]; then network=`cat .network`; fi +if [ ${#chain} -eq 0 ]; then + chain=$(${network}-cli getblockchaininfo | jq -r '.chain') fi # make sure qrcode-encoder in installed diff --git a/home.admin/XXdebugLogs.sh b/home.admin/XXdebugLogs.sh index d4fb439..db9feac 100644 --- a/home.admin/XXdebugLogs.sh +++ b/home.admin/XXdebugLogs.sh @@ -8,7 +8,7 @@ source /home/admin/_version.info ## get basic info (its OK if not set yet) source /mnt/hdd/raspiblitz.conf -# check network and get backup if from old config +# for old nodes if [ ${#network} -eq 0 ]; then echo "backup info: network" network="bitcoin" @@ -19,7 +19,7 @@ if [ ${#network} -eq 0 ]; then network=`sudo cat /home/admin/.network` fi -# check chain and get backup if from system +# for old nodes if [ ${#chain} -eq 0 ]; then echo "backup info: chain" chain="test" diff --git a/home.admin/_bootstrap.migration.sh b/home.admin/_bootstrap.migration.sh index d0dfc3f..d17282a 100644 --- a/home.admin/_bootstrap.migration.sh +++ b/home.admin/_bootstrap.migration.sh @@ -1,17 +1,96 @@ #!/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 -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 + +# DEFAULT VALUES - MISSING data fields on init or upadte + +echo "" +echo "*****************************" +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 -# load raspiblitz config -source /mnt/hdd/raspiblitz.conf +# 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 RaspiBlitz" +echo "Version Migration Steps" echo "*****************************" echo "Version Code: ${codeVersion}" echo "Version Data: ${raspiBlitzVersion}" -echo "TODO: Update Migration check ..." -echo "" \ No newline at end of file +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 "" +exit 0 + diff --git a/home.admin/_bootstrap.sh b/home.admin/_bootstrap.sh index 09de17e..8d1c388 100644 --- a/home.admin/_bootstrap.sh +++ b/home.admin/_bootstrap.sh @@ -212,123 +212,21 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then 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 -configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf') -if [ ${configExists} -eq 0 ]; then - - # 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 - -# RUNNING CHAIN -# chain=test|main -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 - -# HOSTNAME -# hostname=ONEWORDSTRING -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 +# init network and chain values if needed with defaults +valueExists=$(sudo cat /home/admin/raspiblitz.info 2>/dev/null | grep -c "network=") +if [ ${valueExists} -eq 0 ]; then + echo "network=bitcoin" >> /home/admin/raspiblitz.info fi - -# AUTO NAT DISCOVERY -# autoNatDiscovery=off|on -if [ ${#autoNatDiscovery} -eq 0 ]; then - echo "autoNatDiscovery=off" >> $configFile +valueExists=$(sudo cat /home/admin/raspiblitz.info 2>/dev/null | grep -c "chain=") +if [ ${valueExists} -eq 0 ]; then + echo "chain=main" >> /home/admin/raspiblitz.info 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 \ No newline at end of file +# EXIT on BOOTSTRAP HERE AT THE MOMENT +echo "DONE BOOTSTRAP (before any configs etc)" >> $logFile +echo "state=ready" > $infoFile +exit 0 \ No newline at end of file diff --git a/home.admin/assets/bitcoin.conf b/home.admin/assets/bitcoin.conf index 5637544..4cf45d4 100755 --- a/home.admin/assets/bitcoin.conf +++ b/home.admin/assets/bitcoin.conf @@ -1,7 +1,7 @@ # bitcoind configuration -# mainnet/testnet - to switch just comment/uncomment -#testnet=1 +# mainnet/testnet +testnet=0 # Bitcoind options server=1 diff --git a/home.admin/assets/litecoin.conf b/home.admin/assets/litecoin.conf index 875c33a..7d9d94e 100755 --- a/home.admin/assets/litecoin.conf +++ b/home.admin/assets/litecoin.conf @@ -1,7 +1,7 @@ # litecoind configuration -# mainnet/testnet - to switch just comment/uncomment -#testnet=1 +# mainnet/testnet +testnet=1 # litcoind options server=1