raspiblitz/home.admin/60finishHDD.sh

64 lines
1.9 KiB
Bash
Raw Normal View History

2018-07-17 13:12:03 +02:00
#!/bin/sh
echo ""
2018-07-29 01:33:54 +02:00
# load network
network=`cat .network`
2018-07-17 13:12:03 +02:00
echo "*** Checking HDD ***"
mountOK=$(df | grep -c /mnt/hdd)
if [ ${mountOK} -eq 1 ]; then
# HDD is mounted
2018-07-29 01:33:54 +02:00
if [ -d "/mnt/hdd/${network}" ]; then
2018-07-17 13:12:03 +02:00
# HDD has content - continue
echo "OK - HDD is ready."
###### LINK HDD
echo ""
2018-07-29 01:33:54 +02:00
echo "*** Prepare ${network} ***"
2018-07-29 15:54:24 +02:00
sudo killall -u bitcoin
sleep 5
2018-08-24 03:26:57 +02:00
sudo rm -r /home/bitcoin/.${network} 2>/dev/null
2018-07-29 15:54:24 +02:00
sleep 2
if [ -d /home/bitcoin/.${network} ]; then
echo "FAIL - /home/bitcoin/.${network} exists and cannot be removed!"
exit 1
fi
2018-07-29 01:33:54 +02:00
sudo cp /home/admin/assets/${network}.conf /mnt/hdd/${network}/${network}.conf
2018-09-17 12:25:15 +02:00
sudo mkdir /home/admin/.${network} 2>/dev/null
2018-07-29 15:54:24 +02:00
sudo cp /home/admin/assets/${network}.conf /home/admin/.${network}/${network}.conf
2018-07-29 01:33:54 +02:00
sudo ln -s /mnt/hdd/${network} /home/bitcoin/.${network}
2018-07-17 13:12:03 +02:00
sudo mkdir /mnt/hdd/lnd
sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd
2018-07-29 01:33:54 +02:00
sudo chown -R bitcoin:bitcoin /mnt/hdd/${network}
2018-07-17 13:12:03 +02:00
sudo ln -s /mnt/hdd/lnd /home/bitcoin/.lnd
2018-07-29 01:33:54 +02:00
sudo chown -R bitcoin:bitcoin /home/bitcoin/.${network}
2018-07-17 13:12:03 +02:00
sudo chown -R bitcoin:bitcoin /home/bitcoin/.lnd
2018-07-29 01:33:54 +02:00
echo "OK - ${network} setup ready"
2018-07-17 13:12:03 +02:00
2018-07-29 01:33:54 +02:00
###### START NETWORK SERVICE
2018-07-17 13:12:03 +02:00
echo ""
2018-07-29 01:33:54 +02:00
echo "*** Start ${network} ***"
echo "This can take a while .."
2018-07-29 12:21:52 +02:00
sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service
2018-08-07 14:03:59 +02:00
sudo chmod +x /etc/systemd/system/${network}d.service
sudo systemctl daemon-reload
2018-07-29 01:33:54 +02:00
sudo systemctl enable ${network}d.service
sudo systemctl start ${network}d.service
echo "Giving ${network}d service 180 seconds to init - please wait ..."
2018-07-17 13:12:03 +02:00
sleep 180
2018-07-29 01:33:54 +02:00
echo "OK - ${network}d started"
2018-07-17 13:12:03 +02:00
sleep 2
# set SetupState
echo "60" > /home/admin/.setup
./10setupBlitz.sh
else
# HDD is empty - download HDD content
echo "FAIL - HDD is empty."
fi
else
# HDD is not available yet
echo "FAIL - HDD is not mounted."
2018-07-29 01:33:54 +02:00
fi