mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2024-11-19 09:50:19 +01:00
60 lines
1.9 KiB
Bash
Executable File
60 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ $# -eq 0 ]; then
|
|
echo "small config script to switch the LND auto pilot on or off"
|
|
echo "lnd.autopilot.sh [on|off]"
|
|
exit 1
|
|
fi
|
|
|
|
# check lnd.conf exits
|
|
lndConfExists=$(sudo ls /mnt/hdd/lnd/lnd.conf | grep -c 'lnd.conf')
|
|
if [ ${lndConfExists} -eq 0 ]; then
|
|
echo "FAIL - /mnt/hdd/lnd/lnd.conf not found"
|
|
exit 1
|
|
fi
|
|
|
|
# stop services
|
|
echo "making sure services are not running"
|
|
sudo systemctl stop lnd 2>/dev/null
|
|
|
|
# check if "autopilot.active" exists
|
|
valueExists=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep -c 'autopilot.active=')
|
|
if [ ${valueExists} -eq 0 ]; then
|
|
echo "Adding autopilot config defaults to /mnt/hdd/lnd/lnd.conf"
|
|
sudo sed -i '$ a [autopilot]' /mnt/hdd/lnd/lnd.conf
|
|
sudo sed -i '$ a autopilot.active=0' /mnt/hdd/lnd/lnd.conf
|
|
sudo sed -i '$ a autopilot.allocation=0.6' /mnt/hdd/lnd/lnd.conf
|
|
sudo sed -i '$ a autopilot.maxchannels=5' /mnt/hdd/lnd/lnd.conf
|
|
fi
|
|
|
|
# add default value to raspi config if needed
|
|
source /home/admin/raspiblitz.info
|
|
source /mnt/hdd/raspiblitz.conf
|
|
|
|
# switch on
|
|
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
|
echo "switching the LND autopilot ON"
|
|
echo "editing /mnt/hdd/lnd/lnd.conf"
|
|
sudo sed -i "s/^autopilot.active=.*/autopilot.active=1/g" /mnt/hdd/lnd/lnd.conf
|
|
echo "editing /mnt/hdd/raspiblitz.conf"
|
|
/home/admin/config.scripts/blitz.conf.sh set autoPilot "on"
|
|
echo "OK - autopilot is now ON"
|
|
echo "needs reboot to activate new setting"
|
|
exit 0
|
|
fi
|
|
|
|
# switch off
|
|
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
|
echo "switching the LND autopilot OFF"
|
|
echo "editing /mnt/hdd/lnd/lnd.conf"
|
|
sudo sed -i "s/^autopilot.active=.*/autopilot.active=0/g" /mnt/hdd/lnd/lnd.conf
|
|
echo "editing /mnt/hdd/raspiblitz.conf"
|
|
/home/admin/config.scripts/blitz.conf.sh set autoPilot "off"
|
|
echo "OK - autopilot is now OFF"
|
|
echo "needs reboot to activate new setting"
|
|
exit 0
|
|
fi
|
|
|
|
echo "FAIL - Unknown Parameter $1"
|
|
echo "may needs reboot to run normal again"
|
|
exit 1 |