meso-web

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

commit 359d39131d3ee4f87851f4d60808b48dd978b699
parent d041522b7cd94980b983933759cfa10a73dcd567
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 23 Feb 2022 14:48:21 +0100

Rewrite the build_htaccess.sh script in POSIX shell

Diffstat:
Mbuild_htaccess.sh | 85++++++++++++++++++++++++++++++++++++++-----------------------------------------
1 file changed, 41 insertions(+), 44 deletions(-)

diff --git a/build_htaccess.sh b/build_htaccess.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh -e # Copyright (C) 2019-2021 |Meso|Star> (contact@meso-star.com) # @@ -16,53 +16,50 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. if [ $# -lt 1 ]; then - echo "Usage: $0 REMOTE_DIR" + printf "Usage: %s <remote-dir>\n" "$0" >&2 exit 1 fi -redirections=( - "index.html misc/about-fr.html" - "high-tune/high-tune.html htrdr/htrdr.html" - "high-tune/starter-pack.html htrdr/htrdr-atmosphere-spk.html" - "high-tune/downloads/gas_opt_prop_en.pdf htrdr/downloads/gas_opt_prop_en.pdf" - "high-tune/downloads/High-Tune-Starter-Pack-0.1.1.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.1.1.tar.gz" - "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" - "high-tune/downloads/High-Tune-Starter-Pack-0.2.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.2.0.tar.gz" - "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" - "high-tune/downloads/High-Tune-Starter-Pack-0.3.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.3.0.tar.gz" - "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" - "high-tune/downloads/High-Tune-Starter-Pack-0.4.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.4.0.tar.gz" - "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" - "high-tune/downloads/High-Tune-Starter-Pack-0.5.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.5.0.tar.gz" - "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" - "high-tune/downloads/High-Tune-Starter-Pack-0.6.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.6.0.tar.gz" - "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" - "high-tune/downloads/HRES_ARMCu.mp4 htrdr/downloads/HRES_ARMCu.mp4" - "high-tune/man/man1/htpp.1.html htrdr/man/man1/htpp.1.html" - "high-tune/man/man1/htrdr.1.html htrdr/man/man1/htrdr.1.html" - "high-tune/man/man1/htrdr-atmosphere.1.html htrdr/man/man1/htrdr-atmosphere.1.html" - "high-tune/man/man1/htrdr-combustion.1.html htrdr/man/man1/htrdr-combustion.1.html" - "high-tune/man/man1/les2htcp.1.html htrdr/man/man1/les2htcp.1.html" - "high-tune/man/man5/atrri.5.html htrdr/man/man5/atrri.5.html" - "high-tune/man/man5/atrtp.5.html htrdr/man/man5/atrtp.5.html" - "high-tune/man/man5/htcp.5.html htrdr/man/man5/htcp.5.html" - "high-tune/man/man5/htmie.5.html htrdr/man/man5/htmie.5.html" - "high-tune/man/man5/htrdr-image.5.html htrdr/man/man5/htrdr-image.5.html" - "high-tune/man/man5/htrdr-materials.5.html htrdr/man/man5/htrdr-materials.5.html" - "high-tune/man/man5/htrdr-obj.5.html htrdr/man/man5/htrdr-obj.5.html" - "high-tune/man/man5/mrumtl.5.html htrdr/man/man5/mrumtl.5.html" - "high-tune/man/man5/sth.5.html htrdr/man/man5/sth.5.html" -) +redirections="\ + index.html misc/about-fr.html + high-tune/high-tune.html htrdr/htrdr.html + high-tune/starter-pack.html htrdr/htrdr-atmosphere-spk.html + high-tune/downloads/gas_opt_prop_en.pdf htrdr/downloads/gas_opt_prop_en.pdf + high-tune/downloads/High-Tune-Starter-Pack-0.1.1.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.1.1.tar.gz + 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 + high-tune/downloads/High-Tune-Starter-Pack-0.2.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.2.0.tar.gz + 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 + high-tune/downloads/High-Tune-Starter-Pack-0.3.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.3.0.tar.gz + 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 + high-tune/downloads/High-Tune-Starter-Pack-0.4.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.4.0.tar.gz + 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 + high-tune/downloads/High-Tune-Starter-Pack-0.5.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.5.0.tar.gz + 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 + high-tune/downloads/High-Tune-Starter-Pack-0.6.0.tar.gz htrdr/downloads/High-Tune-Starter-Pack-0.6.0.tar.gz + 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 + high-tune/downloads/HRES_ARMCu.mp4 htrdr/downloads/HRES_ARMCu.mp4 + high-tune/man/man1/htpp.1.html htrdr/man/man1/htpp.1.html + high-tune/man/man1/htrdr.1.html htrdr/man/man1/htrdr.1.html + high-tune/man/man1/htrdr-atmosphere.1.html htrdr/man/man1/htrdr-atmosphere.1.html + high-tune/man/man1/htrdr-combustion.1.html htrdr/man/man1/htrdr-combustion.1.html + high-tune/man/man1/les2htcp.1.html htrdr/man/man1/les2htcp.1.html + high-tune/man/man5/atrri.5.html htrdr/man/man5/atrri.5.html + high-tune/man/man5/atrtp.5.html htrdr/man/man5/atrtp.5.html + high-tune/man/man5/htcp.5.html htrdr/man/man5/htcp.5.html + high-tune/man/man5/htmie.5.html htrdr/man/man5/htmie.5.html + high-tune/man/man5/htrdr-image.5.html htrdr/man/man5/htrdr-image.5.html + high-tune/man/man5/htrdr-materials.5.html htrdr/man/man5/htrdr-materials.5.html + high-tune/man/man5/htrdr-obj.5.html htrdr/man/man5/htrdr-obj.5.html + high-tune/man/man5/mrumtl.5.html htrdr/man/man5/mrumtl.5.html + high-tune/man/man5/sth.5.html htrdr/man/man5/sth.5.html" -REMOTE_DIR=$1 +remote_dir=$1 -echo "Options -Indexes" > .htaccess +echo "Options -Indexes" -tput bold; echo ">>> build the .htaccess file"; tput sgr0 -for((i=0; i<${#redirections[@]}; ++i)); do - entry=(${redirections[$i]}) - from=${entry[0]} - to=${entry[1]} - echo "Redirect ${REMOTE_DIR}/${from} ${REMOTE_DIR}/${to}" >> .htaccess +printf "%s\n" "${redirections}" | \ +while read -r i; do + from=$(printf "%s" "${i}" | awk '{print $1}') + to=$(printf "%s" "${i}" | awk '{print $2}') + printf "Redirect %s/%s %s/%s\n" "${remote_dir}" "${from}" "${remote_dir}" "${to}" done -echo ""