blob: 3d83ce37feea8cd6713c9afeda78ea11f1d7fa86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/bin/sh
TARGET="$1" # usually /site, the directory that has all the HTML files including versions
VER="$2" # the docs version
if [ -z "$TARGET" ]; then
echo "Usage: $0 <target> <version>"
echo "No target provided. Exiting."
exit 1
fi
if [ -z "$VER" ]; then
echo "Usage: $0 <target> <version>"
echo "No version provided. Exiting."
exit 1
fi
if ! [ -d "$TARGET/$VER" ]; then
echo "Target directory $TARGET/$VER does not exist. Exiting."
exit 1
fi
# Fix relative links for archive
find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ce/#="/'"$VER"'/ce/#g'
find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ee/#="/'"$VER"'/ee/#g'
find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/runner/#="/'"$VER"'/runner/#g'
find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/omnibus/#="/'"$VER"'/omnibus/#g'
find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/assets/#="/'"$VER"'/assets/#g'
find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#<a href="/">#<a href="/'"$VER"'/">#g'
find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/opensearch.xml#="/'"$VER"'/opensearch.xml#g'
find ${TARGET} -type f -name 'sitemap.xml' -print0 | xargs -0 sed -i 's#docs.gitlab.com/#docs.gitlab.com/'"$VER"'/#g'
# Symlink all README.html to index.html
for i in `find ${TARGET}/${VER} -name README.html`; do ln -sf README.html $(dirname $i)/index.html; done
# Remove CE dir and symlink EE to CE
# https://gitlab.com/gitlab-org/gitlab-docs/issues/418
if [ -d "${TARGET}/${VER}/ce/" ]; then cd ${TARGET}/${VER} && rm -r ce && ln -s ee ce; fi
|