snf.wsring.net

Search

Items tagged with: ###

Friendica update script (for git-based installations)

I've been using this script for ~3 months now. I added a few additional steps based on input from @Steffen K9 🐰 not too long ago. I'm sure it's still not perfect, but it seems to be working just fine for me, so I thought I might as well share it on here and possibly help others!

I find this much simpler than manually extracting archives, fixing permissions, overwritting configs and relinking my personal additions to the site with every update. I also include some tips in the file for dealing with branch changes and such (again, mainly thanks to what I learned from @Steffen K9 🐰 ). I know it's overly verbose, but I'm sure that's no surprise to any of you that have chatted with me on here :P

Instructions are in the comments, although it's probably obvious from the script, it's fairly simple. But I want it to be clear to folks who might not be all that familiar with bash/git/system administration. Anyways, here it is:
#[url=https://snf.wsring.net/search?tag=!/bin/bash]!/bin/bash[/url]
#
# Friendica Update Script
# by Adam Gaskins <self@adamgaskins.com>
# updated 06.17.19
#
# Description: Pull the latest friendica and friendica-addons git changes, then 
# do post-install and maintenance stuff. It is not a great idea to run this 
# script from cron or a systemd timer if you are using the 'develop' or RC 
# branches.
#
# Usage: Save this script somewhere like /usr/local/sbin/friendica_update.sh 
# (but it shouldn't really matter). Then make it executable with something like 
# 'chmod ug+x friendica_update.sh'. Adjust the variables in the 'USER CONFIG' 
# section to match your setup and preferences, and then execute this script by 
# running './usr/local/sbin/friendica_update.sh', or whatever method you prefer. 
# This script is simple and straight forward, but I still added comments for 
# variable explanation, and wherever there wasn't an 'echo' line to explain what 
# was happening, so it should be extremely clear what is going on here!
#
# Tips: These are just a few tips that I found useful, being a relative n00b 
# with git myself. It's just a couple of basic things that one should know how 
# to do, especially if you're going to use a branch other than 'master, like a 
# release candidate (RC) or the 'develop' branch.
#
# To change branches between master, develop, etc. run a command similar 
# to the one below, replacing 'master' with the branch name you wish use. Also, 
# replace 'www-data', if needed, with the user/group that your webserver expects 
# the files to be owned by. The sudo part is very important for git commands 
# that might change or create files, to avoid making the files inaccessible to 
# your webserver!
#   sudo -u www-data -g www-data git checkout master
#   sudo -u www-data -g www-data git checkout develop
#
# To view all available branches on the remote repo run:
#   git branch --list --all --verbose
#
# Sometimes branches are removed on the remote repo, such as those for release 
# candidates that have been merged to master. You may see a message like this: 
#   > Your configuration specifies to merge with the ref 'origin/2019.06-RC' 
#   > from the remote, but no such ref was fetched.
# This means you need to change to another branch, probably 'master' in this 
# case. You'll want to use 'branch' and 'checkout' command shown previously to 
# find and checkout a new branch. You can then do a 'pull' to get your local 
# repo in sync with the remote branch, but add '--prune' this time to remove 
# any old branches that are no longer used!
#   sudo -u www-data -g www-data git fetch --prune
#
# The above commands do NOT need to be run every time, so just do this stuff 
# manually, as needed! like when you wish to switch branches, for example. If 
# you're running an open public node then you probably just want to follow 
# 'master' and never really change branches anyways, but sometimes the RC 
# branches are useful! It all just depends on your confort zone, and how 
# diligently you are keeping an eye on your node.
#
# Oh, and DO NOT FORGET to run these commands in both your main Friendica repo 
# AND the addon/ directory! These are two independent repos and they should be 
# on like branches!
#
# TODO: add logging, error handling, verbosity control
#
# Thanks to Steffen K9 for sharing some tips that helped me write this script!
# Ref: https://social.linuxlusers.com/display/0b6b25a8-705c-e978-6135-0fd801926751
#
# Contact me if you have any corrections, concerns, or suggestions! I'm 
# certainly no wiz at bash nor git, so I'm happy to learn of ways to improve 
# this!

#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]
#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url] USER CONFIG #[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]

# A message shown to users during the update proceedure
MESSAGE="This system is currently undergoing a routine update. Our sincerest apologies for any trouble this may have caused you, but it should only take a moment to complete, then the system will resume normal operation!"

# Path where Friendica git repository resides
BASEPATH='/var/www/friendica/git-repo/'

# Run processes as this user (and group)
RUNAS='www-data'

# Path to php executable, or just 'php' to use the system default 
PHPEXEC='php'

#[url=https://snf.wsring.net/search?tag=#]#[/url] END OF USER CONFIG #[url=https://snf.wsring.net/search?tag=#]#[/url]
#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url]]#[url=https://snf.wsring.net/search?tag=#]#[/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url]#[url=https://snf.wsring.net/search?tag=#]#[/url][/url][/url]

echo -e "Starting update routine for Friendica ($BASEPATH) on $(date)"
pushd $BASEPATH >/dev/null

echo -e "\nEntering maintenance mode:"
sudo -u $RUNAS -g $RUNAS $PHPEXEC bin/console.php maintenance 1 "$MESSAGE"

echo -e "\nUpdating $(pwd):"
sudo -u $RUNAS -g $RUNAS git pull

# addon repo
pushd addon/ >/dev/null

echo -e "\nUpdating $(pwd):"
sudo -u $RUNAS -g $RUNAS git pull

# return to main repo
popd >/dev/null

echo -e "\nInstall/update dependencies in $(pwd):"
sudo -u $RUNAS -g $RUNAS $PHPEXEC bin/composer.phar install --no-dev

echo -e "\nUpdate the database (if needed):"
sudo -u $RUNAS -g $RUNAS $PHPEXEC bin/console.php dbstructure update

echo -e "\nRun post-update tasks:"
sudo -u $RUNAS -g $RUNAS $PHPEXEC bin/console.php postupdate

# Status report
echo -e "\nGit status (main):"
sudo -u $RUNAS -g $RUNAS git status -bsu
echo -e "\nGit status (addon):"
sudo -u $RUNAS -g $RUNAS git -C addon/ status -bsu

# Return to normal mode
echo -e "\nExiting maintenance mode:"
sudo -u $RUNAS -g $RUNAS $PHPEXEC bin/console.php maintenance 0

# Final pop to where we started
popd >/dev/null

echo -e "\nThis script has completed. Please check the output (above) for potentially important messages or issues!"

exit 0

P.S. The text is much easier to read once copied and pasted in a file, all comments are wrapped at 80 characters. I'm sorry the comments are kind of a mess here - at least on my screen using Frio. I would have thought 80 characts would fit :\

!Friendica Support
!Friendica Admins
!The Linux Luser Group
 

For the Newbies: Markdown Quick Reference


My most popular Diaspora post to date has been my Markdown Quick Reference, which shows both the raw and formatted text for various Markdown features.

New arrivals from #GooglePlus and elsewhere may appreciate this.

(Posted as a link as I cannot reshare my own posts.)

#Markdown #Tips

https://joindiaspora.com/posts/54c680b0b40801366b870218b798024d
 
Later posts Earlier posts