diff --git a/issue_template.md b/issue_template.md index 54280a6..a212547 100644 --- a/issue_template.md +++ b/issue_template.md @@ -34,8 +34,8 @@ about: Create a report to help us debug, it would be nice to fill the template a - *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If the error occurs in your browser, explain what you did:* 1. *Go to '...'* - 2. *Click on '....'* - 3. *Scroll down to '....'* + 2. *Click on '...'* + 3. *Scroll down to '...'* 4. *See error* **Expected behavior** diff --git a/scripts/_common.sh b/scripts/_common.sh index 60c4ab5..c047f44 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,8 +4,10 @@ # COMMON VARIABLES #================================================= +YNH_PHP_VERSION="7.3" + # dependencies used by the app -pkg_dependencies="php7.3-gd php7.3-xml mailutils php7.3-fpm" +pkg_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-xml mailutils" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index b970cec..a3ce283 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -14,7 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= @@ -24,32 +22,33 @@ ynh_print_info "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) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info "Backing up the main app directory..." ynh_backup "$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" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Backing up php-fpm configuration..." -ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE @@ -62,4 +61,4 @@ ynh_mysql_dump_db "$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 "Backup script completed for Webtrees. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 1915f06..ebf1659 100755 --- a/scripts/install +++ b/scripts/install @@ -50,9 +50,9 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url +ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url #================================================= # INSTALL DEPENDENCIES @@ -67,18 +67,14 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Creating a MySQL database..." db_name=$(ynh_sanitize_dbid --db_name=$app) -ynh_app_setting_set $app db_name $db_name -ynh_mysql_setup_db $db_name $db_name +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="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=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -86,9 +82,7 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." - -### `ynh_add_nginx_config` will use the file conf/nginx.conf +ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -104,10 +98,11 @@ ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring php-fpm..." +ynh_script_progression --message="Configuring PHP-FPM..." # Create a dedicated php-fpm config -ynh_add_fpm_config +ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # MODIFY A CONFIG FILE @@ -168,7 +163,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -184,4 +179,4 @@ ynh_send_readme_to_admin "$message" # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression --message="Installation of Webtrees completed" diff --git a/scripts/remove b/scripts/remove index 546464e..30d3685 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,28 +12,28 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME # Retrieve app settings -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) #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_print_info "Removing the MySQL database" +ynh_script_progression --message="Removing the MySQL database" # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db $db_user $db_name +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..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -41,25 +41,25 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory..." +ynh_script_progression --message="Removing Webtrees main directory..." # Remove the app directory securely -ynh_secure_remove "$final_path" +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..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Removing php-fpm configuration" +ynh_script_progression --message="Removing PHP-FPM configuration" -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config #================================================= @@ -67,13 +67,13 @@ ynh_remove_fpm_config #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info "Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete $app +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 773be0d..50542e6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -14,13 +13,12 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading settings..." +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -29,11 +27,12 @@ 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) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info "Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -51,14 +50,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info "Restoring the app main directory..." +ynh_script_progression --message="Restoring Webtrees main directory..." ynh_restore_file "$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info "Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create $app @@ -75,14 +74,14 @@ chmod -R 700 $final_path/data # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_restore_file "/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info "Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -90,7 +89,7 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_print_info "Restoring the MySQL database..." +ynh_script_progression --message="Restoring the MySQL database..." db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_mysql_setup_db $db_name $db_name $db_pwd @@ -101,13 +100,13 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= # 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..." -systemctl reload php7.0-fpm -systemctl reload nginx +ynh_systemd_action --service_name=php${phpversion}-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 Webtrees" diff --git a/scripts/upgrade b/scripts/upgrade index 07a94e8..8db744e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -25,7 +25,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info "Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -51,7 +51,7 @@ 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 Webtrees before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -67,7 +67,7 @@ ynh_abort_if_errors #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Upgrading source files..." +ynh_script_progression --message="Upgrading source files..." # Move old app dir mv ${final_path} ${final_path}.old @@ -84,33 +84,33 @@ rm -Rf ${final_path}.old #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info "Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Making sure dedicated system user exists..." +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Upgrading php-fpm configuration..." +ynh_script_progression --message="Upgrading PHP-FPM configuration..." -# Create a dedicated php-fpm config -ynh_add_fpm_config +# Create a dedicated PHP-FPM config +ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION #================================================= # SPECIFIC UPGRADE @@ -135,7 +135,7 @@ chmod -R 700 $final_path/data #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -144,15 +144,18 @@ then ynh_app_setting_set $app unprotected_uris "/" fi +#================================================= +# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=2 -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" --last +