mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-04-12 21:59:19 +02:00
now using config/info files
This commit is contained in:
parent
e4d9d8de81
commit
843042b8f7
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
;;
|
||||
|
@ -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=""
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 ***"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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} ***"
|
||||
|
@ -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'/')
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -1,17 +1,96 @@
|
||||
#!/bin/bash
|
||||
|
||||
# load codeVersion
|
||||
source ./_version.info
|
||||
# LOAD DATA & PRECHECK
|
||||
|
||||
# load raspiblitz config
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
# 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 /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 "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 "Version Code: ${codeVersion}"
|
||||
echo "Version Data: ${raspiBlitzVersion}"
|
||||
|
||||
echo "TODO: Update Migration check ..."
|
||||
echo ""
|
||||
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
|
||||
|
||||
|
@ -212,123 +212,21 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
|
||||
|
||||
fi
|
||||
|
||||
################################
|
||||
# INFOFILE BASICS
|
||||
################################
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
# EXIT on BOOTSTRAP HERE AT THE MOMENT
|
||||
echo "DONE BOOTSTRAP (before any configs etc)" >> $logFile
|
||||
echo "state=ready" > $infoFile
|
||||
exit 0
|
||||
|
||||
################################
|
||||
# CONFIGFILE 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
|
||||
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
|
||||
exit 0
|
@ -1,7 +1,7 @@
|
||||
# bitcoind configuration
|
||||
|
||||
# mainnet/testnet - to switch just comment/uncomment
|
||||
#testnet=1
|
||||
# mainnet/testnet
|
||||
testnet=0
|
||||
|
||||
# Bitcoind options
|
||||
server=1
|
||||
|
@ -1,7 +1,7 @@
|
||||
# litecoind configuration
|
||||
|
||||
# mainnet/testnet - to switch just comment/uncomment
|
||||
#testnet=1
|
||||
# mainnet/testnet
|
||||
testnet=1
|
||||
|
||||
# litcoind options
|
||||
server=1
|
||||
|
Loading…
x
Reference in New Issue
Block a user