Browse Source

[fix] Improve how .well-known path is checked

pull/4/head
Jérôme Lebleu 10 years ago
parent
commit
cc21dc5fa3
  1. 9
      scripts/_common.sh
  2. 8
      scripts/install
  3. 8
      scripts/upgrade

9
scripts/_common.sh

@ -71,3 +71,12 @@ exec_occ() {
(cd "$WORKDIR" && exec_as "$AS_USER" \ (cd "$WORKDIR" && exec_as "$AS_USER" \
php occ --no-interaction --no-ansi "$@") php occ --no-interaction --no-ansi "$@")
} }
# Check if an URL is already handled
# usage: is_url_handled URL
is_url_handled() {
local OUTPUT=($(curl -k -s -o /dev/null \
-w 'x%{redirect_url} %{http_code}' "$1"))
# it's handled if it does not redirect to the SSO nor return 404
[[ ! ${OUTPUT[0]} =~ \/yunohost\/sso\/ && ${OUTPUT[1]} != 404 ]]
}

8
scripts/install

@ -70,12 +70,10 @@ sed -i "s@#APP#@${app}@g" ../conf/nginx.conf
sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf
# check if .well-known is already served on the domain
if [[ $(curl -s -o /dev/null -w '%{http_code}' \
"https://${domain}/.well-known/caldav") =~ ^[23] ]] ; then
# ... and delete it from nginx configuration
# do not serve .well-known if it's already served on the domain
if is_url_handled "https://${domain}/.well-known/caldav" ; then
sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \ sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \
../conf/nginx.conf
../conf/nginx.conf
fi fi
sudo cp ../conf/nginx.conf "$nginx_conf" sudo cp ../conf/nginx.conf "$nginx_conf"

8
scripts/upgrade

@ -91,12 +91,10 @@ sed -i "s@#APP#@${app}@g" ../conf/nginx.conf
sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf
# check if .well-known is already served on the domain
if [[ $(curl -s -o /dev/null -w '%{http_code}' \
"https://${domain}/.well-known/caldav") =~ ^[23] ]] ; then
# ... and delete it from nginx configuration
# do not serve .well-known if it's already served on the domain
if is_url_handled "https://${domain}/.well-known/caldav" ; then
sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \ sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \
../conf/nginx.conf
../conf/nginx.conf
fi fi
sudo cp ../conf/nginx.conf "$nginx_conf" sudo cp ../conf/nginx.conf "$nginx_conf"

Loading…
Cancel
Save