API & WebU get installed from similar release branches like main repo (#3529)

* #3272 adapt API install script version branches

* #3273 adapt webui install script version branches

* #3254 move info

* #3460 change mempool detection

* fix syntax

* fix warning output
This commit is contained in:
/rootzoll
2022-12-16 00:19:12 +01:00
committed by GitHub
parent f067250979
commit 45c2716e0e
4 changed files with 137 additions and 52 deletions

View File

@@ -12,6 +12,12 @@
defaultRepo="rootzoll" defaultRepo="rootzoll"
defaultBranch="v1.8" defaultBranch="v1.8"
defaultAPIuser="fusion44"
defaultAPIrepo="blitz_api"
defaultWEBUIuser="cstenglein"
defaultWEBUIrepo="raspiblitz-web"
me="${0##/*}" me="${0##/*}"
nocolor="\033[0m" nocolor="\033[0m"
@@ -188,7 +194,6 @@ range_argument display "lcd" "hdmi" "headless"
: "${tweak_boot_drive:=true}" : "${tweak_boot_drive:=true}"
range_argument tweak_boot_drive "0" "1" "false" "true" range_argument tweak_boot_drive "0" "1" "false" "true"
# WIFI # WIFI
# --------------------------------------- # ---------------------------------------
# WIFI country code like 'US' (default) # WIFI country code like 'US' (default)
@@ -801,9 +806,9 @@ if ${fatpack}; then
/home/admin/config.scripts/bonus.lnbits.sh install || exit 1 /home/admin/config.scripts/bonus.lnbits.sh install || exit 1
echo "* Adding Raspiblitz API ..." echo "* Adding Raspiblitz API ..."
sudo /home/admin/config.scripts/blitz.web.api.sh on || exit 1 sudo /home/admin/config.scripts/blitz.web.api.sh on "${defaultAPIuser}" "${defaultAPIrepo}" "${branch}" || exit 1
echo "* Adding Raspiblitz WebUI ..." echo "* Adding Raspiblitz WebUI ..."
sudo /home/admin/config.scripts/blitz.web.ui.sh on || exit 1 sudo /home/admin/config.scripts/blitz.web.ui.sh on "${defaultAPIuser}" "${defaultAPIrepo}" "${branch}" || exit 1
# set build code as new default # set build code as new default
sudo rm -r /home/admin/assets/nginx/www_public sudo rm -r /home/admin/assets/nginx/www_public

View File

@@ -276,6 +276,16 @@ if [ "$1" = "target" ]; then
1) quickCheckOK=1 ;; 1) quickCheckOK=1 ;;
esac esac
clear
echo "****************************************************************************"
echo "OK your RaspiBlitz will now go into reboot and try to sync the blockchain"
echo "by itself. If you run into troubles you can always cut power and restart"
echo "setup with a fresh flashed sd card."
echo "****************************************************************************"
echo "PRESS ENTER to trigger reboot."
sleep 1
read key
fi fi
if [ ${quickCheckOK} -eq 0 ]; then if [ ${quickCheckOK} -eq 0 ]; then
@@ -291,16 +301,6 @@ if [ "$1" = "target" ]; then
echo "restarting services ... (please wait)" echo "restarting services ... (please wait)"
sudo systemctl enable bitcoind sudo systemctl enable bitcoind
clear
echo "****************************************************************************"
echo "OK your RaspiBlitz will now go into reboot and try to sync the blockchain"
echo "by itself. If you run into troubles you can always cut power and restart"
echo "setup with a fresh flashed sd card."
echo "****************************************************************************"
echo "PRESS ENTER to trigger reboot."
sleep 1
read key
echo "rebooting" echo "rebooting"
/home/admin/config.scripts/blitz.shutdown.sh reboot /home/admin/config.scripts/blitz.shutdown.sh reboot
exit exit

View File

