sudo needed to check for existing blockchain data

This commit is contained in:
openoms
2019-02-03 09:39:42 +00:00
parent 22b4b4f681
commit 8b04e0f7e0
7 changed files with 536 additions and 9 deletions

View File

@@ -100,6 +100,9 @@ if [ "${state}" = "ready" ]; then
fi
## default menu settings
# to fit the main menu without scrolling:
# HEIGHT=23
# CHOICE_HEIGHT=20
HEIGHT=13
WIDTH=64
CHOICE_HEIGHT=6

View File

@@ -120,7 +120,8 @@ mountOK=$( sudo cat /etc/fstab | grep -c '/mnt/hdd' )
if [ ${mountOK} -eq 1 ]; then
# are there any signs of blockchain data and activity
blockchainDataExists=$(ls /mnt/hdd/${network}/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
# setup running with admin user, but has no permission to read /mnt/hdd/bitcoin/blocks/, sudo needed
blockchainDataExists=$(sudo ls /mnt/hdd/${network}/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
configExists=$(sudo ls /mnt/hdd/${network}/${network}.conf | grep -c '.conf')
if [ ${blockchainDataExists} -eq 1 ]; then
@@ -164,7 +165,7 @@ if [ ${mountOK} -eq 1 ]; then
T "TORRENT --> MAINNET + TESTNET thru Torrent (DEFAULT)" \
D "DOWNLOAD --> MAINNET + TESTNET per FTP (FALLBACK)" \
C "COPY --> BLOCKCHAINDATA from another node with SCP" \
A "ADAPTER --> BLOCKCHAINDATA from 2nD HDD with a powered adapter cable"\
A "ADAPTER --> BLOCKCHAINDATA from 2nd HDD via powered adapter cable"\
S "SYNC --> MAINNET thru Bitcoin Network (ULTRA SLOW)" 2>&1 >/dev/tty)
# Litecoin

View File

@@ -222,8 +222,9 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
# check if HDD contains pre-loaded blockchain data
echo "Check if HDD contains pre-loaded blockchain data .." >> $logFile
litecoinDataExists=$(ls /mnt/hdd/litecoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
bitcoinDataExists=$(ls /mnt/hdd/bitcoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
# setup running with admin user, but has no permission to read /mnt/hdd/bitcoin/blocks/, sudo needed
litecoinDataExists=$(sudo ls /mnt/hdd/litecoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
bitcoinDataExists=$(sudo ls /mnt/hdd/bitcoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
# check if node can go into presync (only for bitcoin)
if [ ${bitcoinDataExists} -eq 1 ]; then
@@ -246,7 +247,7 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
sudo -u bitcoin /usr/local/bin/bitcoind -daemon -conf=/home/admin/assets/bitcoin.conf -pid=/mnt/hdd/bitcoin/bitcoind.pid 2>> $logFile
echo "OK Started bitcoind for presync" >> $logFile
sudo sed -i "s/^message=.*/message='running presync'/g" ${infoFile}
# after admin login, presync will be stoped and HDD unmounted
# after admin login, presync will be stopped and HDD unmounted
exit 0
else