|
@ -5,9 +5,9 @@ |
|
|
# default values or as in the config. |
|
|
# default values or as in the config. |
|
|
# For more details see background_raspiblitzSettings.md |
|
|
# For more details see background_raspiblitzSettings.md |
|
|
|
|
|
|
|
|
# unique id |
|
|
# use to detect multiple starts of service |
|
|
uid=$(date +%s) |
|
|
#uid=$(date +%s) |
|
|
echo "started" > /home/admin/${uid}.boot |
|
|
#echo "started" > /home/admin/${uid}.boot |
|
|
|
|
|
|
|
|
# load codeVersion |
|
|
# load codeVersion |
|
|
source /home/admin/_version.info |
|
|
source /home/admin/_version.info |
|
@ -38,6 +38,8 @@ echo "***********************************************" >> $logFile |
|
|
|
|
|
|
|
|
echo "Resetting the InfoFile: ${infoFile}" |
|
|
echo "Resetting the InfoFile: ${infoFile}" |
|
|
echo "state=starting" > $infoFile |
|
|
echo "state=starting" > $infoFile |
|
|
|
|
|
echo "network=" >> $infoFile |
|
|
|
|
|
echo "chain=" >> $infoFile |
|
|
sudo chmod 777 ${infoFile} |
|
|
sudo chmod 777 ${infoFile} |
|
|
|
|
|
|
|
|
################################ |
|
|
################################ |
|
@ -82,14 +84,14 @@ hddExists=$(lsblk | grep -c sda1) |
|
|
while [ ${hddExists} -eq 0 ] |
|
|
while [ ${hddExists} -eq 0 ] |
|
|
do |
|
|
do |
|
|
# display will ask user to connect a HDD |
|
|
# display will ask user to connect a HDD |
|
|
echo "state=nohdd" > $infoFile |
|
|
sed -i "s/^state=.*/state=nohdd/g" ${infoFile} |
|
|
echo "message='Connect the Hard Drive'" >> $infoFile |
|
|
sed -i "s/^message=.*/message='Connect the Hard Drive'/g" ${infoFile} |
|
|
sleep 5 |
|
|
sleep 5 |
|
|
# retry to find HDD |
|
|
# retry to find HDD |
|
|
hddExists=$(lsblk | grep -c sda1) |
|
|
hddExists=$(lsblk | grep -c sda1) |
|
|
done |
|
|
done |
|
|
|
|
|
|
|
|
# check if the HDD is auto-mounted |
|
|
# check if the HDD is auto-mounted ( auto-mounted = setup-done) |
|
|
hddIsAutoMounted=$(sudo cat /etc/fstab | grep -c '/mnt/hdd') |
|
|
hddIsAutoMounted=$(sudo cat /etc/fstab | grep -c '/mnt/hdd') |
|
|
if [ ${hddIsAutoMounted} -eq 0 ]; then |
|
|
if [ ${hddIsAutoMounted} -eq 0 ]; then |
|
|
|
|
|
|
|
@ -122,8 +124,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then |
|
|
echo "HDD is NOT formatted in ext4." >> $logFile |
|
|
echo "HDD is NOT formatted in ext4." >> $logFile |
|
|
# stop the bootstrap here ... |
|
|
# stop the bootstrap here ... |
|
|
# display will ask user to run setup |
|
|
# display will ask user to run setup |
|
|
echo "state=waitsetup" > $infoFile |
|
|
sed -i "s/^state=.*/state=waitsetup/g" ${infoFile} |
|
|
echo "message='HDD needs SetUp (1)'" >> $infoFile |
|
|
sed -i "s/^message=.*/message='HDD needs SetUp (1)'/g" ${infoFile} |
|
|
exit 0 |
|
|
exit 0 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
@ -134,8 +136,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then |
|
|
mountOK=$(lsblk | grep -c '/mnt/hdd') |
|
|
mountOK=$(lsblk | grep -c '/mnt/hdd') |
|
|
if [ ${mountOK} -eq 0 ]; then |
|
|
if [ ${mountOK} -eq 0 ]; then |
|
|
echo "FAIL - not able to temp-mount HDD" >> $logFile |
|
|
echo "FAIL - not able to temp-mount HDD" >> $logFile |
|
|
echo "state=waitsetup" > $infoFile |
|
|
sed -i "s/^state=.*/state=waitsetup/g" ${infoFile} |
|
|
echo "message='HDD failed Mounting'" >> $infoFile |
|
|
sed -i "s/^message=.*/message='HDD failed Mounting'/g" ${infoFile} |
|
|
# no need to unmount the HDD, it failed mounting |
|
|
# no need to unmount the HDD, it failed mounting |
|
|
exit 0 |
|
|
exit 0 |
|
|
else |
|
|
else |
|
@ -148,13 +150,14 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then |
|
|
configExists=$(ls ${configFile} | grep -c '.conf') |
|
|
configExists=$(ls ${configFile} | grep -c '.conf') |
|
|
if [ ${configExists} -eq 1 ]; then |
|
|
if [ ${configExists} -eq 1 ]; then |
|
|
echo "Found existing configuration" >> $logFile |
|
|
echo "Found existing configuration" >> $logFile |
|
|
echo "state=recovering" > $infoFile |
|
|
sed -i "s/^state=.*/state=recovering/g" ${infoFile} |
|
|
echo "message='Starting Recover'" > $infoFile |
|
|
sed -i "s/^message=.*/message='Starting Recover'/g" ${infoFile} |
|
|
echo "Calling Data Migration .." >> $logFile |
|
|
echo "Calling Data Migration .." >> $logFile |
|
|
sudo /home/admin/_bootstrap.migration.sh |
|
|
sudo /home/admin/_bootstrap.migration.sh |
|
|
echo "Calling Provisioning .." >> $logFile |
|
|
echo "Calling Provisioning .." >> $logFile |
|
|
sudo /home/admin/_bootstrap.provision.sh |
|
|
sudo /home/admin/_bootstrap.provision.sh |
|
|
echo "state=recovered" > $infoFile |
|
|
sed -i "s/^state=.*/state=recovered/g" ${infoFile} |
|
|
|
|
|
sed -i "s/^message=.*/message='Done Recover'/g" ${infoFile} |
|
|
echo "rebooting" >> $logFile |
|
|
echo "rebooting" >> $logFile |
|
|
# save log file for inspection before reboot |
|
|
# save log file for inspection before reboot |
|
|
cp $logFile /home/admin/raspiblitz.recover |
|
|
cp $logFile /home/admin/raspiblitz.recover |
|
@ -169,8 +172,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then |
|
|
lndDataExists=$(ls /mnt/hdd/lnd/lnd.conf | grep -c '.conf') |
|
|
lndDataExists=$(ls /mnt/hdd/lnd/lnd.conf | grep -c '.conf') |
|
|
if [ ${lndDataExists} -eq 1 ]; then |
|
|
if [ ${lndDataExists} -eq 1 ]; then |
|
|
echo "Found existing LND data - old RaspiBlitz?" >> $logFile |
|
|
echo "Found existing LND data - old RaspiBlitz?" >> $logFile |
|
|
echo "state=olddata" > $infoFile |
|
|
sed -i "s/^state=.*/state=olddata/g" ${infoFile} |
|
|
echo "message='No Auto-Update possible'" >> $infoFile |
|
|
sed -i "s/^message=.*/message='No Auto-Update possible'/g" ${infoFile} |
|
|
# keep HDD mounted if user wants to copy data |
|
|
# keep HDD mounted if user wants to copy data |
|
|
exit 0 |
|
|
exit 0 |
|
|
else |
|
|
else |
|
@ -186,8 +189,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then |
|
|
if [ ${bitcoinDataExists} -eq 1 ]; then |
|
|
if [ ${bitcoinDataExists} -eq 1 ]; then |
|
|
|
|
|
|
|
|
# update info file |
|
|
# update info file |
|
|
echo "state=presync" > $infoFile |
|
|
sed -i "s/^state=.*/state=presync/g" ${infoFile} |
|
|
echo "message='starting presync'" >> $infoFile |
|
|
sed -i "s/^message=.*/message='starting presync'/g" ${infoFile} |
|
|
|
|
|
|
|
|
# activating presync |
|
|
# activating presync |
|
|
# so that on a hackathon you can just connect a RaspiBlitz |
|
|
# so that on a hackathon you can just connect a RaspiBlitz |
|
@ -212,8 +215,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then |
|
|
|
|
|
|
|
|
# if it got until here: HDD is empty ext4 |
|
|
# if it got until here: HDD is empty ext4 |
|
|
echo "Waiting for SetUp." >> $logFile |
|
|
echo "Waiting for SetUp." >> $logFile |
|
|
echo "state=waitsetup" > $infoFile |
|
|
sed -i "s/^state=.*/state=waitsetup/g" ${infoFile} |
|
|
echo "message='HDD needs SetUp (2)'" >> $infoFile |
|
|
sed -i "s/^message=.*/message='HDD needs SetUp (2)'/g" ${infoFile} |
|
|
# unmount HDD to be ready for auto-mount during setup |
|
|
# unmount HDD to be ready for auto-mount during setup |
|
|
sudo umount -l /mnt/hdd |
|
|
sudo umount -l /mnt/hdd |
|
|
exit 0 |
|
|
exit 0 |
|
@ -224,16 +227,6 @@ fi |
|
|
# INFOFILE BASICS |
|
|
# INFOFILE BASICS |
|
|
################################ |
|
|
################################ |
|
|
|
|
|
|
|
|
# init network and chain values if needed with defaults |
|
|
|
|
|
valueExists=$(sudo cat ${infoFile} 2>/dev/null | grep -c "network=") |
|
|
|
|
|
if [ ${valueExists} -eq 0 ]; then |
|
|
|
|
|
echo "network=bitcoin" >> ${infoFile} |
|
|
|
|
|
fi |
|
|
|
|
|
valueExists=$(sudo cat ${infoFile} 2>/dev/null | grep -c "chain=") |
|
|
|
|
|
if [ ${valueExists} -eq 0 ]; then |
|
|
|
|
|
echo "chain=main" >> ${infoFile} |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# EXIT on BOOTSTRAP HERE AT THE MOMENT |
|
|
# EXIT on BOOTSTRAP HERE AT THE MOMENT |
|
|
echo "DONE BOOTSTRAP (before any configs etc)" >> $logFile |
|
|
echo "DONE BOOTSTRAP (before any configs etc)" >> $logFile |
|
|
sed -i "s/^state=.*/state=ready/g" ${infoFile} |
|
|
sed -i "s/^state=.*/state=ready/g" ${infoFile} |
|
|