From d50fb1bf6bfa4b7b03a443a6e406f6cc8c8fdcb3 Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Thu, 9 Apr 2020 14:12:49 +0530
Subject: [PATCH 01/11] Updated to version 2020.03
---
README.md | 6 +--
check_process | 18 ++-----
conf/addons.src | 6 +--
conf/app.src | 4 +-
manifest.json | 2 +-
scripts/_common.sh | 18 +++----
scripts/backup | 35 ++++++------
scripts/install | 129 +++++++++++++++++++++++++-------------------
scripts/remove | 46 +++++++++-------
scripts/restore | 45 +++++++++-------
scripts/upgrade | 132 +++++++++++++++++++++++++++++----------------
11 files changed, 252 insertions(+), 189 deletions(-)
diff --git a/README.md b/README.md
index c5bc68e..072513d 100644
--- a/README.md
+++ b/README.md
@@ -6,12 +6,12 @@
[Friendica](http://friendi.ca/) integration for YunoHost
-**Version:2019.01**
+**Version:2020.03**
Current snapshot in *sources*:
-* https://github.com/friendica/friendica: 2019.01
-* https://github.com/friendica/friendica-addons: 2019.01
+* https://github.com/friendica/friendica: 2020.03
+* https://github.com/friendica/friendica-addons: 2020.03
## Important Notes
diff --git a/check_process b/check_process
index 1cbbf2b..0726b57 100644
--- a/check_process
+++ b/check_process
@@ -13,22 +13,14 @@
upgrade=1 from_commit=1c018b9ed379e25d5bcab4bd27e9833feee9da68
backup_restore=1
multi_instance=1
- incorrect_path=1
+ # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
+ # incorrect_path=1
port_already_use=0
change_url=0
- ;;; Levels
- Level 1=auto
- Level 2=auto
- Level 3=auto
- # There is LDAP support for the app
- Level 4=1
- Level 5=auto
- Level 6=auto
- Level 7=auto
- Level 8=0
- Level 9=0
- Level 10=0
+;;; Levels
+ # If the level 5 (Package linter) is forced to 1. Please add justifications here.
+ Level 5=auto
;;; Options
Email=anmol@datamol.org
Notification=change
diff --git a/conf/addons.src b/conf/addons.src
index 5c08c63..78d838c 100644
--- a/conf/addons.src
+++ b/conf/addons.src
@@ -1,6 +1,6 @@
-SOURCE_URL=https://github.com/friendica/friendica-addons/archive/2019.01.zip
-SOURCE_SUM=23edfeddf58de1f605f8cb71603fbb31f415641b76f09a102e4bdb2ec78d508d
+SOURCE_URL=https://github.com/friendica/friendica-addons/archive/2019.12.tar.gz
+SOURCE_SUM=c206a8b0845a4a5102b5a9d1881d039472d734c70d5f1dd52e44684955b6a7f2
SOURCE_SUM_PRG=sha256sum
-SOURCE_FORMAT=zip
+SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
diff --git a/conf/app.src b/conf/app.src
index c8b5fb7..968419c 100644
--- a/conf/app.src
+++ b/conf/app.src
@@ -1,5 +1,5 @@
-SOURCE_URL=https://friendi.ca/wp-content/uploads/2019/02/friendica-full-2019.01.tar.gz
-SOURCE_SUM=895025c0adf042b6139ed3e7c4674a49d3a0237ce3490a367be681e6310c92a3
+SOURCE_URL=https://friendi.ca/wp-content/uploads/2020/03/friendica-full-2020.03.tar.gz
+SOURCE_SUM=dbfb001a90533e57fc453ff8d8d5c017236251aef78e5feb9902744d8b8dc1bd
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
diff --git a/manifest.json b/manifest.json
index 9e5edf2..af61b28 100644
--- a/manifest.json
+++ b/manifest.json
@@ -8,7 +8,7 @@
},
"url": "http://friendi.ca",
"license": "free",
- "version": "2019.01",
+ "version": "2020.03",
"maintainer": {
"name": "Anmol Sharma",
"email": "anmol@datamol.org"
diff --git a/scripts/_common.sh b/scripts/_common.sh
index d8051ab..37d0f4f 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -1,17 +1,11 @@
-
#!/bin/bash
-# ============= FUTURE YUNOHOST HELPER =============
-# Delete a file checksum from the app settings
-#
-# $app should be defined when calling this helper
-#
-# usage: ynh_remove_file_checksum file
-# | arg: file - The file for which the checksum will be deleted
-ynh_delete_file_checksum () {
- local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
- ynh_app_setting_delete $app $checksum_setting_name
-}
+#=================================================
+# COMMON VARIABLES
+#=================================================
+
+# dependencies used by the app
+pkg_dependencies="php-mbstring php-cli php-imagick php-gd php-xml"
# =============================================================================
# COMMON ROUNDCUBE FUNCTIONS
diff --git a/scripts/backup b/scripts/backup
index 6dda7b0..bea7d44 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -24,48 +24,51 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_print_info "Loading installation settings..."
+ynh_script_progression --message="Loading installation settings..." --time --weight=1
app=$YNH_APP_INSTANCE_NAME
-final_path=$(ynh_app_setting_get $app final_path)
-domain=$(ynh_app_setting_get $app domain)
-db_name=$(ynh_app_setting_get $app db_name)
-db_pwd=$(ynh_app_setting_get $app mysqlpwd)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
+#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
-ynh_print_info "Backing up the main app directory..."
-ynh_backup "$final_path"
+ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
+
+ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
-ynh_print_info "Backing up nginx web server configuration..."
-ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
+ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
+
+ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
-ynh_print_info "Backing up php-fpm configuration..."
-ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
+ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1
+
+ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
-ynh_print_info "Backing up the MySQL database..."
-ynh_mysql_dump_db "$db_name" > db.sql
+ynh_script_progression --message="Backing up the MySQL database..." --time --weight=1
+ynh_mysql_dump_db --database="$db_name" > db.sql
# Backup cron job
-ynh_backup "/etc/cron.d/$app"
+ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================
-ynh_print_info "Backup script completed for $app. (YunoHost will now copy those files to the archive)."
-
+ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
diff --git a/scripts/install b/scripts/install
index 472b7e6..57ff2a0 100644
--- a/scripts/install
+++ b/scripts/install
@@ -33,56 +33,71 @@ is_public=1
database="1"
-# This is a multi-instance app, meaning it can be installed several times independently
-# The id of the app as stated in the manifest is available as $YNH_APP_ID
-# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
-# The app instance name is available as $YNH_APP_INSTANCE_NAME
-# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
-# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
-# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
-# The app instance name is probably what you are interested the most, since this is
-# guaranteed to be unique. This is a good unique identifier to define installation path,
-# db names, ...
+### If it's a multi-instance app, meaning it can be installed several times independently
+### The id of the app as stated in the manifest is available as $YNH_APP_ID
+### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
+### The app instance name is available as $YNH_APP_INSTANCE_NAME
+### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
+### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
+### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
+### The app instance name is probably what interests you most, since this is
+### guaranteed to be unique. This is a good unique identifier to define installation path,
+### db names, ...
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
-ynh_print_info "Validating installation parameters..."
-
-# Normalize the url path syntax
-path_url=$(ynh_normalize_url_path $path_url)
-
-# Register (book) web path
-ynh_webpath_register $app $domain $path_url
+### About --weight and --time
+### ynh_script_progression will show to your final users the progression of each scripts.
+### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script.
+### --time is a packager option, it will show you the execution time since the previous call.
+### This option should be removed before releasing your app.
+### Use the execution time, given by --time, to estimate the weight of a step.
+### A common way to do it is to set a weight equal to the execution time in second +1.
+### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call.
+ynh_script_progression --message="Validating installation parameters..." --time --weight=1
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
final_path=/var/www/$app
-test ! -e "$final_path" || ynh_die "This path already contains a folder"
+test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
+
+# Register (book) web path
+ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
-ynh_print_info "Storing installation settings..."
+ynh_script_progression --message="Storing installation settings..." --time --weight=1
-ynh_app_setting_set $app domain $domain
-ynh_app_setting_set $app path $path_url
-ynh_app_setting_set $app admin $admin
-ynh_app_setting_set $app is_public $is_public
-ynh_app_setting_set $app email $admin_mail
-ynh_app_setting_set $app database $database
+ynh_app_setting_set --app=$app --key=domain --value=$domain
+ynh_app_setting_set --app=$app --key=path --value=$path_url
+ynh_app_setting_set --app=$app --key=admin --value=$admin
+ynh_app_setting_set --app=$app --key=is_public --value=$is_public
+ynh_app_setting_set --app=$app --key=email --value=$admin_mail
+ynh_app_setting_set --app=$app --key=database --value=$database
#=================================================
# INSTALL DEPENDENCIES
#=================================================
-ynh_print_info "Installing dependencies..."
-ynh_install_app_dependencies 'php-mbstring|base-files(<<9.0)' php5-cli 'php5-imagick|php-imagick' php5-gd php5-mcrypt 'php-xml|base-files(<<9.0)'
+ynh_script_progression --message="Installing dependencies..." --time --weight=1
+
+### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
+### Those deb packages will be installed as dependencies of this package.
+### If you're not using this helper:
+### - Remove the section "REMOVE DEPENDENCIES" in the remove script
+### - Remove the variable "pkg_dependencies" in _common.sh
+### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
+### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
+
+ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
-ynh_print_info "Creating a MySQL database..."
+ynh_script_progression --message="Creating a MySQL database..." --time --weight=1
+
### Use these lines if you need a database for the application.
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
### The password will be stored as 'mysqlpwd' into the app settings,
@@ -92,32 +107,34 @@ ynh_print_info "Creating a MySQL database..."
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
-db_name=$(ynh_sanitize_dbid $app)
-ynh_app_setting_set $app db_name $db_name
-ynh_mysql_setup_db $db_name $db_name
+db_name=$(ynh_sanitize_dbid --db_name=$app)
+db_user=$db_name
+ynh_app_setting_set --app=$app --key=db_name --value=$db_name
+ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
-ynh_print_info "Setting up source files..."
+ynh_script_progression --message="Setting up source files..." --time --weight=1
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
-ynh_app_setting_set $app final_path $final_path
+ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
-ynh_setup_source "$final_path"
+ynh_setup_source --dest_dir="$final_path"
+
cp -f "$final_path/.htaccess-dist" "$final_path/.htaccess"
# 2 - Addons
sudo mkdir $final_path/addon
-ynh_setup_source "$final_path/addon" "addons"
+ynh_setup_source --dest_dir="$final_path/addon" --source_id="addons"
#=================================================
# NGINX CONFIGURATION
#=================================================
-ynh_print_info "Configuring nginx web server..."
+ynh_script_progression --message="Configuring nginx web server..." --time --weight=1
### `ynh_add_nginx_config` will use the file conf/nginx.conf
@@ -127,36 +144,36 @@ ynh_add_nginx_config
# configure friendica
sudo cp -f "/var/www/$app/config/local-sample.config.php" "/var/www/$app/config/local.config.php"
-ynh_replace_string "your.mysqlhost.com" "localhost" "$final_path/config/local.config.php"
-ynh_replace_string "mysqlusername" "$db_name" "$final_path/config/local.config.php"
-ynh_replace_string "mysqldatabasename" "$db_name" "$final_path/config/local.config.php"
-ynh_replace_string "mysqlpassword" "$db_pwd" "$final_path/config/local.config.php"
-ynh_replace_string "'admin_email' => ''," "'admin_email' => '$admin_mail'," "$final_path/config/local.config.php"
-ynh_replace_string "REGISTER_OPEN" "REGISTER_CLOSED" "$final_path/config/local.config.php"
+ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="mysqlusername" --replace_string="$db_name" --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="mysqldatabasename" --replace_string="$db_name" --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="mysqlpassword" --replace_string="$db_pwd" --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="'admin_email' => ''," --replace_string="'admin_email' => '$admin_mail'," --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="REGISTER_OPEN" --replace_string="REGISTER_CLOSED" --target_file="$final_path/config/local.config.php"
# init db
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "$final_path/database.sql"
# addon config
-sudo cp "../conf/addon.config.php" "$final_path/config/."
+cp "../conf/addon.config.php" "$final_path/config/."
#=================================================
# CREATE DEDICATED USER
#=================================================
-ynh_print_info "Configuring system user..."
+ynh_script_progression --message="Configuring system user..." --time --weight=1
# Create a system user
-ynh_system_user_create $app
+ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
-ynh_print_info "Configuring php-fpm..."
+ynh_script_progression --message="Configuring php-fpm..." --time --weight=1
### `ynh_add_fpm_config` is used to set up a PHP config.
### You can remove it if your app doesn't use PHP.
-### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini
+### `ynh_add_fpm_config` will use the files conf/php-fpm.conf
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
@@ -169,15 +186,15 @@ ynh_print_info "Configuring php-fpm..."
ynh_add_fpm_config
-sudo chown -R www-data:www-data $final_path
+chown -R www-data:www-data $final_path
# 3 - some extra folders
sudo mkdir -p "${final_path}/view/smarty3"
sudo chmod -R 775 $final_path/view/smarty3
# Set up poller
-ynh_replace_string "__YNH_WWW_PATH__" "$final_path" ../conf/poller-cron
-ynh_replace_string "__USER__" "$app" ../conf/poller-cron
-sudo cp ../conf/poller-cron /etc/cron.d/$app
+ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="$final_path" --target_file="../conf/poller-cron"
+ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/poller-cron"
+cp ../conf/poller-cron /etc/cron.d/$app
#=================================================
# STORE THE CONFIG FILE CHECKSUM
@@ -188,7 +205,7 @@ sudo cp ../conf/poller-cron /etc/cron.d/$app
### you can make a backup of this file before modifying it again if the admin had modified it.
# Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum "$final_path/config/local.config.php"
+ynh_store_file_checksum --file="$final_path/config/local.config.php"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
@@ -202,18 +219,18 @@ chown -R $app: $final_path
# unprotected_uris allows SSO credentials to be passed anyway.
-ynh_app_setting_set $app unprotected_uris "/"
+ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
#=================================================
# RELOAD NGINX
#=================================================
-ynh_print_info "Reloading nginx web server..."
+ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
-systemctl reload nginx
+ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
-ynh_print_info "Installation of $app completed"
+ynh_script_progression --message="Installation of $app completed" --time --last
diff --git a/scripts/remove b/scripts/remove
index 365c59e..db0a37c 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -12,41 +12,41 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_print_info "Loading installation settings..."
+ynh_script_progression --message="Loading installation settings..." --time --weight=1
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get $app domain)
-db_name=$(ynh_app_setting_get $app db_name)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+
+#=================================================
+# REMOVE THE MYSQL DATABASE
+#=================================================
+ynh_script_progression --message="Removing the MySQL database..." --time --weight=1
+
+# Remove a database if it exists, along with the associated user
+ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
-ynh_print_info "Removing dependencies"
+ynh_script_progression --message="Removing dependencies..." --time --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
-#=================================================
-# REMOVE THE MYSQL DATABASE
-#=================================================
-ynh_print_info "Removing the MySQL database"
-
-# Remove a database if it exists, along with the associated user
-ynh_mysql_remove_db $db_name $db_name
-
#=================================================
# REMOVE APP MAIN DIR
#=================================================
-ynh_print_info "Removing app main directory"
+ynh_script_progression --message="Removing app main directory..." --time --weight=1
# Remove the app directory securely
-ynh_secure_remove "/var/www/$app"
+ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
-ynh_print_info "Removing nginx web server configuration"
+ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1
# Remove the dedicated nginx config
ynh_remove_nginx_config
@@ -54,23 +54,31 @@ ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
-ynh_print_info "Removing php-fpm configuration"
+ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
+#=================================================
+# REMOVE LOGROTATE CONFIGURATION
+#=================================================
+ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1
+
+# Remove the app-specific logrotate config
+ynh_remove_logrotate
+
# Remove a cron file
-ynh_secure_remove "/etc/cron.d/$app"
+ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
-ynh_print_info "Removing the dedicated system user"
+ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
# Delete a system user
-ynh_system_user_delete $app
+ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
diff --git a/scripts/restore b/scripts/restore
index fb0e695..a4af90e 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -26,32 +26,33 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_print_info "Loading settings..."
+ynh_script_progression --message="Loading settings..." --time --weight=1
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-final_path=$(ynh_app_setting_get $app final_path)
-db_name=$(ynh_app_setting_get $app db_name)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+path_url=$(ynh_app_setting_get --app=$app --key=path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
-ynh_print_info "Validating restoration parameters..."
+ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
-ynh_webpath_available $domain $path_url \
- || ynh_die "Path not available: ${domain}${path_url}"
+ynh_webpath_available --domain=$domain --path_url=$path_url \
+ || ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
- || ynh_die "There is already a directory: $final_path "
+ || ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
-ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
+
+ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE MYSQL DATABASE
@@ -63,7 +64,9 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
-ynh_restore_file "$final_path"
+ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
+
+ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
@@ -84,10 +87,10 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
-ynh_print_info "Reinstalling dependencies..."
-
-ynh_install_app_dependencies 'php-mbstring|base-files(<<9.0)' php5-cli 'php5-imagick|php-imagick' php5-gd php5-mcrypt 'php-xml|base-files(<<9.0)'
+ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1
+# Define and install dependencies
+ynh_install_app_dependencies $pkg_dependencies
# set permission
chmod -R 775 $final_path/view/smarty3
@@ -103,6 +106,12 @@ ynh_restore_file "/etc/cron.d/$app"
chown -R $app: $final_path
+#=================================================
+# RESTORE THE LOGROTATE CONFIGURATION
+#=================================================
+
+ynh_restore_file --origin_path="/etc/logrotate.d/$app"
+
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
@@ -111,13 +120,13 @@ ynh_app_setting_set $app unprotected_uris "/"
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
-ynh_print_info "Reloading nginx web server and php-fpm..."
+ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
-systemctl reload php7.0-fpm
-systemctl reload nginx
+ynh_systemd_action --service_name=php7.0-fpm --action=reload
+ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
-ynh_print_info "Restoration completed for $app"
+ynh_script_progression --message="Restoration completed for $app" --time --last
diff --git a/scripts/upgrade b/scripts/upgrade
index 8e0da3b..7bbf069 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -12,33 +12,45 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_print_info "Loading installation settings..."
+ynh_script_progression --message="Loading installation settings..." --time --weight=1
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get $app domain)
-path_url=$(ynh_app_setting_get $app path)
-final_path=$(ynh_app_setting_get $app final_path)
-db_name=$(ynh_app_setting_get $app db_name)
-db_pwd=$(ynh_app_setting_get $app mysqlpwd)
-admin_mail=$(ynh_app_setting_get $app email)
-admin=$(ynh_app_setting_get $app admin)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+path_url=$(ynh_app_setting_get --app=$app --key=path)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
+admin_mail=$(ynh_app_setting_get --app=$app --key=email)
+admin=$(ynh_app_setting_get --app=$app --key=admin)
+
+#=================================================
+# CHECK VERSION
+#=================================================
+
+### This helper will compare the version of the currently installed app and the version of the upstream package.
+### $upgrade_type can have 2 different values
+### - UPGRADE_APP if the upstream app version has changed
+### - UPGRADE_PACKAGE if only the YunoHost package has changed
+### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
+### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
+upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
-ynh_print_info "Ensuring downward compatibility..."
+ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
# If db_name doesn't exist, create it
-if [ -z $db_name ]; then
- db_name=$(ynh_sanitize_dbid $app)
- ynh_app_setting_set $app db_name $db_name
+if [ -z "$db_name" ]; then
+ db_name=$(ynh_sanitize_dbid --db_name=$app)
+ ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
-ynh_print_info "Backing up the app before upgrading (may take a while)..."
+ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
@@ -49,21 +61,27 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
+
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
-path_url=$(ynh_normalize_url_path $path_url)
+# N.B. : this is for app installations before YunoHost 2.7
+# where this value might be something like /foo/ or foo/
+# instead of /foo ....
+# If nobody installed your app before 2.7, then you may
+# safely remove this line
+path_url=$(ynh_normalize_url_path --path_url=$path_url)
# Add Dependencies
ynh_install_app_dependencies 'php-mbstring|base-files(<<9.0)' php5-cli 'php5-imagick|php-imagick' php5-gd php5-mcrypt 'php-xml|base-files(<<9.0)'
# If final_path doesn't exist, create it
-if [ -z $final_path ]; then
+if [ -z "$final_path" ]; then
final_path=/var/www/$app
- ynh_app_setting_set $app final_path $final_path
+ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# Remove files for upgrade compatibilty from previous versions of Friendica
@@ -79,66 +97,88 @@ fi
# If admin_mail setting doesn't exist, create it
if [ -z $admin_mail ]; then
admin_mail=$(sudo yunohost user info $admin | grep "mail:" | cut -d' ' -f2)
- ynh_app_setting_set $app email $admin_mail
+ ynh_app_setting_set --app=$app --key=email --value=$admin_mail
fi
-# Download, check integrity, uncompress and patch the source from app.src
-ynh_setup_source "$final_path"
+#=================================================
+# DOWNLOAD, CHECK AND UNPACK SOURCE
+#=================================================
+
+if [ "$upgrade_type" == "UPGRADE_APP" ]
+then
+ ynh_script_progression --message="Upgrading source files..." --time --weight=1
+
+ # Download, check integrity, uncompress and patch the source from app.src
+ ynh_setup_source --dest_dir="$final_path"
+fi
# Copy config file for correct place
cp -f "/var/www/$app/config/local-sample.config.php" "/var/www/$app/config/local.config.php"
# Replace strings in config file
-ynh_replace_string "your.mysqlhost.com" "localhost" "$final_path/config/local.config.php"
-ynh_replace_string "mysqlusername" "$db_name" "$final_path/config/local.config.php"
-ynh_replace_string "mysqldatabasename" "$db_name" "$final_path/config/local.config.php"
-ynh_replace_string "mysqlpassword" "$db_pwd" "$final_path/config/local.config.php"
-ynh_replace_string "'admin_email' => ''," "'admin_email' => '$admin_mail'," "$final_path/config/local.config.php"
-ynh_replace_string "REGISTER_OPEN" "REGISTER_CLOSED" "$final_path/config/local.config.php"
+ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="mysqlusername" --replace_string="$db_name" --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="mysqldatabasename" --replace_string="$db_name" --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="mysqlpassword" --replace_string="$db_pwd" --target_file= "$final_path/config/local.config.php"
+ynh_replace_string --match_string="'admin_email' => ''," --replace_string="'admin_email' => '$admin_mail'," --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="REGISTER_OPEN" --replace_string="REGISTER_CLOSED" --target_file="$final_path/config/local.config.php"
#Copy Addons
rm -Rf "$final_path/addon"
-ynh_setup_source "$final_path/addon" "addons"
+ynh_setup_source --dest_dir="$final_path/addon" --source_id="addons"
# 3 - some extra folders
sudo chmod -R 775 $final_path/view/smarty3
-#=================================================
-# CREATE DEDICATED USER
-#=================================================
-ynh_print_info "Making sure dedicated system user exists..."
-
-# Create a dedicated user (if not existing)
-ynh_system_user_create $app
#=================================================
# NGINX CONFIGURATION
#=================================================
-ynh_print_info "Upgrading nginx web server configuration..."
+ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1
# Create a dedicated nginx config
ynh_add_nginx_config
+#=================================================
+# UPGRADE DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
+
+ynh_install_app_dependencies $pkg_dependencies
+
+#=================================================
+# CREATE DEDICATED USER
+#=================================================
+ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
+
+# Create a dedicated user (if not existing)
+ynh_system_user_create --username=$app
+
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
-ynh_print_info "Upgrading php-fpm configuration..."
+ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1
# Create a dedicated php-fpm config
ynh_add_fpm_config
+
+#=================================================
+# STORE THE CONFIG FILE CHECKSUM
+#=================================================
+
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
-ynh_backup_if_checksum_is_different "$final_path/config/local.config.php"
+ynh_backup_if_checksum_is_different --file="$final_path/config/local.config.php"
# Recalculate and store the checksum of the file for the next upgrade.
-ynh_store_file_checksum "$final_path/config/local.config.php"
+ynh_store_file_checksum --file="$final_path/config/local.config.php"
# Set up cron job
-ynh_replace_string "__YNH_WWW_PATH__" "$final_path" ../conf/poller-cron
-ynh_replace_string "__USER__" "$app" ../conf/poller-cron
-sudo cp ../conf/poller-cron /etc/cron.d/$app
+ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="$final_path" --target_file="../conf/poller-cron"
+ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/poller-cron"
+ynh_restore_file --origin_path="../conf/poller-cron" --dest_path="/etc/cron.d/$app"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
@@ -150,21 +190,21 @@ chown -R $app: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
-ynh_print_info "Upgrading SSOwat configuration..."
+ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1
# unprotected_uris allows SSO credentials to be passed anyway.
-ynh_app_setting_set $app skipped_uris "/"
-
+ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
#=================================================
# RELOAD NGINX
#=================================================
-ynh_print_info "Reloading nginx web server..."
+ynh_script_progression --message="Reloading nginx web server..." --time --weight=1
-systemctl reload nginx
+ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
-ynh_print_info "Upgrade of $app completed"
+ynh_script_progression --message="Upgrade of $app completed" --time --last
+
From 42bedb6ade855023c5ee709dbe8a14a7bb77e38e Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Fri, 10 Apr 2020 23:37:43 +0530
Subject: [PATCH 02/11] Remove duplicate dependencies from upgrade
---
scripts/upgrade | 4 ----
1 file changed, 4 deletions(-)
diff --git a/scripts/upgrade b/scripts/upgrade
index 7bbf069..635d147 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -74,10 +74,6 @@ ynh_abort_if_errors
# safely remove this line
path_url=$(ynh_normalize_url_path --path_url=$path_url)
-# Add Dependencies
-ynh_install_app_dependencies 'php-mbstring|base-files(<<9.0)' php5-cli 'php5-imagick|php-imagick' php5-gd php5-mcrypt 'php-xml|base-files(<<9.0)'
-
-
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/var/www/$app
From 561bb0afc087eb7286ac10bb2dcde6fe7444fd8d Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Sat, 11 Apr 2020 00:17:43 +0530
Subject: [PATCH 03/11] cp cron in upgrade
---
scripts/upgrade | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/upgrade b/scripts/upgrade
index 635d147..f4a7511 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -125,7 +125,7 @@ rm -Rf "$final_path/addon"
ynh_setup_source --dest_dir="$final_path/addon" --source_id="addons"
# 3 - some extra folders
-sudo chmod -R 775 $final_path/view/smarty3
+chmod -R 775 $final_path/view/smarty3
#=================================================
@@ -174,7 +174,7 @@ ynh_store_file_checksum --file="$final_path/config/local.config.php"
# Set up cron job
ynh_replace_string --match_string="__YNH_WWW_PATH__" --replace_string="$final_path" --target_file="../conf/poller-cron"
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/poller-cron"
-ynh_restore_file --origin_path="../conf/poller-cron" --dest_path="/etc/cron.d/$app"
+cp "../conf/poller-cron" "/etc/cron.d/$app"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
From 615cd562948ae21e73906e349bd9151eea262d0c Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Mon, 13 Apr 2020 04:09:04 +0530
Subject: [PATCH 04/11] added final_path parameter in remove
---
scripts/install | 2 +-
scripts/remove | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/install b/scripts/install
index 57ff2a0..700fc87 100644
--- a/scripts/install
+++ b/scripts/install
@@ -28,7 +28,7 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url='/'
admin=$YNH_APP_ARG_ADMIN
-admin_mail=$(sudo yunohost user info $admin | grep "mail:" | cut -d' ' -f2)
+admin_mail=$(yunohost user info $admin | grep "mail:" | cut -d' ' -f2)
is_public=1
database="1"
diff --git a/scripts/remove b/scripts/remove
index db0a37c..a807cca 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -18,6 +18,8 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+
#=================================================
# REMOVE THE MYSQL DATABASE
From 1805251664f2ed155b04e6f6594e21bb50b98c96 Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Mon, 20 Apr 2020 10:53:16 +0530
Subject: [PATCH 05/11] Forgot to updated addon sources and updated readme,
manifest
---
README.md | 27 ++++++++++++++++++++++-----
check_process | 2 +-
conf/addons.src | 4 ++--
manifest.json | 4 ++--
pull_request_template.md | 18 ++++++++++++++++++
5 files changed, 45 insertions(+), 10 deletions(-)
create mode 100644 pull_request_template.md
diff --git a/README.md b/README.md
index 072513d..cb7adce 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,12 @@
# Friendica social network for YunoHost
-[![Integration level](https://dash.yunohost.org/integration/friendica.svg)](https://ci-apps.yunohost.org/jenkins/job/friendica%20%28Community%29/lastBuild/consoleFull)
+[![Integration level](https://dash.yunohost.org/integration/friendica.svg)](https://dash.yunohost.org/appci/app/friendica)
[![Install Friendica with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=friendica)
+> *This package allow you to install Friendica quickly and simply on a YunoHost server.
+If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
+
[Friendica](http://friendi.ca/) integration for YunoHost
**Version:2020.03**
@@ -19,7 +22,10 @@ Before installing, read the [Friendica installation instructions](https://github
- SSL certificate validation requirement (now with support for [Let's Encrypt!](https://letsencrypt.org)). See Installation section below.
- Dedicated domain (must install under web root like **https://hub.example.com/** not **https://example.com/hub/** )
-Note:You can use accounts from YunoHost's LDAP. There are not yet active SSO.
+#### Multi-users support
+
+LDAP auth supported. There are not yet active SSO.
+
# To-do
- [ ] Fail2Ban support
@@ -30,9 +36,6 @@ Before installing, read the [Friendica installation instructions](https://github
### Register a new domain and add it to YunoHost
Friendica requires a dedicated domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Friendica uses the full domain and is installed on the root, you can create a subdomain such as friendica.domain.tld. Don't forget to update your DNS if you manage them manually.
-Friendica requires browser-approved SSL certificates. If you have certificates not issued by [Let's Encrypt](https://letsencrypt.org/), install them manually as usual.
-
-
### Install the Friendica application
Use the YunoHost admin panel to install Friendica by entering the GitHub repo address in the custom app URL
@@ -42,3 +45,17 @@ Make sure to select your domain from the previous section as the application dom
After the installation,login with the username provided at the time of the installaion with your SSO password.You can then create your profile and access the admin panel from the button in the center of the top nav bar, just adjecent to the search bar.(The admin panel don't have text,so don't get confuse with it)
Public users can register and use the instance as normal users. SSO users can login with there username and password as normal users too.
+
+Developers info
+----------------
+
+**Only if you want to use a testing branch for coding, instead of merging directly into master.**
+Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/friendica_ynh/tree/testing).
+
+To try the testing branch, please proceed like that.
+```
+sudo yunohost app install https://github.com/YunoHost-Apps/friendica_ynh/tree/testing --debug
+or
+sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/friendica_ynh/tree/testing --debug
+```
+
diff --git a/check_process b/check_process
index 0726b57..eb9fe54 100644
--- a/check_process
+++ b/check_process
@@ -10,7 +10,7 @@
setup_private=0
setup_public=1
upgrade=1
- upgrade=1 from_commit=1c018b9ed379e25d5bcab4bd27e9833feee9da68
+ upgrade=1 from_commit=3396188976f75170f2217fcc0e6c9b5f61f7b9e9
backup_restore=1
multi_instance=1
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
diff --git a/conf/addons.src b/conf/addons.src
index 78d838c..9ce9c67 100644
--- a/conf/addons.src
+++ b/conf/addons.src
@@ -1,5 +1,5 @@
-SOURCE_URL=https://github.com/friendica/friendica-addons/archive/2019.12.tar.gz
-SOURCE_SUM=c206a8b0845a4a5102b5a9d1881d039472d734c70d5f1dd52e44684955b6a7f2
+SOURCE_URL=https://github.com/friendica/friendica-addons/archive/2020.03.tar.gz
+SOURCE_SUM=937aa87bbe8a40ef78348387969e77ac0422d2ce8bd00579aaf4ce45ea1362da
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
diff --git a/manifest.json b/manifest.json
index af61b28..48d1380 100644
--- a/manifest.json
+++ b/manifest.json
@@ -8,13 +8,13 @@
},
"url": "http://friendi.ca",
"license": "free",
- "version": "2020.03",
+ "version": "2020.03-ynh2",
"maintainer": {
"name": "Anmol Sharma",
"email": "anmol@datamol.org"
},
"requirements": {
- "yunohost": ">= 2.7.2"
+ "yunohost": ">= 3.5"
},
"previous_maintainers": {
"name": "aymhce",
diff --git a/pull_request_template.md b/pull_request_template.md
new file mode 100644
index 0000000..0287f9f
--- /dev/null
+++ b/pull_request_template.md
@@ -0,0 +1,18 @@
+## Problem
+- *Description of why you made this PR*
+
+## Solution
+- *And how do you fix that problem*
+
+## PR Status
+- [ ] Code finished.
+- [ ] Tested with Package_check.
+- [ ] Fix or enhancement tested.
+- [ ] Upgrade from last version tested.
+- [ ] Can be reviewed and tested.
+
+## Package_check results
+---
+*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
+
+[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/REPLACEBYYOURAPP_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/REPLACEBYYOURAPP_ynh%20PR-NUM-%20(USERNAME)/)
From 24520f0641b6146675543def504e73ef45b5b0f8 Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Thu, 23 Apr 2020 04:17:10 +0530
Subject: [PATCH 06/11] fix ldap and php version 7.0
---
conf/nginx.conf | 2 +-
conf/php-fpm.conf | 108 ++++++++++++++++++++++++++++------------------
scripts/install | 4 +-
3 files changed, 70 insertions(+), 44 deletions(-)
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 5bb7945..45ea394 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -71,7 +71,7 @@ location __PATH__ {
location ~* \.php$ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
try_files $uri =404;
- fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock;
+ fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf
index 57affa6..ab5dca9 100644
--- a/conf/php-fpm.conf
+++ b/conf/php-fpm.conf
@@ -1,10 +1,11 @@
; Start a new pool named 'www'.
-; the variable $pool can we used in any directive and will be replaced by the
+; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[__NAMETOCHANGE__]
; Per pool prefix
; It only applies on the following directives:
+; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
@@ -24,28 +25,35 @@ group = __USER__
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
-; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
+; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
-; 'port' - to listen on a TCP socket to all addresses on a
-; specific port;
+; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
+; a specific port;
+; 'port' - to listen on a TCP socket to all addresses
+; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
-listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock
+listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock
-; Set listen(2) backlog. A value of '-1' means unlimited.
-; Default Value: 128 (-1 on FreeBSD and OpenBSD)
-;listen.backlog = 128
+; Set listen(2) backlog.
+; Default Value: 511 (-1 on FreeBSD and OpenBSD)
+;listen.backlog = 511
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
-; BSD-derived systems allow connections regardless of permissions.
+; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660
-
-; List of ipv4 addresses of FastCGI clients which are allowed to connect.
+; When POSIX Access Control Lists are supported you can set them using
+; these options, value is a comma separated list of user/group names.
+; When set, listen.owner and listen.group are ignored
+;listen.acl_users =
+;listen.acl_groups =
+
+; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
@@ -59,7 +67,13 @@ listen.group = www-data
; - The pool processes will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
-; priority = -19
+; process.priority = -19
+
+; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
+; or group is differrent than the master process user. It allows to create process
+; core dump and ptrace the process for the pool user.
+; Default Value: no
+; process.dumpable = yes
; Choose how the process manager will control the number of child processes.
; Possible Values:
@@ -96,7 +110,7 @@ pm = dynamic
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
-pm.max_children = 10
+pm.max_children = 5
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
@@ -117,12 +131,12 @@ pm.max_spare_servers = 3
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
-
+
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
-pm.max_requests = 500
+;pm.max_requests = 500
; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following informations:
@@ -170,7 +184,7 @@ pm.max_requests = 500
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
-; Example:
+; Example:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
@@ -215,7 +229,7 @@ pm.max_requests = 500
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
-; It's available in: ${prefix}/share/fpm/status.html
+; It's available in: /usr/share/php/7.0/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
@@ -275,7 +289,7 @@ pm.max_requests = 500
; - %{megabytes}M
; - %{mega}M
; %n: pool name
-; %o: ouput header
+; %o: output header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
@@ -283,7 +297,7 @@ pm.max_requests = 500
; - ....
; %p: PID of the child that serviced the request
; %P: PID of the parent of the child that serviced the request
-; %q: the query string
+; %q: the query string
; %Q: the '?' character if query string exists
; %r: the request URI (without the query string, see %q and %Q)
; %R: remote IP address
@@ -291,47 +305,51 @@ pm.max_requests = 500
; %t: server time the request was received
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
+; The strftime(3) format must be encapsuled in a %{}t tag
+; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
+; The strftime(3) format must be encapsuled in a %{}t tag
+; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
; %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
-
+
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
-slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log
-
+;slowlog = log/$pool.log.slow
+
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
-request_slowlog_timeout = 5s
-
+;request_slowlog_timeout = 0
+
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_terminate_timeout = 1d
-
+
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
-
+
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
-
+
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
-; Note: chrooting is a great security feature and should be used whenever
+; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
@@ -347,16 +365,25 @@ chdir = __FINALPATH__
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
-catch_workers_output = yes
+;catch_workers_output = yes
+
+; Clear environment in FPM workers
+; Prevents arbitrary environment variables from reaching FPM worker processes
+; by clearing the environment in workers before env vars specified in this
+; pool configuration are added.
+; Setting to "no" will make all environment variables available to PHP code
+; via getenv(), $_ENV and $_SERVER.
+; Default Value: yes
+;clear_env = no
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
-; exectute php code.
+; execute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
-;security.limit_extensions = .php .php3 .php4 .php5
-
+;security.limit_extensions = .php .php3 .php4 .php5 .php7
+
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
@@ -370,7 +397,7 @@ catch_workers_output = yes
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
-; be overwritten from PHP call 'ini_set'.
+; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
@@ -392,13 +419,12 @@ catch_workers_output = yes
;php_admin_value[memory_limit] = 32M
; Common values to change to increase file upload limit
-; upload_max_filesize = 50M
-; post_max_size = 50M
-; mail.add_x_header = Off
+; php_admin_value[upload_max_filesize] = 50M
+; php_admin_value[post_max_size] = 50M
+; php_admin_flag[mail.add_x_header] = Off
; Other common parameters
-; max_execution_time = 600
-; max_input_time = 300
-; memory_limit = 256M
-; short_open_tag = On
-
+; php_admin_value[max_execution_time] = 600
+; php_admin_value[max_input_time] = 300
+; php_admin_value[memory_limit] = 256M
+; php_admin_flag[short_open_tag] = On
diff --git a/scripts/install b/scripts/install
index 700fc87..dee2fff 100644
--- a/scripts/install
+++ b/scripts/install
@@ -149,7 +149,7 @@ ynh_replace_string --match_string="mysqlusername" --replace_string="$db_nam
ynh_replace_string --match_string="mysqldatabasename" --replace_string="$db_name" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="mysqlpassword" --replace_string="$db_pwd" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="'admin_email' => ''," --replace_string="'admin_email' => '$admin_mail'," --target_file="$final_path/config/local.config.php"
-ynh_replace_string --match_string="REGISTER_OPEN" --replace_string="REGISTER_CLOSED" --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="OPEN" --replace_string="CLOSED" --target_file="$final_path/config/local.config.php"
# init db
@@ -210,7 +210,7 @@ ynh_store_file_checksum --file="$final_path/config/local.config.php"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
-
+ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" <<< "INSERT INTO `addon` (`id`, `name`, `version`, `installed`, `hidden`, `timestamp`, `plugin_admin`) VALUES (NULL, 'ldapauth', '', '1', '0', '1', '0');"
chown -R $app: $final_path
#=================================================
From ccc5ba1fb51acdd60386c2b5176594e69a73e50f Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Thu, 23 Apr 2020 04:30:59 +0530
Subject: [PATCH 07/11] fix mysql
---
scripts/install | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/install b/scripts/install
index dee2fff..21ea4d3 100644
--- a/scripts/install
+++ b/scripts/install
@@ -210,7 +210,7 @@ ynh_store_file_checksum --file="$final_path/config/local.config.php"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
-ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" <<< "INSERT INTO `addon` (`id`, `name`, `version`, `installed`, `hidden`, `timestamp`, `plugin_admin`) VALUES (NULL, 'ldapauth', '', '1', '0', '1', '0');"
+ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" <<< INSERT INTO `addon` (`id`, `name`, `version`, `installed`, `hidden`, `timestamp`, `plugin_admin`) VALUES (NULL, 'ldapauth', '', '1', '0', '1', '0');
chown -R $app: $final_path
#=================================================
From 87ab7677eb2c873ff4cbf350b654559f6d90fd98 Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Thu, 23 Apr 2020 04:48:14 +0530
Subject: [PATCH 08/11] fix mysql_2
---
scripts/install | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/install b/scripts/install
index 21ea4d3..6317dbf 100644
--- a/scripts/install
+++ b/scripts/install
@@ -210,7 +210,7 @@ ynh_store_file_checksum --file="$final_path/config/local.config.php"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
-ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" <<< INSERT INTO `addon` (`id`, `name`, `version`, `installed`, `hidden`, `timestamp`, `plugin_admin`) VALUES (NULL, 'ldapauth', '', '1', '0', '1', '0');
+ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" <<< "INSERT INTO addon (id, name, version, installed, hidden, timestamp, plugin_admin) VALUES (NULL, 'ldapauth', '', '1', '0', '1', '0');"
chown -R $app: $final_path
#=================================================
From c4baf754a07912d605a3ec5afc136438d28ffdb0 Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Thu, 23 Apr 2020 17:16:17 +0530
Subject: [PATCH 09/11] fix mysql_3
---
scripts/install | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/scripts/install b/scripts/install
index 6317dbf..8a52d4c 100644
--- a/scripts/install
+++ b/scripts/install
@@ -210,9 +210,14 @@ ynh_store_file_checksum --file="$final_path/config/local.config.php"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
-ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" <<< "INSERT INTO addon (id, name, version, installed, hidden, timestamp, plugin_admin) VALUES (NULL, 'ldapauth', '', '1', '0', '1', '0');"
+ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" << EOF
+REPLACE INTO `addon` SET
+`name` = 'ldapauth',
+`installed` = 1,
+`timestamp` = UNIX_TIMESTAMP(),
+`plugin_admin` = 0;
+EOF
chown -R $app: $final_path
-
#=================================================
# SETUP SSOWAT
#=================================================
From cde0452df5ca87454ec6de99886701be432671a9 Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Thu, 23 Apr 2020 22:23:35 +0530
Subject: [PATCH 10/11] fix mysql_4
---
scripts/install | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/scripts/install b/scripts/install
index 8a52d4c..a29b22e 100644
--- a/scripts/install
+++ b/scripts/install
@@ -210,13 +210,7 @@ ynh_store_file_checksum --file="$final_path/config/local.config.php"
# Run composer
(cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
-ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" << EOF
-REPLACE INTO `addon` SET
-`name` = 'ldapauth',
-`installed` = 1,
-`timestamp` = UNIX_TIMESTAMP(),
-`plugin_admin` = 0;
-EOF
+ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" <<< "INSERT INTO addon (id, name, version, installed, hidden, timestamp, plugin_admin) VALUES (NULL, 'ldapauth', '', '1', '0', UNIX_TIMESTAMP(), '0');"
chown -R $app: $final_path
#=================================================
# SETUP SSOWAT
From 7084c324f075bd0e8322c251d1b5dcb88b9d69f2 Mon Sep 17 00:00:00 2001
From: anmol26s <5068843+anmol26s@users.noreply.github.com>
Date: Fri, 24 Apr 2020 01:05:23 +0530
Subject: [PATCH 11/11] Removed logrotate
---
scripts/restore | 6 ------
scripts/upgrade | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/scripts/restore b/scripts/restore
index a4af90e..971f179 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -106,12 +106,6 @@ ynh_restore_file "/etc/cron.d/$app"
chown -R $app: $final_path
-#=================================================
-# RESTORE THE LOGROTATE CONFIGURATION
-#=================================================
-
-ynh_restore_file --origin_path="/etc/logrotate.d/$app"
-
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
diff --git a/scripts/upgrade b/scripts/upgrade
index f4a7511..792e153 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -117,7 +117,7 @@ ynh_replace_string --match_string="mysqlusername" --replace_string="$db_nam
ynh_replace_string --match_string="mysqldatabasename" --replace_string="$db_name" --target_file="$final_path/config/local.config.php"
ynh_replace_string --match_string="mysqlpassword" --replace_string="$db_pwd" --target_file= "$final_path/config/local.config.php"
ynh_replace_string --match_string="'admin_email' => ''," --replace_string="'admin_email' => '$admin_mail'," --target_file="$final_path/config/local.config.php"
-ynh_replace_string --match_string="REGISTER_OPEN" --replace_string="REGISTER_CLOSED" --target_file="$final_path/config/local.config.php"
+ynh_replace_string --match_string="OPEN" --replace_string="CLOSED" --target_file="$final_path/config/local.config.php"
#Copy Addons