1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/friendica_ynh.git synced 2024-09-03 18:36:14 +02:00

Merge branch 'src' into fail

This commit is contained in:
eric_G 2023-08-21 12:26:50 +02:00 committed by GitHub
commit 80ae1372d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 116 additions and 104 deletions

View file

@ -20,7 +20,7 @@ Friendica is a decentralised communications platform that integrates social comm
Friendica connects you effortlessly to a federated communications network of several thousand servers, with more than half a million user registrations. You can directly connect to anyone on Friendica, Mastodon, Diaspora, GnuSocial, Pleroma, or Hubzilla, regardless where each user profile is hosted. Friendica connects you effortlessly to a federated communications network of several thousand servers, with more than half a million user registrations. You can directly connect to anyone on Friendica, Mastodon, Diaspora, GnuSocial, Pleroma, or Hubzilla, regardless where each user profile is hosted.
**Shipped version:** 2023.09~ynh1 **Shipped version:** 2023.05~ynh1
**Demo:** https://dir.friendica.social/servers **Demo:** https://dir.friendica.social/servers

View file

@ -20,7 +20,7 @@ Friendica is a decentralised communications platform that integrates social comm
Friendica connects you effortlessly to a federated communications network of several thousand servers, with more than half a million user registrations. You can directly connect to anyone on Friendica, Mastodon, Diaspora, GnuSocial, Pleroma, or Hubzilla, regardless where each user profile is hosted. Friendica connects you effortlessly to a federated communications network of several thousand servers, with more than half a million user registrations. You can directly connect to anyone on Friendica, Mastodon, Diaspora, GnuSocial, Pleroma, or Hubzilla, regardless where each user profile is hosted.
**Version incluse :** 2023.09~ynh1 **Version incluse :** 2023.05~ynh1
**Démo :** https://dir.friendica.social/servers **Démo :** https://dir.friendica.social/servers

View file

@ -1,2 +0,0 @@
# Run poller periodically to update Friendica
*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __INSTALL_DIR__/bin/worker.php

22
conf/systemd.service Normal file
View file

@ -0,0 +1,22 @@
[Unit]
Description=Friendica daemon
After=network.target mariadb.service
Requires=network.target remote-fs.target nss-lookup.target
[Service]
User=__APP__
Group=__APP__
WorkingDirectory=__INSTALL_DIR__/
Type=simple
StandardOutput=null
StandardError=syslog
ExecStart=/usr/bin/php__PHPVERSION__ __INSTALL_DIR__/bin/daemon.php start
ExecStop=/usr/bin/php__PHPVERSION__ __INSTALL_DIR__/bin/daemon.php stop
PIDFile=friendica/daemon.pid
PrivateTmp=true
InaccessibleDirectories=/home /root /boot /opt /mnt /media
ReadOnlyDirectories=/etc /usr
Restart=always
[Install]
WantedBy=multi-user.target

View file

@ -5,7 +5,7 @@ name = "Friendica"
description.en = "Social Communication Server" description.en = "Social Communication Server"
description.fr = "Serveur de Communication Social" description.fr = "Serveur de Communication Social"
version = "2023.09~ynh1" version = "2023.05~ynh1"
maintainers = [] maintainers = []
@ -46,6 +46,18 @@ ram.runtime = "50M"
default = "en" default = "en"
[resources] [resources]
[resources.sources]
[resources.sources.main]
url = "https://github.com/friendica/friendica/archive/refs/tags/2023.05.tar.gz"
sha256 = "727a8fdab6a2f6424d3dbc895496447e750eb0f8e1e11b70f1e229a7e3c9a31d"
autoupdate.strategy = "latest_github_tag"
[resources.sources.addons]
url = "https://github.com/friendica/friendica-addons/archive/refs/tags/2023.05.tar.gz"
sha256 = "df29aed28c0208e162c76f91949d0c3a0f77fe09853fe1a6d854b9956075d8a0"
autoupdate.strategy = "latest_github_tag"
[resources.system_user] [resources.system_user]
[resources.install_dir] [resources.install_dir]

View file

@ -4,11 +4,6 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# commit hashes
# 2023.08
version_commit="2dbfb070083ec395bf5d24ec89fe96b282c6a12d"
addons_version_commit="f2cc0312ca9a95d99a8330452848180792bf9227"
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -40,12 +40,17 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
# Backup cron job ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/cron.d/$app"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE

View file

