mirror of
https://github.com/YunoHost-Apps/redirect_ynh.git
synced 2024-09-03 20:16:10 +02:00
Remove sudo
This commit is contained in:
parent
58ac1c2291
commit
0518b75125
5 changed files with 29 additions and 29 deletions
|
@ -19,8 +19,8 @@ set -e
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
domain=$(yunohost app setting $app domain)
|
||||
|
||||
# Copy the conf files
|
||||
sudo mkdir -p ./conf
|
||||
sudo cp -a "/etc/nginx/conf.d/${domain}.d/${app}.conf" ./conf/nginx.conf
|
||||
mkdir -p ./conf
|
||||
cp -a "/etc/nginx/conf.d/${domain}.d/${app}.conf" ./conf/nginx.conf
|
|
@ -31,7 +31,7 @@ path=${path%/}
|
|||
location=${path:-/}
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $domain$path -a $app \
|
||||
yunohost app checkurl $domain$path -a $app \
|
||||
|| (echo "Path not available: $domain$path" && exit 1)
|
||||
|
||||
# Validate redirect path
|
||||
|
@ -40,32 +40,32 @@ url_regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=
|
|||
"Invalid destination: $redirect_path" 1
|
||||
|
||||
# Save extra settings
|
||||
sudo yunohost app setting $app is_public -v "$is_public"
|
||||
sudo yunohost app setting $app redirect_type -v "$redirect_type"
|
||||
sudo yunohost app setting $app redirect_path -v "$redirect_path"
|
||||
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"
|
||||
|
||||
# Nginx configuration
|
||||
sed -i "s@YNH_LOCATION@$location@g" ../conf/nginx-*.conf
|
||||
if [ "$redirect_type" = "visible_302" ];
|
||||
then
|
||||
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-visible-302.conf
|
||||
sudo cp ../conf/nginx-visible-302.conf /etc/nginx/conf.d/$domain.d/$app.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
|
||||
sudo cp ../conf/nginx-visible-301.conf /etc/nginx/conf.d/$domain.d/$app.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
|
||||
sudo cp ../conf/nginx-proxy.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
cp ../conf/nginx-proxy.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
fi
|
||||
|
||||
# Make app public if necessary
|
||||
if [[ "$is_public" -ne 0 ]];
|
||||
then
|
||||
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||
yunohost app setting $app unprotected_uris -v "/"
|
||||
fi
|
||||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
service nginx reload
|
||||
yunohost app ssowatconf
|
||||
|
|
|
@ -16,11 +16,11 @@ set -e
|
|||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
domain=$(yunohost app setting $app domain)
|
||||
|
||||
# Remove configuration files
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
||||
# Restart services
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
service nginx reload
|
||||
yunohost app ssowatconf
|
||||
|
|
|
@ -29,7 +29,7 @@ redirect_path=$(ynh_app_setting_get "$app" redirect_path)
|
|||
path=${path%/}
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $domain$path -a $app \
|
||||
yunohost app checkurl $domain$path -a $app \
|
||||
|| die "The path ${domain}${path} is not available for app installation."
|
||||
|
||||
# Validate redirect path
|
||||
|
@ -44,14 +44,14 @@ NGINX_CONF="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
|||
You should safely delete it before restoring this app."
|
||||
|
||||
# Restore configuration files
|
||||
sudo cp -a ./conf/nginx.conf "$NGINX_CONF"
|
||||
cp -a ./conf/nginx.conf "$NGINX_CONF"
|
||||
|
||||
# Make app public if necessary
|
||||
if [[ "$is_public" -ne 0 ]];
|
||||
then
|
||||
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||
yunohost app setting $app unprotected_uris -v "/"
|
||||
fi
|
||||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
service nginx reload
|
||||
yunohost app ssowatconf
|
||||
|
|
|
@ -38,7 +38,7 @@ path=${path%/}
|
|||
location=${path:-/}
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $domain$path -a $app \
|
||||
yunohost app checkurl $domain$path -a $app \
|
||||
|| (echo "Path not available: $domain$path" && exit 1)
|
||||
|
||||
# Validate redirect path
|
||||
|
@ -51,23 +51,23 @@ sed -i "s@YNH_LOCATION@$location@g" ../conf/nginx-*.conf
|
|||
if [ "$redirect_type" = "visible_302" ];
|
||||
then
|
||||
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-visible-302.conf
|
||||
sudo cp ../conf/nginx-visible-302.conf /etc/nginx/conf.d/$domain.d/$app.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
|
||||
sudo cp ../conf/nginx-visible-301.conf /etc/nginx/conf.d/$domain.d/$app.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
|
||||
sudo cp ../conf/nginx-proxy.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
cp ../conf/nginx-proxy.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
fi
|
||||
|
||||
# Make app public if necessary
|
||||
if [[ "$is_public" -ne 0 ]];
|
||||
then
|
||||
sudo yunohost app setting $app unprotected_uris -v "/"
|
||||
yunohost app setting $app unprotected_uris -v "/"
|
||||
fi
|
||||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
service nginx reload
|
||||
yunohost app ssowatconf
|
||||
|
|
Loading…
Reference in a new issue