2018-12-06 17:39:06 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script gets called from a fresh SD card
|
|
|
|
# starting up that has an config file on HDD
|
|
|
|
# from old RaspiBlitz or manufacturer to
|
2019-09-22 15:34:03 +02:00
|
|
|
# to install and config services
|
2018-12-06 17:39:06 +01:00
|
|
|
|
|
|
|
# LOGFILE - store debug logs of bootstrap
|
|
|
|
logFile="/home/admin/raspiblitz.log"
|
|
|
|
|
|
|
|
# INFOFILE - state data from bootstrap
|
|
|
|
infoFile="/home/admin/raspiblitz.info"
|
|
|
|
|
|
|
|
# CONFIGFILE - configuration of RaspiBlitz
|
|
|
|
configFile="/mnt/hdd/raspiblitz.conf"
|
|
|
|
|
|
|
|
# debug info
|
|
|
|
echo "STARTED Provisioning --> see logs in ${logFile}"
|
|
|
|
echo "STARTED Provisioning from preset config file" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Provisioning from Config'/g" ${infoFile}
|
|
|
|
|
|
|
|
# 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 run provision!" >> ${logFile}
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-01-07 17:11:21 +01:00
|
|
|
# check if file system was expanded to full capacity and sd card is bigger then 8GB
|
|
|
|
# see: https://github.com/rootzoll/raspiblitz/issues/936
|
2020-01-08 11:49:02 +01:00
|
|
|
isRaspbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Raspbian')
|
|
|
|
if [ ${isRaspbian} -gt 0 ]; then
|
2020-01-07 17:11:21 +01:00
|
|
|
echo "### RASPBIAN: CHECKING SD CARD SIZE ###" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Checking SD Card'/g" ${infoFile}
|
|
|
|
byteSizeSdCard=$(df --output=size,source | grep "/dev/root" | tr -cd "[0-9]")
|
|
|
|
echo "Size in Bytes is: ${byteSizeSdCard}" >> ${logFile}
|
|
|
|
if [ ${byteSizeSdCard} -lt 8192000 ]; then
|
|
|
|
echo "SD Card filesystem is smaller then 8GB." >> ${logFile}
|
|
|
|
if [ ${fsexpanded} -eq 1 ]; then
|
|
|
|
echo "There was already an attempt to expand the fs, but still not bigger then 8GB." >> ${logFile}
|
|
|
|
echo "SD card seems to small - at least a 16GB card is needed. Display on LCD to user." >> ${logFile}
|
|
|
|
sudo sed -i "s/^state=.*/state=sdtoosmall/g" ${infoFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Min 16GB SD card needed'/g" ${infoFile}
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Try to expand SD card FS, display info and reboot." >> ${logFile}
|
|
|
|
sudo sed -i "s/^state=.*/state=reboot/g" ${infoFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Expanding SD Card'/g" ${infoFile}
|
|
|
|
sudo sed -i "s/^fsexpanded=.*/fsexpanded=1/g" ${infoFile}
|
|
|
|
sudo raspi-config --expand-rootfs
|
|
|
|
sleep 6
|
|
|
|
sudo shutdown -r now
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Size looks good. Bigger then 8GB card is used." >> ${logFile}
|
|
|
|
fi
|
|
|
|
else
|
2020-01-08 11:49:02 +01:00
|
|
|
echo "Baseimage is not raspbian (${isRaspbian}), skipping the sd card size check." >> ${logFile}
|
2020-01-07 17:11:21 +01:00
|
|
|
fi
|
|
|
|
|
2018-12-12 15:29:38 +01:00
|
|
|
# import config values
|
|
|
|
sudo chmod 777 ${configFile}
|
2018-12-12 16:12:56 +01:00
|
|
|
source ${configFile}
|
2018-12-12 15:29:38 +01:00
|
|
|
|
2020-01-24 22:24:31 +01:00
|
|
|
# check if the system was configured for HDMI and needs switch
|
|
|
|
# keep as one of the first so that user can see video output
|
|
|
|
if [ "${lcd2hdmi}" == "on" ]; then
|
|
|
|
echo "RaspiBlitz has config to run with HDMI video outout." >> ${logFile}
|
|
|
|
# check that raspiblitz.info shows that confing script was not run yet
|
|
|
|
switchScriptNotRunYet=$(sudo cat /home/admin/raspiblitz.info | grep -c "lcd2hdmi=off")
|
|
|
|
if [ ${switchScriptNotRunYet} -eq 1 ]; then
|
|
|
|
echo "--> Switching to HDMI video output & rebooting" >> ${logFile}
|
|
|
|
sudo /home/admin/config.scripts/blitz.lcd.sh hdmi on
|
|
|
|
else
|
|
|
|
echo "OK RaspiBlitz was already switched to HDMI output." >> ${logFile}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-12-06 17:39:06 +01:00
|
|
|
##########################
|
|
|
|
# BASIC SYSTEM SETTINGS
|
|
|
|
##########################
|
|
|
|
|
|
|
|
echo "### BASIC SYSTEM SETTINGS ###" >> ${logFile}
|
2018-12-12 16:46:54 +01:00
|
|
|
sudo sed -i "s/^message=.*/message='Setup System .'/g" ${infoFile}
|
2018-12-06 17:39:06 +01:00
|
|
|
|
2020-01-20 21:05:40 +01:00
|
|
|
# install litecoin (just if needed)
|
|
|
|
if [ "${network}" = "litecoin" ]; then
|
|
|
|
echo "Installing Litecoin ..." >> ${logFile}
|
|
|
|
/home/admin/config.scripts/blitz.litecoin.sh on >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2018-12-06 17:39:06 +01:00
|
|
|
# set hostname data
|
|
|
|
echo "Setting lightning alias: ${hostname}" >> ${logFile}
|
|
|
|
sudo sed -i "s/^alias=.*/alias=${hostname}/g" /home/admin/assets/lnd.${network}.conf >> ${logFile} 2>&1
|
|
|
|
|
2019-01-15 02:37:14 +01:00
|
|
|
# link old SSH PubKeys
|
|
|
|
# so that client ssh_known_hosts is not complaining after update
|
|
|
|
if [ -d "/mnt/hdd/ssh" ]; then
|
|
|
|
echo "Old SSH PubKey exists on HDD > just linking them" >> ${logFile}
|
|
|
|
else
|
|
|
|
echo "No SSH PubKey exists on HDD > copy from SD card and linking them" >> ${logFile}
|
|
|
|
sudo cp -r /etc/ssh /mnt/hdd/ssh >> ${logFile} 2>&1
|
|
|
|
fi
|
|
|
|
sudo rm -rf /etc/ssh >> ${logFile} 2>&1
|
|
|
|
sudo ln -s /mnt/hdd/ssh /etc/ssh >> ${logFile} 2>&1
|
|
|
|
|
2019-07-28 23:26:14 +02:00
|
|
|
# optimze if RAM >1GB
|
|
|
|
kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
|
|
|
|
if [ ${kbSizeRAM} -gt 1500000 ]; then
|
|
|
|
echo "Detected RAM >1GB --> optimizing ${network}.conf"
|
2019-08-02 22:24:20 +02:00
|
|
|
sudo sed -i "s/^dbcache=.*/dbcache=1024/g" /mnt/hdd/${network}/${network}.conf
|
2019-08-08 02:15:44 +02:00
|
|
|
sudo sed -i "s/^maxmempool=.*/maxmempool=256/g" /mnt/hdd/${network}/${network}.conf
|
2019-07-28 23:26:14 +02:00
|
|
|
fi
|
|
|
|
|
2019-12-12 14:51:21 +01:00
|
|
|
# link and copy HDD content into new OS on sd card
|
2018-12-06 17:39:06 +01:00
|
|
|
echo "Copy HDD content for user admin" >> ${logFile}
|
|
|
|
sudo mkdir /home/admin/.${network} >> ${logFile} 2>&1
|
|
|
|
sudo cp /mnt/hdd/${network}/${network}.conf /home/admin/.${network}/${network}.conf >> ${logFile} 2>&1
|
|
|
|
sudo mkdir /home/admin/.lnd >> ${logFile} 2>&1
|
|
|
|
sudo cp /mnt/hdd/lnd/lnd.conf /home/admin/.lnd/lnd.conf >> ${logFile} 2>&1
|
|
|
|
sudo cp /mnt/hdd/lnd/tls.cert /home/admin/.lnd/tls.cert >> ${logFile} 2>&1
|
|
|
|
sudo mkdir /home/admin/.lnd/data >> ${logFile} 2>&1
|
|
|
|
sudo cp -r /mnt/hdd/lnd/data/chain /home/admin/.lnd/data/chain >> ${logFile} 2>&1
|
|
|
|
sudo chown -R admin:admin /home/admin/.${network} >> ${logFile} 2>&1
|
|
|
|
sudo chown -R admin:admin /home/admin/.lnd >> ${logFile} 2>&1
|
|
|
|
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service >> ${logFile} 2>&1
|
2018-12-11 19:17:35 +01:00
|
|
|
sed -i "5s/.*/Wants=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile} 2>&1
|
|
|
|
sed -i "6s/.*/After=${network}d.service/" /home/admin/assets/lnd.service >> ${logFile} 2>&1
|
2018-12-06 17:39:06 +01:00
|
|
|
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile} 2>&1
|
|
|
|
|
2019-09-22 15:34:03 +02:00
|
|
|
sudo cp /home/admin/assets/tmux.conf.local /mnt/hdd/.tmux.conf.local >> ${logFile} 2>&1
|
|
|
|
sudo chown admin:admin /mnt/hdd/.tmux.conf.local >> ${logFile} 2>&1
|
|
|
|
sudo ln -s -f /mnt/hdd/.tmux.conf.local /home/admin/.tmux.conf.local >> ${logFile} 2>&1
|
|
|
|
|
2019-04-02 22:00:39 +02:00
|
|
|
# backup LND dir (especially for macaroons and tlscerts)
|
|
|
|
# https://github.com/rootzoll/raspiblitz/issues/324
|
|
|
|
echo "*** Make backup of LND directory" >> ${logFile}
|
2019-09-22 15:34:03 +02:00
|
|
|
sudo rm -r /mnt/hdd/backup_lnd
|
2019-04-02 22:00:39 +02:00
|
|
|
sudo cp -r /mnt/hdd/lnd /mnt/hdd/backup_lnd >> ${logFile} 2>&1
|
|
|
|
numOfDiffers=$(sudo diff -arq /mnt/hdd/lnd /mnt/hdd/backup_lnd | grep -c "differ")
|
|
|
|
if [ ${numOfDiffers} -gt 0 ]; then
|
|
|
|
echo "FAIL: Backup was not successfull" >> ${logFile}
|
|
|
|
sudo diff -arq /mnt/hdd/lnd /mnt/hdd/backup_lnd >> ${logFile} 2>&1
|
|
|
|
echo "removing backup dir to prevent false override" >> ${logFile}
|
|
|
|
else
|
|
|
|
echo "OK Backup is valid." >> ${logFile}
|
|
|
|
fi
|
|
|
|
echo "" >> ${logFile}
|
|
|
|
|
2018-12-06 17:39:06 +01:00
|
|
|
# finish setup (SWAP, Benus, Firewall, Update, ..)
|
2018-12-12 16:46:54 +01:00
|
|
|
sudo sed -i "s/^message=.*/message='Setup System ..'/g" ${infoFile}
|
2018-12-11 19:17:35 +01:00
|
|
|
/home/admin/90finishSetup.sh >> ${logFile} 2>&1
|
2018-12-06 17:39:06 +01:00
|
|
|
|
|
|
|
##########################
|
|
|
|
# PROVISIONING SERVICES
|
|
|
|
##########################
|
2018-12-12 16:12:30 +01:00
|
|
|
sudo sed -i "s/^message=.*/message='Installing Services'/g" ${infoFile}
|
2018-12-06 17:39:06 +01:00
|
|
|
|
2018-12-12 16:12:30 +01:00
|
|
|
echo "### RUNNING PROVISIONING SERVICES ###" >> ${logFile}
|
2018-12-06 17:39:06 +01:00
|
|
|
|
|
|
|
# TESTNET
|
|
|
|
if [ "${chain}" = "test" ]; then
|
|
|
|
echo "Provisioning TESTNET - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Provisioning Testnet'/g" ${infoFile}
|
|
|
|
sudo /home/admin/config.scripts/network.chain.sh testnet >> ${logFile} 2>&1
|
2019-09-22 15:34:03 +02:00
|
|
|
else
|
2018-12-06 17:39:06 +01:00
|
|
|
echo "Provisioning TESTNET - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-06-12 23:40:56 +02:00
|
|
|
# TOR
|
|
|
|
if [ "${runBehindTor}" = "on" ]; then
|
|
|
|
echo "Provisioning TOR - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup TOR (takes time)'/g" ${infoFile}
|
|
|
|
sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1
|
2019-09-22 15:34:03 +02:00
|
|
|
else
|
2019-06-12 23:40:56 +02:00
|
|
|
echo "Provisioning TOR - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2018-12-06 17:39:06 +01:00
|
|
|
# AUTO PILOT
|
|
|
|
if [ "${autoPilot}" = "on" ]; then
|
|
|
|
echo "Provisioning AUTO PILOT - run config script" >> ${logFile}
|
2018-12-12 17:38:17 +01:00
|
|
|
sudo sed -i "s/^message=.*/message='Setup AutoPilot'/g" ${infoFile}
|
2018-12-06 17:39:06 +01:00
|
|
|
sudo /home/admin/config.scripts/lnd.autopilot.sh on >> ${logFile} 2>&1
|
2019-09-22 15:34:03 +02:00
|
|
|
else
|
2018-12-06 17:39:06 +01:00
|
|
|
echo "Provisioning AUTO PILOT - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-06-13 18:03:17 +02:00
|
|
|
# NETWORK UPNP
|
|
|
|
if [ "${networkUPnP}" = "on" ]; then
|
|
|
|
echo "Provisioning NETWORK UPnP - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup UPnP'/g" ${infoFile}
|
|
|
|
sudo /home/admin/config.scripts/network.upnp.sh on >> ${logFile} 2>&1
|
2019-09-22 15:34:03 +02:00
|
|
|
else
|
2019-06-13 18:03:17 +02:00
|
|
|
echo "Provisioning NETWORK UPnP - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# LND AUTO NAT DISCOVERY
|
2018-12-06 17:39:06 +01:00
|
|
|
if [ "${autoNatDiscovery}" = "on" ]; then
|
2019-06-13 18:03:17 +02:00
|
|
|
echo "Provisioning LND AUTO NAT DISCOVERY - run config script" >> ${logFile}
|
2018-12-12 17:38:17 +01:00
|
|
|
sudo sed -i "s/^message=.*/message='Setup AutoNAT'/g" ${infoFile}
|
2018-12-06 17:39:06 +01:00
|
|
|
sudo /home/admin/config.scripts/lnd.autonat.sh on >> ${logFile} 2>&1
|
2019-09-22 15:34:03 +02:00
|
|
|
else
|
2018-12-06 17:39:06 +01:00
|
|
|
echo "Provisioning AUTO NAT DISCOVERY - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2018-12-20 14:13:42 +01:00
|
|
|
# DYNAMIC DNS
|
|
|
|
if [ "${#dynDomain}" -gt 0 ]; then
|
|
|
|
echo "Provisioning DYNAMIC DNS - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup DynamicDNS'/g" ${infoFile}
|
|
|
|
sudo /home/admin/config.scripts/internet.dyndomain.sh on ${dynDomain} ${dynUpdateUrl} >> ${logFile} 2>&1
|
|
|
|
else
|
|
|
|
echo "Provisioning DYNAMIC DNS - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2018-12-06 17:39:06 +01:00
|
|
|
# RTL
|
|
|
|
if [ "${rtlWebinterface}" = "on" ]; then
|
|
|
|
echo "Provisioning RTL - run config script" >> ${logFile}
|
2018-12-12 17:38:17 +01:00
|
|
|
sudo sed -i "s/^message=.*/message='Setup RTL (takes time)'/g" ${infoFile}
|
2019-12-25 01:23:34 +01:00
|
|
|
sudo -u admin /home/admin/config.scripts/bonus.rtl.sh on >> ${logFile} 2>&1
|
2018-12-12 18:29:49 +01:00
|
|
|
sudo systemctl disable RTL # will get enabled after recover dialog
|
2018-12-12 18:21:01 +01:00
|
|
|
else
|
2018-12-06 17:39:06 +01:00
|
|
|
echo "Provisioning RTL - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-12-18 13:26:49 +01:00
|
|
|
#LOOP
|
|
|
|
if [ "${loop}" = "on" ]; then
|
|
|
|
echo "Provisioning Lightning Loop - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup Lightning Loop'/g" ${infoFile}
|
2019-12-25 01:23:34 +01:00
|
|
|
sudo -u admin /home/admin/config.scripts/bonus.loop.sh on >> ${logFile} 2>&1
|
2019-12-18 13:26:49 +01:00
|
|
|
sudo systemctl disable loopd # will get enabled after recover dialog
|
|
|
|
else
|
|
|
|
echo "Provisioning Lightning Loop - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
|
|
|
#BTC RPC EXPLORER
|
|
|
|
if [ "${BTCRPCexplorer}" = "on" ]; then
|
|
|
|
echo "Provisioning BTCRPCexplorer - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup BTCRPCexplorer (takes time)'/g" ${infoFile}
|
2019-12-25 01:23:34 +01:00
|
|
|
sudo -u admin /home/admin/config.scripts/bonus.btc-rpc-explorer.sh on >> ${logFile} 2>&1
|
2019-12-18 13:26:49 +01:00
|
|
|
sudo systemctl disable btc-rpc-explorer # will get enabled after recover dialog
|
|
|
|
else
|
|
|
|
echo "Provisioning BTCRPCexplorer - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
|
|
|
#ELECTRS
|
|
|
|
if [ "${ElectRS}" = "on" ]; then
|
|
|
|
echo "Provisioning ElectRS - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup ElectRS (takes time)'/g" ${infoFile}
|
2019-12-25 01:23:34 +01:00
|
|
|
sudo -u admin /home/admin/config.scripts/bonus.electrs.sh on >> ${logFile} 2>&1
|
2019-12-18 13:26:49 +01:00
|
|
|
sudo systemctl disable electrs # will get enabled after recover dialog
|
|
|
|
else
|
|
|
|
echo "Provisioning ElectRS - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# BTCPAYSERVER - not restored due to need for domain name and port forwarding
|
|
|
|
if [ "${BTCPayServer}" = "on" ]; then
|
2020-01-28 19:56:35 +01:00
|
|
|
# --> TODO: BTCPay Server install does not run clean during provision
|
|
|
|
# --> needs install when everything is already 'running'
|
|
|
|
#if [ "${runBehindTor}" = "on" ] && [ "${BTCPayDomain}" = "localhost" ]; then
|
|
|
|
# echo "Provisioning BTCPAYSERVER on TOR - run config script" >> ${logFile}
|
|
|
|
# sudo sed -i "s/^message=.*/message='Setup BTCPay (takes time)'/g" ${infoFile}
|
|
|
|
# sudo -u admin /home/admin/config.scripts/bonus.btcpayserver.sh on tor >> ${logFile} 2>&1
|
|
|
|
#else
|
2020-01-28 17:54:28 +01:00
|
|
|
# provisioning non-TOR BTCPayServer is not supported yet - needs manual reinstall
|
|
|
|
echo "Setting BTCPayServer to be off - will need to be reinstalled from the menu again" >> ${logFile}
|
|
|
|
sudo sed -i "s/^BTCPayServer=.*/BTCPayServer=off/g" /mnt/hdd/raspiblitz.conf
|
2020-01-28 19:56:35 +01:00
|
|
|
#fi
|
2019-12-18 13:26:49 +01:00
|
|
|
else
|
|
|
|
echo "Provisioning BTCPayServer - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# LNDMANAGE
|
|
|
|
if [ "${lndmanage}" = "on" ]; then
|
|
|
|
echo "Provisioning lndmanage - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup lndmanage '/g" ${infoFile}
|
2019-12-25 01:23:34 +01:00
|
|
|
sudo -u admin /home/admin/config.scripts/bonus.lndmanage.sh on >> ${logFile} 2>&1
|
2019-12-18 13:26:49 +01:00
|
|
|
else
|
|
|
|
echo "Provisioning ElectRS - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-03-17 16:11:28 +01:00
|
|
|
# CUSTOM PORT
|
|
|
|
echo "Provisioning LND Port" >> ${logFile}
|
2019-04-03 05:37:46 +02:00
|
|
|
if [ ${#lndPort} -eq 0 ]; then
|
|
|
|
lndPort=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep "^listen=*" | cut -f2 -d':')
|
|
|
|
fi
|
2019-03-17 16:11:28 +01:00
|
|
|
if [ ${#lndPort} -gt 0 ]; then
|
|
|
|
if [ "${lndPort}" != "9735" ]; then
|
|
|
|
echo "User is running custom LND port: ${lndPort}" >> ${logFile}
|
|
|
|
sudo /home/admin/config.scripts/lnd.setport.sh ${lndPort} >> ${logFile} 2>&1
|
|
|
|
else
|
|
|
|
echo "User is running standard LND port: ${lndPort}" >> ${logFile}
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Was not able to get LND port from config." >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-04-10 00:32:14 +02:00
|
|
|
# DNS Server
|
|
|
|
if [ ${#dnsServer} -gt 0 ]; then
|
|
|
|
echo "Provisioning DNS Server - Setting DNS Server" >> ${logFile}
|
|
|
|
sudo /home/admin/config.scripts/internet.dns.sh ${dnsServer} >> ${logFile} 2>&1
|
|
|
|
else
|
|
|
|
echo "Provisioning DNS Server - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-04-02 22:00:39 +02:00
|
|
|
# ROOT SSH KEYS
|
|
|
|
# check if a backup on HDD exists and when retsore back
|
|
|
|
backupRootSSH=$(sudo ls /mnt/hdd/ssh/root_backup 2>/dev/null | grep -c "id_rsa")
|
|
|
|
if [ ${backupRootSSH} -gt 0 ]; then
|
|
|
|
echo "Provisioning Root SSH Keys - RESTORING from HDD" >> ${logFile}
|
|
|
|
sudo cp -r /mnt/hdd/ssh/root_backup /root/.ssh
|
|
|
|
sudo chown -R root:root /root/.ssh
|
|
|
|
else
|
|
|
|
echo "Provisioning Root SSH Keys - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-04-04 00:13:42 +02:00
|
|
|
# SSH TUNNEL
|
|
|
|
if [ "${#sshtunnel}" -gt 0 ]; then
|
|
|
|
echo "Provisioning SSH Tunnel - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup SSH Tunnel'/g" ${infoFile}
|
|
|
|
sudo /home/admin/config.scripts/internet.sshtunnel.py restore ${sshtunnel} >> ${logFile} 2>&1
|
2019-09-22 15:34:03 +02:00
|
|
|
else
|
2019-04-04 00:13:42 +02:00
|
|
|
echo "Provisioning SSH Tunnel - not active" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-07-29 00:42:19 +02:00
|
|
|
# LCD ROTATE
|
2020-03-22 02:31:35 +01:00
|
|
|
if [ "${#lcdrotate}" -eq 0 ]; then
|
2020-03-22 01:54:15 +01:00
|
|
|
# when upgrading from an old raspiblitz - enforce lcdrotate = 0
|
|
|
|
lcdrotate=0
|
2019-07-29 00:42:19 +02:00
|
|
|
fi
|
2020-03-22 01:54:15 +01:00
|
|
|
echo "Provisioning LCD rotate - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='LCD Rotate'/g" ${infoFile}
|
|
|
|
sudo /home/admin/config.scripts/blitz.lcdrotate.sh ${lcdrotate} >> ${logFile} 2>&1
|
2019-07-29 00:42:19 +02:00
|
|
|
|
2020-01-26 04:14:24 +01:00
|
|
|
# TOUCHSCREEN
|
2019-07-02 22:59:32 +02:00
|
|
|
if [ "${#touchscreen}" -gt 0 ]; then
|
|
|
|
echo "Provisioning Touchscreen - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup Touchscreen'/g" ${infoFile}
|
|
|
|
sudo /home/admin/config.scripts/blitz.touchscreen.sh ${touchscreen} >> ${logFile} 2>&1
|
2019-09-22 15:34:03 +02:00
|
|
|
else
|
2019-07-02 22:59:32 +02:00
|
|
|
echo "Provisioning Touchscreen - not active" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-08-05 23:10:56 +02:00
|
|
|
# UPS
|
|
|
|
if [ "${#ups}" -gt 0 ]; then
|
|
|
|
echo "Provisioning UPS - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup UPS'/g" ${infoFile}
|
|
|
|
sudo /home/admin/config.scripts/blitz.ups.sh on ${ups} >> ${logFile} 2>&1
|
2019-09-22 15:34:03 +02:00
|
|
|
else
|
2019-08-05 23:10:56 +02:00
|
|
|
echo "Provisioning UPS - not active" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2020-02-10 20:44:41 +01:00
|
|
|
# LNBits
|
|
|
|
if [ "${LNBits}" = "on" ]; then
|
|
|
|
echo "Provisioning LNBits - run config script" >> ${logFile}
|
|
|
|
sudo sed -i "s/^message=.*/message='Setup LNBits '/g" ${infoFile}
|
|
|
|
sudo -u admin /home/admin/config.scripts/bonus.lnbits.sh on >> ${logFile} 2>&1
|
|
|
|
else
|
|
|
|
echo "Provisioning LNBits - keep default" >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-04-27 16:14:26 +02:00
|
|
|
# replay backup LND conf & tlscerts
|
2019-04-02 22:00:39 +02:00
|
|
|
# https://github.com/rootzoll/raspiblitz/issues/324
|
|
|
|
echo "" >> ${logFile}
|
2019-04-27 16:14:26 +02:00
|
|
|
echo "*** Replay backup of LND conf/tls" >> ${logFile}
|
2019-04-02 22:00:39 +02:00
|
|
|
if [ -d "/mnt/hdd/backup_lnd" ]; then
|
2019-04-27 16:14:26 +02:00
|
|
|
|
|
|
|
echo "Copying TLS ..." >> ${logFile}
|
|
|
|
sudo cp /mnt/hdd/backup_lnd/lnd.conf /mnt/hdd/lnd/lnd.conf >> ${logFile} 2>&1
|
|
|
|
sudo cp /mnt/hdd/backup_lnd/tls.cert /mnt/hdd/lnd/tls.cert >> ${logFile} 2>&1
|
|
|
|
sudo cp /mnt/hdd/backup_lnd/tls.key /mnt/hdd/lnd/tls.key >> ${logFile} 2>&1
|
|
|
|
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd >> ${logFile} 2>&1
|
|
|
|
echo "On next final restart admin creds will be updated by _boostrap.sh" >> ${logFile}
|
|
|
|
|
2019-04-02 22:00:39 +02:00
|
|
|
echo "DONE" >> ${logFile}
|
|
|
|
else
|
|
|
|
echo "No BackupDir so skipping that step." >> ${logFile}
|
|
|
|
fi
|
|
|
|
echo "" >> ${logFile}
|
|
|
|
|
2019-12-15 15:29:45 +01:00
|
|
|
# repair Bitcoin conf if needed
|
|
|
|
echo "*** Repair Bitcioin Conf (if needed)" >> ${logFile}
|
|
|
|
confExists="$(sudo ls /mnt/hdd/${network} | grep -c "${network}.conf")"
|
|
|
|
if [ ${confExists} -eq 0 ]; then
|
|
|
|
echo "Doing init of ${network}.conf" >> ${logFile}
|
|
|
|
sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf
|
|
|
|
sudo chown bitcoin:bitcoin /mnt/hdd/bitcoin/bitcoin.conf
|
|
|
|
fi
|
|
|
|
echo "Aligning lnd.conf & ${network}.conf" >> ${logFile}
|
|
|
|
rpcpass=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep "${network}d.rpcpass" | cut -d "=" -f2)
|
|
|
|
sudo sed -i "s/^rpcpassword=.*/rpcpassword=${rpcpass}/g" /mnt/hdd/bitcoin/bitcoin.conf 2>/dev/null
|
|
|
|
|
|
|
|
# singal setup done
|
2018-12-12 16:12:30 +01:00
|
|
|
sudo sed -i "s/^message=.*/message='Setup Done'/g" ${infoFile}
|
2019-02-18 18:41:12 +01:00
|
|
|
|
2019-12-10 14:47:23 +01:00
|
|
|
# set the local network hostname (just if set in config - will not be set anymore by default in newer version)
|
2019-04-03 01:44:55 +02:00
|
|
|
# have at the end - see https://github.com/rootzoll/raspiblitz/issues/462
|
2019-12-10 14:47:23 +01:00
|
|
|
# see also https://github.com/rootzoll/raspiblitz/issues/819
|
2019-04-03 01:44:55 +02:00
|
|
|
if [ ${#hostname} -gt 0 ]; then
|
|
|
|
hostnameSanatized=$(echo "${hostname}"| tr -dc '[:alnum:]\n\r')
|
|
|
|
if [ ${#hostnameSanatized} -gt 0 ]; then
|
2019-12-10 14:47:23 +01:00
|
|
|
# by default set hostname for older versions on update
|
|
|
|
if [ ${#setnetworkname} -eq 0 ]; then
|
|
|
|
setnetworkname=1
|
|
|
|
fi
|
|
|
|
if [ "${setnetworkname}" = "1" ]; then
|
|
|
|
echo "Setting new network hostname '$hostnameSanatized'" >> ${logFile}
|
|
|
|
sudo raspi-config nonint do_hostname ${hostnameSanatized} >> ${logFile} 2>&1
|
|
|
|
else
|
|
|
|
echo "Not setting local network hostname" >> ${logFile}
|
|
|
|
fi
|
2019-04-03 01:44:55 +02:00
|
|
|
else
|
|
|
|
echo "WARNING: hostname in raspiblitz.conf contains just special chars" >> ${logFile}
|
|
|
|
fi
|
2019-09-22 15:34:03 +02:00
|
|
|
else
|
2019-04-03 01:44:55 +02:00
|
|
|
echo "No hostname set." >> ${logFile}
|
|
|
|
fi
|
|
|
|
|
2019-12-12 14:51:21 +01:00
|
|
|
# PERMANENT MOUNT OF HDD/SSD
|
|
|
|
# always at the end, because data drives will be just available again after a reboot
|
|
|
|
echo "Prepare fstab for permanent data drive mounting .." >> ${logFile}
|
|
|
|
# get info on data drive
|
|
|
|
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
|
|
|
|
# update /etc/fstab
|
|
|
|
echo "datadisk --> ${datadisk}" >> ${logFile}
|
|
|
|
sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${datadisk} >> ${logFile}
|
|
|
|
|
2019-11-26 22:02:53 +01:00
|
|
|
echo "DONE - Give raspi some cool off time after hard building .... 5 secs sleep" >> ${logFile}
|
|
|
|
sleep 5
|
2019-02-18 18:41:12 +01:00
|
|
|
|
2019-09-22 15:34:03 +02:00
|
|
|
echo "END Provisioning" >> ${logFile}
|