diff --git a/home.admin/97addMobileWalletShango.sh b/home.admin/97addMobileWalletShango.sh index 2d85f70..14bd940 100644 --- a/home.admin/97addMobileWalletShango.sh +++ b/home.admin/97addMobileWalletShango.sh @@ -9,12 +9,19 @@ clear echo "*** Setup ***" sudo apt-get install qrencode -y -# get local IP -myip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') - -# replace dyndomain if available -if [ ${#dynDomain} -gt 0 ]; then - myip="${dynDomain}" +justLocal=1 +# if dynDomain is set connect from outside is possible (no notice) +if [ ${#dynDomain} -gt 0 ]; then + justLocal=0 +fi +# if sshtunnel to 10009/8080 then outside reach is possible (no notice) +isForwarded=$(echo ${sshtunnel} | grep -c "10009<") +if [ ${isForwarded} -gt 0 ]; then + justLocal=0 +fi +isForwarded=$(echo ${sshtunnel} | grep -c "8080<") +if [ ${isForwarded} -gt 0 ]; then + justLocal=0 fi clear @@ -28,7 +35,7 @@ echo "iOS: Read https://testflight.apple.com/join/WwCjFnS8 (open on device)" echo "Android: https://play.google.com/apps/testing/com.shango (open on device)" echo "" echo "*** STEP 1 ***" -if [ ${#dynDomain} -eq 0 ]; then +if [ ${justLocal} -eq 1 ]; then echo "Once you have the app is running make sure you are on the same local network (WLAN same as LAN)." fi echo "On Setup Step 'Choose LND Server Type' connect to 'DIY SELF HOSTED'" @@ -40,10 +47,33 @@ 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 +# default host to local IP +host=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') +# default port to 10009 +port="10009" + +# change host to dynDNS if set +if [ ${#dynDomain} -gt 0 ]; then + host="${dynDomain}" + echo "port 10009 forwarding from dynDomain ${host}" +fi + +# check if port 10009 is forwarded +if [ ${#sshtunnel} -gt 0 ]; then + isForwarded=$(echo ${sshtunnel} | grep -c "10009<") + if [ ${isForwarded} -gt 0 ]; then + host=$(echo $sshtunnel | cut -d '@' -f2 | cut -d ' ' -f1) + port=$(echo $sshtunnel | awk '{split($0,a,"10009<"); print a[2]}' | sed 's/[^0-9]//g') + echo "port 10009 forwarding from port ${port} from server ${host}" + else + echo "port 10009 is not part of the ssh forwarding - keep default port 10009" + fi +fi + clear echo "*** STEP 2 : SCAN MACAROON (make whole QR code fill camera) ***" #echo -e "${myip}:10009,\n$(xxd -p -c2000 ~/.lnd/data/chain/${network}/${chain}net/admin.macaroon)," > qr.txt && qrencode -t ANSIUTF8 < qr.txt -echo -e "${myip}:10009,\n$(xxd -p -c2000 ./.lnd/data/chain/${network}/${chain}net/admin.macaroon)," > qr.txt && qrencode -t ANSI256 < qr.txt +echo -e "${host}:${port},\n$(xxd -p -c2000 ./.lnd/data/chain/${network}/${chain}net/admin.macaroon)," > qr.txt && qrencode -t ANSI256 < qr.txt echo "(To shrink QR code: OSX->CMD- / LINUX-> CTRL-) Press ENTER when finished." read key shred qr.txt