1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pixelfed_ynh.git synced 2024-09-03 20:06:04 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2019-05-17 01:02:03 +02:00
parent ad803a74ba
commit 1f1a2e6c07
8 changed files with 194 additions and 224 deletions

View file

@ -11,19 +11,6 @@ The federated image sharing service Pixelfed, for YunoHost
**Shipped version:** 0.9.0
I'm waiting for an official release (alpha/beta or stable) to invest more time on this package.
Don't hesitate to give a hand if you wish, I assume only the nginx file needs improvments.
# State of this package
* works fine:
* [x] basic install/remove process
* [x] backup/restore
* to be confirmed
* [ ] fail2ban support
## Screenshots
![](https://camo.githubusercontent.com/c1c2e74057dcff57e103fcbb3239840802fcf752/68747470733a2f2f706978656c6665642e6e7963332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f6d656469612f53637265656e25323053686f74253230323031392d30322d30352532306174253230362e33342e3539253230504d2e706e67)
@ -53,15 +40,15 @@ To change that setting, edit `/var/www/pixelfed/.env` and set `OPEN_REGISTRATION
#### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pixelfed%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/pixelfed/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pixelfed%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pixelfed/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/pixelfed%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/pixelfed/)
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/pixelfed/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pixelfed/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/pixelfed/)
## Links
* Report a bug about this package: https://github.com/YunoHost-Apps/pixelfed_ynh
* Pixelfed website: https://pixelfed.org
* Pixelfed github website: https://github.com/pixelfed/pixelfed
* Upstream app repository: https://github.com/pixelfed/pixelfed
* YunoHost website: https://yunohost.org
---

View file

@ -57,11 +57,11 @@ ynh_install_composer () {
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$workdir/.composer" \
php${phpversion} -- --quiet --install-dir="$workdir" \
|| ynh_die "Unable to install Composer."
|| ynh_die --message="Unable to install Composer."
# update dependencies to create composer.lock
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \
|| ynh_die "Unable to update core dependencies with Composer."
|| ynh_die --message="Unable to update core dependencies with Composer."
}
@ -85,7 +85,7 @@ ynh_install_php () {
if [ "$phpversion" == "7.0" ]
then
ynh_die "Do not use ynh_install_php to install php7.0"
ynh_die --message="Do not use ynh_install_php to install php7.0"
fi
# Store the ID of this app and the version of php requested for it

View file

@ -20,46 +20,46 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_print_info --message="Loading installation settings..."
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)
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)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_print_info "Backing up the main app directory..."
ynh_print_info --message="Backing up the main app directory..."
ynh_backup "$final_path"
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_print_info "Backing up nginx web server configuration..."
ynh_print_info --message="Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
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_print_info --message="Backing up php-fpm configuration..."
ynh_backup "/etc/php/7.2/fpm/pool.d/$app.conf"
ynh_backup --src_path="/etc/php/7.2/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================
ynh_print_info "Backing up the PostgreSQL database..."
ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db "$db_name" > db.sql
ynh_psql_dump_db --database="$db_name" > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -24,14 +24,14 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_print_info --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get "$app" final_path)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
# Add settings here as needed by your application
#db_name=$(ynh_app_setting_get "$app" db_name)
#db_pwd=$(ynh_app_setting_get $app db_pwd)
#db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
#db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd)
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
@ -48,7 +48,7 @@ fi
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_print_info "Updating nginx web server configuration..."
ynh_print_info --message="Updating nginx web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -56,10 +56,10 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum "$nginx_conf_path"
ynh_delete_file_checksum --file="$nginx_conf_path"
mv "$nginx_conf_path" "/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
@ -69,17 +69,19 @@ fi
#=================================================
config="$final_path/.env"
ynh_replace_string "APP_URL=.*" "APP_URL=https://$new_domain" "$config"
ynh_replace_string "ADMIN_DOMAIN=.*" "ADMIN_DOMAIN=\"$new_domain\"" "$config"
ynh_replace_string "APP_DOMAIN=.*" "APP_DOMAIN=\"$new_domain\"" "$config"
ynh_replace_string "MAIL_FROM_ADDRESS=.*" "MAIL_FROM_ADDRESS=\"pixelfed@$new_domain\"" "$config"
ynh_replace_string --match_string="APP_URL=.*" --replace_string="APP_URL=https://$new_domain" --target_file="$config"
ynh_replace_string --match_string="ADMIN_DOMAIN=.*" --replace_string="ADMIN_DOMAIN=\"$new_domain\"" --target_file="$config"
ynh_replace_string --match_string="APP_DOMAIN=.*" --replace_string="APP_DOMAIN=\"$new_domain\"" --target_file="$config"
ynh_replace_string --match_string="MAIL_FROM_ADDRESS=.*" --replace_string="MAIL_FROM_ADDRESS=\"pixelfed@$new_domain\"" --target_file="$config"
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
# STORE THE CONFIG FILE CHECKSUM
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config"
ynh_backup_if_checksum_is_different --file="$config"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$config"
#=================================================
# APPLY CHANGES
@ -92,17 +94,18 @@ pushd "$final_path"
php7.2 artisan route:cache
php7.2 artisan horizon:purge
popd
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Change of URL completed for $app"
ynh_print_info --message="Change of URL completed for $app"

View file

@ -23,7 +23,7 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
app_key=$(ynh_string_random 32 | base64)
app_key=$(ynh_string_random --length=32 | base64)
app_key="base64:$app_key"
app=$YNH_APP_INSTANCE_NAME
@ -31,69 +31,67 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_print_info "Validating installation parameters..."
ynh_print_info --message="Validating installation parameters..."
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" "$domain" "$path_url"
ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set "$app" domain "$domain"
ynh_app_setting_set "$app" path "$path_url"
ynh_app_setting_set "$app" is_public "$is_public"
ynh_app_setting_set "$app" app_key "$app_key"
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=is_public --value="$is_public"
ynh_app_setting_set --app="$app" --key=app_key --value="$app_key"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info "Installing dependencies..."
ynh_print_info --message="Installing dependencies..."
ynh_install_app_dependencies "$pkg_dependencies"
#=================================================
# INSTALL PHP
#=================================================
ynh_print_info "Installing php..."
ynh_print_info --message="Installing php..."
ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies"
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_print_info "Creating a PostgreSQL database..."
ynh_print_info --message="Creating a PostgreSQL database..."
ynh_psql_test_if_first_run
db_name=$(ynh_sanitize_dbid "$app")
db_user=$db_name
db_pwd=$(ynh_string_random)
ynh_app_setting_set "$app" db_name "$db_name"
ynh_app_setting_set "$app" db_pwd "$db_pwd"
ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
ynh_app_setting_set --app="$app" --key=db_pwd --value="$db_pwd"
# Initialize database and store postgres password for upgrade
ynh_psql_setup_db "$db_user" "$db_name" "$db_pwd"
systemctl reload postgresql
ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
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"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx web server..."
ynh_print_info --message="Configuring nginx web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
@ -101,7 +99,7 @@ ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system user..."
ynh_print_info --message="Configuring system user..."
# Create a system user
ynh_system_user_create "$app"
@ -109,7 +107,7 @@ ynh_system_user_create "$app"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Configuring php-fpm..."
ynh_print_info --message="Configuring php-fpm..."
# Create a dedicated php-fpm config
ynh_add_fpm_config --phpversion="7.2"
@ -131,20 +129,20 @@ ynh_install_composer --phpversion="7.2" --workdir="$final_path"
config="$final_path/.env"
cp ../conf/.env "$config"
ynh_replace_string "__APP__" "$app" "$config"
ynh_replace_string "__APP_KEY__" "$app_key" "$config"
ynh_replace_string "__DOMAIN__" "$domain" "$config"
ynh_replace_string "__PATH__" "$path_url" "$config"
ynh_replace_string "__DB_NAME__" "$db_name" "$config"
ynh_replace_string "__DB_USER__" "$db_user" "$config"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$config"
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$config"
ynh_replace_string --match_string="__APP_KEY__" --replace_string="$app_key" --target_file="$config"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config"
ynh_store_file_checksum --file="$config"
#=================================================
# DEPLOYMENT
@ -174,24 +172,24 @@ chown -R "$app": "$final_path/storage/"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring SSOwat..."
ynh_print_info --message="Configuring SSOwat..."
# Make app public if necessary
if [ "$is_public" -eq 1 ]
then
# 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="/"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"
ynh_print_info --message="Installation of $app completed"

View file

@ -12,48 +12,29 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_print_info --message="Loading installation settings..."
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)
db_user=$db_name
final_path=$(ynh_app_setting_get "$app" final_path)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_print_info "Removing the PostgreSQL database"
ynh_print_info --message="Removing the PostgreSQL database..."
ynh_psql_execute_as_root "\connect $db_name
SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';"
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db "$db_user" "$db_name"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_print_info "Removing nginx web server configuration"
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Removing php-fpm configuration"
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_print_info "Removing dependencies"
ynh_print_info --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
@ -62,31 +43,47 @@ ynh_remove_php
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_print_info "Removing app main directory"
ynh_print_info --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove "$final_path"
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_print_info --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_print_info --message="Removing php-fpm configuration..."
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
#=================================================
# RESTART PHP-FPM 7.0 FPM
#=================================================
ynh_print_info --message="Start php7.0-fpm..."
#Sometimes with package_check php7.0-fpm fail to reload and stop. So starting the service, just in case.
ynh_systemd_action --service_name=php7.0-fpm --action=start
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info "Removing the dedicated system user"
ynh_print_info --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete "$app"
#=================================================
# START PHP-FPM 7.0 FPM
#=================================================
ynh_print_info "Start php7.0-fpm"
#Sometimes with package_check php7.0-fpm fail to reload and stop. So starting the service, just in case.
systemctl start php7.0-fpm
ynh_system_user_delete --username="$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"
ynh_print_info --message="Removal of $app completed"

View file

@ -20,25 +20,26 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading settings..."
ynh_print_info --message="Loading settings..."
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" db_pwd)
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_user=$db_name
db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_print_info "Validating restoration parameters..."
ynh_print_info --message="Validating restoration parameters..."
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
@ -46,22 +47,22 @@ test ! -d "$final_path" \
# 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 APP MAIN DIR
#=================================================
ynh_print_info "Restoring the app main directory..."
ynh_print_info --message="Restoring the app main directory..."
ynh_restore_file "$final_path"
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreating the dedicated system user..."
ynh_print_info --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create "$app"
ynh_system_user_create --username="$app"
#=================================================
# RESTORE USER RIGHTS
@ -73,46 +74,47 @@ chown -R "$app": "$final_path"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# INSTALL DEPENDENCIES
# REINSTALL DEPENDENCIES
#=================================================
ynh_print_info "Installing dependencies..."
ynh_print_info --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies "$pkg_dependencies"
#=================================================
# INSTALL PHP
#=================================================
ynh_print_info "Installing php..."
ynh_print_info --message="Installing php..."
ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies"
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_print_info "Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run
ynh_psql_setup_db "$db_name" "$db_name" "$db_pwd"
ynh_psql_execute_file_as_root ./db.sql "$db_name"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_restore_file "/etc/php/7.2/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/php/7.2/fpm/pool.d/$app.conf"
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_print_info --message="Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user"$db_user" --db_name="$db_name" --db_pwd="$db_pwd"
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_print_info "Reloading nginx web server and php-fpm..."
ynh_print_info --message="Reloading nginx web server and php-fpm..."
systemctl reload php7.2-fpm
systemctl reload nginx
ynh_systemd_action --service_name=php7.2-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed for $app"
ynh_print_info --message="Restoration completed for $app"

View file

@ -12,57 +12,63 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_app_setting_get "$app" path)
admin=$(ynh_app_setting_get "$app" admin)
is_public=$(ynh_app_setting_get "$app" is_public)
final_path=$(ynh_app_setting_get "$app" final_path)
language=$(ynh_app_setting_get "$app" language)
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)
admin=$(ynh_app_setting_get --app="$app" --key=admin)
is_public=$(ynh_app_setting_get --app="$app" --key=is_public)
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
language=$(ynh_app_setting_get --app="$app" --key=language)
db_name=$(ynh_app_setting_get --app="$app" --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get "$app" db_pwd)
app_key=$(ynh_app_setting_get "$app" app_key)
db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd)
app_key=$(ynh_app_setting_get --app="$app" --key=app_key)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info "Ensuring downward compatibility..."
ynh_print_info --message="Ensuring downward compatibility..."
# Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set "$app" is_public 1
ynh_app_setting_set --app="$app" --key=is_public --value=1
is_public=1
elif [ "$is_public" = "No" ]; then
ynh_app_setting_set "$app" is_public 0
ynh_app_setting_set --app="$app" --key=is_public --value=0
is_public=0
fi
# 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"
db_name=$(ynh_sanitize_dbid --db_name="$app")
ynh_app_setting_set --app="$app" --key=db_name --value="$db_name"
fi
# If final_path doesn't exist, create it
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
# If app_key doesn't exist, retrieve it
if [ -z "$app_key" ]; then
app_key=$(grep -oP "APP_KEY=\Kbase64.*" "$final_path/.env")
ynh_app_setting_set "$app" app_key "$app_key"
ynh_app_setting_set --app="$app" --key=app_key --value="$app_key"
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_print_info "Backing up the app before upgrading (may take a while)..."
ynh_print_info --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
@ -73,32 +79,24 @@ 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
# 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")
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Upgrading source files..."
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_print_info --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
ynh_setup_source --dest_dir="$final_path"
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Upgrading nginx web server configuration..."
ynh_print_info --message="Upgrading nginx web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
@ -106,21 +104,21 @@ ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_print_info "Upgrading dependencies..."
ynh_print_info --message="Upgrading dependencies..."
ynh_install_app_dependencies "$pkg_dependencies"
#=================================================
# UPGRADE PHP
#=================================================
ynh_print_info "Upgrading php..."
ynh_print_info --message="Upgrading php..."
ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Making sure dedicated system user exists..."
ynh_print_info --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create "$app"
@ -128,7 +126,7 @@ ynh_system_user_create "$app"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Upgrading php-fpm configuration..."
ynh_print_info --message="Upgrading php-fpm configuration..."
# Create a dedicated php-fpm config
ynh_add_fpm_config --phpversion="7.2"
@ -150,28 +148,13 @@ ynh_install_composer --phpversion="7.2" --workdir="$final_path"
config="$final_path/.env"
cp ../conf/.env "$config"
ynh_replace_string "__APP__" "$app" "$config"
ynh_replace_string "__APP_KEY__" "$app_key" "$config"
ynh_replace_string "__DOMAIN__" "$domain" "$config"
ynh_replace_string "__PATH__" "$path_url" "$config"
ynh_replace_string "__DB_NAME__" "$db_name" "$config"
ynh_replace_string "__DB_USER__" "$db_user" "$config"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$config"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
config="$final_path/.env"
cp ../conf/.env "$config"
ynh_replace_string "__APP__" "$app" "$config"
ynh_replace_string "__APP_KEY__" "$app_key" "$config"
ynh_replace_string "__DOMAIN__" "$domain" "$config"
ynh_replace_string "__PATH__" "$path_url" "$config"
ynh_replace_string "__DB_NAME__" "$db_name" "$config"
ynh_replace_string "__DB_USER__" "$db_user" "$config"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$config"
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$config"
ynh_replace_string --match_string="__APP_KEY__" --replace_string="$app_key" --target_file="$config"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config"
ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config"
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config"
#=================================================
# DEPLOYMENT
@ -189,13 +172,13 @@ pushd "$final_path"
popd
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_backup_if_checksum_is_different "$config"
ynh_backup_if_checksum_is_different --file="$config"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "$config"
ynh_store_file_checksum --file="$config"
#=================================================
# GENERIC FINALIZATION
@ -209,24 +192,24 @@ chown -R "$app": "$final_path"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
ynh_print_info --message="Upgrading SSOwat configuration..."
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# 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="/"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"
ynh_print_info --message="Upgrade of $app completed"