From 0f145c9bb191c45ee83c4107014afaec671c8283 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Apr 2022 20:36:45 +0200 Subject: [PATCH] Apply last example_ynh --- check_process | 9 +++++--- conf/app.src | 2 ++ conf/nginx.conf | 3 +-- doc/DESCRIPTION.md | 1 + doc/DESCRIPTION_fr.md | 1 + manifest.json | 4 ++-- scripts/_common.sh | 8 +++++++ scripts/backup | 16 +++++++------ scripts/install | 54 ++++++++++++++++++++++++++----------------- scripts/remove | 25 +++++++++++--------- scripts/restore | 9 ++++---- scripts/upgrade | 31 +++++++++++++------------ 12 files changed, 98 insertions(+), 65 deletions(-) create mode 100644 doc/DESCRIPTION.md create mode 100644 doc/DESCRIPTION_fr.md diff --git a/check_process b/check_process index 7c0bf58..c431696 100644 --- a/check_process +++ b/check_process @@ -3,7 +3,6 @@ domain="domain.tld" path="/path" is_public=1 - password="strong-password" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -12,13 +11,17 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=d05248ceeffca8401dea6ac14bf7af7096345cbe + upgrade=1 from_commit=d05248ceeffca8401dea6ac14bf7af7096345cbe + # 0.9.5.2~ynh1 + upgrade=1 from_commit=3c3d7d56540e12245f45dc7c3b9334285ac475ca backup_restore=1 multi_instance=1 + port_already_use=0 change_url=0 ;;; Options +Email= Notification=none ;;; Upgrade options ; commit=d05248ceeffca8401dea6ac14bf7af7096345cbe name=Merge pull request #14 -manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1 + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1 diff --git a/conf/app.src b/conf/app.src index abf2269..f3976ff 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,3 +3,5 @@ SOURCE_SUM=274511844032e9bf3eeb00ef70b676dea7e74e2922141f17b63d90796ead6e83 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index f5b8efa..d48ac66 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ location __PATH__/ { # Path to source - alias __FINALPATH__/galette/webroot/; + alias __FINALPATH__/galette/webroot/ ; index index.html index.php; @@ -10,7 +10,6 @@ location __PATH__/ { client_max_body_size 50M; try_files $uri $uri/ @__APP__; - location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..82d8bab --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Galette is a membership management web application towards non profit organizations. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..5efbd75 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Outil de gestion d'adhérents et de cotisation en ligne pour associations diff --git a/manifest.json b/manifest.json index 5ed48f3..40ac092 100644 --- a/manifest.json +++ b/manifest.json @@ -2,11 +2,11 @@ "name": "Galette", "id": "galette", "packaging_format": 1, - "description": { + "description": { "en": "Membership management web application for non profit organizations", "fr": "Outil de gestion d'adhérents et de cotisation en ligne pour associations" }, - "version": "0.9.5.2~ynh1", + "version": "0.9.5.2~ynh2", "url": "https://www.galette.eu", "upstream": { "license": "GPL-3.0-or-later", diff --git a/scripts/_common.sh b/scripts/_common.sh index 4a4eb1e..501397f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,6 +9,10 @@ YNH_PHP_VERSION="7.3" pkg_dependencies="postgresql php${YNH_PHP_VERSION}-tidy php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-pgsql php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-curl" +#================================================= +# PERSONAL HELPERS +#================================================= + #================================================= # EXPERIMENTAL HELPERS #================================================= @@ -61,3 +65,7 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" # Send the email to the recipients echo "$mail_message" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" } + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index be2ba02..1fcd657 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # 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 @@ -19,6 +20,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -50,13 +52,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -#================================================= -# BACKUP THE POSTGRESQL DATABASE -#================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." - -ynh_psql_dump_db --database="$db_name" > db.sql - #================================================= # SPECIFIC BACKUP #================================================= @@ -65,6 +60,13 @@ ynh_psql_dump_db --database="$db_name" > db.sql ynh_backup --src_path="/etc/logrotate.d/$app" +#================================================= +# BACKUP THE POSTGRESQL DATABASE +#================================================= +ynh_print_info --message="Backing up the PostgreSQL database..." + +ynh_psql_dump_db --database="$db_name" > db.sql + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 9f6fcb3..08517a1 100755 --- a/scripts/install +++ b/scripts/install @@ -23,17 +23,18 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -timezone="$(cat /etc/timezone)" app=$YNH_APP_INSTANCE_NAME +timezone="$(cat /etc/timezone)" + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=1 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 @@ -46,6 +47,8 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url +#================================================= +# STANDARD MODIFICATIONS #================================================= # INSTALL DEPENDENCIES #================================================= @@ -53,16 +56,6 @@ ynh_script_progression --message="Installing dependencies..." --weight=20 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE A POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 - -db_name=$(ynh_sanitize_dbid --db_name=$app) -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_name --db_name=$db_name - #================================================= # CREATE DEDICATED USER #================================================= @@ -71,6 +64,17 @@ ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app --home_dir="$final_path" +#================================================= +# CREATE A POSTGRESQL DATABASE +#================================================= +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 + +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_psql_test_if_first_run +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -80,9 +84,9 @@ 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" -chmod 750 $final_path -chmod -R o-rwx $final_path -chown -R $app:www-data $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -97,18 +101,22 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 +# Create a dedicated PHP-FPM config ynh_add_fpm_config phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= -# CONFIGURE GALETTE +# SPECIFIC SETUP #================================================= -ynh_script_progression --message="Configuring Galette..." --weight=1 +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_add_config --template="../conf/config.inc.php.dist" --destination="$final_path/galette/config/config.inc.php" -#================================================= -# GENERIC FINALIZATION +chmod 400 "$final_path/galette/config/config.inc.php" +chown $app:$app "$final_path/galette/config/config.inc.php" + #================================================= # SECURE FILES AND DIRECTORIES #================================================= @@ -122,6 +130,8 @@ do chmod g+rwx $final_path/galette/data/$folder done +#================================================= +# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= @@ -135,9 +145,11 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Configuring permissions..." --weight=1 -# Make app public if necessary or protect it +# Make app public if necessary if [ $is_public -eq 1 ] then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi @@ -160,7 +172,7 @@ Database information you'll need: Type: pgsql Host: localhost Port: 5432 -User: "$db_name" +User: "$db_user" Password: "$db_pwd" Name: "$db_name" diff --git a/scripts/remove b/scripts/remove index 08bd945..c5caaa6 100755 --- a/scripts/remove +++ b/scripts/remove @@ -22,6 +22,16 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#================================================= +# STANDARD REMOVE +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." + +# Remove the app-specific logrotate config +ynh_remove_logrotate + #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= @@ -30,14 +40,6 @@ ynh_script_progression --message="Removing the PostgreSQL database..." --weight= # 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_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -63,11 +65,12 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=3 ynh_remove_fpm_config #================================================= -# REMOVE LOGROTATE CONFIGURATION +# REMOVE DEPENDENCIES #================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 -# Remove the app-specific logrotate config -ynh_remove_logrotate +# Remove metapackage and its dependencies +ynh_remove_app_dependencies #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index 684bfe4..f52afb1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# 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 @@ -20,7 +20,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -39,14 +39,14 @@ timezone="$(cat /etc/timezone)" ynh_script_progression --message="Validating restoration parameters..." --weight=2 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_script_progression --message="Restoring the NGINX configuration..." --weight=1 +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -76,6 +76,7 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_add_fpm_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # REINSTALL DEPENDENCIES diff --git a/scripts/upgrade b/scripts/upgrade index c45d35c..bbd114f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,6 +28,7 @@ timezone="$(cat /etc/timezone)" #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -45,6 +46,8 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -83,14 +86,14 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" -#================================================= -# STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then + ynh_script_progression --message="Upgrading source files..." + # Download, check integrity, uncompress and patch the source from app.src mv "$final_path" "$final_path.old" @@ -107,9 +110,9 @@ then ynh_secure_remove "$final_path.old" fi -chmod 750 $final_path -chmod -R o-rwx $final_path -chown -R $app:www-data $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -137,16 +140,6 @@ ynh_add_fpm_config #================================================= # SPECIFIC UPGRADE #================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -#================================================= -# GENERIC FINALIZATION -#================================================= # SECURE FILES AND DIRECTORIES #================================================= @@ -161,6 +154,14 @@ done #================================================= # GENERIC FINALIZATION +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + #================================================= # RELOAD NGINX #=================================================