Improve Patch command (#3130)

This commit is contained in:
/rootzoll 2022-05-18 22:02:37 +02:00 committed by GitHub
parent fa7868006c
commit b7c823f3e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 100 additions and 42 deletions

View file

@ -138,8 +138,19 @@ patch()
clear
case $CHOICE in
PATCH)
sudo -u admin /home/admin/config.scripts/blitz.github.sh -run
sleep 4
echo
echo "#######################################################"
echo "### UPDATE BLITZ --> SCRIPTS (code)"
/home/admin/config.scripts/blitz.github.sh -run
echo
echo "#######################################################"
echo "### UPDATE BLITZ --> API"
sudo /home/admin/config.scripts/blitz.web.api.sh update-code
echo
echo "#######################################################"
echo "### UPDATE BLITZ --> WEBUI"
sudo /home/admin/config.scripts/blitz.web.ui.sh update
sleep 5
whiptail --title " Patching/Syncing " --yes-button "Reboot" --no-button "Skip Reboot" --yesno " OK patching/syncing done.
By default a reboot is advised.

View file

@ -35,7 +35,10 @@ function blitzhelp() {
echo " status informational Blitz status screen"
echo " sourcemode copy blockchain source modus"
echo " check check if Blitz configuration files are correct"
echo " patch sync scripts with latest set github and branch"
echo " patch sync all scripts with latest from github and branch"
echo " patch code sync only blitz scripts with latest from github and branch"
echo " patch api sync only Blitz-API with latest from github and branch"
echo " patch web sync only Blitz-WebUI with latest from github and branch"
echo " cache check on chache system state"
echo " github jumping directly into the options to change branch/repo/pr"
echo
@ -113,8 +116,10 @@ function release() {
# command: debug
function debug() {
echo "Printing debug logs. Be patient, this should take maximum 2 minutes ..."
echo "Printing debug logs. Be patient, this should take maximum 2 minutes .."
sudo rm /var/cache/raspiblitz/debug.log 2>/dev/null
/home/admin/config.scripts/blitz.debug.sh > /var/cache/raspiblitz/debug.log
echo "Redacting .."
/home/admin/config.scripts/blitz.debug.sh redact /var/cache/raspiblitz/debug.log
sudo chmod 640 /var/cache/raspiblitz/debug.log
sudo chown root:sudo /var/cache/raspiblitz/debug.log
@ -131,7 +136,29 @@ function debug() {
# syncs script with latest set github and branch
function patch() {
cd /home/admin
/home/admin/config.scripts/blitz.github.sh -run
if [ "$1" == "" ] || [ "$1" == "code" ]; then
echo
echo "#######################################################"
echo "### UPDATE BLITZ --> SCRIPTS (code)"
/home/admin/config.scripts/blitz.github.sh -run
fi
if [ "$1" == "" ] || [ "$1" == "api" ]; then
echo
echo "#######################################################"
echo "### UPDATE BLITZ --> API"
sudo /home/admin/config.scripts/blitz.web.api.sh update-code
fi
if [ "$1" == "" ] || [ "$1" == "web" ]; then
echo
echo "#######################################################"
echo "### UPDATE BLITZ --> WEBUI"
sudo /home/admin/config.scripts/blitz.web.ui.sh update
fi
echo
}
# command: off

View file

@ -239,7 +239,7 @@ else
echo "*** LAST BLITZAPI LOGS ***"
echo "sudo journalctl -u blitzapi -b --no-pager -n20"
sudo journalctl -u nginx -b --no-pager -n20
sudo journalctl -u blitzapi -b --no-pager -n20
echo
fi
@ -395,6 +395,7 @@ echo "*** SYSTEM CACHE STATUS ***"
/home/admin/_cache.sh "export" ln_default | grep -v "ln_default_address"
/home/admin/_cache.sh "export" btc_default | grep -v "btc_default_address"
echo
echo "*** LOGFILES ***"
sudo journalctl --disk-usage
sudo du -sh /var/log

View file

@ -167,18 +167,6 @@ sudo -u admin chmod 755 /home/admin/setup.scripts/*.sh
sudo -u admin chmod 755 /home/admin/config.scripts/*.py
echo "# ******************************************"
echo "# Syncing Webcontent .."
sudo mkdir -p /var/www/public
webuiexists=$(ls /home/admin/blitz_web/build/index.html | grep -c "index.html")
if [ ${webuiexists} -eq 0 ]; then
# copy github compiled webui
echo "- update webui with latest default compiled from github"
sudo cp -a /home/admin/assets/nginx/www_public/* /var/www/public
sudo chown www-data:www-data /var/www/public
else
echo "- found user compiled webui (dont overwrite with compiled webui from github)"
fi
echo "# Checking if the content of BlitzPy changed .."
checkSumBlitzPyAfter=$(find /home/admin/raspiblitz/home.admin/BlitzPy -type f -exec md5sum {} \; | md5sum)
echo "# checkSumBlitzPyBefore = ${checkSumBlitzPyBefore}"

View file

@ -209,16 +209,32 @@ fi
###################
if [ "$1" = "update-code" ]; then
echo "# Update Web API CODE"
sudo systemctl stop blitzapi
cd /root/blitz_api
git fetch
git pull
pip install -r requirements.txt
sudo systemctl start blitzapi
echo "# blitzapi updates and restarted"
exit 0
apiActive=$(sudo ls /etc/systemd/system/blitzapi.service | grep -c blitzapi.service)
if [ "${apiActive}" != "0" ]; then
echo "# Update Web API CODE"
sudo systemctl stop blitzapi
cd /root/blitz_api
currentBranch=$(git rev-parse --abbrev-ref HEAD)
echo "# updating local repo ..."
oldCommit=$(git rev-parse HEAD)
git fetch
git reset --hard origin/${currentBranch}
newCommit=$(git rev-parse HEAD)
if [ "${oldCommit}" != "${newCommit}" ]; then
pip install -r requirements.txt
else
echo "# no code changes"
fi
sudo systemctl start blitzapi
echo "# BRANCH ---> ${currentBranch}"
echo "# old commit -> ${oldCommit}"
echo "# new commit -> ${newCommit}"
echo "# blitzapi updates and restarted"
exit 0
else
echo "# blitzapi not active"
exit 1
fi
fi
###################

View file

@ -89,20 +89,35 @@ fi
# UPDATE
###################
if [ "$1" = "update" ]; then
echo "# Update Web API"
cd /root/blitz_web
git fetch
git pull
source <(/home/admin/config.scripts/bonus.nodejs.sh info)
${NODEPATH}/yarn install
${NODEPATH}/yarn build
sudo rm -r /var/www/public/* 2>/dev/null
sudo cp -r /root/blitz_web/build/* /var/www/public
sudo chown www-data:www-data -R /var/www/public
echo "# blitzapi updates and restarted"
exit 0
webuiActive=$(sudo ls /root/blitz_web/README.md | grep -c "README")
if [ "${webuiActive}" != "0" ]; then
echo "# Update Web API"
cd /root/blitz_web
currentBranch=$(git rev-parse --abbrev-ref HEAD)
echo "# updating local repo ..."
oldCommit=$(git rev-parse HEAD)
git fetch
git reset --hard origin/${currentBranch}
newCommit=$(git rev-parse HEAD)
if [ "${oldCommit}" != "${newCommit}" ]; then
source <(/home/admin/config.scripts/bonus.nodejs.sh info)
${NODEPATH}/yarn install
${NODEPATH}/yarn build
sudo rm -r /var/www/public/* 2>/dev/null
sudo cp -r /root/blitz_web/build/* /var/www/public
sudo chown www-data:www-data -R /var/www/public
else
echo "# no code changes"
fi
echo "# BRANCH ---> ${currentBranch}"
echo "# old commit -> ${oldCommit}"
echo "# new commit -> ${newCommit}"
echo "# reload WebUI in your browser"
exit 0
else
echo "# webui not active"
exit 1
fi
fi
###################