meso-web

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

01-setup-redirections.sh (3984B)


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