@ -28,26 +28,13 @@ ynh_app_setting_set --app=$app --key=email --value=$email
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=5 ynh_script_progression --message="Setting up source files..." --weight=5
git config --system --add safe.directory $install_dir # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
# 1 - Clone stable repo ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons"
git clone --quiet https://github.com/friendica/friendica.git -b stable "$install_dir"
# Reset branch to the level of update we needed
pushd "$install_dir"
git reset --hard --quiet $version_commit
popd
# Copy .htaccess-dist to ..htaccess # Copy .htaccess-dist to ..htaccess
cp -f "$install_dir/.htaccess-dist" "$install_dir/.htaccess" cp -f "$install_dir/.htaccess-dist" "$install_dir/.htaccess"
# 2 - Clone addons repo
git clone --quiet https://github.com/friendica/friendica-addons.git -b stable "$install_dir/addon"
# Reset addons branch to the level of update we needed
pushd "$install_dir/addon"
git reset --hard --quiet $addons_version_commit
popd
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir" chown -R $app:www-data "$install_dir"
@ -59,6 +46,16 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
# Create a dedicated PHP-FPM configy
ynh_add_fpm_config --usage=low --footprint=low
ynh_add_systemd_config
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
@ -67,14 +64,6 @@ ynh_script_progression --message="Adding the LDAP Auth addon configuration file.
# LDAP addon config # LDAP addon config
ynh_add_config --template="../conf/addon.config.php" --destination="$install_dir/config/addon.config.php" ynh_add_config --template="../conf/addon.config.php" --destination="$install_dir/config/addon.config.php"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP_FPM..." --weight=4
# Create a dedicated PHP-FPM configy
ynh_add_fpm_config --usage=low --footprint=low
# 3 - some extra folders # 3 - some extra folders
mkdir -p "$install_dir/view/smarty3" mkdir -p "$install_dir/view/smarty3"
chmod -R 775 "$install_dir/view/smarty3" chmod -R 775 "$install_dir/view/smarty3"
@ -109,6 +98,13 @@ pushd "$install_dir"
ynh_exec_as "$app" php$phpversion bin/console.php addon enable ldapauth ynh_exec_as "$app" php$phpversion bin/console.php addon enable ldapauth
popd popd
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,9 +10,20 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 # REMOVE SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
ynh_remove_systemd_config
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -25,9 +36,6 @@ ynh_remove_fpm_config
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -37,9 +37,10 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file "/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
chown root: "/etc/cron.d/$app" systemctl enable $app.service --quiet
chmod 644 "/etc/cron.d/$app"
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log"
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
@ -48,11 +49,13 @@ ynh_systemd_action --action=restart --service_name=fail2ban
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================

View file

@ -22,6 +22,13 @@ timezone=$(cat /etc/timezone)
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# CHECK THE PATH # CHECK THE PATH
#================================================= #=================================================
@ -32,18 +39,23 @@ if [ -f $install_dir/.htconfig.php ]; then
ynh_secure_remove "$install_dir/.htconfig.php" ynh_secure_remove "$install_dir/.htconfig.php"
fi fi
# Remove files for upgrade compatibilty from previous versions of Friendica
if [ -f $install_dir/.htconfig.php ]; then if [ -f $install_dir/.htconfig.php ]; then
ynh_secure_remove "$install_dir/config/local.ini.php" ynh_secure_remove "$install_dir/.htconfig.php"
fi
if [ -f "/etc/cron.d/$app" ]; then
ynh_secure_remove --file="/etc/cron.d/$app"
fi fi
# If admin_mail setting doesn't exist, create it # If admin_mail setting doesn't exist, create it
if [ -z $email ]; then if [ -z "${email:-}" ]; then
email=$(ynh_user_get_info --username=$admin --key=mail) email=$(ynh_user_get_info --username=$admin --key=mail)
ynh_app_setting_set --app=$app --key=email --value=$email ynh_app_setting_set --app=$app --key=email --value=$email
fi fi
# If language setting doesn't exist, create it # If language setting doesn't exist, create it
if [ -z $language ]; then if [ -z "${language:-}" ]; then
language=en language=en
ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=language --value=$language
fi fi
@ -54,63 +66,17 @@ fi
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --weight=3 ynh_script_progression --message="Upgrading source files..." --weight=1
# Check if the repo can be updated with git
if [ `cd $install_dir && git rev-parse --is-inside-work-tree &> /dev/null` ];
then
# Update through Git
pushd "$install_dir"
git fetch
git checkout stable
git pull
git reset --hard $version_commit
popd
pushd "$install_dir/addon"
git fetch
git checkout stable
git pull
git reset --hard $addons_version_commit
popd
# If Git is not present upgrade through manual method
else
# Create a temporary directory and backup smarty3 folder # Download, check integrity, uncompress and patch the source from app.src
tmpdir="$(mktemp -d)" ynh_setup_source --dest_dir="$install_dir" --keep ="config/local.config.php view/smarty3"
cp -a "$install_dir/view/smarty3" "$tmpdir/smarty3" ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons"
# Remove the app directory securely
ynh_secure_remove --file="$install_dir"
# 1 - Clone stable repo
git clone --quiet https://github.com/friendica/friendica.git -b stable "$install_dir"
# Reset branch to the level of update we needed
pushd "$install_dir"
git reset --hard --quiet $version_commit
popd
# 2 - Clone addons repo
git clone --quiet https://github.com/friendica/friendica-addons.git -b stable "$install_dir/addon"
# Reset addons branch to the level of update we needed
pushd "$install_dir/addon"
git reset --hard --quiet $addons_version_commit
popd
# Restore the smarty3 folder
cp -a "$tmpdir/smarty3" "$install_dir/view/smarty3"
ynh_secure_remove --file="$tmpdir"
fi
fi fi
# Copy config file for correct place chmod -R 775 "$install_dir/view/smarty3"
ynh_add_config --template="../conf/local-sample.config.php" --destination="$install_dir/config/local.config.php"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir" chown -R $app:www-data "$install_dir"
# 3 - some extra folders
chmod -R 775 "$install_dir/view/smarty3"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -125,14 +91,14 @@ ynh_add_fpm_config --usage=low --footprint=low
# Create a dedicated Fail2Ban config # Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$" ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$"
ynh_add_systemd_config
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
# Run Composer # Run Composer
pushd "$install_dir" pushd "$install_dir"
ynh_exec_as "$app" php$phpversion bin/composer.phar install --no-dev --quiet ynh_exec_as "$app" php$phpversion bin/composer.phar install --no-dev --quiet
@ -140,6 +106,13 @@ pushd "$install_dir"
#ynh_exec_as "$app" bin/console config system addon ldapauth #ynh_exec_as "$app" bin/console config system addon ldapauth
popd popd
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================