Reduce use of "sudo" (#4522)

This commit is contained in:
/rootzoll 2024-06-19 23:02:41 +02:00 committed by GitHub
parent e4c51fe22e
commit 22a95cae08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 12 deletions

View file

@ -358,7 +358,7 @@ else
fileFlagExists=$(sudo ls /mnt/hdd/app-storage/electrs/initial-sync.done 2>/dev/null | grep -c 'initial-sync.done')
if [ "${ElectRS}" == "on" ] && [ $fileFlagExists -eq 0 ]; then
error=""
source <(sudo /home/admin/config.scripts/bonus.electrs.sh status-sync 2>/dev/null)
source <(/home/admin/config.scripts/bonus.electrs.sh status-sync 2>/dev/null)
if [ ${#infoSync} -gt 0 ]; then
appInfoLine="Electrum: ${infoSync}"
fi
@ -368,7 +368,7 @@ else
fileFlagExists=$(sudo ls /mnt/hdd/app-storage/fulcrum/initial-sync.done 2>/dev/null | grep -c 'initial-sync.done')
if [ "${fulcrum}" == "on" ] && [ $fileFlagExists -eq 0 ]; then
error=""
source <(sudo /home/admin/config.scripts/bonus.fulcrum.sh status-sync 2>/dev/null)
source <(/home/admin/config.scripts/bonus.fulcrum.sh status-sync 2>/dev/null)
if [ ${#infoSync} -gt 0 ]; then
appInfoLine="Fulcrum: ${infoSync}"
fi

View file

@ -66,7 +66,7 @@ RaspiBlitz image to your SD card.
}
# get status of txindex
source <(/home/admin/config.scripts/network.txindex.sh status)
source <(sudo /home/admin/config.scripts/network.txindex.sh status)
OPTIONS=()
#OPTIONS+=(HARDWARE "Run Hardwaretest")

View file

@ -717,6 +717,7 @@ do
if [ ${recheckRAID} -eq 1 ]; then
# check if BTRTFS raid is active & scrub
logger -p info "background.sh - RAID data check"
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
if [ "${isBTRFS}" == "1" ] && [ "${isRaid}" == "1" ]; then
echo "STARTING BTRFS RAID DATA CHECK ..."

View file

@ -148,13 +148,12 @@ if [ "$2" = "info" ]; then
if [ "$1" == "signet" ]; then
subfolder="signet/"
fi
btc_blocks_data_kb=$(sudo du -s /mnt/hdd/bitcoin/${subfolder}blocks 2>/dev/null | cut -f1)
btc_blocks_data_kb=$(du -s /mnt/hdd/bitcoin/${subfolder}blocks | cut -f1)
if [ "${btc_blocks_data_kb}" == "" ]; then
btc_blocks_data_kb="0"
fi
# print data
# parse data
btc_blocks_headers=$(echo "${blockchaininfo}" | jq -r '.headers')
btc_blocks_verified=$(echo "${blockchaininfo}" | jq -r '.blocks')
@ -257,7 +256,7 @@ if [ "$2" = "peer-kickstart" ]; then
if [ "$(cat /mnt/hdd/raspiblitz.conf | grep -c "^runBehindTor=on")" != "0" ]; then
addressFormat="tor"
else
source <(sudo /home/admin/config.scripts/internet.sh status global)
source <(/home/admin/config.scripts/internet.sh status global)
if [ "${ipv6}" == "off" ]; then
addressFormat="ipv4"
else

View file

@ -218,7 +218,7 @@ if [ "$1" = "status" ]; then
fi
# try to detect if its an SSD
isSMART=$(sudo smartctl -a /dev/${hdd} | grep -c "Serial Number:")
isSMART=$(smartctl -a /dev/${hdd} | grep -c "Serial Number:")
echo "isSMART=${isSMART}"
isSSD=1
isRotational=$(echo "${smartCtlA}" | grep -c "Rotation Rate:")
@ -458,7 +458,7 @@ if [ "$1" = "status" ]; then
fi
echo "hddRaspiVersion='${hddRaspiVersion}'"
smartCtlA=$(sudo smartctl -a /dev/${hdd} | tr -d '"')
smartCtlA=$(smartctl -a /dev/${hdd} | tr -d '"')
# try to detect if its an SSD
isSMART=$(echo "${smartCtlA}" | grep -c "Serial Number:")

View file

@ -30,7 +30,14 @@ if [ "$1" = "status" ]; then
echo "##### STATUS TXINDEX"
indexByteSize=$(sudo du -s /mnt/hdd/bitcoin/indexes/txindex 2>/dev/null | cut -f1)
# check user is root
if [ "$EUID" -ne 0 ]; then
logger "FAIL: network.txindex.sh status needs sudo"
echo "error='missing sudo'"
exit 1
fi
indexByteSize=$(du -s /mnt/hdd/bitcoin/indexes/txindex 2>/dev/null | cut -f1)
if [ "${indexByteSize}" == "" ]; then
indexByteSize=0
fi
@ -44,8 +51,8 @@ if [ "$1" = "status" ]; then
# try to gather if still indexing
source <(/home/admin/_cache.sh get btc_mainnet_blocks_headers)
blockchainHeight="${btc_mainnet_blocks_headers}"
indexedToBlock=$(sudo tail -n 200 /mnt/hdd/${network}${pathAdd}/debug.log | grep "Syncing txindex with block chain from height" | tail -n 1 | cut -d " " -f 9 | sed 's/[^0-9]*//g')
indexFinished=$(sudo tail -n 200 /mnt/hdd/${network}${pathAdd}/debug.log | grep -c "txindex is enabled at height")
indexedToBlock=$(tail -n 200 /mnt/hdd/${network}${pathAdd}/debug.log | grep "Syncing txindex with block chain from height" | tail -n 1 | cut -d " " -f 9 | sed 's/[^0-9]*//g')
indexFinished=$(tail -n 200 /mnt/hdd/${network}${pathAdd}/debug.log | grep -c "txindex is enabled at height")
if [ ${#indexedToBlock} -eq 0 ] || [ ${indexFinished} -gt 0 ] || [ "${indexedToBlock}" = "${blockchainHeight}" ]; then
echo "isIndexed=1"