diff --git a/check_process b/check_process index 1568e71..0bd8ae7 100644 --- a/check_process +++ b/check_process @@ -3,7 +3,8 @@ domain="domain.tld" path="/path" is_public=1 - password="strong-password" + admin="john" + password="1Strong-Password" database="pgsql" ; Checks pkg_linter=1 @@ -13,13 +14,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 - change_url=0 + port_already_use=0 + change_url=1 ;;; 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/config.inc.php.pgsql b/conf/config.inc.php.pgsql index b41aacc..a466db5 100644 --- a/conf/config.inc.php.pgsql +++ b/conf/config.inc.php.pgsql @@ -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 */ 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/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 6c513d3..6b5c43f 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", @@ -46,9 +46,17 @@ "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" + }, { "name": "database", "type": "string", diff --git a/scripts/_common.sh b/scripts/_common.sh index a6147aa..b9174d9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -11,55 +11,14 @@ pkg_dependencies="php${YNH_PHP_VERSION}-tidy php${YNH_PHP_VERSION}-intl php${YNH pgsql_pkg_dependencies="postgresql php${YNH_PHP_VERSION}-pgsql" +#================================================= +# PERSONAL HELPERS +#================================================= + #================================================= # 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/backup b/scripts/backup index 56eeddb..5a15463 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 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 old mode 100755 new mode 100644 index 733c84b..51523cc --- a/scripts/install +++ b/scripts/install @@ -23,18 +23,21 @@ 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 database=$YNH_APP_ARG_DATABASE -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 @@ -48,6 +51,8 @@ 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 +#================================================= +# STANDARD MODIFICATIONS #================================================= # INSTALL DEPENDENCIES #================================================= @@ -93,9 +98,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 @@ -110,18 +115,45 @@ 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.$database" --destination="$final_path/galette/config/config.inc.php" +chmod 400 "$final_path/galette/config/config.inc.php" +chown $app:$app "$final_path/galette/config/config.inc.php" + #================================================= -# GENERIC FINALIZATION +# 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 #================================================= @@ -135,6 +167,8 @@ do chmod g+rwx $final_path/galette/data/$folder done +#================================================= +# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= @@ -148,9 +182,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 @@ -161,30 +197,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_name" -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 #================================================= diff --git a/scripts/remove b/scripts/remove old mode 100755 new mode 100644 index 6e43901..2574adb --- a/scripts/remove +++ b/scripts/remove @@ -25,6 +25,14 @@ database=$(ynh_app_setting_get --app=$app --key=database) #================================================= # 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 #================================================= @@ -38,14 +46,6 @@ else ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name fi -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -71,11 +71,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 a7ac755..5190e54 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 31f60d2..2e9c46c 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 #=================================================