01-setup-redirections.sh (2643B)
1 #!/bin/sh 2 3 # Copyright (C) 2017-2026 |Méso|Star> (contact@meso-star.com) 4 # 5 # This file is part of Méso-Web. 6 # 7 # Méso-Web is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation, either version 3 of the License, or 10 # (at your option) any later version. 11 # 12 # Méso-Web is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with Méso-Web. If not, see <http://www.gnu.org/licenses/>. 19 20 . "sty.sh" 21 22 set -e 23 24 redirections="\ 25 high-tune/high-tune.html htrdr/htrdr.html 26 high-tune/starter-pack.html htrdr/htrdr-atmosphere-spk.html 27 high-tune/downloads/gas_opt_prop_en.pdf htrdr/downloads/gas_opt_prop_en.pdf 28 high-tune/man/man1/htpp.1.html htrdr/man/man1/htpp.1.html 29 high-tune/man/man1/htrdr.1.html htrdr/man/man1/htrdr.1.html 30 high-tune/man/man1/htrdr-atmosphere.1.html htrdr/man/man1/htrdr-atmosphere.1.html 31 high-tune/man/man1/htrdr-combustion.1.html htrdr/man/man1/htrdr-combustion.1.html 32 high-tune/man/man1/les2htcp.1.html htrdr/man/man1/les2htcp.1.html 33 high-tune/man/man5/atrri.5.html htrdr/man/man5/atrri.5.html 34 high-tune/man/man5/atrtp.5.html htrdr/man/man5/atrtp.5.html 35 high-tune/man/man5/htcp.5.html htrdr/man/man5/htcp.5.html 36 high-tune/man/man5/htmie.5.html htrdr/man/man5/htmie.5.html 37 high-tune/man/man5/htrdr-image.5.html htrdr/man/man5/htrdr-image.5.html 38 high-tune/man/man5/htrdr-materials.5.html htrdr/man/man5/htrdr-materials.5.html 39 high-tune/man/man5/htrdr-obj.5.html htrdr/man/man5/htrdr-obj.5.html 40 high-tune/man/man5/mrumtl.5.html htrdr/man/man5/mrumtl.5.html 41 high-tune/man/man5/sth.5.html htrdr/man/man5/smsh.5.html 42 htrdr/man/man1/htrdr-planeto.1.html htrdr/man/man1/htrdr-planets.1.html" 43 44 redirection() 45 { 46 sed -e "s;@REDIRECTION@;$1;g" -e 's;@TIME@;5;g' \ 47 templates/redirect.html 48 } 49 50 cd .. # Move to the root of working directory 51 52 printf "%s\n" "${redirections}" | \ 53 while read -r i; do 54 55 from="$(printf '%s\n' "${i}" | cut -d' ' -f1)" 56 mkdir -p "$(dirname "${from}")" 57 58 # Set the destination file relative to the source file directory 59 to="$(printf '%s\n' "${i}" | cut -d' ' -f2)" 60 to="$(relpath_to_dir "${from}" "${PWD}")${to}" 61 62 >&2 printf 'Redirecting %s to %s\n' "${from}" "${to}" 63 64 65 if [ "${from##*.}" = "html" ]; then 66 redirection "${to}" > "${from}" 67 else 68 ln -sf "${to}" "${from}" 69 fi 70 71 printf '%s\n' "${from}" 72 done