@@ -5,21 +5,20 @@
# restart the systemd `blitzapi` when credentials of lnd or bitcoind are changed and it will # restart the systemd `blitzapi` when credentials of lnd or bitcoind are changed and it will
# excute the `update-config` automatically before restarting # excute the `update-config` automatically before restarting
# NORMALLY user/repo/version will be defined by calling script - see build_sdcard.sh
# the following is just a fallback to try during development if script given branch does not exist
FALLACK_BRANCH="main"
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
echo "Manage RaspiBlitz Web API" echo "Manage RaspiBlitz Web API"
echo "blitz.web.api.sh on [?GITHUBUSER] [?REPO] [?BRANCH]" echo "blitz.web.api.sh on [?GITHUBUSER] [?REPO] [?BRANCH] [?COMMITORTAG]"
echo "blitz.web.api.sh update-config" echo "blitz.web.api.sh update-config"
echo "blitz.web.api.sh update-code [?BRANCH]" echo "blitz.web.api.sh update-code [?BRANCH]"
echo "blitz.web.api.sh off" echo "blitz.web.api.sh off"
exit 1 exit 1
fi fi
DEFAULT_GITHUB_USER="fusion44"
DEFAULT_GITHUB_REPO="blitz_api"
DEFAULT_GITHUB_BRANCH="main"
DEFAULT_GITHUB_COMMITORTAG="v0.5.0-beta"
################### ###################
# UPDATE CONFIG # UPDATE CONFIG
################### ###################
@@ -144,20 +143,49 @@ fi
################### ###################
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
if [ "$2" != "" ]; then # get parameters
DEFAULT_GITHUB_USER="$2" GITHUB_USER=$2
if [ "${GITHUB_USER}" == "" ]; then
echo "# FAIL: No GITHUB_USER provided"
exit 1
fi
GITHUB_REPO=$3
if [ "${GITHUB_REPO}" == "" ]; then
echo "# FAIL: No GITHUB_REPO provided"
exit 1
fi
GITHUB_BRANCH=$4
if [ "${GITHUB_BRANCH}" == "" ]; then
echo "# FAIL: No GITHUB_BRANCH provided"
exit 1
fi
GITHUB_COMMITORTAG=$5
if [ "${GITHUB_COMMITORTAG}" == "" ]; then
echo "# INFO: No GITHUB_COMMITORTAG provided .. will use latest code on branch"
fi fi
if [ "$3" != "" ]; then # check if given branch exits on that github user/repo
DEFAULT_GITHUB_REPO="$3" branchExists=$(curl -s "https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/branches/${GITHUB_BRANCH}" | grep -c "\"name\": \"${GITHUB_BRANCH}\"")
if [ ${branchExists} -lt 1 ]; then
echo
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "# WARNING! The given API repo is not available:"
echo "# user(${GITHUB_USER}) repo(${GITHUB_REPO}) branch(${GITHUB_BRANCH})"
echo "# WORKING WITH FALLBACK REPO - USE JUST FOR DEVELOPMENT - DONT USE IN PRODUCTION"
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
sleep 10
GITHUB_BRANCH="${FALLACK_BRANCH}"
fi fi
if [ "$4" != "" ]; then # re-check (if case its fallback)
DEFAULT_GITHUB_BRANCH="$4" branchExists=$(curl -s "https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/branches/${GITHUB_BRANCH}" | grep -c "\"name\": \"${GITHUB_BRANCH}\"")
fi if [ ${branchExists} -lt 1 ]; then
echo
if [ "$5" != "" ]; then echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
DEFAULT_GITHUB_COMMITORTAG="$5" echo "# FAIL! user(${GITHUB_USER}) repo(${GITHUB_REPO}) branch(${GITHUB_BRANCH})"
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1
fi fi
echo "# INSTALL Web API ..." echo "# INSTALL Web API ..."
@@ -192,27 +220,35 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
cd /home/blitzapi || exit 1 cd /home/blitzapi || exit 1
# git clone https://github.com/fusion44/blitz_api.git /home/blitzapi/blitz_api # git clone https://github.com/fusion44/blitz_api.git /home/blitzapi/blitz_api
if ! sudo -u blitzapi git clone https://github.com/${DEFAULT_GITHUB_USER}/${DEFAULT_GITHUB_REPO}.git blitz_api; then echo "# clone github: ${GITHUB_USER}/${GITHUB_REPO}"
if ! sudo -u blitzapi git clone https://github.com/${GITHUB_USER}/${GITHUB_REPO}.git blitz_api; then
echo "error='git clone failed'" echo "error='git clone failed'"
exit 1 exit 1
fi fi
cd blitz_api || exit 1 cd blitz_api || exit 1
if ! sudo -u blitzapi git checkout ${DEFAULT_GITHUB_BRANCH}; then echo "# checkout branch: ${GITHUB_BRANCH}"
if ! sudo -u blitzapi git checkout ${GITHUB_BRANCH}; then
echo "error='git checkout failed'" echo "error='git checkout failed'"
exit 1 exit 1
fi fi
if ! git reset --hard ${DEFAULT_GITHUB_COMMITORTAG}; then if [ "${GITHUB_COMMITORTAG}" != "" ]; then
echo "error='git reset failed'" echo "# setting code to tag/commit: ${GITHUB_COMMITORTAG}"
exit 1 if ! git reset --hard ${GITHUB_COMMITORTAG}; then
echo "error='git reset failed'"
exit 1
fi
else
echo "# using lastest code in branch"
fi fi
# install # install
echo "# running install"
sudo -u blitzapi python3 -m venv venv sudo -u blitzapi python3 -m venv venv
if ! sudo -u blitzapi ./venv/bin/pip install -r requirements.txt --no-deps; then if ! sudo -u blitzapi ./venv/bin/pip install -r requirements.txt --no-deps; then
echo "error='pip install failed'" echo "error='pip install failed'"
exit 1 exit 1
fi fi
# build the config and set unique secret (its OK to be a new secret every install/upadte) # build the config and set unique secret (its OK to be a new secret every install/update)
/home/admin/config.scripts/blitz.web.api.sh update-config /home/admin/config.scripts/blitz.web.api.sh update-config
secret=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 64 ; echo '') secret=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 64 ; echo '')
sed -i "s/^secret=.*/secret=${secret}/g" ./.env sed -i "s/^secret=.*/secret=${secret}/g" ./.env

