1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/redirect_ynh.git synced 2024-09-03 20:16:10 +02:00
This commit is contained in:
Éric Gaspar 2023-09-26 21:40:29 +02:00
parent 158d5c106b
commit 29ec80be00
2 changed files with 9 additions and 46 deletions

View file

@ -12,9 +12,6 @@ source /usr/share/yunohost/helpers
# LOAD SETTINGS
#=================================================
redirect_type=$(ynh_app_setting_get --app=$app --key=redirect_type)
redirect_path=$(ynh_app_setting_get --app=$app --key=redirect_path)
# Validate redirect path
url_regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
[[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1

View file

@ -9,17 +9,6 @@
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
# Retrieve arguments
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? redirect_type=$(ynh_app_setting_get --app=$app --key=redirect_type)
#REMOVEME? redirect_path=$(ynh_app_setting_get --app=$app --key=redirect_path)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -33,24 +22,25 @@ then
fi
# Migrate away from old stuff with 'is_public' and old redirect type names
#REMOVEME? #REMOVEME? is_public=$(ynh_app_setting_get "$app" is_public)
#REMOVEME? if [ -n "$is_public" ]
is_public=$(ynh_app_setting_get "$app" is_public)
if [ -n "$is_public" ]
then
#REMOVEME? if [ "$is_public" = "Yes" ]; then
if [ "$is_public" = "Yes" ]; then
is_public=1
#REMOVEME? elif [ "$is_public" = "No" ]; then
elif [ "$is_public" = "No" ]; then
is_public=0
fi
#REMOVEME? if [ "$is_public" = "0" ] && [ "$redirect_type" != "proxy" ]; then
if [ "$is_public" = "0" ] && [ "$redirect_type" != "proxy" ]; then
echo "WARNING: You previously had a 'supposedly' private 301 or 302 redirection... but it was found that it was public all along and it is not easy to create such a private redirection. Your 301 or 302 redirection will be re-flagged as public..." >&2
is_public=1
fi
#REMOVEME? if [ "$redirect_type" == "proxy" ] && [ "$is_public" = "1" ]
if [ "$redirect_type" == "proxy" ] && [ "$is_public" = "1" ]
then
redirect_type="public_proxy"
#REMOVEME? elif [ "$redirect_type" == "proxy" ] && [ "$is_public" = "0" ]
elif [ "$redirect_type" == "proxy" ] && [ "$is_public" = "0" ]
then
redirect_type="private_proxy"
elif [ "$redirect_type" == "visible_302" ]
@ -64,27 +54,10 @@ then
ynh_app_setting_set $app 'redirect_type' $redirect_type
fi
# Migrate legacy permissions to new system
#REMOVEME? if ynh_legacy_permissions_exists
then
#REMOVEME? ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
# Backup the current version of the app
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
# restore it if the upgrade fails
#REMOVEME? ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
#REMOVEME? ynh_abort_if_errors
# Validate redirect path
url_regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
[[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1
@ -120,16 +93,9 @@ fi
if [ "$redirect_type" != "private_proxy" ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
#REMOVEME? ynh_permission_update --permission="main" --add="visitors"
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================