From 70ed79a22d1808ce1f3170098d9971fec461598b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 14 Nov 2021 15:32:27 +0100 Subject: [PATCH 01/12] Upgrade to 4.3 --- conf/app.src | 1 - manifest.json | 2 +- scripts/_common.sh | 5 +---- scripts/install | 2 +- scripts/restore | 3 ++- scripts/upgrade | 3 ++- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/conf/app.src b/conf/app.src index aa31234..abf2269 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,4 +3,3 @@ SOURCE_SUM=274511844032e9bf3eeb00ef70b676dea7e74e2922141f17b63d90796ead6e83 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/manifest.json b/manifest.json index 16e62cf..5ed48f3 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,7 @@ "email": "" }, "requirements": { - "yunohost": ">= 4.2.4" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index cbc1622..4a4eb1e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,13 +4,10 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="postgresql" - # dependencies used by the app YNH_PHP_VERSION="7.3" -extra_php_dependencies="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" +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" #================================================= # EXPERIMENTAL HELPERS diff --git a/scripts/install b/scripts/install index f700a8f..9f6fcb3 100755 --- a/scripts/install +++ b/scripts/install @@ -97,7 +97,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_add_fpm_config phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= diff --git a/scripts/restore b/scripts/restore index 2dc6085..684bfe4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -75,7 +75,7 @@ chown -R $app:www-data "$final_path" ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1 ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_add_fpm_config #================================================= # REINSTALL DEPENDENCIES @@ -110,6 +110,7 @@ done #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 ynh_restore_file --origin_path="/etc/logrotate.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index 705f109..c45d35c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -132,13 +132,14 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" +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 From 657776374d3bc83012361b743667ecca1a0e9678 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 22 Nov 2021 13:30:24 +0100 Subject: [PATCH 02/12] Update nginx.conf --- conf/nginx.conf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 8ed74b8..f5b8efa 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,10 +4,6 @@ location __PATH__/ { # Path to source alias __FINALPATH__/galette/webroot/; - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - index index.html index.php; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file From 0f145c9bb191c45ee83c4107014afaec671c8283 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Apr 2022 20:36:45 +0200 Subject: [PATCH 03/12] 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'adhrents 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 #================================================= From 6b47e21942da5a45ebe35ca6f59a78e2823c5aaa Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Apr 2022 22:15:12 +0200 Subject: [PATCH 04/12] full install automation --- check_process | 4 +- doc/DISCLAIMER.md | 4 -- doc/DISCLAIMER_fr.md | 4 -- manifest.json | 14 ++++- scripts/_common.sh | 49 ------------------ scripts/change_url | 121 +++++++++++++++++++++++++++++++++++++++++++ scripts/install | 49 +++++++++--------- 7 files changed, 162 insertions(+), 83 deletions(-) create mode 100644 scripts/change_url diff --git a/check_process b/check_process index c431696..ec68e6c 100644 --- a/check_process +++ b/check_process @@ -3,6 +3,8 @@ domain="domain.tld" path="/path" is_public=1 + admin="john" + password="1Strong-Password" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -17,7 +19,7 @@ backup_restore=1 multi_instance=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Options Email= Notification=none diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index bc45156..e69de29 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,4 +0,0 @@ -## Configuration - -1. The app will require to complete the registration process after the instllation is complete by visiting the domain on which Galette is installed. -1. The Postgresql database credentials will be sent to the admin mail. Fill these details while doing the registration process. diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index 4d95474..e69de29 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -1,4 +0,0 @@ -## Configuration - -1. Une fois l'installation terminée, l'application devra terminer le processus d'enregistrement en **visitant le domaine** sur lequel Galette est installé. -1. Les informations d'identification de la base de données Postgresql seront envoyées à **l'email admin**. Remplissez ces détails lors du processus d'inscription. diff --git a/manifest.json b/manifest.json index 40ac092..638ebbc 100644 --- a/manifest.json +++ b/manifest.json @@ -46,8 +46,20 @@ "help": { "en": "If enabled, Galette will be accessible by people who do not have an account. This can be changed later via the webadmin.", "fr": "Si cette case est cochée, Galette sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." - }, + }, "default": true + }, + { + "name": "admin", + "type": "user" + }, + { + "name": "password", + "type": "password", + "help": { + "en": "Use the help field to add an information for the admin about this question.", + "fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question." + } } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 501397f..111f5ee 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -17,55 +17,6 @@ pkg_dependencies="postgresql php${YNH_PHP_VERSION}-tidy php${YNH_PHP_VERSION}-in # EXPERIMENTAL HELPERS #================================================= -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: app_message - The message to send to the administrator. -# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -ynh_send_readme_to_admin() { - local app_message="${1:-...No specific information...}" - local recipients="${2:-root}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" - - local mail_message="This is an automated message from your beloved YunoHost server. -Specific information for the application $app. -$app_message ---- -Automatic diagnosis data from YunoHost -$(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/change_url b/scripts/change_url new file mode 100644 index 0000000..d49f7fb --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,121 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." + +# Needed for helper "ynh_add_nginx_config" +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=$app --key=db_name) +#db_user=$db_name +#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) + +#================================================= +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + ynh_clean_check_starting + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the NGINX config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original NGINX config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for NGINX helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated NGINX config + ynh_add_nginx_config +fi + +# Change the domain for NGINX +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + 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 --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +# ... +#================================================= + +#================================================= +# GENERIC FINALISATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 08517a1..8bd239f 100755 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,8 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +admin=$YNH_APP_ARG_ADMIN +password=$YNH_APP_ARG_PASSWORD app=$YNH_APP_INSTANCE_NAME @@ -117,6 +119,29 @@ ynh_add_config --template="../conf/config.inc.php.dist" --destination="$final_pa chmod 400 "$final_path/galette/config/config.inc.php" chown $app:$app "$final_path/galette/config/config.inc.php" +#================================================= +# SETUP APPLICATION WITH CURL +#================================================= +ynh_script_progression --message="Setuping application with CURL..." + +# Set the app as temporarily public for curl call +ynh_script_progression --message="Configuring SSOwat..." +# Making the app public for curl +ynh_permission_update --permission="main" --add="visitors" + +# Installation with curl +ynh_script_progression --message="Finalizing installation..." +ynh_local_curl "/installer.php" "install_permsok=1" +ynh_local_curl "/installer.php" "install_type=i" +ynh_local_curl "/installer.php" "install_dbtype=pgsql" "install_dbhost=localhost" "install_dbport=5432" "install_dbuser=$db_user" "install_dbpass=$db_pwd" "install_dbname=$db_name" "install_dbprefix=galette_" +ynh_local_curl "/installer.php" "install_dbperms_ok=1" +ynh_local_curl "/installer.php" "install_dbwrite_ok=1" +ynh_local_curl "/installer.php" "install_adminlogin=$admin" "install_adminpass=$password" "install_adminpass_verif=$password" +ynh_local_curl "/installer.php" "install_prefs_ok=1" + +# Remove the public access +ynh_permission_update --permission="main" --remove="visitors" + #================================================= # SECURE FILES AND DIRECTORIES #================================================= @@ -160,30 +185,6 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# SEND A README FOR THE ADMIN -#================================================= - -message="Galette need you to finish the installation manually. - -Please open "https://$domain/$path_url/installer.php" and finish the install process. - -Database information you'll need: -Type: pgsql -Host: localhost -Port: 5432 -User: "$db_user" -Password: "$db_pwd" -Name: "$db_name" - -Important! Once done, please remember to run as root or with sudo: -Restrict the rights of the config file \`chmod -R 500 "$final_path/galette/config"\` -\`Remove the install file "$final_path/galette/install"\` - -If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/galette_ynh" - -ynh_send_readme_to_admin "$message" - #================================================= # END OF SCRIPT #================================================= From 094259ceead20f1fa86e5edcfbd9c2773067d42e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Apr 2022 22:25:43 +0200 Subject: [PATCH 05/12] Update config.inc.php.dist --- conf/config.inc.php.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.inc.php.dist b/conf/config.inc.php.dist index b41aacc..a466db5 100644 --- a/conf/config.inc.php.dist +++ b/conf/config.inc.php.dist @@ -14,7 +14,7 @@ define("HOST_DB", "localhost"); /* tcp port for the database */ define("PORT_DB", "5432"); /* the username for the database */ -define("USER_DB", "__DB_NAME__"); +define("USER_DB", "__DB_USER__"); /* password for the username define above */ define("PWD_DB", "__DB_PWD__"); /* the database name */ From a0e3158d4cc097582ef5e2a2455365dbff8d6034 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 14 Apr 2022 00:33:50 +0200 Subject: [PATCH 06/12] implement mysql --- check_process | 1 + conf/config.inc.php.mysql | 25 +++++++++++++ ...nfig.inc.php.dist => config.inc.php.pgsql} | 0 manifest.json | 9 +++++ scripts/_common.sh | 4 ++- scripts/backup | 20 +++++++---- scripts/install | 35 +++++++++++++------ scripts/remove | 10 +++++- scripts/restore | 16 ++++++--- scripts/upgrade | 2 +- 10 files changed, 97 insertions(+), 25 deletions(-) create mode 100644 conf/config.inc.php.mysql rename conf/{config.inc.php.dist => config.inc.php.pgsql} (100%) diff --git a/check_process b/check_process index 7c0bf58..1568e71 100644 --- a/check_process +++ b/check_process @@ -4,6 +4,7 @@ path="/path" is_public=1 password="strong-password" + database="pgsql" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/config.inc.php.mysql b/conf/config.inc.php.mysql new file mode 100644 index 0000000..b2e6d86 --- /dev/null +++ b/conf/config.inc.php.mysql @@ -0,0 +1,25 @@ + db.sql - #================================================= # SPECIFIC BACKUP #================================================= @@ -65,6 +59,18 @@ 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..." + +if [ $database == "pgsql" ] +then + ynh_psql_dump_db --database="$db_name" > db.sql +else + ynh_mysql_dump_db --database="$db_name" > db.sql +fi + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 9f6fcb3..733c84b 100755 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +database=$YNH_APP_ARG_DATABASE timezone="$(cat /etc/timezone)" app=$YNH_APP_INSTANCE_NAME @@ -45,24 +46,20 @@ 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 +ynh_app_setting_set --app=$app --key=database --value=$database #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." --weight=20 +if [ $database == "pgsql" ] +then + pkg_dependencies="$pkg_dependencies pgsql_pkg_dependencies" +fi + 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 +68,22 @@ 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 +if [ $database == "pgsql" ] +then + ynh_psql_test_if_first_run + ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +else + ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -105,7 +118,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= ynh_script_progression --message="Configuring Galette..." --weight=1 -ynh_add_config --template="../conf/config.inc.php.dist" --destination="$final_path/galette/config/config.inc.php" +ynh_add_config --template="../conf/config.inc.php.$database" --destination="$final_path/galette/config/config.inc.php" #================================================= # GENERIC FINALIZATION diff --git a/scripts/remove b/scripts/remove index 08bd945..6e43901 100755 --- a/scripts/remove +++ b/scripts/remove @@ -21,14 +21,22 @@ port=$(ynh_app_setting_get --app=$app --key=port) 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) +database=$(ynh_app_setting_get --app=$app --key=database) +#================================================= +# STANDARD REMOVE #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +if [ $database == "pgsql" ] +then + ynh_psql_remove_db --db_user=$db_user --db_name=$db_name +else + ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +fi #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index 684bfe4..a7ac755 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,8 +29,8 @@ 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=psqlpwd) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +database=$(ynh_app_setting_get --app=$app --key=database) timezone="$(cat /etc/timezone)" #================================================= @@ -90,9 +90,17 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 -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 +if [ $database == "pgsql" ] +then + db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) + 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 +else + db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) + ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd + ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +fi #================================================= # RESTORE USER RIGHTS diff --git a/scripts/upgrade b/scripts/upgrade index c45d35c..31f60d2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,8 +21,8 @@ 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=psqlpwd) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +database=$(ynh_app_setting_get --app=$app --key=database) timezone="$(cat /etc/timezone)" #================================================= From becd6e7a48e7845c7cb629c3bc83dddfbfc1a33d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 14 Apr 2022 08:12:32 +0200 Subject: [PATCH 07/12] Update manifest.json --- manifest.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/manifest.json b/manifest.json index 638ebbc..a4219a8 100644 --- a/manifest.json +++ b/manifest.json @@ -55,11 +55,7 @@ }, { "name": "password", - "type": "password", - "help": { - "en": "Use the help field to add an information for the admin about this question.", - "fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question." - } + "type": "password" } ] } From 70251445d41b4b9790edab3d721dbc3eb5ddb5b8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 14 Apr 2022 08:20:58 +0200 Subject: [PATCH 08/12] Update config.inc.php.mysql --- conf/config.inc.php.mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.inc.php.mysql b/conf/config.inc.php.mysql index b2e6d86..1c6445c 100644 --- a/conf/config.inc.php.mysql +++ b/conf/config.inc.php.mysql @@ -14,7 +14,7 @@ define("HOST_DB", "localhost"); /* tcp port for the database */ define("PORT_DB", "3306"); /* the username for the database */ -define("USER_DB", "__DB_NAME__"); +define("USER_DB", "__DB_USER__"); /* password for the username define above */ define("PWD_DB", "__DB_PWD__"); /* the database name */ From 042611b88a7a6f5a994b839a15d3e58894be5640 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 14 Apr 2022 19:39:41 +0200 Subject: [PATCH 09/12] Fix dependencies --- scripts/install | 2 +- scripts/restore | 5 +++++ scripts/upgrade | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 51523cc..745a2af 100644 --- a/scripts/install +++ b/scripts/install @@ -60,7 +60,7 @@ ynh_script_progression --message="Installing dependencies..." --weight=20 if [ $database == "pgsql" ] then - pkg_dependencies="$pkg_dependencies pgsql_pkg_dependencies" + pkg_dependencies="$pkg_dependencies $pgsql_pkg_dependencies" fi ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies diff --git a/scripts/restore b/scripts/restore index 5190e54..7bb5590 100644 --- a/scripts/restore +++ b/scripts/restore @@ -84,6 +84,11 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) ynh_script_progression --message="Reinstalling dependencies..." --weight=6 # Define and install dependencies +if [ $database == "pgsql" ] +then + pkg_dependencies="$pkg_dependencies $pgsql_pkg_dependencies" +fi + ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2e9c46c..e7ab777 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -127,7 +127,12 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=1 -ynh_install_app_dependencies $pkg_dependencies +if [ $database == "pgsql" ] +then + pkg_dependencies="$pkg_dependencies $pgsql_pkg_dependencies" +fi + +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= # PHP-FPM CONFIGURATION From 446da0ab17b8c6c9a0c1400ea8adcd93265e97eb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 15 Apr 2022 01:28:38 +0200 Subject: [PATCH 10/12] Fix upgrade --- scripts/install | 2 ++ scripts/upgrade | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 745a2af..7d35f46 100644 --- a/scripts/install +++ b/scripts/install @@ -85,8 +85,10 @@ if [ $database == "pgsql" ] then ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name + ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd else ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name + ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index e7ab777..3af57ab 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ 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) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) database=$(ynh_app_setting_get --app=$app --key=database) timezone="$(cat /etc/timezone)" @@ -59,10 +60,10 @@ if [ -z "$db_name" ]; then ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi -# If db_name doesn't exist, create it +# If db_pwd doesn't exist, create it if [ -z "$db_pwd" ]; then db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) - ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd + ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd fi # If final_path doesn't exist, create it From e571dcc9fa3cb90064ec2769bffb956b31ab86b9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 16 Apr 2022 20:35:54 +0200 Subject: [PATCH 11/12] Update _common.sh --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b9174d9..7e4130d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,7 @@ # dependencies used by the app YNH_PHP_VERSION="7.3" -pkg_dependencies="php${YNH_PHP_VERSION}-tidy php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-curl" +pkg_dependencies="php${YNH_PHP_VERSION}-tidy php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-mysql" pgsql_pkg_dependencies="postgresql php${YNH_PHP_VERSION}-pgsql" From 663ede2773d9f47b57a06a06fd2f82a07472462a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 Apr 2022 20:10:22 +0200 Subject: [PATCH 12/12] more generic SQL --- scripts/backup | 7 ++++--- scripts/install | 5 +++-- scripts/remove | 5 +++-- scripts/restore | 5 +++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/backup b/scripts/backup index 5a15463..9da531e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -62,15 +62,16 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= -# BACKUP THE POSTGRESQL DATABASE +# BACKUP THE SQL DATABASE #================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." if [ $database == "pgsql" ] then + ynh_print_info --message="Backing up the PostgreSQL database..." ynh_psql_dump_db --database="$db_name" > db.sql else - ynh_mysql_dump_db --database="$db_name" > db.sql + ynh_print_info --message="Backing up the MySQL database..." +ynh_mysql_dump_db --database="$db_name" > db.sql fi #================================================= diff --git a/scripts/install b/scripts/install index 7d35f46..999f730 100644 --- a/scripts/install +++ b/scripts/install @@ -74,19 +74,20 @@ ynh_script_progression --message="Configuring system user..." --weight=1 ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# CREATE A POSTGRESQL DATABASE +# CREATE A SQL 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 if [ $database == "pgsql" ] then + ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd else + ynh_script_progression --message="Creating a MySQL database..." --weight=2 ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd fi diff --git a/scripts/remove b/scripts/remove index 2574adb..7df80a7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -34,15 +34,16 @@ ynh_script_progression --message="Removing logrotate configuration..." ynh_remove_logrotate #================================================= -# REMOVE THE POSTGRESQL DATABASE +# REMOVE THE SQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2 # Remove a database if it exists, along with the associated user if [ $database == "pgsql" ] then + ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2 ynh_psql_remove_db --db_user=$db_user --db_name=$db_name else + ynh_script_progression --message="Removing the MySQL database..." --weight=2 ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name fi diff --git a/scripts/restore b/scripts/restore index 7bb5590..c9e78bf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -92,17 +92,18 @@ fi ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies #================================================= -# RESTORE THE POSTGRESQL DATABASE +# RESTORE THE SQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 if [ $database == "pgsql" ] then + ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) 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 else + ynh_script_progression --message="Restoring the MySQL database..." --weight=6 db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql