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 clear
case $CHOICE in case $CHOICE in
PATCH) PATCH)
sudo -u admin /home/admin/config.scripts/blitz.github.sh -run echo
sleep 4 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. whiptail --title " Patching/Syncing " --yes-button "Reboot" --no-button "Skip Reboot" --yesno " OK patching/syncing done.
By default a reboot is advised. By default a reboot is advised.

View file

@ -35,7 +35,10 @@ function blitzhelp() {
echo " status informational Blitz status screen" echo " status informational Blitz status screen"
echo " sourcemode copy blockchain source modus" echo " sourcemode copy blockchain source modus"
echo " check check if Blitz configuration files are correct" 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 " cache check on chache system state"
echo " github jumping directly into the options to change branch/repo/pr" echo " github jumping directly into the options to change branch/repo/pr"
echo echo
@ -113,8 +116,10 @@ function release() {
# command: debug # command: debug
function 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 /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 /home/admin/config.scripts/blitz.debug.sh redact /var/cache/raspiblitz/debug.log
sudo chmod 640 /var/cache/raspiblitz/debug.log sudo chmod 640 /var/cache/raspiblitz/debug.log
sudo chown root:sudo /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 # syncs script with latest set github and branch
function patch() { function patch() {
cd /home/admin 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 # command: off

View file

@ -239,7 +239,7 @@ else
echo "*** LAST BLITZAPI LOGS ***" echo "*** LAST BLITZAPI LOGS ***"
echo "sudo journalctl -u blitzapi -b --no-pager -n20" 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 echo
fi 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" ln_default | grep -v "ln_default_address"
/home/admin/_cache.sh "export" btc_default | grep -v "btc_default_address" /home/admin/_cache.sh "export" btc_default | grep -v "btc_default_address"
echo
echo "*** LOGFILES ***" echo "*** LOGFILES ***"
sudo journalctl --disk-usage sudo journalctl --disk-usage
sudo du -sh /var/log 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 sudo -u admin chmod 755 /home/admin/config.scripts/*.py
echo "# ******************************************" 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 .." echo "# Checking if the content of BlitzPy changed .."
checkSumBlitzPyAfter=$(find /home/admin/raspiblitz/home.admin/BlitzPy -type f -exec md5sum {} \; | md5sum) checkSumBlitzPyAfter=$(find /home/admin/raspiblitz/home.admin/BlitzPy -type f -exec md5sum {} \; | md5sum)
echo "# checkSumBlitzPyBefore = ${checkSumBlitzPyBefore}" echo "# checkSumBlitzPyBefore = ${checkSumBlitzPyBefore}"

View file

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

View file

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