Remove sudo

This commit is contained in:
Jean-Baptiste Holcroft 2018-05-26 10:01:42 +02:00
parent 58ac1c2291
commit 0518b75125
5 changed files with 29 additions and 29 deletions

View file

@ -19,8 +19,8 @@ set -e
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments # Retrieve arguments
domain=$(sudo yunohost app setting $app domain) domain=$(yunohost app setting $app domain)
# Copy the conf files # Copy the conf files
sudo mkdir -p ./conf mkdir -p ./conf
sudo 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

View file

@ -31,7 +31,7 @@ path=${path%/}
location=${path:-/} location=${path:-/}
# Check domain/path availability # 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) || (echo "Path not available: $domain$path" && exit 1)
# Validate redirect path # 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 "Invalid destination: $redirect_path" 1
# Save extra settings # Save extra settings
sudo yunohost app setting $app is_public -v "$is_public" yunohost app setting $app is_public -v "$is_public"
sudo yunohost app setting $app redirect_type -v "$redirect_type" yunohost app setting $app redirect_type -v "$redirect_type"
sudo yunohost app setting $app redirect_path -v "$redirect_path" yunohost app setting $app redirect_path -v "$redirect_path"
# Nginx configuration # Nginx configuration
sed -i "s@YNH_LOCATION@$location@g" ../conf/nginx-*.conf sed -i "s@YNH_LOCATION@$location@g" ../conf/nginx-*.conf
if [ "$redirect_type" = "visible_302" ]; if [ "$redirect_type" = "visible_302" ];
then then
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-visible-302.conf 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" ]; elif [ "$redirect_type" = "visible_301" ];
then then
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-visible-301.conf 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" ]; elif [ "$redirect_type" = "proxy" ];
then then
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-proxy.conf 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 fi
# Make app public if necessary # Make app public if necessary
if [[ "$is_public" -ne 0 ]]; if [[ "$is_public" -ne 0 ]];
then then
sudo yunohost app setting $app unprotected_uris -v "/" yunohost app setting $app unprotected_uris -v "/"
fi fi
# Reload Nginx and regenerate SSOwat conf # Reload Nginx and regenerate SSOwat conf
sudo service nginx reload service nginx reload
sudo yunohost app ssowatconf yunohost app ssowatconf

View file

@ -16,11 +16,11 @@ set -e
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments # Retrieve arguments
domain=$(sudo yunohost app setting $app domain) domain=$(yunohost app setting $app domain)
# Remove configuration files # 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 # Restart services
sudo service nginx reload service nginx reload
sudo yunohost app ssowatconf yunohost app ssowatconf

View file

@ -29,7 +29,7 @@ redirect_path=$(ynh_app_setting_get "$app" redirect_path)
path=${path%/} path=${path%/}
# Check domain/path availability # 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." || die "The path ${domain}${path} is not available for app installation."
# Validate redirect path # 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." You should safely delete it before restoring this app."
# Restore configuration files # Restore configuration files
sudo cp -a ./conf/nginx.conf "$NGINX_CONF" cp -a ./conf/nginx.conf "$NGINX_CONF"
# Make app public if necessary # Make app public if necessary
if [[ "$is_public" -ne 0 ]]; if [[ "$is_public" -ne 0 ]];
then then
sudo yunohost app setting $app unprotected_uris -v "/" yunohost app setting $app unprotected_uris -v "/"
fi fi
# Reload Nginx and regenerate SSOwat conf # Reload Nginx and regenerate SSOwat conf
sudo service nginx reload service nginx reload
sudo yunohost app ssowatconf yunohost app ssowatconf

View file

@ -38,7 +38,7 @@ path=${path%/}
location=${path:-/} location=${path:-/}
# Check domain/path availability # 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) || (echo "Path not available: $domain$path" && exit 1)
# Validate redirect path # Validate redirect path
@ -51,23 +51,23 @@ sed -i "s@YNH_LOCATION@$location@g" ../conf/nginx-*.conf
if [ "$redirect_type" = "visible_302" ]; if [ "$redirect_type" = "visible_302" ];
then then
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-visible-302.conf 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" ]; elif [ "$redirect_type" = "visible_301" ];
then then
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-visible-301.conf 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" ]; elif [ "$redirect_type" = "proxy" ];
then then
sed -i "s@YNH_REDIRECT_PATH@$redirect_path@g" ../conf/nginx-proxy.conf 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 fi
# Make app public if necessary # Make app public if necessary
if [[ "$is_public" -ne 0 ]]; if [[ "$is_public" -ne 0 ]];
then then
sudo yunohost app setting $app unprotected_uris -v "/" yunohost app setting $app unprotected_uris -v "/"
fi fi
# Reload Nginx and regenerate SSOwat conf # Reload Nginx and regenerate SSOwat conf
sudo service nginx reload service nginx reload
sudo yunohost app ssowatconf yunohost app ssowatconf