mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-28 04:26:28 +02:00
add switchNet
This commit is contained in:
@@ -66,7 +66,8 @@ else
|
||||
CONNECT "Connect to a Peer" \
|
||||
lnbalance "Detailed Wallet Balances" \
|
||||
lnchannels "Lightning Channel List" \
|
||||
RECKLES "Console / Terminal")
|
||||
RECKLES "Console / Terminal"\
|
||||
REKT "Go Reckless! Switch Testnet/Mainnet")
|
||||
|
||||
fi
|
||||
|
||||
@@ -132,6 +133,9 @@ case $CHOICE in
|
||||
RECKLES)
|
||||
lncli -h
|
||||
echo "SUCH WOW come back with ./00mainMenu.sh"
|
||||
;;
|
||||
REKT) # switch configs
|
||||
sudo ./95switchNetEnv.sh;
|
||||
;;
|
||||
X) # unlock
|
||||
./AAunlockLND.sh
|
||||
|
52
home.admin/95switchNetEnv.sh
Executable file
52
home.admin/95switchNetEnv.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
BITCOIN_CONFIG="/home/bitcoin/.bitcoin/bitcoin.conf"
|
||||
LND_CONFIG="/home/bitcoin/.lnd/lnd.conf"
|
||||
# function to detect main/testnet
|
||||
|
||||
function isMainnet(){
|
||||
grep "^#testnet=1$" -q $BITCOIN_CONFIG && return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
function switchToMainnet {
|
||||
echo "switching to mainnet"
|
||||
sed -i 's/^testnet=1/#testnet=1/g' $BITCOIN_CONFIG && \
|
||||
sed -i 's/^bitcoin.testnet=1/#bitcoin.testnet=1/g' $LND_CONFIG && \
|
||||
sed -i 's/^#bitcoin.mainnet=1/bitcoin.mainnet=1/g' $LND_CONFIG
|
||||
echo "switched to mainnet"
|
||||
}
|
||||
|
||||
function switchToTestnet {
|
||||
echo "switching to testnet"
|
||||
sed -i 's/^#testnet=1/testnet=1/g' $BITCOIN_CONFIG && \
|
||||
sed -i 's/^#bitcoin.testnet=1/bitcoin.testnet=1/g' $LND_CONFIG && \
|
||||
sed -i 's/^bitcoin.mainnet=1/#bitcoin.mainnet=1/g' $LND_CONFIG
|
||||
echo "switched to testnet"
|
||||
}
|
||||
|
||||
# change to test: check both configs for commented out testnet arguments and mainnet
|
||||
echo "stopping lnd client"
|
||||
systemctl stop lnd
|
||||
sleep 4
|
||||
echo "stopping bitcoind client"
|
||||
systemctl stop bitcoind
|
||||
sleep 4
|
||||
isMainnet
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "switching from mainnet to testnet"
|
||||
switchToTestnet
|
||||
else
|
||||
echo "switching from testnet to mainnet"
|
||||
switchToMainnet
|
||||
fi
|
||||
echo "copying over config to bitcoin user"
|
||||
cp $BITCOIN_CONFIG /home/admin/.bitcoin/
|
||||
systemctl start bitcoind
|
||||
echo "started bitcoind back up, giving it a minute to come up"
|
||||
sleep 60
|
||||
systemctl start lnd
|
||||
echo "started lnd back up, giving it a minute, you will have to unlock your wallet"
|
||||
sleep 60
|
||||
echo "finished config switch - started back up"
|
||||
echo "you will still have to unlock your LND wallet"
|
||||
./00mainMenu.sh
|
Reference in New Issue
Block a user