mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-10-02 12:12:51 +02:00
Merge branch 'dev' into zeus
This commit is contained in:
@@ -462,7 +462,9 @@ case $CHOICE in
|
||||
sleep 10
|
||||
echo "stop ${network}d (2) - please wait .."
|
||||
sudo systemctl stop ${network}d
|
||||
echo "starting shutdown"
|
||||
sleep 3
|
||||
sync
|
||||
echo "starting shutdown ..."
|
||||
sudo shutdown now
|
||||
exit 0
|
||||
;;
|
||||
|
@@ -48,7 +48,7 @@ if [ ${existsHDD} -gt 0 ]; then
|
||||
|
||||
# init the RASPIBLITZ Config
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
configExists=$(sudo ls ${configFile} | grep -c 'raspiblitz.conf')
|
||||
configExists=$(sudo ls ${configFile} 2>/dev/null | grep -c 'raspiblitz.conf')
|
||||
if [ ${configExists} -eq 0 ]; then
|
||||
|
||||
# create file and use init values from raspiblitz.info
|
||||
|
@@ -63,7 +63,7 @@ echo "allow: lightning gRPC"
|
||||
sudo ufw allow 10009 comment 'lightning gRPC'
|
||||
echo "allow: lightning REST API"
|
||||
sudo ufw allow 8080 comment 'lightning REST API'
|
||||
echo "allow: trasmission"
|
||||
echo "allow: transmission"
|
||||
sudo ufw allow 51413 comment 'transmission'
|
||||
echo "allow: local web admin"
|
||||
sudo ufw allow from 192.168.0.0/16 to any port 80 comment 'allow local LAN web'
|
||||
@@ -81,4 +81,4 @@ sudo apt-get update
|
||||
echo "OK - System is now up to date"
|
||||
|
||||
# mark setup is done
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
|
||||
|
@@ -77,7 +77,21 @@ else
|
||||
lndconnect --host=${dynDomain}
|
||||
fi
|
||||
|
||||
echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished."
|
||||
|
||||
platform='unknown'
|
||||
unamestr=`uname`
|
||||
if [[ "$unamestr" == 'Linux' ]]; then
|
||||
platform='linux'
|
||||
elif [[ "$unamestr" == 'Darwin' ]]; then
|
||||
platform='Darwin' # mac OSX
|
||||
fi
|
||||
|
||||
if [[ $platform == 'Linux' ]]; then
|
||||
echo "(To shrink QR code: CTRL-) Press ENTER when finished."
|
||||
elif [[ $platform == 'Darwin' ]]; then
|
||||
echo "(To shrink QR code: CMD-) Press ENTER when finished."
|
||||
fi
|
||||
|
||||
read key
|
||||
|
||||
clear
|
||||
|
@@ -156,6 +156,14 @@ else
|
||||
echo "Provisioning TOR - keep default" >> ${logFile}
|
||||
fi
|
||||
|
||||
# CUSTOM LND PORT
|
||||
# if a custom LND port was set, then run config for that
|
||||
portNumber=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep "^listen=" | cut -f2 -d':')
|
||||
if [ ${#portNumber} -gt 0 ]; then
|
||||
echo "Provisioning Custom LND Port ${portNumber}- run config script" >> ${logFile}
|
||||
sudo /home/admin/config.scripts/lnd.setportsh ${portNumber} >> ${logFile} 2>&1
|
||||
fi
|
||||
|
||||
sudo sed -i "s/^message=.*/message='Setup Done'/g" ${infoFile}
|
||||
|
||||
echo "DONE - Give raspi some cool off time after hard building .... 20 secs sleep" >> ${logFile}
|
||||
|
138
home.admin/config.scripts/blitz.datadrive.sh
Normal file
138
home.admin/config.scripts/blitz.datadrive.sh
Normal file
@@ -0,0 +1,138 @@
|
||||
#!/bin/bash
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "managing additional data storage"
|
||||
echo "blitz.datadrive.sh [on|off]"
|
||||
echo "exits on 0 = needs reboot"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if sudo
|
||||
if [ "$EUID" -ne 0 ]
|
||||
then echo "Please run as root (with sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# update install sources
|
||||
echo "make sure BTRFS is installed ..."
|
||||
sudo apt-get install -y btrfs-tools
|
||||
echo ""
|
||||
|
||||
# check on/off state
|
||||
dataStorageNotAvailableYet=$(sudo btrfs filesystem df /mnt/data 2>&1 | grep -c "ERROR: not a btrfs filesystem")
|
||||
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||
echo "Trying to switch additional data storage on ..."
|
||||
if [ ${dataStorageNotAvailableYet} -eq 0 ]; then
|
||||
echo "FAIL -> data storage is already on"
|
||||
exit 1
|
||||
fi
|
||||
elif [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
||||
echo "Trying to switch additional data storage off ..."
|
||||
if [ ${dataStorageNotAvailableYet} -eq 1 ]; then
|
||||
echo "FAIL -> data storage is already off"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "FAIL -> Parameter '${$1}' not known."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
###################
|
||||
# SWITCH ON
|
||||
###################
|
||||
|
||||
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
||||
|
||||
# detect the two usb drives
|
||||
echo "Detecting two USB sticks/drives with same size ..."
|
||||
lsblk -o NAME | grep "^sd" | while read -r test1 ; do
|
||||
size1=$(lsblk -o NAME,SIZE -b | grep "^${test1}" | awk '$1=$1' | cut -d " " -f 2)
|
||||
echo "Checking : ${test1} size(${size1})"
|
||||
lsblk -o NAME | grep "^sd" | grep -v "${test1}" | while read -r test2 ; do
|
||||
size2=$(lsblk -o NAME,SIZE -b | grep "^${test2}" | awk '$1=$1' | cut -d " " -f 2)
|
||||
if [ "${size1}" = "${size2}" ]; then
|
||||
echo " MATCHING ${test2} size(${size2})"
|
||||
echo "${test1}" > .dev1.tmp
|
||||
echo "${test2}" > .dev2.tmp
|
||||
else
|
||||
echo " different ${test2} size(${size2})"
|
||||
fi
|
||||
done
|
||||
done
|
||||
dev1=$(cat .dev1.tmp)
|
||||
dev2=$(cat .dev2.tmp)
|
||||
rm -f .dev1.tmp
|
||||
rm -f .dev2.tmp
|
||||
echo "RESULTS:"
|
||||
echo "dev1(${dev1})"
|
||||
echo "dev2(${dev2})"
|
||||
echo ""
|
||||
|
||||
# check that results are available
|
||||
if [ ${#dev1} -eq 0 ] || [ ${#dev2} -eq 0 ]; then
|
||||
echo "!! FAIL -> was not able to detect two devices with the same size"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check size (at least 4GB minus some tolerance)
|
||||
size=$(lsblk -o NAME,SIZE -b | grep "^${dev1}" | awk '$1=$1' | cut -d " " -f 2)
|
||||
if [ ${size} -lt 3500000000 ]; then
|
||||
echo "!! FAIL -> too small - additional storage needs to be bigger than 4GB"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if devices are containing old data
|
||||
echo "Analysing Drives ..."
|
||||
nameDev1=$(lsblk -o NAME,LABEL | grep "^${dev1}" | awk '$1=$1' | cut -d " " -f 2)
|
||||
nameDev2=$(lsblk -o NAME,LABEL | grep "^${dev2}" | awk '$1=$1' | cut -d " " -f 2)
|
||||
if [ "${nameDev1}" = "DATASTORE" ] || [ "${nameDev2}" = "DATASTORE" ]; then
|
||||
# TODO: once implemented -> also make sure that dev1 is named "DATASTORE" and if 2nd is other -> format and add as raid
|
||||
echo "!! NOT IMPLEMENTED YET -> devices seem contain old data, because name is 'DATASTORE'"
|
||||
echo "if you dont care about that data: format devices devices on other computer with FAT(32) named TEST"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK drives dont contain old data."
|
||||
echo ""
|
||||
|
||||
# format first drive
|
||||
echo "Formatting /dev/${dev1} with BTRFS ..."
|
||||
sudo mkfs.btrfs -L DATASTORE -f /dev/${dev1}
|
||||
echo "OK"
|
||||
echo ""
|
||||
|
||||
# mount the BTRFS drive
|
||||
echo "Mounting under /mnt/data ..."
|
||||
sudo mkdir -p /mnt/data
|
||||
sudo mount /dev/${dev1} /mnt/data
|
||||
echo "OK"
|
||||
echo ""
|
||||
|
||||
# adding the second device
|
||||
echo "Adding the second device as RAID1 .."
|
||||
sudo btrfs device add -f /dev/${dev2} /mnt/data
|
||||
sudo btrfs filesystem balance start -dconvert=raid1 -mconvert=raid1 /mnt/data
|
||||
echo ""
|
||||
exit 0
|
||||
|
||||
# adding the second device
|
||||
uuid=$(sudo btrfs filesystem show /mnt/data | grep "uuid:" | awk '$1=$1' | cut -d " " -f 4)
|
||||
|
||||
fi
|
||||
|
||||
###################
|
||||
# SWITCH OFF
|
||||
###################
|
||||
|
||||
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
||||
|
||||
echo "TODO -> Turn off"
|
||||
|
||||
sudo btrfs filesystem show /mnt/data
|
||||
sudo btrfs filesystem df /mnt/data
|
||||
|
||||
sudo umount /mnt/data
|
||||
|
||||
exit 0
|
||||
|
||||
fi
|
Reference in New Issue
Block a user