diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/normalize-links.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/normalize-links.sh b/scripts/normalize-links.sh new file mode 100755 index 000000000..c31e37a10 --- /dev/null +++ b/scripts/normalize-links.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +TARGET="$1" +VER="$2" + +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' + +# 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 |