mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-19 12:10:33 +02:00
setup provision
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - its now done in bootstrap and setupcontroller
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
|
@@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - it now done in _provision.setup.sh or _provision_.sh
|
||||
# ---> the experimental "adding RAID drive" section for BRTFS gets dropped here
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
|
@@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - it now done in _provision.setup.sh
|
||||
# --- BUT check how its used in repair script
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - it now done in _provision.setup.sh
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: should be good to be deleted - it now done in _provision.setup.sh and setup dialogs
|
||||
|
||||
## get basic info
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
@@ -78,17 +80,7 @@ while [ ${chainIsReady} -eq 0 ]
|
||||
echo "*** Check LND Config ***"
|
||||
configExists=$( sudo ls /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep -c lnd.conf )
|
||||
if [ ${configExists} -eq 0 ]; then
|
||||
echo "Creating LND config ..."
|
||||
sudo mkdir /mnt/hdd/lnd 2> /dev/null
|
||||
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd
|
||||
sudo cp /home/admin/assets/lnd.${network}.conf /mnt/hdd/lnd/lnd.conf
|
||||
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf
|
||||
if [ -d /home/bitcoin/.lnd ]; then
|
||||
echo "OK - LND config written"
|
||||
else
|
||||
echo "FAIL - Was not able to setup LND"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
else
|
||||
echo "OK - exists"
|
||||
fi
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: CHECK IF IS NOW REPLACED BY NEW EVENT WAIT DIALOGS
|
||||
|
||||
source /home/admin/_version.info
|
||||
source /home/admin/raspiblitz.info
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#!/bin/bash
|
||||
echo ""
|
||||
|
||||
# TODO: COPY OVER COMPLETLY INTO _provison_.sh
|
||||
|
||||
# add bonus scripts (auto install deactivated to reduce third party repos)
|
||||
/home/admin/91addBonus.sh
|
||||
|
||||
|
@@ -1,4 +1,6 @@
|
||||
|
||||
# TODO: COPY OVER COMPLETLY INTO _provison_.sh
|
||||
|
||||
mkdir /home/admin/tmpScriptDL
|
||||
cd /home/admin/tmpScriptDL
|
||||
echo "installing bash completion for bitcoin-cli and lncli"
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#!/bin/bash
|
||||
echo ""
|
||||
|
||||
# TODO: should be good to be deleted - it now done in _provision.setup.sh and setup dialogs
|
||||
|
||||
# load setup config
|
||||
source /home/admin/raspiblitz.info
|
||||
|
||||
|
@@ -408,7 +408,7 @@ do
|
||||
recheckIBD=$((($counter % 60)+1))
|
||||
if [ ${recheckIBD} -eq 1 ]; then
|
||||
# check if flag exists (got created on 50syncHDD.sh)
|
||||
flagExists=$(ls /home/admin/selfsync.flag 2>/dev/null | grep -c "selfsync.flag")
|
||||
flagExists=$(ls /mnt/hdd/${network}/blocks/selfsync.flag 2>/dev/null | grep -c "selfsync.flag")
|
||||
if [ ${flagExists} -eq 1 ]; then
|
||||
finishedIBD=$(sudo -u bitcoin ${network}-cli getblockchaininfo | grep "initialblockdownload" | grep -c "false")
|
||||
if [ ${finishedIBD} -eq 1 ]; then
|
||||
|
@@ -437,6 +437,9 @@ if [ ${isMounted} -eq 0 ]; then
|
||||
# PROVISION PROCESS
|
||||
#############################################
|
||||
|
||||
# refresh data from info file
|
||||
source ${infoFile}
|
||||
|
||||
# temp mount the HDD
|
||||
echo "Temp mounting data drive ($hddCandidate)" >> $logFile
|
||||
if [ "${hddFormat}" != "btrfs" ]; then
|
||||
@@ -455,15 +458,42 @@ if [ ${isMounted} -eq 0 ]; then
|
||||
# kick-off provision process
|
||||
sed -i "s/^state=.*/state=provision/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='Starting Provision'/g" ${infoFile}
|
||||
#sed -i "s/^chain=.*/chain=${chain}/g" ${infoFile}
|
||||
#sed -i "s/^network=.*/network=${network}/g" ${infoFile}
|
||||
|
||||
# errors from this process will be refelcted ins state / message of raspiblitz.info
|
||||
echo "Calling Data Migration for possible updates .." >> $logFile
|
||||
sudo /home/admin/_bootstrap.update.sh
|
||||
if [ "$?" == "0" ]; then
|
||||
echo "Calling Provisioning .." >> $logFile
|
||||
sudo /home/admin/_bootstrap.provision.sh
|
||||
# if setup - run provision setup first
|
||||
if [ "${setupPhase}" == "setup" ]; then
|
||||
echo "Calling _bootstrap.setup.sh for basic setup tasks .." >> $logFile
|
||||
sudo /home/admin/_provision.setup.sh
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "EXIT BECAUSE OF ERROR STATE" >> $logFile
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# if update - run provision update migration first
|
||||
if [ "${setupPhase}" == "update" ]; then
|
||||
echo "Calling _bootstrap.update.sh for possible update migrations .." >> $logFile
|
||||
sudo /home/admin/_provision.update.sh
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "EXIT BECAUSE OF ERROR STATE" >> $logFile
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# if update - run provision update migration first
|
||||
if [ "${setupPhase}" == "migration" ]; then
|
||||
echo "Calling _bootstrap.migration.sh for possible update migrations .." >> $logFile
|
||||
sudo /home/admin/_provision.migration.sh
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "EXIT BECAUSE OF ERROR STATE" >> $logFile
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Calling _bootstrap.provision.sh for general system provisioning .." >> $logFile
|
||||
sudo /home/admin/_provision_.sh
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "EXIT BECAUSE OF ERROR STATE" >> $logFile
|
||||
exit 1
|
||||
fi
|
||||
|
||||
###################################################
|
||||
@@ -477,8 +507,8 @@ if [ ${isMounted} -eq 0 ]; then
|
||||
# TODO: DETECT WHEN USER SETUP IS DONE
|
||||
echo "TODO: DETECT WHEN USER FINAL DIALOG IS DONE" >> $logFile
|
||||
|
||||
# offer option to COPY BLOCKHCAIN (see 50copyHDD.sh)
|
||||
# handle possible errors
|
||||
# set passwords
|
||||
# show seed words
|
||||
|
||||
# get latest network info & update raspiblitz.info (in case network changes)
|
||||
|
54
home.admin/_provision.migration.sh
Executable file
54
home.admin/_provision.migration.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
# LOGFILE - store debug logs of bootstrap
|
||||
logFile="/home/admin/raspiblitz.log"
|
||||
|
||||
# INFOFILE - state data from bootstrap
|
||||
infoFile="/home/admin/raspiblitz.info"
|
||||
source ${infoFile}
|
||||
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# load old or init raspiblitz config
|
||||
# debug info
|
||||
echo "STARTED Migration --> see logs in ${logFile}"
|
||||
echo "STARTED Migration" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Provision Migration'/g" ${infoFile}
|
||||
|
||||
if [ "${hddGotMigrationData}" == "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='config: missing hddGotMigrationData'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: missing hddGotMigrationData in (${infoFile})!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
||||
|
||||
err=""
|
||||
nodenameUpperCase=$(echo "${hddGotMigrationData}" | tr "[a-z]" "[A-Z]")
|
||||
echo "**************************************************" >> ${logFile}
|
||||
echo "MIGRATION FROM ${nodenameUpperCase} TO RASPIBLITZ" >> ${logFile}
|
||||
echo "**************************************************" >> ${logFile}
|
||||
echo "- started ..." >> ${logFile}
|
||||
source <(sudo /home/admin/config.scripts/blitz.migration.sh migration-${hddGotMigrationData})
|
||||
if [ "${err}" != "" ]; then
|
||||
echo "MIGRATION FAILED: ${err}" >> ${logFile}
|
||||
echo "Format data disk on laptop & recover funds with fresh sd card using seed words + static channel backup." >> ${logFile}
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='migration failed'/g" ${infoFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if free space is lower than 100GB (100000000) delete backup files
|
||||
if [ "${hddDataFreeKB}" != "" ] && [ ${hddDataFreeKB} -lt 407051412 ]; then
|
||||
echo "- free space of data disk is low ... deleting 'backup_migration'" >> ${logFile}
|
||||
sudo rm -R /mnt/hdd/backup_migration
|
||||
else
|
||||
echo "- old data of ${nodenameUpperCase} can be found in '/mnt/hdd/backup_migration'" >> ${logFile}
|
||||
fi
|
||||
echo "OK MIGRATION" >> ${logFile}
|
||||
echo "END Migration" >> ${logFile}
|
||||
exit 0
|
||||
|
355
home.admin/_provision.setup.sh
Executable file
355
home.admin/_provision.setup.sh
Executable file
@@ -0,0 +1,355 @@
|
||||
#!/bin/bash
|
||||
|
||||
# LOGFILE - store debug logs of bootstrap
|
||||
logFile="/home/admin/raspiblitz.log"
|
||||
|
||||
# INFOFILE - state data from bootstrap
|
||||
infoFile="/home/admin/raspiblitz.info"
|
||||
source ${infoFile}
|
||||
|
||||
# SETUPFILE - setup data of RaspiBlitz
|
||||
setupFile="/var/cache/raspiblitz/temp/raspiblitz.setup"
|
||||
source ${setupFile}
|
||||
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
source ${configFile}
|
||||
|
||||
# load old or init raspiblitz config
|
||||
# debug info
|
||||
echo "STARTED Setup --> see logs in ${logFile}"
|
||||
echo "STARTED Setup" >> ${logFile}
|
||||
sudo sed -i "s/^message=.*/message='Provision Setup'/g" ${infoFile}
|
||||
|
||||
###################################
|
||||
# Set Password A
|
||||
|
||||
if [ "${passwordA}" == "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='config: missing passwordA'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: missing passwordA in (${setupFile})!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo /home/admin/config.scripts/blitz.setpassword.sh a "${passwordA}" >> ${logFile}
|
||||
|
||||
###################################
|
||||
# Preserve SSH keys
|
||||
# just copy dont link anymore
|
||||
# see: https://github.com/rootzoll/raspiblitz/issues/1798
|
||||
|
||||
# link ssh directory from SD card to HDD
|
||||
echo "# --> SSH key settings" >> ${logFile}
|
||||
echo "# copying SSH pub keys to HDD" >> ${logFile}
|
||||
sudo cp -r /etc/ssh /mnt/hdd/ssh >> ${logFile}
|
||||
echo "# OK" >> ${logFile}
|
||||
|
||||
###################################
|
||||
# Prepare Blockchain Service
|
||||
|
||||
if [ "${network}" == "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='config: missing network'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: missing network in (${setupFile})!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${chain}" == "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='config: missing chain'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: missing chain in (${setupFile})!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make sure choosen blockchain service is installed
|
||||
if [ "${network}" != "bitcoin" ]; then
|
||||
# TODO also ... check if /home/admin/selfsync.flag is needed on other chains
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='TODO: install ${network}'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "TODO: make sure ${network} is installed!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# copy configs files and directories
|
||||
echo ""
|
||||
echo "*** Prepare ${network} ***" >> ${logFile}
|
||||
sudo -u bitcoin mkdir /mnt/hdd/${network} 2>/dev/null
|
||||
sudo -u bitcoin mkdir /mnt/hdd/${network}/blocks 2>/dev/null
|
||||
sudo -u bitcoin mkdir /mnt/hdd/${network}/chainstate 2>/dev/null
|
||||
sudo cp /home/admin/assets/${network}.conf /mnt/hdd/${network}/${network}.conf
|
||||
sudo mkdir /home/admin/.${network} 2>/dev/null
|
||||
sudo cp /home/admin/assets/${network}.conf /home/admin/.${network}/${network}.conf
|
||||
|
||||
# optimize RAM for blockchain validation (bitcoin only)
|
||||
if [ "${network}" == "bitcoin" ] && [ "${hddBlocksBitcoin}" == "0" ]; then
|
||||
echo "*** Optimizing RAM for Sync ***" >> ${logFile}
|
||||
kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
|
||||
echo "dont forget to reduce dbcache once IBD is done" > "/mnt/hdd/${network}/blocks/selfsync.flag"
|
||||
# RP4 4GB
|
||||
if [ ${kbSizeRAM} -gt 3500000 ]; then
|
||||
echo "Detected RAM >=4GB --> optimizing ${network}.conf" >> ${logFile}
|
||||
sudo sed -i "s/^dbcache=.*/dbcache=3072/g" /mnt/hdd/${network}/${network}.conf
|
||||
# RP4 2GB
|
||||
elif [ ${kbSizeRAM} -gt 1500000 ]; then
|
||||
echo "Detected RAM >=2GB --> optimizing ${network}.conf" >> ${logFile}
|
||||
sudo sed -i "s/^dbcache=.*/dbcache=1536/g" /mnt/hdd/${network}/${network}.conf
|
||||
#RP3/4 1GB
|
||||
else
|
||||
echo "Detected RAM <=1GB --> optimizing ${network}.conf" >> ${logFile}
|
||||
sudo sed -i "s/^dbcache=.*/dbcache=512/g" /mnt/hdd/${network}/${network}.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# start network service
|
||||
echo ""
|
||||
echo "*** Start ${network} ***" >> ${logFile}
|
||||
echo "- This can take a while .." >> ${logFile}
|
||||
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
|
||||
#sudo chmod +x /etc/systemd/system/${network}d.service
|
||||
sudo systemctl daemon-reload >> ${logFile}
|
||||
sudo systemctl enable ${network}d.service >> ${logFile}
|
||||
sudo systemctl start ${network}d.service >> ${logFile}
|
||||
|
||||
# check if bitcoin has started
|
||||
bitcoinRunning=0
|
||||
loopcount=0
|
||||
while [ ${bitcoinRunning} -eq 0 ]
|
||||
do
|
||||
>&2 echo "# (${loopcount}/200) checking if ${network}d is running ... " >> ${logFile}
|
||||
bitcoinRunning=$(${network}-cli getblockchaininfo 2>/dev/null | grep "initialblockdownload" -c)
|
||||
sleep 2
|
||||
sync
|
||||
loopcount=$(($loopcount +1))
|
||||
if [ ${loopcount} -gt 200 ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: failed ${network}'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: failed ${network}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
###################################
|
||||
# Prepare Lightning
|
||||
|
||||
if [ "${lightning}" == "lnd" ]; then
|
||||
|
||||
###################################
|
||||
# LND
|
||||
|
||||
if [ "${passwordC}" == "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='config: missing passwordC'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: missing passwordC in (${setupFile})!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if user uploaded an LND rescue file
|
||||
if [ "${lndrescue}" != "" ]; then
|
||||
echo "Restore LND data from uploaded rescue file ${lndrescue} ..." >> ${logFile}
|
||||
source <(sudo /home/admin/config.scripts/lnd.backup.sh lnd-import ${lndrescue})
|
||||
if [ "${error}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd import backup failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd import backup failed" >> ${logFile}
|
||||
echo "${error}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# preparing new LND config
|
||||
echo "Creating new LND config ..." >> ${logFile}
|
||||
sudo -u bitcoin mkdir /mnt/hdd/lnd 2> /dev/null
|
||||
sudo cp /home/admin/assets/lnd.${network}.conf /mnt/hdd/lnd/lnd.conf
|
||||
sudo chown bitcoin:bitcoin /mnt/hdd/lnd/lnd.conf
|
||||
sudo /home/admin/config.scripts/lnd.setname.sh ${hostname}
|
||||
fi
|
||||
|
||||
# check if now a config exists
|
||||
configLinkedCorrectly=$(sudo ls sudo ls /home/bitcoin/.lnd/lnd.conf | grep -c "lnd.conf")
|
||||
if [ "${configLinkedCorrectly}" != "1" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd conf link broken'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd conf link broken" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Init LND service & start
|
||||
echo "*** Init LND Service & Start ***" >> ${logFile}
|
||||
|
||||
# just in case
|
||||
sudo systemctl stop lnd 2>/dev/null
|
||||
sudo systemctl disable lnd 2>/dev/null
|
||||
|
||||
# make sure lnd gets started after blockchain service
|
||||
sed -i "5s/.*/Wants=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile}
|
||||
sed -i "6s/.*/After=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile}
|
||||
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile}
|
||||
sudo /home/admin/config.scripts/internet.tor.sh lndconf-on >> ${logFile}
|
||||
|
||||
# start lnd up
|
||||
echo "Starting LND Service ..." >> ${logFile}
|
||||
sudo systemctl enable lnd >> ${logFile}
|
||||
sudo systemctl start lnd >> ${logFile}
|
||||
|
||||
# check that lnd started
|
||||
lndRunning=0
|
||||
loopcount=0
|
||||
while [ ${lndRunning} -eq 0 ]
|
||||
do
|
||||
lndRunning=$(sudo systemctl status lnd.service | grep -c running)
|
||||
if [ ${lndRunning} -eq 0 ]; then
|
||||
date +%s >> ${logFile}
|
||||
echo "LND not ready yet ... waiting another 60 seconds." >> ${logFile}
|
||||
sleep 10
|
||||
fi
|
||||
loopcount=$(($loopcount +1))
|
||||
if [ ${loopcount} -gt 100 ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: failed lnd start'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: failed lnd start" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo "OK - LND is running" ${logFile}
|
||||
sleep 10
|
||||
|
||||
# Check LND health/fails (to be extended)
|
||||
tlsExists=$(sudo ls /mnt/hdd/lnd/tls.cert 2>/dev/null | grep -c "tls.cert")
|
||||
if [ ${tlsExists} -eq 0 ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: missing lnd tls'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: missing lnd tls" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# import static channel backup if was uploaded
|
||||
if [ "${staticchannelbackup}" != "" ]; then
|
||||
echo "Preparing static channel backup file ${staticchannelbackup} ..." >> ${logFile}
|
||||
source <(sudo /home/admin/config.scripts/lnd.backup.sh scb-import ${staticchannelbackup})
|
||||
if [ "${error}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd import SCB failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd import SCB failed" >> ${logFile}
|
||||
echo "${error}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# WALLET --> SEED + SCB
|
||||
if [ "${seedWords}" != "" ] && [ "${staticchannelbackup}" != "" ]; the
|
||||
|
||||
sudo /home/admin/config.scripts/lnd.initwallet.py scb ${passwordC} "${seedWords}" "${staticchannelbackup}" ${seedPassword}
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SCB failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd wallet SCB failed" >> ${logFile}
|
||||
echo "${err}" >> ${logFile}
|
||||
echo "${errMore}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# WALLET --> SEED
|
||||
elif [ "${seedWords}" != "" ]
|
||||
|
||||
sudo /home/admin/config.scripts/lnd.initwallet.py seed ${passwordC} "${seedWords}" ${seedPassword}
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd wallet SEED failed" >> ${logFile}
|
||||
echo "${err}" >> ${logFile}
|
||||
echo "${errMore}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# WALLET --> NEW
|
||||
else
|
||||
|
||||
source <(sudo /home/admin/config.scripts/lnd.initwallet.py new ${passwordC})
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd wallet SEED failed" >> ${logFile}
|
||||
echo "${err}" >> ${logFile}
|
||||
echo "${errMore}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# write created seedwords into SETUPFILE to be displayed to user on final setup later
|
||||
echo "seedwordsNEW=${seedwords}" >> ${setupFile}
|
||||
echo "seedwords6x4NEW=${seedwords6x4}" >> ${setupFile}
|
||||
|
||||
fi
|
||||
|
||||
# sync macaroons & TLS to other users
|
||||
echo "*** Copy LND Macaroons to user admin ***" >> ${logFile}
|
||||
|
||||
# make sure wallet is unlocked
|
||||
sleep 3
|
||||
/home/admin/config.scripts/lnd.unlock.sh "${passwordC}"
|
||||
sleep 3
|
||||
|
||||
# check if macaroon exists now - if not fail
|
||||
macaroonExists=$(sudo -u bitcoin ls -la /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c admin.macaroon)
|
||||
if [ ${macaroonExists} -eq 0 ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd no macaroons'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd no macaroons" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# now sync macaroons & TLS zo other users
|
||||
sudo /home/admin/config.scripts/lnd.credentials.sh sync
|
||||
|
||||
# unlock Wallet (if needed)
|
||||
echo "*** Check Wallet Lock ***"
|
||||
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
|
||||
if [ ${locked} -gt 0 ]; then
|
||||
echo "OK - Wallet is locked ... starting unlocking dialog"
|
||||
/home/admin/config.scripts/lnd.unlock.sh
|
||||
else
|
||||
echo "OK - Wallet is already unlocked"
|
||||
fi
|
||||
|
||||
# make a final lnd check
|
||||
source <(/home/admin/config.scripts/lnd.check.sh basic-setup)
|
||||
if [ "${err}" != "" ]; then
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='setup: lnd wallet SEED failed'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "FAIL: setup: lnd wallet SEED failed" >> ${logFile}
|
||||
echo "${err}" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ "${lightning}" == "cln" ]; then
|
||||
|
||||
###################################
|
||||
# c-lightning
|
||||
|
||||
sed -i "s/^state=.*/state=error/g" ${infoFile}
|
||||
sed -i "s/^message=.*/message='TODO: install c-lightning'/g" ${infoFile}
|
||||
echo "FAIL see ${logFile}"
|
||||
echo "TODO: install c-lightning!" >> ${logFile}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "END Setup" >> ${logFile}
|
||||
exit 0
|
||||
|
@@ -9,6 +9,9 @@ infoFile="/home/admin/raspiblitz.info"
|
||||
# CONFIGFILE - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# SETUPFILE - configuration of RaspiBlitz
|
||||
setupFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# debug info
|
||||
echo "STARTED Update/Init --> see logs in ${logFile}"
|
||||
echo "STARTED Update/Init" >> ${logFile}
|
@@ -13,9 +13,11 @@ peerbloomfilters=1
|
||||
# Connection settings
|
||||
rpcuser=raspibolt
|
||||
rpcpassword=passwordB
|
||||
rpcport=8332
|
||||
main.rpcport=8332
|
||||
test.rpcport=18332
|
||||
rpcallowip=127.0.0.1
|
||||
rpcbind=127.0.0.1:8332
|
||||
main.rpcbind=127.0.0.1:8332
|
||||
test.rpcbind=127.0.0.1:18332
|
||||
zmqpubrawblock=tcp://127.0.0.1:28332
|
||||
zmqpubrawtx=tcp://127.0.0.1:28333
|
||||
|
||||
|
Reference in New Issue
Block a user