Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Name Updates #3

Open
JarrydVanHoy opened this issue Dec 27, 2022 · 0 comments
Open

Image Name Updates #3

JarrydVanHoy opened this issue Dec 27, 2022 · 0 comments

Comments

@JarrydVanHoy
Copy link

JarrydVanHoy commented Dec 27, 2022

Hi, I'm new to UmbrelOS so I apologize ahead of time if I installed something wrong which caused my issues, but to get your umbrel-details to work for me, I had to update 3 things:

  1. Renaming the bitcoin image name for the docker commands to bitcoin_bitcoind_1.
  2. Renaming the lnd image name for the docker commands to lightning_lnd_1.
  3. Updated how I parsed the bitcoin version with the following:
    # get bitcoin info
    networkVersion=`docker exec bitcoin_bitcoind_1 bitcoin-cli -version | head -n 1 | awk -F" " '{print $NF}' 2>/dev/null`
    

I also fixed some other things and cleaned up some things. Take the adjustments if you want:

#!/bin/bash

# set colors
color_red='\033[0;31m'
color_green='\033[0;32m'
color_amber='\033[0;33m'
color_yellow='\033[1;93m'
color_blue='\033[0;94m'
color_gray='\033[0;37m'

# get memory
ram_avail=$(free -m | grep Mem | awk '{ print $7 }')
ram=$(printf "%sM / %sM" "${ram_avail}" "$(free -m | grep Mem | awk '{ print $2 }')")

if [ ${ram_avail} -lt 50 ]; then
  color_ram="${color_red}\e[7m"
else
  color_ram=${color_green}
fi

# get hdd
hdd="/dev/sda1"
hdd_used_space=$(df -h | grep ${hdd} | sed -e's/  */ /g' | cut -d" " -f 3  2>/dev/null)
hdd_used_ratio=$(df -h | grep ${hdd} | sed -e's/  */ /g' | cut -d" " -f 5 | tr -dc '0-9' 2>/dev/null)
hddUsedInfo="${hdd_used_space} (${hdd_used_ratio}%)"

# get bitcoin info
networkVersion=`docker exec bitcoin_bitcoind_1 bitcoin-cli -version | head -n 1 | awk -F" " '{print $NF}' 2>/dev/null`
networkInfo=$(docker exec bitcoin_bitcoind_1 bitcoin-cli getnetworkinfo 2>/dev/null)
networkConnections=$(echo ${networkInfo} | jq -r '.connections')
networkConnectionsInfo="Connections: ${color_green}${networkConnections}"
btc_price_response=$(curl -X 'GET' 'https://api.kraken.com/0/public/Ticker?pair=XBTUSD' -H 'accept: application/json' 2>/dev/null)
btc_price=$(echo ${btc_price_response} | jq -r '.result.XXBTZUSD.a[0]')

blockInfo="-"
blockchaininfo=$(docker exec bitcoin_bitcoind_1 bitcoin-cli getblockchaininfo 2>/dev/null)
block_chain=$(docker exec bitcoin_bitcoind_1 bitcoin-cli getblockcount 2>/dev/null)
block_verified="$(echo ${blockchaininfo} | jq -r '.blocks')"
block_diff=$(expr ${block_chain::-1} - ${block_verified::-1})
blockInfo="${block_verified}/${block_chain}"

progress="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
sync_percentage=$(echo $progress | awk '{printf( "%.2f%%", 100 * $1)}')

if [ ${block_diff} -eq 0 ]; then    # fully synced
  sync_color="${color_green}"
elif [ ${block_diff} -le 10 ]; then   # <= 2 blocks behind
  sync_color="${color_yellow}"
else
  sync_color="${color_red}"
fi

# get LDN info
ln_getInfo=$(docker exec lightning_lnd_1 lncli getinfo 2>/dev/null)
ln_version=$(echo "${ln_getInfo}" | jq -r '.version' | cut -d' ' -f1)
ln_sync=$(echo "${ln_getInfo}" | grep "synced_to_chain" | grep "true" -c)
ln_alias="$(echo "${ln_getInfo}" | jq -r '.alias')" 2>/dev/null

