diff --git a/conf/application.ini b/conf/application.ini index 082485e..41a9ddf 100644 --- a/conf/application.ini +++ b/conf/application.ini @@ -315,7 +315,7 @@ mail_func_additional_parameters = Off folders_spec_limit = 50 curl_proxy = "" curl_proxy_auth = "" -custom_login_link='__PATH__/sso.php' +custom_login_link='' custom_logout_link='https://__MAIN_DOMAIN__/yunohost/sso/?action=logout' http_client_ip_check_proxy = Off fast_cache_memcache_host = "127.0.0.1" @@ -333,4 +333,4 @@ dev_password = "" [version] current = "2.28.1" -saved = "Wed, 21 Jun 2023 06:38:05 +0000" \ No newline at end of file +saved = "Wed, 21 Jun 2023 06:38:05 +0000" diff --git a/manifest.toml b/manifest.toml index fc53449..8ef5d49 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "SnappyMail" description.en = "Simple, modern, lightweight & fast web-based e-mail client" description.fr = "Client de messagerie Web simple, moderne, léger et rapide" -version = "2.28.4~ynh1" +version = "2.28.4~ynh2" maintainers = ["eric_G"] diff --git a/scripts/install b/scripts/install index 7ee25ff..4320ecd 100755 --- a/scripts/install +++ b/scripts/install @@ -31,7 +31,7 @@ ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage ynh_script_progression --message="Setting up source files..." --weight=3 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir/app" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -57,20 +57,20 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -mkdir -p "$install_dir/data/_data_/_default_/configs" -chown $app:$app -R "$install_dir/data/_data_" +mkdir -p "$install_dir/app/data/_data_/_default_/configs" +chown $app:$app -R "$install_dir/app/data/_data_" -ynh_add_config --template="application.ini" --destination="$install_dir/data/_data_/_default_/configs/application.ini" +ynh_add_config --template="application.ini" --destination="$install_dir/app/data/_data_/_default_/configs/application.ini" -chmod 400 "$install_dir/data/_data_/_default_/configs/application.ini" -chown $app:$app "$install_dir/data/_data_/_default_/configs/application.ini" +chmod 400 "$install_dir/app/data/_data_/_default_/configs/application.ini" +chown $app:$app "$install_dir/app/data/_data_/_default_/configs/application.ini" #================================================= # SETUP SSO #================================================= ynh_script_progression --message="Applying SSO patch..." --weight=1 -ynh_add_config --template="../sources/sso.php" --destination="$install_dir/sso.php" +ynh_add_config --template="../sources/sso.php" --destination="$install_dir/index.php" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index c7fa8da..811b6cd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,6 +38,17 @@ if [ -z "${fpm_usage:-}" ]; then ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage fi +# Do something when upgrading from 2.3.2~ynh1 or lower +if ynh_compare_current_package_version --comparison le --version 2.28.4~ynh1 +then + # Move everything inside a $install_dir/app/ subfolder + # This allows to have a $install_dir/index.php handling the SSO + mkdir -p $install_dir/app + # Ugly way to not return an error when moving everything to a subfolter of the same folder https://stackoverflow.com/a/43262922 + find $install_dir -maxdepth 1 -mindepth 1 -not -name app -exec mv -t $install_dir/app {} + + chown $app:root $install_dir/app/ +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -47,7 +58,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" --keep="data/_data_/_default_/configs/application.ini" + ynh_setup_source --dest_dir="$install_dir/app" --keep="data/_data_/_default_/configs/application.ini" fi chmod -R o-rwx "$install_dir" @@ -74,17 +85,17 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -ynh_add_config --template="application.ini" --destination="$install_dir/data/_data_/_default_/configs/application.ini" +ynh_add_config --template="application.ini" --destination="$install_dir/app/data/_data_/_default_/configs/application.ini" -chmod 400 "$install_dir/data/_data_/_default_/configs/application.ini" -chown $app:$app "$install_dir/data/_data_/_default_/configs/application.ini" +chmod 400 "$install_dir/app/data/_data_/_default_/configs/application.ini" +chown $app:$app "$install_dir/app/data/_data_/_default_/configs/application.ini" #================================================= # SETUP SSO #================================================= ynh_script_progression --message="Applying SSO patch..." --weight=1 -ynh_add_config --template="../sources/sso.php" --destination="$install_dir/sso.php" +ynh_add_config --template="../sources/sso.php" --destination="$install_dir/index.php" #================================================= # END OF SCRIPT diff --git a/sources/sso.php b/sources/sso.php index 44356f6..1013197 100644 --- a/sources/sso.php +++ b/sources/sso.php @@ -2,7 +2,7 @@ // Enable SnappyMail Api and include index file $_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true; -require 'index.php'; +require 'app/index.php'; // Retrieve email and password if (isset($_SERVER['HTTP_EMAIL']) && isset($_SERVER['PHP_AUTH_PW'])) { @@ -10,8 +10,8 @@ if (isset($_SERVER['HTTP_EMAIL']) && isset($_SERVER['PHP_AUTH_PW'])) { $password = $_SERVER['PHP_AUTH_PW']; $ssoHash = \RainLoop\Api::CreateUserSsoHash($email, $password); // redirect to webmail sso url - \header('Location: https://__DOMAIN____PATH__/?sso&hash='.$ssoHash); + \header('Location: https://__DOMAIN____PATH__/app/?sso&hash='.$ssoHash); } else { - \header('Location: https://__DOMAIN____PATH__/snappymail/'); + \header('Location: https://__DOMAIN____PATH__/app/'); }