Fix electrs data dir user at update, update electrs to v0.10.4 (#4480)

* Fix electrs data dir user at update
* check and create, fix persmissions of storage dir when on
the data disk is not always available yet when the install option is running
* apply formatting
* fix storage dir before code install check
* electrs update v0.10.4
* update in changes
---------
Co-authored-by: openoms <oms@tuta.io>
This commit is contained in:
Stephan Oeste 2024-03-17 08:52:22 +01:00 committed by GitHub
parent 7426a3a287
commit 9e64abc9d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 61 additions and 53 deletions

View file

@ -10,7 +10,7 @@
- Update: LND v0.17.3-beta [details](https://github.com/lightningnetwork/lnd/releases/tag/v0.17.3-beta) - Update: LND v0.17.3-beta [details](https://github.com/lightningnetwork/lnd/releases/tag/v0.17.3-beta)
- Update: Core Lightning v23.11.2 [details](https://github.com/ElementsProject/lightning/releases/tag/v23.11.2) - Update: Core Lightning v23.11.2 [details](https://github.com/ElementsProject/lightning/releases/tag/v23.11.2)
- Update: C-lightningREST v0.10.7 [details](https://github.com/Ride-The-Lightning/c-lightning-REST/releases/tag/v0.10.7) - Update: C-lightningREST v0.10.7 [details](https://github.com/Ride-The-Lightning/c-lightning-REST/releases/tag/v0.10.7)
- Update: Electrum Server in Rust (electrs) v0.10.2 [details](https://github.com/romanz/electrs/blob/master/RELEASE-NOTES.md#0102-dec-31-2023) - Update: Electrum Server in Rust (electrs) v0.10.4 [details](https://github.com/romanz/electrs/blob/master/RELEASE-NOTES.md#0104-mar-15-2024)
- Update: Fulcrum Electrum server v1.10.0 (CLI install script) [details](https://github.com/cculianu/Fulcrum/releases/tag/v1.10.0) - Update: Fulcrum Electrum server v1.10.0 (CLI install script) [details](https://github.com/cculianu/Fulcrum/releases/tag/v1.10.0)
- Update: BTC-RPC-Explorer v3.4.0 [details](https://github.com/janoside/btc-rpc-explorer/blob/master/CHANGELOG.md#v340) - Update: BTC-RPC-Explorer v3.4.0 [details](https://github.com/janoside/btc-rpc-explorer/blob/master/CHANGELOG.md#v340)
- Update: JoinMarket v0.9.11 [details](https://github.com/JoinMarket-Org/joinmarket-clientserver/releases/tag/v0.9.11) - Update: JoinMarket v0.9.11 [details](https://github.com/JoinMarket-Org/joinmarket-clientserver/releases/tag/v0.9.11)

View file

@ -1,17 +1,17 @@
#!/bin/bash #!/bin/bash
# https://github.com/romanz/electrs/releases # https://github.com/romanz/electrs/releases
ELECTRSVERSION="v0.10.2" ELECTRSVERSION="v0.10.4"
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to switch the Electrum Rust Server on or off" echo "config script to switch the Electrum Rust Server on or off"
echo "bonus.electrs.sh status -> dont call in loops" echo "bonus.electrs.sh status -> dont call in loops"
echo "bonus.electrs.sh status-sync" echo "bonus.electrs.sh status-sync"
echo "bonus.electrs.sh [on|off|menu|update]" echo "bonus.electrs.sh [on|off|menu|update]"
echo "bonus.electrs.sh [install|uninstall]" echo "bonus.electrs.sh [install|uninstall]"
echo "installs the version $ELECTRSVERSION" echo "installs the version $ELECTRSVERSION"
exit 1 exit 1
fi fi
PGPsigner="romanz" PGPsigner="romanz"
@ -55,7 +55,10 @@ if [ "$1" = "status" ]; then
localPortRunning=$(sudo netstat -an | grep -c '0.0.0.0:50001') localPortRunning=$(sudo netstat -an | grep -c '0.0.0.0:50001')
echo "localTCPPortActive=${localPortRunning}" echo "localTCPPortActive=${localPortRunning}"
publicPortRunning=$(nc -z -w6 ${publicip} 50001 2>/dev/null; echo $?) publicPortRunning=$(
nc -z -w6 ${publicip} 50001 2>/dev/null
echo $?
)
if [ "${publicPortRunning}" == "0" ]; then if [ "${publicPortRunning}" == "0" ]; then
# OK looks good - but just means that something is answering on that port # OK looks good - but just means that something is answering on that port
echo "publicTCPPortAnswering=1" echo "publicTCPPortAnswering=1"
@ -66,7 +69,10 @@ if [ "$1" = "status" ]; then
echo "portSSL='50002'" echo "portSSL='50002'"
localPortRunning=$(sudo netstat -an | grep -c '0.0.0.0:50002') localPortRunning=$(sudo netstat -an | grep -c '0.0.0.0:50002')
echo "localHTTPPortActive=${localPortRunning}" echo "localHTTPPortActive=${localPortRunning}"
publicPortRunning=$(nc -z -w6 ${publicip} 50002 2>/dev/null; echo $?) publicPortRunning=$(
nc -z -w6 ${publicip} 50002 2>/dev/null
echo $?
)
if [ "${publicPortRunning}" == "0" ]; then if [ "${publicPortRunning}" == "0" ]; then
# OK looks good - but just means that something is answering on that port # OK looks good - but just means that something is answering on that port
echo "publicHTTPPortAnswering=1" echo "publicHTTPPortAnswering=1"
@ -177,7 +183,7 @@ This can take multiple hours.
fi fi
if [ ${nginxTest} -eq 0 ]; then if [ ${nginxTest} -eq 0 ]; then
dialog --title "Testing nginx.conf has failed" --msgbox " dialog --title "Testing nginx.conf has failed" --msgbox "
Nginx is in a failed state. Will attempt to fix. Nginx is in a failed state. Will attempt to fix.
Try connecting via port 50002 or Tor again once finished. Try connecting via port 50002 or Tor again once finished.
Check 'sudo nginx -t' for a detailed error message. Check 'sudo nginx -t' for a detailed error message.
@ -194,17 +200,17 @@ Check 'sudo nginx -t' for a detailed error message.
fi fi
# Options (available without TOR) # Options (available without TOR)
OPTIONS=( \ OPTIONS=(
CONNECT "How to Connect" \ CONNECT "How to Connect"
REINDEX "Delete&Rebuild Index" \ REINDEX "Delete&Rebuild Index"
STATUS "ElectRS Status Info" STATUS "ElectRS Status Info"
) )
CHOICE=$(whiptail --clear --title "Electrum Rust Server" --menu "menu" 10 50 4 "${OPTIONS[@]}" 2>&1 >/dev/tty) CHOICE=$(whiptail --clear --title "Electrum Rust Server" --menu "menu" 10 50 4 "${OPTIONS[@]}" 2>&1 >/dev/tty)
clear clear
case $CHOICE in case $CHOICE in
CONNECT) CONNECT)
echo "######## How to Connect to Electrum Rust Server #######" echo "######## How to Connect to Electrum Rust Server #######"
echo echo
echo "Install the Electrum Wallet App on your laptop from:" echo "Install the Electrum Wallet App on your laptop from:"
@ -235,13 +241,13 @@ Check 'sudo nginx -t' for a detailed error message.
read key read key
sudo /home/admin/config.scripts/blitz.display.sh hide sudo /home/admin/config.scripts/blitz.display.sh hide
;; ;;
STATUS) STATUS)
sudo /home/admin/config.scripts/bonus.electrs.sh status sudo /home/admin/config.scripts/bonus.electrs.sh status
echo echo
echo "Press ENTER to get back to main menu." echo "Press ENTER to get back to main menu."
read key read key
;; ;;
REINDEX) REINDEX)
echo "######## Delete/Rebuild Index ########" echo "######## Delete/Rebuild Index ########"
echo "# stopping service" echo "# stopping service"
sudo systemctl stop electrs sudo systemctl stop electrs
@ -264,15 +270,15 @@ fi
echo "# Making sure services are not running" echo "# Making sure services are not running"
sudo systemctl stop electrs 2>/dev/null sudo systemctl stop electrs 2>/dev/null
# uninstall # install
if [ "$1" = "install" ]; then if [ "$1" = "install" ]; then
echo "# INSTALL ELECTRS" echo "# INSTALL ELECTRS"
if id "electrs" &>/dev/null; then if id "electrs" &>/dev/null; then
echo "# user electrs exists already (codebase is installed)" echo "# user electrs exists already (codebase is installed)"
else else
echo "# Installing codebase" echo "# Installing codebase"
echo echo
echo "# Creating the electrs user" echo "# Creating the electrs user"
echo echo
@ -284,7 +290,7 @@ if [ "$1" = "install" ]; then
echo echo
# https://github.com/romanz/electrs/blob/master/doc/usage.md#build-dependencies # https://github.com/romanz/electrs/blob/master/doc/usage.md#build-dependencies
sudo -u electrs curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sudo -u electrs sh -s -- --default-toolchain none -y sudo -u electrs curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sudo -u electrs sh -s -- --default-toolchain none -y
sudo apt install -y clang cmake build-essential # for building 'rust-rocksdb' sudo apt install -y clang cmake build-essential # for building 'rust-rocksdb'
echo echo
echo "# Downloading and building electrs $ELECTRSVERSION. This will take ~40 minutes" echo "# Downloading and building electrs $ELECTRSVERSION. This will take ~40 minutes"
@ -296,18 +302,11 @@ if [ "$1" = "install" ]; then
# verify # verify
sudo -u electrs /home/admin/config.scripts/blitz.git-verify.sh \ sudo -u electrs /home/admin/config.scripts/blitz.git-verify.sh \
"${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" || exit 1 "${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" || exit 1
# build # build
sudo -u electrs /home/electrs/.cargo/bin/cargo build --locked --release || exit 1 sudo -u electrs /home/electrs/.cargo/bin/cargo build --locked --release || exit 1
echo
echo "# The electrs database will be built in /mnt/hdd/app-storage/electrs/db. Takes ~18 hours and ~50Gb diskspace"
echo
sudo mkdir /mnt/hdd/app-storage/electrs 2>/dev/null
sudo chown -R electrs:electrs /mnt/hdd/app-storage/electrs
fi fi
exit 0 exit 0
fi fi
@ -315,6 +314,16 @@ fi
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# ACTIVATING ELECTRS" echo "# ACTIVATING ELECTRS"
# check and create storage dir
if ! sudo ls /mnt/hdd/app-storage/electrs 2>/dev/null; then
sudo mkdir /mnt/hdd/app-storage/electrs
echo
echo "# The electrs database will be built in /mnt/hdd/app-storage/electrs/db. Takes ~18 hours and ~50Gb diskspace"
echo
fi
# always fix user id
sudo chown -R electrs:electrs /mnt/hdd/app-storage/electrs
isInstalled=$(sudo ls /etc/systemd/system/electrs.service 2>/dev/null | grep -c 'electrs.service') isInstalled=$(sudo ls /etc/systemd/system/electrs.service 2>/dev/null | grep -c 'electrs.service')
if [ ${isInstalled} -eq 0 ]; then if [ ${isInstalled} -eq 0 ]; then
@ -365,12 +374,11 @@ server_banner = \"Welcome to electrs $ELECTRSVERSION - the Electrum Rust Server
echo echo
echo "# Checking for config.toml" echo "# Checking for config.toml"
echo echo
if [ ! -f "/home/electrs/.electrs/config.toml" ] if [ ! -f "/home/electrs/.electrs/config.toml" ]; then
then echo "Failed to create config.toml"
echo "Failed to create config.toml" exit 1
exit 1 else
else echo "OK"
echo "OK"
fi fi
echo echo
@ -378,14 +386,14 @@ server_banner = \"Welcome to electrs $ELECTRSVERSION - the Electrum Rust Server
echo echo
isElectrs=$(sudo cat /etc/nginx/nginx.conf 2>/dev/null | grep -c 'upstream electrs') isElectrs=$(sudo cat /etc/nginx/nginx.conf 2>/dev/null | grep -c 'upstream electrs')
if [ ${isElectrs} -gt 0 ]; then if [ ${isElectrs} -gt 0 ]; then
echo "electrs is already configured with Nginx. To edit manually run \`sudo nano /etc/nginx/nginx.conf\`" echo "electrs is already configured with Nginx. To edit manually run \`sudo nano /etc/nginx/nginx.conf\`"
elif [ ${isElectrs} -eq 0 ]; then elif [ ${isElectrs} -eq 0 ]; then
isStream=$(sudo cat /etc/nginx/nginx.conf 2>/dev/null | grep -c 'stream {') isStream=$(sudo cat /etc/nginx/nginx.conf 2>/dev/null | grep -c 'stream {')
if [ ${isStream} -eq 0 ]; then if [ ${isStream} -eq 0 ]; then
echo " echo "
stream { stream {
upstream electrs { upstream electrs {
server 127.0.0.1:50001; server 127.0.0.1:50001;
@ -402,9 +410,9 @@ stream {
} }
}" | sudo tee -a /etc/nginx/nginx.conf }" | sudo tee -a /etc/nginx/nginx.conf
elif [ ${isStream} -eq 1 ]; then elif [ ${isStream} -eq 1 ]; then
sudo truncate -s-2 /etc/nginx/nginx.conf sudo truncate -s-2 /etc/nginx/nginx.conf
echo " echo "
upstream electrs { upstream electrs {
server 127.0.0.1:50001; server 127.0.0.1:50001;
} }
@ -420,10 +428,10 @@ stream {
} }
}" | sudo tee -a /etc/nginx/nginx.conf }" | sudo tee -a /etc/nginx/nginx.conf
elif [ ${isStream} -gt 1 ]; then elif [ ${isStream} -gt 1 ]; then
echo " Too many \`stream\` commands in nginx.conf. Please edit manually: \`sudo nano /etc/nginx/nginx.conf\` and retry" echo " Too many \`stream\` commands in nginx.conf. Please edit manually: \`sudo nano /etc/nginx/nginx.conf\` and retry"
exit 1 exit 1
fi fi
fi fi
echo echo
@ -477,7 +485,7 @@ WantedBy=multi-user.target
fi fi
# whitelist downloading to localhost from bitcoind # whitelist downloading to localhost from bitcoind
if ! sudo grep -Eq "^whitelist=download@127.0.0.1" /mnt/hdd/bitcoin/bitcoin.conf;then if ! sudo grep -Eq "^whitelist=download@127.0.0.1" /mnt/hdd/bitcoin/bitcoin.conf; then
echo "whitelist=download@127.0.0.1" | sudo tee -a /mnt/hdd/bitcoin/bitcoin.conf echo "whitelist=download@127.0.0.1" | sudo tee -a /mnt/hdd/bitcoin/bitcoin.conf
bitcoindRestart=yes bitcoindRestart=yes
fi fi
@ -569,7 +577,7 @@ if [ "$1" = "update" ]; then
sudo -u electrs git fetch sudo -u electrs git fetch
localVersion=$(/home/electrs/electrs/target/release/electrs --version) localVersion=$(/home/electrs/electrs/target/release/electrs --version)
updateVersion=$(curl --header "X-GitHub-Api-Version:2022-11-28" -s https://api.github.com/repos/romanz/electrs/releases/latest|grep tag_name|head -1|cut -d '"' -f4) updateVersion=$(curl --header "X-GitHub-Api-Version:2022-11-28" -s https://api.github.com/repos/romanz/electrs/releases/latest | grep tag_name | head -1 | cut -d '"' -f4)
if [ $localVersion = $updateVersion ]; then if [ $localVersion = $updateVersion ]; then
echo "# Up-to-date on version $localVersion" echo "# Up-to-date on version $localVersion"
@ -580,11 +588,11 @@ if [ "$1" = "update" ]; then
sudo -u electrs git reset --hard $updateVersion sudo -u electrs git reset --hard $updateVersion
sudo -u electrs /home/admin/config.scripts/blitz.git-verify.sh \ sudo -u electrs /home/admin/config.scripts/blitz.git-verify.sh \
"${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" || exit 1 "${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" || exit 1
echo "# Installing build dependencies" echo "# Installing build dependencies"
sudo -u electrs curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sudo -u electrs sh -s -- --default-toolchain none -y sudo -u electrs curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sudo -u electrs sh -s -- --default-toolchain none -y
sudo apt install -y clang cmake build-essential # for building 'rust-rocksdb' sudo apt install -y clang cmake build-essential # for building 'rust-rocksdb'
echo echo
echo "# Build Electrs ..." echo "# Build Electrs ..."