diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2020-06-02 18:03:53 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2020-06-03 11:49:20 +0300 |
commit | d7736ff04302f24d5e533dd29ee5b41de139af85 (patch) | |
tree | cc7cdc7700c10672b2be9762aad287b4d00fe25e /scripts | |
parent | ac93fd8eddfc9ee5d4288c9ad609c80106e19b28 (diff) |
Be more specific what directories to traverse when using find
Since we have both TARGET and VER, let's use both and be explicit
on the directory find runs on.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/normalize-links.sh | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/scripts/normalize-links.sh b/scripts/normalize-links.sh index c94c5ffe..25a396d5 100755 --- a/scripts/normalize-links.sh +++ b/scripts/normalize-links.sh @@ -1,16 +1,21 @@ #!/bin/sh -TARGET="$1" # usually /site, the directory that has all the HTML files including versions -VER="$2" # the docs version +TARGET="$1" # The directory that has all the HTML files including versions. + # Usually public/ locally and /site in the Docker image. + +VER="$2" # The docs version which is a directory holding all the respective + # versioned site, for example 13.0/ if [ -z "$TARGET" ]; then echo "Usage: $0 <target> <version>" + echo "Example: $0 public 13.0" echo "No target provided. Exiting." exit 1 fi if [ -z "$VER" ]; then echo "Usage: $0 <target> <version>" + echo "Example: $0 public 13.0" echo "No version provided. Exiting." exit 1 fi @@ -29,52 +34,53 @@ fi ## Relative URLs ## echo "Replace relative URLs in $TARGET/$VER for /ce/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ce/#="/'"$VER"'/ce/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ce/#="/'"$VER"'/ce/#g' echo "Replace relative URLs in $TARGET/$VER for /ee/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ee/#="/'"$VER"'/ee/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ee/#="/'"$VER"'/ee/#g' echo "Replace relative URLs in $TARGET/$VER for /runner/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/runner/#="/'"$VER"'/runner/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/runner/#="/'"$VER"'/runner/#g' echo "Replace relative URLs in $TARGET/$VER for /omnibus/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/omnibus/#="/'"$VER"'/omnibus/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/omnibus/#="/'"$VER"'/omnibus/#g' echo "Replace relative URLs in $TARGET/$VER for /charts/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/charts/#="/'"$VER"'/charts/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/charts/#="/'"$VER"'/charts/#g' echo "Replace relative URLs in $TARGET/$VER for /assets/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/assets/#="/'"$VER"'/assets/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/assets/#="/'"$VER"'/assets/#g' echo "Replace relative URLs in $TARGET/$VER for /frontend/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/frontend/#="/'"$VER"'/frontend/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/frontend/#="/'"$VER"'/frontend/#g' echo "Replace relative URLs in $TARGET/$VER for /" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#<a href="/">#<a href="/'"$VER"'/">#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#<a href="/">#<a href="/'"$VER"'/">#g' echo "Replace relative URLs in $TARGET/$VER for opensearch.xml" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/opensearch.xml#="/'"$VER"'/opensearch.xml#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/opensearch.xml#="/'"$VER"'/opensearch.xml#g' ## ## Full URLs ## echo "Replace full URLs in $TARGET/$VER for /ce/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/ce/#="/'"$VER"'/ce/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/ce/#="/'"$VER"'/ce/#g' +<<<<<<< HEAD echo "Replace full URLs in $TARGET/$VER for /ee/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/ee/#="/'"$VER"'/ee/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/ee/#="/'"$VER"'/ee/#g' echo "Replace full URLs in $TARGET/$VER for /runner/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/runner/#="/'"$VER"'/runner/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/runner/#="/'"$VER"'/runner/#g' echo "Replace full URLs in $TARGET/$VER for /omnibus/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/omnibus/#="/'"$VER"'/omnibus/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/omnibus/#="/'"$VER"'/omnibus/#g' echo "Replace full URLs in $TARGET/$VER for /charts/" -find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/charts/#="/'"$VER"'/charts/#g' +find ${TARGET}/$VER -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/charts/#="/'"$VER"'/charts/#g' echo "Fix URLs inside the sitemap" -find ${TARGET} -type f -name 'sitemap.xml' -print0 | xargs -0 sed -i 's#docs.gitlab.com/#docs.gitlab.com/'"$VER"'/#g' +find ${TARGET}/$VER -type f -name 'sitemap.xml' -print0 | xargs -0 sed -i 's#docs.gitlab.com/#docs.gitlab.com/'"$VER"'/#g' ## ## In order to have clean URLs, we symlink README.html to index.html. |