mirror of
https://github.com/YunoHost-Apps/reverseproxy_ynh.git
synced 2024-09-03 20:16:23 +02:00
Various fixes for linter warnings / deprecrated practices
This commit is contained in:
parent
29ba781fd7
commit
6cfc256603
6 changed files with 30 additions and 37 deletions
|
@ -10,8 +10,8 @@
|
|||
"fr": "Créer une redirection ou un proxy vers un autre emplacement"
|
||||
},
|
||||
"version": "1.0.0~ynh2",
|
||||
"url": "https://github.com/YunoHost-Apps/redirect_ynh",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"url": "https://github.com/YunoHost-Apps/redirect_ynh",
|
||||
"maintainer": {
|
||||
"name": "opi",
|
||||
"email": "opi@zeropi.net"
|
||||
|
@ -43,6 +43,7 @@
|
|||
},
|
||||
{
|
||||
"name": "redirect_path",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Redirect destination path",
|
||||
"fr": "Emplacement de destination"
|
||||
|
@ -57,6 +58,10 @@
|
|||
"en": "Is it a public redirect?",
|
||||
"fr": "Est-ce une redirection publique ?"
|
||||
},
|
||||
"help": {
|
||||
"en": "A private redirection will only be effective for logged-in users.",
|
||||
"fr": "Une redirection privée ne fonctionnera que pour les utilisateurs identifiés."
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
|
|
|
@ -38,8 +38,8 @@ ynh_abort_if_errors
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(yunohost app setting $app domain)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
|
||||
# Copy the conf files
|
||||
mkdir -p ./conf
|
||||
cp -a "/etc/nginx/conf.d/${domain}.d/${app}.conf" ./conf/nginx.conf
|
||||
cp -a "/etc/nginx/conf.d/${domain}.d/${app}.conf" ./conf/nginx.conf
|
||||
|
|
|
@ -45,32 +45,33 @@ path=${path%/}
|
|||
location=${path:-/}
|
||||
|
||||
# Check domain/path availability
|
||||
yunohost app checkurl $domain$path -a $app \
|
||||
|| ynh_die "Path not available: $domain$path"
|
||||
ynh_webpath_register $app $domain $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
|
||||
[[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1
|
||||
|
||||
# Save extra settings
|
||||
yunohost app setting $app is_public -v "$is_public"
|
||||
yunohost app setting $app redirect_type -v "$redirect_type"
|
||||
yunohost app setting $app redirect_path -v "$redirect_path"
|
||||
ynh_app_setting_set $app is_public "$is_public"
|
||||
ynh_app_setting_set $app redirect_type "$redirect_type"
|
||||
ynh_app_setting_set $app redirect_path "$redirect_path"
|
||||
|
||||
# Nginx configuration
|
||||
sed -i "s@YNH_LOCATION@$location@g" ../conf/nginx-*.conf
|
||||
for FILE in $(ls ../conf/nginx-*.conf)
|
||||
do
|
||||
ynh_replace_string "YNH_LOCATION" "$location" $FILE
|
||||
done
|
||||
if [ "$redirect_type" = "visible_302" ];
|
||||
then
|
||||
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-visible-302.conf
|
||||
ynh_replace_string "YNH_REDIRECT_PATH" "$redirect_path" ../conf/nginx-visible-302.conf
|
||||
cp ../conf/nginx-visible-302.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
elif [ "$redirect_type" = "visible_301" ];
|
||||
then
|
||||
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-visible-301.conf
|
||||
ynh_replace_string "YNH_REDIRECT_PATH" "$redirect_path" ../conf/nginx-visible-301.conf
|
||||
cp ../conf/nginx-visible-301.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
elif [ "$redirect_type" = "proxy" ];
|
||||
then
|
||||
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-proxy.conf
|
||||
ynh_replace_string "YNH_REDIRECT_PATH" "$redirect_path" ../conf/nginx-proxy.conf
|
||||
cp ../conf/nginx-proxy.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
fi
|
||||
|
||||
|
@ -92,4 +93,3 @@ fi
|
|||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
service nginx reload
|
||||
yunohost app ssowatconf
|
||||
|
|
|
@ -26,11 +26,10 @@ source /usr/share/yunohost/helpers
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(yunohost app setting $app domain)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
|
||||
# Remove configuration files
|
||||
rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
||||
# Restart services
|
||||
service nginx reload
|
||||
yunohost app ssowatconf
|
||||
|
|
|
@ -48,19 +48,15 @@ redirect_path=$(ynh_app_setting_get "$app" redirect_path)
|
|||
path=${path%/}
|
||||
|
||||
# Check domain/path availability
|
||||
yunohost app checkurl $domain$path -a $app \
|
||||
|| die "The path ${domain}${path} is not available for app installation."
|
||||
ynh_webpath_register $app $domain $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
|
||||
[[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1
|
||||
|
||||
# Check configuration files
|
||||
NGINX_CONF="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
[[ -f $NGINX_CONF ]] && die \
|
||||
"The NGINX configuration already exists at '${NGINX_CONF}'.
|
||||
You should safely delete it before restoring this app."
|
||||
[[ -f $NGINX_CONF ]] && ynh_die "The NGINX configuration already exists at '${NGINX_CONF}'. You should safely delete it before restoring this app."
|
||||
|
||||
# Restore configuration files
|
||||
cp -a ./conf/nginx.conf "$NGINX_CONF"
|
||||
|
@ -82,4 +78,3 @@ fi
|
|||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
service nginx reload
|
||||
yunohost app ssowatconf
|
||||
|
|
|
@ -74,28 +74,23 @@ path=${path%/}
|
|||
#force location to be / or /foo
|
||||
location=${path:-/}
|
||||
|
||||
# Check domain/path availability
|
||||
yunohost app checkurl $domain$path -a $app \
|
||||
|| ynh_die "Path not available: $domain$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
|
||||
[[ ! $redirect_path =~ $url_regex ]] && ynh_die "Invalid destination: $redirect_path" 1
|
||||
|
||||
# Nginx configuration
|
||||
sed -i "s@YNH_LOCATION@$location@g" ../conf/nginx-*.conf
|
||||
ynh_replace_string "YNH_LOCATION" "$location" ../conf/nginx-*.conf
|
||||
if [ "$redirect_type" = "visible_302" ];
|
||||
then
|
||||
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-visible-302.conf
|
||||
ynh_replace_string "YNH_REDIRECT_PATH" "$redirect_path" ../conf/nginx-visible-302.conf
|
||||
cp ../conf/nginx-visible-302.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
elif [ "$redirect_type" = "visible_301" ];
|
||||
then
|
||||
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-visible-301.conf
|
||||
ynh_replace_string "YNH_REDIRECT_PATH" "$redirect_path" ../conf/nginx-visible-301.conf
|
||||
cp ../conf/nginx-visible-301.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
elif [ "$redirect_type" = "proxy" ];
|
||||
then
|
||||
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-proxy.conf
|
||||
ynh_replace_string "YNH_REDIRECT_PATH" "$redirect_path" ../conf/nginx-proxy.conf
|
||||
cp ../conf/nginx-proxy.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
fi
|
||||
|
||||
|
@ -116,4 +111,3 @@ fi
|
|||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
service nginx reload
|
||||
yunohost app ssowatconf
|
||||
|
|
Loading…
Reference in a new issue