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 'testing'

This commit is contained in:
anmol 2019-03-12 16:41:55 +05:30
commit 975893dd0f
12 changed files with 209 additions and 94 deletions

View file

@ -6,12 +6,12 @@
[Friendica](http://friendi.ca/) integration for YunoHost<br> [Friendica](http://friendi.ca/) integration for YunoHost<br>
**Version:2018.09**<br><br> **Version:2019.01**<br><br>
Current snapshot in *sources*: Current snapshot in *sources*:
* https://github.com/friendica/friendica: 2018.09 (commit c48fcd4a8f329946cdf09d214596ecf29e859cff) * https://github.com/friendica/friendica: 2019.01
* https://github.com/friendica/friendica-addons: 2018.09 (commit 9c275a4185956fb2ca790263fb72f6da6311742f) * https://github.com/friendica/friendica-addons: 2018.01
## Important Notes ## Important Notes
@ -22,11 +22,8 @@ Before installing, read the [Friendica installation instructions](https://github
<b>Note:</b>You can use accounts from YunoHost's LDAP. There are not yet active SSO.<br><br> <b>Note:</b>You can use accounts from YunoHost's LDAP. There are not yet active SSO.<br><br>
# To-do # To-do
- [X] Installation and remove script. - [ ] Fail2Ban support
- [X] Ldap integration.
- [X] Upgrade script
- [X] Backup and restore script.
- [X] Multi-instance
## Installation ## Installation

View file

@ -1,5 +1,4 @@
;; Default test ;; Test complet
auto_remove=1
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
admin="john" (USER) admin="john" (USER)
@ -11,18 +10,19 @@
setup_private=0 setup_private=0
setup_public=1 setup_public=1
upgrade=1 upgrade=1
upgrade=1 from_commit=1c018b9ed379e25d5bcab4bd27e9833feee9da68
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
incorrect_path=1 incorrect_path=1
port_already_use=0 port_already_use=0
change_url=0 change_url=0
;;; Levels ;;; Levels
Level 1=auto Level 1=auto
Level 2=auto Level 2=auto
Level 3=auto Level 3=auto
# There is LDAP support for the app # There is LDAP support for the app
Level 4=1 Level 4=1
# Level 5:
Level 5=auto Level 5=auto
Level 6=auto Level 6=auto
Level 7=auto Level 7=auto
@ -31,4 +31,4 @@
Level 10=0 Level 10=0
;;; Options ;;; Options
Email=anmol@datamol.org Email=anmol@datamol.org
Notification=none Notification=change

11
conf/addon.config.php Normal file
View file

@ -0,0 +1,11 @@
<?php
// Addon configuration
// Copy this configuration file to addon.config.php and edit it if you want to configure addons, see below example for the twitter addon
return [
'ldapauth' => [
'ldap_server' => 'localhost',
'ldap_searchdn' => 'ou=users,dc=yunohost,dc=org',
'ldap_userattr' => 'uid',
'ldap_autocreateaccount_emailattribute' => 'mail',
],
];

View file

@ -1,21 +0,0 @@
<?php return <<<INI
; Copy this configuration file to addon.ini.php and edit it if you want to configure addons, see below example for the twitter addon
;[twitter]
;consumerkey = localhost
;consumersecret = mysqlusername
[system]
addon = ldapauth
[ldapauth]
ldap_server = 'localhost'
ldap_searchdn = 'ou=users,dc=yunohost,dc=org'
ldap_userattr = 'uid'
ldap_autocreateaccount = 'true'
ldap_autocreateaccount_emailattribute = 'mail'
INI;
// Keep this line

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/friendica/friendica-addons/archive/2018.09.zip SOURCE_URL=https://github.com/friendica/friendica-addons/archive/2019.01.zip
SOURCE_SUM=4862f5d8fb46375ea0232ab3bf6c012153371e51d6d1505bc25a696a7aefc82a SOURCE_SUM=23edfeddf58de1f605f8cb71603fbb31f415641b76f09a102e4bdb2ec78d508d
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -1,6 +1,6 @@
SOURCE_URL=https://github.com/friendica/friendica/archive/2018.09.zip SOURCE_URL=https://friendi.ca/wp-content/uploads/2019/02/friendica-full-2019.01.tar.gz
SOURCE_SUM=02407b87da8d645faaa88429970617231d71bb7611ebe2770f5cca5c54e60e2e SOURCE_SUM=895025c0adf042b6139ed3e7c4674a49d3a0237ce3490a367be681e6310c92a3
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME= SOURCE_FILENAME=

View file

@ -8,7 +8,7 @@
}, },
"url": "http://friendi.ca", "url": "http://friendi.ca",
"license": "free", "license": "free",
"version": "2018.09", "version": "2019.01",
"maintainer": { "maintainer": {
"name": "Anmol Sharma", "name": "Anmol Sharma",
"email": "anmol@datamol.org" "email": "anmol@datamol.org"

View file

@ -6,24 +6,25 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Get the _common.sh file if it's not in the current directory source ../settings/scripts/_common.sh
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -37,24 +38,34 @@ db_pwd=$(ynh_app_setting_get $app mysqlpwd)
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Backing up the main app directory..."
ynh_backup "$final_path" ynh_backup "$final_path"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP THE PHP-FPM CONFIGURATION # BACKUP THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Backing up php-fpm configuration..."
ynh_backup "/etc/php5/fpm/pool.d/$app.conf" ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db "$db_name" > db.sql ynh_mysql_dump_db "$db_name" > db.sql
# Backup cron job # Backup cron job
ynh_backup "/etc/cron.d/$app" ynh_backup "/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will now copy those files to the archive)."

View file

@ -13,6 +13,10 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -44,21 +48,23 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_print_info "Validating installation parameters..."
# Normalize the url path syntax # Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url) path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register $app $domain $path_url
### 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 final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die "This path already contains a folder"
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_print_info "Storing installation settings..."
ynh_app_setting_set $app domain $domain ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set $app path $path_url
@ -70,13 +76,21 @@ ynh_app_setting_set $app database $database
#================================================= #=================================================
# INSTALL DEPENDENCIES # 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_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)'
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
# If your app uses a MySQL database, you can use these lines to bootstrap ynh_print_info "Creating a MySQL database..."
# a database, an associated user and save the password in app settings ### 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,
### and will be available as $db_pwd
### If you're not using these lines:
### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
### - 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) db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name ynh_app_setting_set $app db_name $db_name
@ -85,6 +99,11 @@ ynh_mysql_setup_db $db_name $db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info "Setting up source files..."
### `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 final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
@ -98,30 +117,34 @@ ynh_setup_source "$final_path/addon" "addons"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Configuring nginx web server..."
### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
# configure friendica # configure friendica
sudo cp -f "/var/www/$app/config/local-sample.ini.php" "/var/www/$app/config/local.ini.php" 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.ini.php" ynh_replace_string "your.mysqlhost.com" "localhost" "$final_path/config/local.config.php"
ynh_replace_string "mysqlusername" "$db_name" "$final_path/config/local.ini.php" ynh_replace_string "mysqlusername" "$db_name" "$final_path/config/local.config.php"
ynh_replace_string "mysqldatabasename" "$db_name" "$final_path/config/local.ini.php" ynh_replace_string "mysqldatabasename" "$db_name" "$final_path/config/local.config.php"
ynh_replace_string "mysqlpassword" "$db_pwd" "$final_path/config/local.ini.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.ini.php" ynh_replace_string "'admin_email' => ''," "'admin_email' => '$admin_mail'," "$final_path/config/local.config.php"
ynh_replace_string "register_policy = REGISTER_OPEN" "register_policy = REGISTER_CLOSED" "$final_path/config/local.ini.php" ynh_replace_string "REGISTER_OPEN" "REGISTER_CLOSED" "$final_path/config/local.config.php"
# init db # init db
ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "$final_path/database.sql" ynh_mysql_connect_as "$db_name" "$db_pwd" "$db_name" < "$final_path/database.sql"
# addon config # addon config
sudo cp "../conf/addon.ini.php" "$final_path/config/." sudo cp "../conf/addon.config.php" "$final_path/config/."
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create $app ynh_system_user_create $app
@ -129,12 +152,22 @@ ynh_system_user_create $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Configuring php-fpm..."
### `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
### 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
### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
### With the reload at the end of the script.
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config
# set permission
sudo chown -R www-data:www-data $final_path sudo chown -R www-data:www-data $final_path
# 3 - some extra folders # 3 - some extra folders
@ -147,14 +180,19 @@ ynh_replace_string "__USER__" "$app" ../conf/poller-cron
sudo cp ../conf/poller-cron /etc/cron.d/$app sudo cp ../conf/poller-cron /etc/cron.d/$app
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
### `ynh_store_file_checksum` is used to store the checksum of a file.
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
### 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 # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/config/local.ini.php" ynh_store_file_checksum "$final_path/config/local.config.php"
# Run composer # Run composer
(cd $final_path && sudo php bin/composer.phar install) (cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
chown -R $app: $final_path chown -R $app: $final_path
@ -170,6 +208,12 @@ ynh_app_setting_set $app unprotected_uris "/"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
sudo systemctl reload php5-fpm ynh_print_info "Reloading nginx web server..."
sudo systemctl reload nginx
sudo yunohost app ssowatconf systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"

View file

@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -21,6 +22,7 @@ db_name=$(ynh_app_setting_get $app db_name)
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Removing dependencies"
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -28,6 +30,7 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info "Removing the MySQL database"
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_name $db_name ynh_mysql_remove_db $db_name $db_name
@ -35,6 +38,7 @@ ynh_mysql_remove_db $db_name $db_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Removing app main directory"
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "/var/www/$app" ynh_secure_remove "/var/www/$app"
@ -42,6 +46,7 @@ ynh_secure_remove "/var/www/$app"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing nginx web server configuration"
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -49,6 +54,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing php-fpm configuration"
# Remove the dedicated php-fpm config # Remove the dedicated php-fpm config
ynh_remove_fpm_config ynh_remove_fpm_config
@ -61,6 +67,13 @@ ynh_secure_remove "/etc/cron.d/$app"
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Removing the dedicated system user"
# Delete a system user # Delete a system user
ynh_system_user_delete $app ynh_system_user_delete $app
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"

View file

@ -6,25 +6,28 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
# Get the _common.sh file if it's not in the current directory source ../settings/scripts/_common.sh
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
@ -36,7 +39,9 @@ db_name=$(ynh_app_setting_get $app db_name)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ ynh_print_info "Validating restoration parameters..."
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path " || ynh_die "There is already a directory: $final_path "
@ -63,6 +68,7 @@ ynh_restore_file "$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create $app
@ -71,13 +77,14 @@ ynh_system_user_create $app
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # 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_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)'
@ -92,11 +99,25 @@ ynh_restore_file "/etc/cron.d/$app"
# Run composer # Run composer
(cd $final_path && sudo php bin/composer.phar install) (cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
chown -R $app: $final_path
# unprotected_uris allows SSO credentials to be passed anyway. # unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/" ynh_app_setting_set $app unprotected_uris "/"
# And Reload services #=================================================
sudo service php5-fpm reload # GENERIC FINALIZATION
sudo service nginx reload #=================================================
sudo yunohost app ssowatconf # RELOAD NGINX AND PHP-FPM
#=================================================
ynh_print_info "Reloading nginx web server and php-fpm..."
systemctl reload php7.0-fpm
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed for $app"

View file

@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -23,9 +24,21 @@ db_pwd=$(ynh_app_setting_get $app mysqlpwd)
admin_mail=$(ynh_app_setting_get $app email) admin_mail=$(ynh_app_setting_get $app email)
admin=$(ynh_app_setting_get $app admin) admin=$(ynh_app_setting_get $app admin)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info "Ensuring downward compatibility..."
# 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
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_print_info "Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -52,11 +65,19 @@ if [ -z $final_path ]; then
final_path=/var/www/$app final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app final_path $final_path
fi fi
# Remove files for upgrade compatibilty from previous versions of Friendica
if [ -f $final_path/.htconfig.php ]; then if [ -f $final_path/.htconfig.php ]; then
rm "$final_path/.htconfig.php" rm "$final_path/.htconfig.php"
fi fi
if [ -z $admin_mail ]; then # If admin_mail setting doesn't exist if [ -f $final_path/.htconfig.php ]; then
rm "$final_path/config/local.ini.php"
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) 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 email $admin_mail
fi fi
@ -65,15 +86,15 @@ fi
ynh_setup_source "$final_path" ynh_setup_source "$final_path"
# Copy config file for correct place # Copy config file for correct place
cp -f "/var/www/$app/config/local-sample.ini.php" "/var/www/$app/config/local.ini.php" cp -f "/var/www/$app/config/local-sample.config.php" "/var/www/$app/config/local.config.php"
# Replace strings in config file # Replace strings in config file
ynh_replace_string "your.mysqlhost.com" "localhost" "$final_path/config/local.ini.php" ynh_replace_string "your.mysqlhost.com" "localhost" "$final_path/config/local.config.php"
ynh_replace_string "mysqlusername" "$db_name" "$final_path/config/local.ini.php" ynh_replace_string "mysqlusername" "$db_name" "$final_path/config/local.config.php"
ynh_replace_string "mysqldatabasename" "$db_name" "$final_path/config/local.ini.php" ynh_replace_string "mysqldatabasename" "$db_name" "$final_path/config/local.config.php"
ynh_replace_string "mysqlpassword" "$db_pwd" "$final_path/config/local.ini.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.ini.php" ynh_replace_string "'admin_email' => ''," "'admin_email' => '$admin_mail'," "$final_path/config/local.config.php"
ynh_replace_string "register_policy = REGISTER_OPEN" "register_policy = REGISTER_CLOSED" "$final_path/config/local.ini.php" ynh_replace_string "REGISTER_OPEN" "REGISTER_CLOSED" "$final_path/config/local.config.php"
#Copy Addons #Copy Addons
@ -86,24 +107,33 @@ sudo chmod -R 775 $final_path/view/smarty3
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Making sure dedicated system user exists..."
# Create a system user # Create a dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create $app
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Upgrading nginx web server configuration..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading php-fpm configuration..."
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$final_path/config/local.ini.php" ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
# Recalculate and store the config file checksum into the app settings ### 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_store_file_checksum "$final_path/config/local.ini.php" ynh_backup_if_checksum_is_different "$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"
# Set up cron job # Set up cron job
ynh_replace_string "__YNH_WWW_PATH__" "$final_path" ../conf/poller-cron ynh_replace_string "__YNH_WWW_PATH__" "$final_path" ../conf/poller-cron
@ -112,6 +142,7 @@ sudo cp ../conf/poller-cron /etc/cron.d/$app
# Run composer # Run composer
(cd $final_path && sudo php bin/composer.phar install) (cd $final_path && sudo php bin/composer.phar install)
(cd $final_path && sudo bin/console config system addon ldapauth)
# Set app as owner # Set app as owner
chown -R $app: $final_path chown -R $app: $final_path
@ -119,13 +150,21 @@ chown -R $app: $final_path
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_print_info "Upgrading SSOwat configuration..."
# unprotected_uris allows SSO credentials to be passed anyway. # unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app skipped_uris "/" ynh_app_setting_set $app skipped_uris "/"
# Reload services #=================================================
sudo service php5-fpm reload || true # RELOAD NGINX
sudo service nginx reload || true #=================================================
sudo yunohost app ssowatconf ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"