committed by
GitHub
24 changed files with 562 additions and 193 deletions
@ -0,0 +1,87 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# load raspiblitz config data |
||||
|
source /home/admin/raspiblitz.info |
||||
|
source /mnt/hdd/raspiblitz.conf |
||||
|
|
||||
|
# export go vars (if needed) |
||||
|
if [ ${#GOROOT} -eq 0 ]; then |
||||
|
export GOROOT=/usr/local/go |
||||
|
export PATH=$PATH:$GOROOT/bin |
||||
|
fi |
||||
|
if [ ${#GOPATH} -eq 0 ]; then |
||||
|
export GOPATH=/usr/local/gocode |
||||
|
export PATH=$PATH:$GOPATH/bin |
||||
|
fi |
||||
|
|
||||
|
# make sure go is installed |
||||
|
goInstalled=$(go version 2>/dev/null | grep -c 'go') |
||||
|
if [ ${goInstalled} -eq 0 ];then |
||||
|
echo "### Installing GO ###" |
||||
|
wget https://storage.googleapis.com/golang/go1.11.linux-armv6l.tar.gz |
||||
|
sudo tar -C /usr/local -xzf go1.11.linux-armv6l.tar.gz |
||||
|
sudo rm *.gz |
||||
|
sudo mkdir /usr/local/gocode |
||||
|
sudo chmod 777 /usr/local/gocode |
||||
|
goInstalled=$(go version 2>/dev/null | grep -c 'go') |
||||
|
fi |
||||
|
if [ ${goInstalled} -eq 0 ];then |
||||
|
echo "FAIL: Was not able to install GO (needed to run LndConnect)" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# make sure qrcode-encoder in installed |
||||
|
clear |
||||
|
echo "*** Setup ***" |
||||
|
echo "" |
||||
|
echo "Installing lndconnect. Please wait..." |
||||
|
echo "" |
||||
|
echo "Getting github.com/LN-Zap/lndconnect (please wait) ..." |
||||
|
go get -d github.com/LN-Zap/lndconnect |
||||
|
cd $GOPATH/src/github.com/LN-Zap/lndconnect |
||||
|
echo "" |
||||
|
echo "Building github.com/LN-Zap/lndconnect ..." |
||||
|
make |
||||
|
cd |
||||
|
sleep 3 |
||||
|
|
||||
|
clear |
||||
|
echo "******************************" |
||||
|
echo "Connect Zeus Mobile Wallet" |
||||
|
echo "******************************" |
||||
|
echo "" |
||||
|
echo "GETTING THE APP" |
||||
|
echo "At the moment this app is in alpha stages." |
||||
|
echo "You can compile the code for iOS or Android but only an Android APK is currently available for downloads." |
||||
|
echo "Go to https://github.com/ZeusLN/zeus/releases to find the latest release." |
||||
|
echo "" |
||||
|
echo "*** STEP 1 ***" |
||||
|
if [ ${#dynDomain} -eq 0 ]; then |
||||
|
echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)." |
||||
|
fi |
||||
|
echo "During setup of the Zeus app you should get to the 'Settings' screen." |
||||
|
echo "" |
||||
|
echo "---> Click on the Scan lndconnect config button" |
||||
|
echo "Make the this terminal as big as possible - fullscreen would be best." |
||||
|
echo "Then PRESS ENTER here in the terminal to generare the QR code and scan it with the app." |
||||
|
read key |
||||
|
|
||||
|
clear |
||||
|
echo "*** STEP 2 : Click on Scan (make whole QR code fill camera) ***" |
||||
|
|
||||
|
if [ ${#dynDomain} -eq 0 ]; then |
||||
|
# If you drop the -i parameter, lndconnect will use the external IP. |
||||
|
lndconnect -i --port=8080 |
||||
|
else |
||||
|
# when dynamic domain is set |
||||
|
lndconnect --host=${dynDomain} --port=8080 |
||||
|
fi |
||||
|
|
||||
|
echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished." |
||||
|
read key |
||||
|
|
||||
|
clear |
||||
|
echo "If it's not working - check issues on GitHub:" |
||||
|
echo "https://github.com/ZeusLN/zeus" |
||||
|
echo "https://github.com/LN-Zap/lndconnect/issues" |
||||
|
echo "" |
@ -0,0 +1,4 @@ |
|||||
|
# Installs package if not yet installed |
||||
|
if [ $(sudo dpkg-query -l | grep "ii $1" | wc -l) = 0 ]; then |
||||
|
sudo apt-get install $1 -y > /dev/null |
||||
|
fi |
@ -0,0 +1,37 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# Check if lnd is synced to chain and channels are open |
||||
|
# If it isn't, wait until it is |
||||
|
# exits with 1 if it isn't. |
||||
|
|
||||
|
network=$1 |
||||
|
chain=$2 |
||||
|
|
||||
|
# check if chain is in sync |
||||
|
cmdChainInSync="lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c" |
||||
|
chainInSync=${cmdChainInSync} |
||||
|
while [ $chainInSync -eq 0 ]; do |
||||
|
dialog --title "Fail: not in sync" \ |
||||
|
--ok-label "Try now" \ |
||||
|
--cancel-label "Give up" \ |
||||
|
--pause "\n\n'lncli getinfo' shows 'synced_to_chain': false\n\nTry again in a few seconds." 15 60 5 |
||||
|
|
||||
|
if [ $? -gt 0 ]; then |
||||
|
exit 1 |
||||
|
fi |
||||
|
chainInSync=${cmdChainInSync} |
||||
|
done |
||||
|
|
||||
|
# check number of connected peers |
||||
|
echo "check for open channels" |
||||
|
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | grep chan_id -c) |
||||
|
if [ ${openChannels} -eq 0 ]; then |
||||
|
echo "" |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first." |
||||
|
echo "!!!!!!!!!!!!!!!!!!!" |
||||
|
echo "" |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
exit 0 |
@ -0,0 +1,8 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# Display an image on the LCD |
||||
|
|
||||
|
# make sure fbi is installed |
||||
|
./XXaptInstall.sh fbi |
||||
|
|
||||
|
sudo fbi -a -T 1 -d /dev/fb1 --noverbose $1 2> /dev/null |
@ -0,0 +1,24 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# Display a QR code for the string in qr.txt |
||||
|
|
||||
|
# make sure qrcode-encode and fbi are installed |
||||
|
#clear |
||||
|
#echo "*** Setup ***" |
||||
|
|
||||
|
echo 50 | whiptail --title "Installing" --backtitle "QR-Code" --gauge "please wait" 4 40 100 |
||||
|
./XXaptInstall.sh qrencode |
||||
|
echo 90 | whiptail --title "Installing" --backtitle "QR-Code" --gauge "please wait" 4 40 100 |
||||
|
./XXaptInstall.sh fbi |
||||
|
|
||||
|
whiptail --title "Get ready" --backtitle "QR-Code in Terminal Window" \ |
||||
|
--msgbox "Make this terminal window as large as possible - fullscreen would be best. \n\nThe QR-Code might be too large for your display. In that case, shrink the letters by pressing the keys Ctrl and Minus (or Cmd and Minus if you are on a Mac) \n\nPRESS ENTER when you are ready to see the QR-code." 20 60 |
||||
|
|
||||
|
clear |
||||
|
qrencode -t ANSI256 < /home/admin/qr.txt |
||||
|
shred /home/admin/qr.txt |
||||
|
rm -f /home/admin/qr.txt |
||||
|
echo "(To shrink QR code: macOS press CMD- / LINUX press CTRL-) Press ENTER when finished." |
||||
|
read key |
||||
|
|
||||
|
clear |
@ -0,0 +1,10 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# Display a QR code for the string in qr.txt |
||||
|
|
||||
|
# make sure qrcode-encode and fbi are installed |
||||
|
./XXaptInstall.sh qrencode |
||||
|
./XXaptInstall.sh fbi |
||||
|
|
||||
|
qrencode -l L -o /home/admin/qr.png < /home/admin/qr.txt > /dev/null |
||||
|
sudo fbi -a -T 1 -d /dev/fb1 --noverbose /home/admin/qr.png 2> /dev/null |
@ -0,0 +1,4 @@ |
|||||
|
#!/bin/bash |
||||
|
sudo killall -3 fbi |
||||
|
shred /home/admin/qr.png 2> /dev/null |
||||
|
rm -f /home/admin/qr.png 2> /dev/null |
After Width: | Height: | Size: 47 KiB |
@ -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 |
Loading…
Reference in new issue