diff --git a/README.md b/README.md index 1057ed7..c92f64d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Emailpoubelle for YunoHost [![Integration level](https://dash.yunohost.org/integration/emailpoubelle.svg)](https://dash.yunohost.org/appci/app/emailpoubelle) ![](https://ci-apps.yunohost.org/ci/badges/emailpoubelle.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/emailpoubelle.maintain.svg) -[![Install Emailpoubelle with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=emailpoubelle) +[![Install Emailpoubelle with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=emailpoubelle) > *This package allows you to install Emailpoubelle quickly and simply on a YunoHost server. If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* diff --git a/check_process b/check_process index 321fbee..fbe3e58 100644 --- a/check_process +++ b/check_process @@ -16,11 +16,8 @@ upgrade=1 backup_restore=1 multi_instance=0 - incorrect_path=1 port_already_use=0 (XXXX) change_url=0 -;;; Levels - Level 5=auto ;;; Options Email= Notification=none diff --git a/conf/nginx.conf b/conf/nginx.conf index f68d0a7..e864672 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -14,7 +14,7 @@ location __PATH__/ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/manifest.json b/manifest.json index 74892e8..1eace0d 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "misterl56@hotmail.com" }, "requirements": { - "yunohost": ">= 3.5.2" + "yunohost": ">= 3.8.1" }, "multi_instance": false, "services": [ @@ -77,7 +77,7 @@ "help": { "en": "The app can be accessed outside Yunohost and anyone will be able to create a trash email adress", "fr": "L'application sera accessible en dehors de yunohost et n'importe qui pourra y créer une adresse poubelle" - } + } } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index f1cb75a..f3e5490 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,6 +1,26 @@ +#!/bin/bash + #================================================= # COMMON VARIABLES #================================================= -pkg_dependencies="php-geoip php7.0-cli" + +YNH_PHP_VERSION="7.3" + +# dependencies used by the app +pkg_dependencies="php-geoip php${YNH_PHP_VERSION}-cli" + app="emailpoubelle" + lang="fr_FR.UTF-8 en_US.UTF-8 it_IT.UTF-8" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index d640ec4..7d5dbfb 100644 --- a/scripts/backup +++ b/scripts/backup @@ -25,7 +25,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -34,39 +34,43 @@ domain=$(ynh_app_setting_get $app domain) db_name=$(ynh_app_setting_get $app db_name) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# BACKUP THE PHP-FPM CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Backing up the MySQL database..." ynh_mysql_dump_db "$db_name" > db.sql #================================================= # BACKUP THE CRON FILE #================================================= -ynh_script_progression --message="Backing up cron configuration..." ynh_backup --src_path="/etc/cron.d/$app" #================================================= # BACKUP postfix conf #================================================= -ynh_script_progression --message="Backing up postfix conf configuration..." ynh_backup "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" @@ -74,4 +78,4 @@ ynh_backup "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index e52c69f..0353f66 100644 --- a/scripts/install +++ b/scripts/install @@ -29,9 +29,6 @@ ynh_script_progression --message="Validating installation parameters..." --weigh final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - # Check web path availability ynh_webpath_available $domain $path_url # Register (book) web path @@ -68,8 +65,8 @@ locale-gen #================================================= #INSTALL SOURCES #=============================================== - ynh_script_progression --message="Setting up source files..." --weight=5 + # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" cp ../conf/index_source.php $final_path/www/index.php @@ -80,6 +77,14 @@ ln -s $final_path/lang/fr $final_path/lang/fr_FR ln -s $final_path/lang/it $final_path/lang/it_IT ln -s $final_path/www/template-exemple $final_path/template-exemple +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +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) #=============================================== #SETTINGS & DATABASE @@ -136,24 +141,25 @@ chown root:root /etc/cron.d/$app chmod 644 /etc/cron.d/$app # Create a dedicated nginx config -ynh_script_progression --message="Configuring nginx web server..." --weight=2 +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 ynh_add_nginx_config #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." --weight=1 -# Make app public if necessary +# Make app public if necessary or protect it if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + ynh_permission_update --permission "main" --add "visitors" fi #================================================= # RELOAD SERVICES #================================================= ynh_systemd_action --service_name=nginx --action=reload + ynh_systemd_action --service_name=postfix --action=reload -service php* reload + ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 590b955..ae850d8 100644 --- a/scripts/remove +++ b/scripts/remove @@ -21,8 +21,6 @@ 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) - - #================================================= # REMOVE THE MYSQL DATABASE #================================================= @@ -31,8 +29,6 @@ ynh_script_progression --message="Removing the MySQL database..." # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name - - #================================================= # REMOVE DEPENDENCIES #================================================= @@ -41,7 +37,6 @@ ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -50,7 +45,6 @@ ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -59,7 +53,6 @@ ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config - #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index 68cfa32..35f1242 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,17 +1,9 @@ #!/bin/bash - -#================================================= -# GENERIC START -#================================================= #================================================= # IMPORT GENERIC HELPERS #================================================= -#if [ ! -e _common.sh ]; then -# # Get the _common.sh file if it's not in the current directory -# cp ../settings/scripts/_common.sh ./_common.sh -# chmod a+rx _common.sh -#fi + source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -87,7 +79,6 @@ for i in $lang ; do done locale-gen - #================================================= # RESTORE POSTFIX ALIASES #================================================= @@ -103,6 +94,15 @@ if ! grep -q "devnull:/dev/null" /etc/aliases ; then newaliases fi +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=5 + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +ynh_add_fpm_config + #================================================= # RESTORE THE CRON FILE #================================================= @@ -115,10 +115,10 @@ ynh_restore_file "/etc/cron.d/$app" #================================================= # RELOAD NGINX & ALIASES #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 postmap $final_path/var/virtual -ynh_systemd_action --service_name=php7.0-fpm --action=restart +ynh_systemd_action --service_name=php${phpversion}-fpm --action=restart ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=postfix --action=reload @@ -126,4 +126,4 @@ ynh_systemd_action --service_name=postfix --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last \ No newline at end of file +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index ac92353..f3d3505 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,18 +20,12 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public) admin=$(ynh_app_setting_get $app admin) final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION #================================================= -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. -### Not used yet in this script upgrade_type=$(ynh_check_app_version_changed) #================================================= @@ -59,7 +53,6 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -70,17 +63,10 @@ ynh_clean_setup () { # 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 THE PATH -#================================================= -# Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) - - #================================================= #check for matlink's version - DEPRECATED - uninstall & reinstall #================================================= @@ -140,8 +126,17 @@ ynh_add_nginx_config # UPGRADE DEPENDENCIES #================================================= ynh_script_progression --message="Upgrading dependencies..." + ynh_install_app_dependencies $pkg_dependencies +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 + +# Create a dedicated PHP-FPM config +ynh_add_fpm_config + #================================================= #UPDATE SETTINGS #================================================= @@ -158,8 +153,8 @@ fi #================================================= #INSTALL SOURCES #=============================================== - ynh_script_progression --message="Upgrading source files..." + # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" cp ../conf/index_source.php $final_path/www/index.php @@ -191,18 +186,14 @@ yunohost tools regen-conf postfix -f chown -R www-data:www-data $final_path chown root:root /etc/cron.d/$app - #================================================= # RELOAD SERVICES #================================================= -ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=php7.0-fpm --action=restart - ynh_script_progression --message="Reloading nginx web server..." + ynh_systemd_action --service_name=nginx --action=reload ynh_script_progression --message="Reloading postfix..." ynh_systemd_action --service_name=postfix --action=reload ynh_script_progression --message="Upgrade of $app completed" --last -