14 changed files with 363 additions and 104 deletions
@ -0,0 +1,84 @@ |
|||||
|
#!/bin/bash |
||||
|
_temp="./download/dialog.$$" |
||||
|
|
||||
|
## get basic info |
||||
|
source /home/admin/raspiblitz.info 2>/dev/null |
||||
|
|
||||
|
passwordValid=0 |
||||
|
result="" |
||||
|
while [ ${passwordValid} -eq 0 ] |
||||
|
do |
||||
|
# show password info dialog |
||||
|
dialog --backtitle "RaspiBlitz - Setup" --msgbox "RaspiBlitz uses 4 different passwords. |
||||
|
Referenced as password A, B, C and D. |
||||
|
|
||||
|
A) Master User Password |
||||
|
B) Blockchain RPC Password |
||||
|
C) LND Wallet Password |
||||
|
D) LND Seed Password |
||||
|
|
||||
|
Choose now 4 new passwords - all min 8 chars, |
||||
|
no spaces and only special characters - or . |
||||
|
Write them down & store them in a safe place. |
||||
|
" 15 52 |
||||
|
|
||||
|
# ask user for new password A |
||||
|
dialog --backtitle "RaspiBlitz - Setup"\ |
||||
|
--inputbox "Please enter your Master/Admin Password A:\n!!! This is new password to login per SSH !!!" 10 52 2>$_temp |
||||
|
|
||||
|
# get user input |
||||
|
result=$( cat $_temp ) |
||||
|
shred $_temp |
||||
|
passwordValid=1 |
||||
|
|
||||
|
clearedResult=$(echo "${result}" | tr -dc '[:alnum:]-.' | tr -d ' ') |
||||
|
if [ ${#clearedResult} != ${#result} ] || [ ${#clearedResult} -eq 0 ]; then |
||||
|
clear |
||||
|
echo "FAIL - Password contained not allowed chars (see next screen)" |
||||
|
echo "Press ENTER to continue .." |
||||
|
read key |
||||
|
passwordValid=0 |
||||
|
else |
||||
|
|
||||
|
# change user passwords and then change hostname |
||||
|
echo "pi:$result" | sudo chpasswd |
||||
|
echo "root:$result" | sudo chpasswd |
||||
|
echo "bitcoin:$result" | sudo chpasswd |
||||
|
echo "admin:$result" | sudo chpasswd |
||||
|
sleep 1 |
||||
|
|
||||
|
# sucess info dialog |
||||
|
dialog --backtitle "RaspiBlitz" --msgbox "OK - password changed to '$result'\nfor all users pi, admin, root & bitcoin" 6 52 |
||||
|
|
||||
|
# repeat until user input is nit length 0 |
||||
|
result="" |
||||
|
dialog --backtitle "RaspiBlitz - Setup"\ |
||||
|
--inputbox "Enter your RPC Password B:" 9 52 2>$_temp |
||||
|
result=$( cat $_temp ) |
||||
|
shred $_temp |
||||
|
|
||||
|
clearedResult=$(echo "${result}" | tr -dc '[:alnum:]-.' | tr -d ' ') |
||||
|
if [ ${#clearedResult} != ${#result} ] || [ ${#clearedResult} -eq 0 ]; then |
||||
|
clear |
||||
|
echo "FAIL - Password contained not allowed chars (see next screen)" |
||||
|
echo "Press ENTER to continue to start again" |
||||
|
read key |
||||
|
passwordValid=0 |
||||
|
else |
||||
|
|
||||
|
# set Blockchain RPC Password (for admin cli & template for user bitcoin) |
||||
|
sed -i "s/^rpcpassword=.*/rpcpassword=${result}/g" /home/admin/assets/${network}.conf |
||||
|
sed -i "s/^${network}d.rpcpass=.*/${network}d.rpcpass=${result}/g" /home/admin/assets/lnd.${network}.conf |
||||
|
|
||||
|
# success info dialog |
||||
|
dialog --backtitle "RaspiBlitz - SetUP" --msgbox "OK - RPC password changed to '$result'\n\nNow starting the Setup of your RaspiBlitz." 7 52 |
||||
|
clear |
||||
|
|
||||
|
fi |
||||
|
|
||||
|
fi |
||||
|
|
||||
|
done |
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,45 @@ |
|||||
|
#!/bin/bash |
||||
|
echo "" |
||||
|
|
||||
|
# load setup config |
||||
|
source /home/admin/raspiblitz.info |
||||
|
|
||||
|
# load version |
||||
|
source /home/admin/_version.info |
||||
|
|
||||
|
# show info to user |
||||
|
dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " --msgbox " |
||||
|
Press OK for a final reboot. |
||||
|
|
||||
|
Remember: After every reboot |
||||
|
you need to unlock the LND wallet. |
||||
|
" 10 42 |
||||
|
|
||||
|
# 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 |
||||
|
|
||||
|
# set the hostname inputed on initDialog |
||||
|
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 |
||||
|
|
||||
|
clear |
||||
|
echo "Setup done. Rebooting now." |
||||
|
sudo shutdown -r now |
@ -0,0 +1,135 @@ |
|||||
|
#!/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 |
||||
|
# to install and config services |
||||
|
|
||||
|
# 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 |
||||
|
|
||||
|
########################## |
||||
|
# BASIC SYSTEM SETTINGS |
||||
|
########################## |
||||
|
|
||||
|
echo "### BASIC SYSTEM SETTINGS ###" >> ${logFile} |
||||
|
|
||||
|
# 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 |
||||
|
|
||||
|
# auto-mount HDD |
||||
|
sudo umount -l /mnt/hdd >> ${logFile} 2>&1 |
||||
|
echo "Auto-Mounting HDD - calling script" >> ${logFile} |
||||
|
/home/admin/40addHDD.sh >> ${logFile} 2>&1 |
||||
|
|
||||
|
# link and copy HDD content into new OS |
||||
|
echo "Link HDD content for user bitcoin" >> ${logFile} |
||||
|
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd >> ${logFile} 2>&1 |
||||
|
sudo chown -R bitcoin:bitcoin /mnt/hdd/${network} >> ${logFile} 2>&1 |
||||
|
sudo ln -s /mnt/hdd/${network} /home/bitcoin/.${network} >> ${logFile} 2>&1 |
||||
|
sudo ln -s /mnt/hdd/lnd /home/bitcoin/.lnd >> ${logFile} 2>&1 |
||||
|
sudo chown -R bitcoin:bitcoin /home/bitcoin/.${network} >> ${logFile} 2>&1 |
||||
|
sudo chown -R bitcoin:bitcoin /home/bitcoin/.lnd >> ${logFile} 2>&1 |
||||
|
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 |
||||
|
echo "Enabling Services" >> ${logFile} |
||||
|
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service >> ${logFile} 2>&1 |
||||
|
sudo chmod +x /etc/systemd/system/${network}d.service >> ${logFile} 2>&1 |
||||
|
sudo systemctl daemon-reload >> ${logFile} 2>&1 |
||||
|
sudo systemctl enable ${network}d.service >> ${logFile} 2>&1 |
||||
|
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.service >> ${logFile} 2>&1 |
||||
|
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.service >> ${logFile} 2>&1 |
||||
|
sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile} 2>&1 |
||||
|
sudo chmod +x /etc/systemd/system/lnd.service >> ${logFile} 2>&1 |
||||
|
sudo systemctl enable lnd >> ${logFile} 2>&1 |
||||
|
|
||||
|
# finish setup (SWAP, Benus, Firewall, Update, ..) |
||||
|
./90finishSetup.sh >> ${logFile} 2>&1 |
||||
|
|
||||
|
# set the local network hostname |
||||
|
if [ ${#hostname} -gt 0 ]; then |
||||
|
echo "Setting new network hostname '$hostname'" >> ${logFile} |
||||
|
sudo raspi-config nonint do_hostname ${hostname} >> ${logFile} 2>&1 |
||||
|
else |
||||
|
echo "No hostname set." >> ${logFile} |
||||
|
fi |
||||
|
|
||||
|
########################## |
||||
|
# PROVISIONING SERVICES |
||||
|
########################## |
||||
|
|
||||
|
echo "### RUNNING PROVISIONING SERVICES ###" >> ${logFile} |
||||
|
|
||||
|
# 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 |
||||
|
else |
||||
|
echo "Provisioning TESTNET - keep default" >> ${logFile} |
||||
|
fi |
||||
|
|
||||
|
# AUTO PILOT |
||||
|
if [ "${autoPilot}" = "on" ]; then |
||||
|
echo "Provisioning AUTO PILOT - run config script" >> ${logFile} |
||||
|
sudo sed -i "s/^message=.*/message='Provisioning AutoPilot'/g" ${infoFile} |
||||
|
sudo /home/admin/config.scripts/lnd.autopilot.sh on >> ${logFile} 2>&1 |
||||
|
else |
||||
|
echo "Provisioning AUTO PILOT - keep default" >> ${logFile} |
||||
|
fi |
||||
|
|
||||
|
# AUTO NAT DISCOVERY |
||||
|
if [ "${autoNatDiscovery}" = "on" ]; then |
||||
|
echo "Provisioning AUTO NAT DISCOVERY - run config script" >> ${logFile} |
||||
|
sudo sed -i "s/^message=.*/message='Provisioning AutoNAT'/g" ${infoFile} |
||||
|
sudo /home/admin/config.scripts/lnd.autonat.sh on >> ${logFile} 2>&1 |
||||
|
else |
||||
|
echo "Provisioning AUTO NAT DISCOVERY - keep default" >> ${logFile} |
||||
|
fi |
||||
|
|
||||
|
# RTL |
||||
|
if [ "${rtlWebinterface}" = "on" ]; then |
||||
|
echo "Provisioning RTL - run config script" >> ${logFile} |
||||
|
sudo sed -i "s/^message=.*/message='Provisioning RTL'/g" ${infoFile} |
||||
|
sudo /home/admin/config.scripts/bonus.rtl.sh on >> ${logFile} 2>&1 |
||||
|
else |
||||
|
echo "Provisioning RTL - keep default" >> ${logFile} |
||||
|
fi |
||||
|
|
||||
|
# TOR |
||||
|
if [ "${runBehindTor}" = "on" ]; then |
||||
|
echo "Provisioning TOR - run config script" >> ${logFile} |
||||
|
sudo sed -i "s/^message=.*/message='Provisioning TOR'/g" ${infoFile} |
||||
|
sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1 |
||||
|
else |
||||
|
echo "Provisioning TOR - keep default" >> ${logFile} |
||||
|
fi |
||||
|
|
||||
|
echo "END Provisioning" >> ${logFile} |
Loading…
Reference in new issue