diff --git a/check_process b/check_process index eb459a1..b3c2bef 100644 --- a/check_process +++ b/check_process @@ -16,7 +16,6 @@ backup_restore=1 multi_instance=0 change_url=0 - incorrect_path=1 change_url=1 ;;; Options Email= diff --git a/conf/emailpoubelle.cron b/conf/emailpoubelle.cron index 2a85ff7..4189f85 100644 --- a/conf/emailpoubelle.cron +++ b/conf/emailpoubelle.cron @@ -1 +1 @@ -0 */2 * * * www-data cd __FINALPATH__/www/; /usr/bin/php index.php > /dev/null 2>&1 \ No newline at end of file +0 */2 * * * __APP__ cd __FINALPATH__/www/; /usr/bin/php index.php > /dev/null 2>&1 \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index 155d397..da71733 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,19 +2,20 @@ location __PATH__/ { # Path to source - alias __FINALPATH__/ ; + alias __FINALPATH__/www/ ; # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } -### PHP configuration - index www/index.php; + index index.php; + try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/scripts/_common.sh b/scripts/_common.sh index 7305c81..277549b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,5 +6,4 @@ YNH_PHP_VERSION="7.3" extra_php_dependencies="php-geoip php${YNH_PHP_VERSION}-cli" -app="emailpoubelle" lang="fr_FR.UTF-8 en_US.UTF-8 it_IT.UTF-8" diff --git a/scripts/backup b/scripts/backup index 71a9b30..55b54cd 100644 --- a/scripts/backup +++ b/scripts/backup @@ -25,9 +25,10 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # STANDARD BACKUP STEPS @@ -49,12 +50,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 MYSQL DATABASE -#================================================= - -ynh_mysql_dump_db "$db_name" > db.sql - #================================================= # BACKUP THE CRON FILE #================================================= @@ -65,7 +60,14 @@ ynh_backup --src_path="/etc/cron.d/$app" # BACKUP postfix conf #================================================= -ynh_backup "/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" +ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/98-postfix_emailpoubelle" + +#================================================= +# BACKUP THE MYSQL DATABASE +#================================================= +ynh_print_info --message="Backing up the MySQL database..." + +ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index 495b7eb..b286df6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,20 +24,15 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 # 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)..." --time --weight=1 +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -72,14 +67,14 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1 +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -105,25 +100,19 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -131,4 +120,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 26de30a..2b0d1a6 100644 --- a/scripts/install +++ b/scripts/install @@ -24,12 +24,8 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN -ynh_print_OFF password=$YNH_APP_ARG_PASSWORD -ynh_print_ON is_public=$YNH_APP_ARG_IS_PUBLIC -final_path=/var/www/$app -db_user=emailPoubelle app=$YNH_APP_INSTANCE_NAME @@ -52,7 +48,6 @@ 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=admin --value=$admin -ynh_app_setting_set --app=$app --key=db_name --value=$db_user ynh_app_setting_set --app=$app --key=final_path --value=$final_path #================================================= @@ -82,6 +77,10 @@ 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 +#chmod 750 "$final_path" +#chmod -R o-rwx "$final_path" +#chown -R $app:www-data "$final_path" + #================================================= # CREATE A MYSQL DATABASE #================================================= @@ -119,7 +118,7 @@ newaliases #adding cronjob for removing expired email addresses ynh_add_config --template="../conf/emailpoubelle.cron" --destination="/etc/cron.d/$app" -chown root:root /etc/cron.d/$app +chown root: /etc/cron.d/$app chmod 644 /etc/cron.d/$app #================================================= @@ -152,6 +151,7 @@ fi #================================================= # RELOAD SERVICES #================================================= + ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=postfix --action=reload ynh_systemd_action --service_name=php$phpversion-fpm --action=reload diff --git a/scripts/restore b/scripts/restore index 6883306..ac8e557 100644 --- a/scripts/restore +++ b/scripts/restore @@ -30,14 +30,13 @@ path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) admin=$(ynh_app_setting_get $app admin) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " @@ -114,7 +113,7 @@ 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=php$phpversion-fpm --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index d64a1c4..54c1bbd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -63,32 +63,10 @@ fi # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all + ynh_app_setting_delete --app=$app --key=is_public fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." -# Backup the current version of the app -ynh_backup_before_upgrade -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 - -#================================================= -# Migrate legacy permissions to new system -#================================================= -if ynh_legacy_permissions_exists -then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -139,18 +117,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_script_progression --message="Reloading NGINX web server..." + ynh_systemd_action --service_name=php$phpversion-fpm --action=reload - -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 #=================================================