if [ ${ln_sync} -eq 0 ]; then
  if [ ${#ln_getInfo} -eq 0 ]; then
    ln_baseInfo="${color_red} Not Started | Not Ready Yet"
  else
    ln_baseInfo="${color_amber} Waiting for Chain Sync"
  fi
else
  ln_walletbalance="$(docker exec lightning_lnd_1 lncli walletbalance | jq -r '.total_balance')" 2>/dev/null
  ln_channelbalance="$(docker exec lightning_lnd_1 lncli channelbalance | jq -r '.balance')" 2>/dev/null
  ln_channels_online="$(echo "${ln_getInfo}" | jq -r '.num_active_channels')" 2>/dev/null
  ln_channels_total="$(docker exec lightning_lnd_1 lncli listchannels | jq '.[] | length')" 2>/dev/null
  ln_channels_color="${color_green}"
  if [ "${ln_channels_online}" != "${ln_channels_total}" ]; then ln_channels_color="${color_yellow}"; fi
  ln_peers="$(echo "${ln_getInfo}" | jq -r '.num_peers')" 2>/dev/null
  ln_channelInfo="${color_gray}Channels: ${ln_channels_color}${ln_channels_online}/${ln_channels_total}"
  ln_baseInfo="${color_gray}Wallet: ${ln_walletbalance}, LND: ${ln_channelbalance}"
  ln_peersInfo="${color_gray}Peers: ${color_green}${ln_peers}"
  ln_dailyfees="$(docker exec lightning_lnd_1 lncli feereport | jq -r '.day_fee_sum')" 2>/dev/null
  ln_weeklyfees="$(docker exec lightning_lnd_1 lncli feereport | jq -r '.week_fee_sum')" 2>/dev/null
  ln_monthlyfees="$(docker exec lightning_lnd_1 lncli feereport | jq -r '.month_fee_sum')" 2>/dev/null
  ln_feeReport="Fees: ${color_green}${ln_dailyfees}D-${ln_weeklyfees}W-${ln_monthlyfees}M"
fi

# some base values
uptime=$(uptime --pretty)
datetime=`date -R | rev | cut -c 7- | rev`
load=$(w | head -n 1 | cut -d 'v' -f2 | cut -d ':' -f2)
node_alias=`hostname`
local_ip=`hostname -I | cut -d " " -f1`
chain="main"
codeVersion=`cat /etc/default/umbrel | cut -d "=" -f2`
tempC=`vcgencmd measure_temp | cut -d "=" -f2 | rev | cut -c 3- | rev`

# print screen
clear
printf "
${color_blue}
${color_blue}                   ${color_blue}Umbrel ${codeVersion} ${color_green} ${node_alias}.local
${color_blue}                   ${color_gray}Bitcoin Fullnode + Lightning Network
${color_blue}                   ${color_blue}------------------------------------
${color_blue}                   ${color_gray}Refreshed: ${datetime}
${color_blue}    .--------.     ${color_gray}CPU: ${load##up*,  }, Temp: ${tempC}°C
${color_blue}  .=:        :=.   ${color_gray}RAM: ${color_ram}${ram} ${color_gray}HDD: ${color_green}%s
${color_blue} .=:.   ..   .:=.  ${color_gray}SSH umbrel@${color_green}${local_ip}${color_gray}
${color_blue} --::---::---::--  ${color_gray}Bitcoin ${color_green}${networkVersion}, 
${color_blue}      =:   =.      ${color_gray}${networkConnectionsInfo}
${color_blue}      =:  .=.      ${color_gray}Blocks: ${sync_color}${blockInfo} (%s)
${color_blue}      =:  .=.      ${color_gray}LND ${color_green}${ln_version} ${color_blue}${ln_alias}
${color_blue}                   ${color_gray}${ln_baseInfo}
${color_blue}                   ${color_gray}${ln_channelInfo}, ${ln_peersInfo}
${color_blue}                   ${color_gray}${ln_feeReport}
${color_blue}                   
${color_blue}                   ${color_gray}BTC Price: \$${btc_price}
$lastLine
" \
"${hddUsdedInfo}" "${sync_percentage}"

Edit: further editted the styling as my LND balances would bleed over to the next line

Edit 2: img added
Xnip2023-01-06_08-48-38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant