Browse Source

process info/config correct

dev
rootzoll 6 years ago
parent
commit
d8fea374f1
  1. 2
      home.admin/00infoLCD.sh
  2. 191
      home.admin/00mainMenu.sh
  3. 6
      home.admin/95finalSetup.sh

2
home.admin/00infoLCD.sh

@ -49,7 +49,7 @@ while :
# 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 # keep for old nodes
hostname=`sudo cat /home/admin/.hostname` 2>/dev/null hostname=$(sudo cat /home/admin/.hostname 2>/dev/null)
if [ ${#hostname} -eq 0 ]; then if [ ${#hostname} -eq 0 ]; then
hostname="raspiblitz" hostname="raspiblitz"
fi fi

191
home.admin/00mainMenu.sh

@ -1,50 +1,79 @@
#!/bin/bash #!/bin/bash
echo "Starting the main menu - please wait ..." echo "Starting the main menu - please wait ..."
# CONFIGFILE - configuration of RaspiBlitz
configFile="/mnt/hdd/raspiblitz.conf"
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
# check if HDD is connected
hddExists=$(lsblk | grep -c sda1)
if [ ${hddExists} -eq 0 ]; then
echo "***********************************************************"
echo "WARNING: NO HDD FOUND -> Shutdown, connect HDD and restart."
echo "***********************************************************"
exit
fi
# check data from _bootstrap.sh that was running on device setup # check data from _bootstrap.sh that was running on device setup
infoFile='/home/admin/raspiblitz.info'
bootstrapInfoExists=$(ls $infoFile | grep -c '.info') bootstrapInfoExists=$(ls $infoFile | grep -c '.info')
if [ ${bootstrapInfoExists} -eq 1 ]; then if [ ${bootstrapInfoExists} -eq 0 ]; then
echo "***********************************************************"
# load the data from the info file echo "WARNING: NO raspiblitz.info FOUND -> bootstrap not running?"
source ${infoFile} echo "***********************************************************"
exit
# if pre-sync is running - stop it fi
if [ "${state}" = "presync" ]; then
# stopping the pre-sync
echo ""
echo "********************************************"
echo "Stopping pre-sync ... pls wait (up to 1min)"
echo "********************************************"
sudo -u root bitcoin-cli -conf=/home/admin/assets/bitcoin.conf stop
echo "bitcoind called to stop .."
sleep 50
# unmount the temporary mount
echo "Unmount HDD .."
sudo umount -l /mnt/hdd
sleep 3
# update info file
state=waitsetup
sudo sed -i "s/^state=.*/state=waitsetup/g" $infoFile
sudo sed -i "s/^message=.*/message='Pre-Sync Stopped'/g" $infoFile
fi
# signal if bootstrap recover is not ready yet # load the data from the info file (will get produced on every startup)
if [ "${state}" = "recovering" ]; then source ${infoFile}
echo "WARNING: bootstrap is still updating - please close SSH and login later again"
exit 1 if [ "${state}" = "recovering" ]; then
fi echo "***********************************************************"
echo "WARNING: bootstrap still updating - close SSH, login later"
echo "***********************************************************"
exit
fi
# signal that after bootstrap recover user dialog is needed # signal that after bootstrap recover user dialog is needed
if [ "${state}" = "recovered" ]; then if [ "${state}" = "recovered" ]; then
echo "System recovered - needs final user settings" echo "System recovered - needs final user settings"
./20recoverDialog.sh ./20recoverDialog.sh
exit 1 exit 1
fi fi
# if pre-sync is running - stop it - before continue
if [ "${state}" = "presync" ]; then
# stopping the pre-sync
echo ""
echo "********************************************"
echo "Stopping pre-sync ... pls wait (up to 1min)"
echo "********************************************"
sudo -u root bitcoin-cli -conf=/home/admin/assets/bitcoin.conf stop
echo "bitcoind called to stop .."
sleep 50
# unmount the temporary mount
echo "Unmount HDD .."
sudo umount -l /mnt/hdd
sleep 3
# update info file
state=waitsetup
sudo sed -i "s/^state=.*/state=waitsetup/g" $infoFile
sudo sed -i "s/^message=.*/message='Pre-Sync Stopped'/g" $infoFile
fi
# if state=ready -> setup is done or started
if [ "${state}" = "ready" ]; then
configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then
echo "setup is done - loading config data"
source ${configFile}
setupStep=100
else
echo "setup still in progress - setupStep(${setupStep})"
fi
fi fi
## default menu settings ## default menu settings
@ -56,44 +85,6 @@ TITLE=""
MENU="Choose one of the following options:" MENU="Choose one of the following options:"
OPTIONS=() OPTIONS=()
## get basic info (its OK if not set yet)
source /mnt/hdd/raspiblitz.conf
# check hostname and get backup if from old config
if [ ${#hostname} -eq 0 ]; then
echo "backup info for old nodes: hostname"
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
if [ ${#network} -eq 0 ]; then
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
# keep for old nodes
network=`sudo cat /home/admin/.network 2>/dev/null`
fi
if [ ${#network} -eq 0 ]; then
network="bitcoin"
fi
fi
# for old nodes
if [ ${#chain} -eq 0 ]; then
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
chain="main"
fi
fi
# check if RTL web interface is installed # check if RTL web interface is installed
runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service') runningRTL=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
@ -125,36 +116,35 @@ waitUntilChainNetworkIsReady()
done done
} }
## get actual setup info
source ${infoFile}
if [ ${#setupStep} -eq 0 ]; then if [ ${#setupStep} -eq 0 ]; then
echo "WARN: no setup step found in raspiblitz.info" echo "WARN: no setup step found in raspiblitz.info"
setupStep=0 setupStep=0
fi fi
if [ ${setupStep} -eq 0 ]; then if [ ${setupStep} -eq 0 ]; then
# check data from boostrap # check data from boostrap
# TODO: when olddata --> CLEAN OR MANUAL-UPDATE-INFO # TODO: when olddata --> CLEAN OR MANUAL-UPDATE-INFO
if [ "${state}" = "olddata" ]; then if [ "${state}" = "olddata" ]; then
# old data setup
BACKTITLE="RaspiBlitz - Manual Update"
TITLE="⚡ Found old RaspiBlitz Data on HDD ⚡"
MENU="\n ATTENTION: OLD DATA COULD COINTAIN FUNDS\n"
OPTIONS+=(MANUAL "read how to recover your old funds" \
DELETE "erase old data, keep blockchain, reboot" )
HEIGHT=11
else
# start setup # old data setup
BACKTITLE="RaspiBlitz - Setup" BACKTITLE="RaspiBlitz - Manual Update"
TITLE="⚡ Welcome to your RaspiBlitz ⚡" TITLE="⚡ Found old RaspiBlitz Data on HDD ⚡"
MENU="\nChoose how you want to setup your RaspiBlitz: \n " MENU="\n ATTENTION: OLD DATA COULD COINTAIN FUNDS\n"
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \ OPTIONS+=(MANUAL "read how to recover your old funds" \
LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" ) DELETE "erase old data, keep blockchain, reboot" )
HEIGHT=11 HEIGHT=11
fi else
# start setup
BACKTITLE="RaspiBlitz - Setup"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nChoose how you want to setup your RaspiBlitz: \n "
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \
LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" )
HEIGHT=11
fi
elif [ ${setupStep} -lt 100 ]; then elif [ ${setupStep} -lt 100 ]; then
@ -200,11 +190,6 @@ else
TITLE="Webinterface: http://${localip}:3000" TITLE="Webinterface: http://${localip}:3000"
fi fi
switchOption="to MAINNET"
if [ "${chain}" = "main" ]; then
switchOption="back to TESTNET"
fi
# Basic Options # Basic Options
OPTIONS+=(INFO "RaspiBlitz Status Screen" \ OPTIONS+=(INFO "RaspiBlitz Status Screen" \
FUNDING "Fund your on-chain Wallet" \ FUNDING "Fund your on-chain Wallet" \

6
home.admin/95finalSetup.sh

@ -9,7 +9,6 @@ source /home/admin/_version.info
# show info to user # show info to user
dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " --msgbox " dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " --msgbox "
After reboot RaspiBlitz After reboot RaspiBlitz
needs to be unlocked and needs to be unlocked and
sync with the network. sync with the network.
@ -46,6 +45,7 @@ fi
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
clear clear
echo "Setup done. Rebooting now. PRESS ENTER" echo "Setup done. Rebooting now."
read key
sleep 3
sudo shutdown -r now sudo shutdown -r now
Loading…
Cancel
Save