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
 
This is my working docker-compose.yml

version: '2'
# Testkommentar

services:
db:
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- db:/var/lib/mysql/
environment:
- MYSQL_ROOT_PASSWORD=ASDFGJKLÖÄ
env_file:
- db.env
- smtp.env
- friendica.env
networks:
- proxy-tier

app:
image: friendica/server:fpm
restart: always
volumes:
- friendica:/var/www/html
- ./app/local.config.php:/var/www/html/config/local.config.php
environment:
- AUTOINSTALL=true
- MAILNAME=friendica.schuerz.at
- TZ=EUROPE/Vienna
- LANGUAGE=de
env_file:
- db.env
- smtp.env
- friendica.env
depends_on:
- db
networks:
- proxy-tier
- default

web:
image: nginx
restart: always
volumes:
- friendica:/var/www/html:ro
- ./web/nginx.conf:/etc/nginx/nginx.conf:ro
environment:
- VIRTUAL_HOST=friendica.schuerz.at
- LETSENCRYPT_HOST=friendica.schuerz.at
- LETSENCRYPT_EMAIL=XXX@YYY.ZZ
depends_on:
- app
env_file:
- db.env
- smtp.env
- friendica.env
networks:
- proxy-tier
- default

cron:
image: friendica/server:fpm
restart: always
volumes:
- friendica:/var/www/html:ro
- ./app/local.config.php:/var/www/html/config/local.config.php:ro
entrypoint: /cron.sh
env_file:
- db.env
- friendica.env
depends_on:
- db
- app
networks:
- proxy-tier

proxy:
build: ./proxy
restart: always
ports:
- 80:80
- 443:443
labels:
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
volumes:
- certs:/etc/nginx/certs:ro
- vhost.d:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- proxy-tier
- default

letsencrypt-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
restart: always
volumes:
- certs:/etc/nginx/certs
- vhost.d:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- proxy-tier
depends_on:
- proxy

volumes:
db:
friendica:
certs:
vhost.d:
html:

networks:
proxy-tier:
default:



cat proxy/Dockerfile
FROM jwilder/nginx-proxy:alpine

COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf


cat proxy/uploadsize.conf
client_max_body_size 10G;


cat web/nginx.conf
##
# Friendica Nginx configuration
# by Olaf Conradi, modified by Philipp Holzer
#
worker_processes 4;

events {
worker_connections 1024;
}

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

http {
charset utf-8;

include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

# If behind reverse proxy, forwards the correct IP
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 192.168.0.0/16;
set_real_ip_from fc00::/7;
real_ip_header X-Real-IP;

upstream php-handler {
server app:9000;
}

server {
listen 80;
#server name social.schuerz.at;
server_name friendica.schuerz.at;

index index.php;

root /var/www/html;
#Uncomment the following line to include a standard configuration file
#Note that the most specific rule wins and your standard configuration
#will therefore *add* to this file, but not override it.
#include standard.conf
# allow uploads up to 20MB in size
client_max_body_size 20m;
client_body_buffer_size 128k;

# rewrite to front controller as default rule
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?pagename=$1;
}
}
# make sure webfinger and other well known services aren't blocked
# by denying dot files and rewrite request to the front controller
location ^~ /.well-known/ {
allow all;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?pagename=$1;
}
}

# statically serve these file types when possible
# otherwise fall back to front controller
# allow browser to cache them
# added .htm for advanced source code editor library
#location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {
# expires 30d;
# try_files $uri /index.php?pagename=$uri&$args;
#}

include mime.types;

# block these file types
location ~* \.(tpl|md|tgz|log|out)$ {
deny all;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# or a unix socket
location ~* \.php$ {
# Zero-day exploit defense.
# http://forum.nginx.org/read.php?2,88845,page=3
# Won't work properly (404 error) if the file is not stored on this
# server, which is entirely possible with php-fpm/php-fcgi.
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on
# another machine. And then cross your fingers that you won't get hacked.
try_files $uri =404;

# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_pass php-handler;

include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

# deny access to all dot files
location ~ /\. {
deny all;
}
}
}
 

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