meso-web

Sources of the |Méso|Star> website
git clone git://git.meso-star.com/meso-web.git
Log | Files | Refs | README | LICENSE

01-setup-redirections.sh (4011B)


      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/downloads/High-Tune-Starter-Pack-0.1.1.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.1.1.tar.gz
     29   high-tune/downloads/High-Tune-Starter-Pack-0.1.1.tar.gz.sig htrdr/downloads/High-Tune-Starter-Pack-0.1.1.tar.gz.sig
     30   high-tune/downloads/High-Tune-Starter-Pack-0.2.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.2.0.tar.gz
     31   high-tune/downloads/High-Tune-Starter-Pack-0.2.0.tar.gz.sig htrdr/downloads/High-Tune-Starter-Pack-0.2.0.tar.gz.sig
     32   high-tune/downloads/High-Tune-Starter-Pack-0.3.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.3.0.tar.gz
     33   high-tune/downloads/High-Tune-Starter-Pack-0.3.0.tar.gz.sig htrdr/downloads/High-Tune-Starter-Pack-0.3.0.tar.gz.sig
     34   high-tune/downloads/High-Tune-Starter-Pack-0.4.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.4.0.tar.gz
     35   high-tune/downloads/High-Tune-Starter-Pack-0.4.0.tar.gz.sig htrdr/downloads/High-Tune-Starter-Pack-0.4.0.tar.gz.sig
     36   high-tune/downloads/High-Tune-Starter-Pack-0.5.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.5.0.tar.gz
     37   high-tune/downloads/High-Tune-Starter-Pack-0.5.0.tar.gz.sig htrdr/downloads/High-Tune-Starter-Pack-0.5.0.tar.gz.sig
     38   high-tune/downloads/High-Tune-Starter-Pack-0.6.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.6.0.tar.gz
     39   high-tune/downloads/High-Tune-Starter-Pack-0.6.0.tar.gz.sig htrdr/downloads/High-Tune-Starter-Pack-0.6.0.tar.gz.sig
     40   high-tune/man/man1/htpp.1.html htrdr/man/man1/htpp.1.html
     41   high-tune/man/man1/htrdr.1.html htrdr/man/man1/htrdr.1.html
     42   high-tune/man/man1/htrdr-atmosphere.1.html htrdr/man/man1/htrdr-atmosphere.1.html
     43   high-tune/man/man1/htrdr-combustion.1.html htrdr/man/man1/htrdr-combustion.1.html
     44   high-tune/man/man1/les2htcp.1.html htrdr/man/man1/les2htcp.1.html
     45   high-tune/man/man5/atrri.5.html htrdr/man/man5/atrri.5.html
     46   high-tune/man/man5/atrtp.5.html htrdr/man/man5/atrtp.5.html
     47   high-tune/man/man5/htcp.5.html htrdr/man/man5/htcp.5.html
     48   high-tune/man/man5/htmie.5.html htrdr/man/man5/htmie.5.html
     49   high-tune/man/man5/htrdr-image.5.html htrdr/man/man5/htrdr-image.5.html
     50   high-tune/man/man5/htrdr-materials.5.html htrdr/man/man5/htrdr-materials.5.html
     51   high-tune/man/man5/htrdr-obj.5.html htrdr/man/man5/htrdr-obj.5.html
     52   high-tune/man/man5/mrumtl.5.html htrdr/man/man5/mrumtl.5.html
     53   high-tune/man/man5/sth.5.html htrdr/man/man5/smsh.5.html
     54   htrdr/man/man1/htrdr-planeto.1.html htrdr/man/man1/htrdr-planets.1.html"
     55 
     56 redirection()
     57 {
     58   sed -e "s;@REDIRECTION@;$1;g" -e 's;@TIME@;5;g' \
     59       templates/redirect.html
     60 }
     61 
     62 cd .. # Move to the root of working directory
     63 
     64 printf "%s\n" "${redirections}" | \
     65 while read -r i; do
     66 
     67   from="$(printf '%s\n' "${i}" | cut -d' ' -f1)"
     68   mkdir -p "$(dirname "${from}")"
     69 
     70   # Set the destination file relative to the source file directory
     71   to="$(printf '%s\n' "${i}" | cut -d' ' -f2)"
     72   to="$(relpath_to_dir "${from}" "${PWD}")${to}"
     73 
     74   >&2 printf 'Redirecting %s to %s\n' "${from}" "${to}"
     75 
     76 
     77   if [ "${from##*.}" = "html" ]; then
     78     redirection "${to}" > "${from}"
     79   else
     80     ln -sf "${to}" "${from}"
     81   fi
     82 
     83   printf '%s\n' "${from}"
     84 done