View File

@@ -2,10 +2,14 @@
# main repo: https://github.com/cstenglein/raspiblitz-web # main repo: https://github.com/cstenglein/raspiblitz-web
# NORMALLY user/repo/version will be defined by calling script - see build_sdcard.sh
# the following is just a fallback to try during development if script given branch does not exist
FALLACK_BRANCH="master"
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
echo "Manage RaspiBlitz Web UI" echo "Manage RaspiBlitz WebUI"
echo "blitz.web.ui.sh on [?GITHUBUSER] [?REPO] [?BRANCH]" echo "blitz.web.ui.sh on [?GITHUBUSER] [?REPO] [?BRANCH] [?COMMITORTAG]"
echo "blitz.web.ui.sh update" echo "blitz.web.ui.sh update"
echo "blitz.web.ui.sh off" echo "blitz.web.ui.sh off"
exit 0 exit 0
@@ -17,45 +21,85 @@ if [ "$EUID" -ne 0 ]; then
exit 1 exit 1
fi fi
DEFAULT_GITHUB_USER="cstenglein"
DEFAULT_GITHUB_REPO="raspiblitz-web"
DEFAULT_GITHUB_BRANCH="master"
################### ###################
# ON / INSTALL # ON / INSTALL
################### ###################
if [ "$1" = "1" ] || [ "$1" = "on" ]; then if [ "$1" = "1" ] || [ "$1" = "on" ]; then
if [ "$2" != "" ]; then # get parameters
DEFAULT_GITHUB_USER="$2" GITHUB_USER=$2
if [ "${GITHUB_USER}" == "" ]; then
echo "# FAIL: No GITHUB_USER provided"
exit 1
fi
GITHUB_REPO=$3
if [ "${GITHUB_REPO}" == "" ]; then
echo "# FAIL: No GITHUB_REPO provided"
exit 1
fi
GITHUB_BRANCH=$4
if [ "${GITHUB_BRANCH}" == "" ]; then
echo "# FAIL: No GITHUB_BRANCH provided"
exit 1
fi
GITHUB_COMMITORTAG=$5
if [ "${GITHUB_COMMITORTAG}" == "" ]; then
echo "# INFO: No GITHUB_COMMITORTAG provided .. will use latest code on branch"
fi fi
if [ "$3" != "" ]; then # check if given branch exits on that github user/repo
DEFAULT_GITHUB_REPO="$3" branchExists=$(curl -s "https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/branches/${GITHUB_BRANCH}" | grep -c "\"name\": \"${GITHUB_BRANCH}\"")
if [ ${branchExists} -lt 1 ]; then
echo
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "# WARNING! The given WebUI repo is not available:"
echo "# user(${GITHUB_USER}) repo(${GITHUB_REPO}) branch(${GITHUB_BRANCH})"
echo "# WORKING WITH FALLBACK REPO - USE JUST FOR DEVELOPMENT - DONT USE IN PRODUCTION"
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
sleep 10
GITHUB_BRANCH="${FALLACK_BRANCH}"
fi fi
if [ "$4" != "" ]; then # re-check (if case its fallback)
DEFAULT_GITHUB_BRANCH="$4" branchExists=$(curl -s "https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/branches/${GITHUB_BRANCH}" | grep -c "\"name\": \"${GITHUB_BRANCH}\"")
if [ ${branchExists} -lt 1 ]; then
echo
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "# FAIL! user(${GITHUB_USER}) repo(${GITHUB_REPO}) branch(${GITHUB_BRANCH})"
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1
fi fi
echo "# INSTALL WebUI" echo "# INSTALL WebUI"
# clean all source # clean all source
rm -r /root/blitz_web 2>/dev/null rm -r /root/blitz_web 2>/dev/null
rm -r /root/${DEFAULT_GITHUB_REPO} 2>/dev/null rm -r /root/${GITHUB_REPO} 2>/dev/null
rm -r /home/blitzapi/blitz_web 2>/dev/null rm -r /home/blitzapi/blitz_web 2>/dev/null
rm -r /home/blitzapi/${DEFAULT_GITHUB_REPO} 2>/dev/null rm -r /home/blitzapi/${GITHUB_REPO} 2>/dev/null
cd /home/blitzapi || exit 1 cd /home/blitzapi || exit 1
if ! git clone https://github.com/${DEFAULT_GITHUB_USER}/${DEFAULT_GITHUB_REPO}.git; then echo "# clone github: ${GITHUB_USER}/${GITHUB_REPO}"
if ! git clone https://github.com/${GITHUB_USER}/${GITHUB_REPO}.git; then
echo "error='git clone failed'" echo "error='git clone failed'"
exit 1 exit 1
fi fi
mv /home/blitzapi/${DEFAULT_GITHUB_REPO} /home/blitzapi/blitz_web mv /home/blitzapi/${GITHUB_REPO} /home/blitzapi/blitz_web
cd blitz_web || exit 1 cd blitz_web || exit 1
if ! git checkout ${DEFAULT_GITHUB_BRANCH}; then echo "# checkout branch: ${GITHUB_BRANCH}"
if ! git checkout ${GITHUB_BRANCH}; then
echo "error='git checkout failed'" echo "error='git checkout failed'"
exit 1 exit 1
fi fi
if [ "${GITHUB_COMMITORTAG}" != "" ]; then
echo "# setting code to tag/commit: ${GITHUB_COMMITORTAG}"
if ! git reset --hard ${GITHUB_COMMITORTAG}; then
echo "error='git reset failed'"
exit 1
fi
else
echo "# using lastest code in branch"
fi
echo "# Compile WebUI" echo "# Compile WebUI"
/home/admin/config.scripts/bonus.nodejs.sh on /home/admin/config.scripts/bonus.nodejs.sh on