#!/bin/sh # (C) 2015 by Matteo Pasotti # (C) 2015 by Marja van Waes # License: GPLv3+ # This script needs bash, perl, rsync, unzip, wget # This script does currently _not_ fetch the English files # The reason is, that updates of localised source files are manually copied to # Calenco, with a risk (it happened to at least 6 of us) that English files do # accidentally get overwritten instead. # So, until we have automated the copying of the xml files: # Please fetch the English html files manually, after making sure this error # did not happen again. # FIXME # The download path and the name of the zip files have changed, e.g. for Catalan: # https://docteam.mageia.org.uk/Factory/zipped/ca/drakx-installer-help/DrakX-CA-InlineHelp.zip # The script needs to be adjusted, but we might want to first change where on # https://docteam.mageia.org.uk/ Calenco writes the files to , e.g. for Catalan: # https://docteam.mageia.org.uk/Factory/zipped/drakx-installer-help/ca.zip # Having all the zip files there in one directory, would make it possible to see # when they were last updated without having to go up and down the directory tree. set -e LANGS="ca cs de el en eo es et eu fr hr hu id it nl nb pl pt pt_br ro ru sk sl sq sv tr uk zh_cn" DLPATH="http://docteam.mageia.nl/zipped/drakx-installer-help/" DOCSRC="${DLPATH}" txtbld=$(tput bold) # Bold red=$(tput setaf 1) # red blue=$(tput setaf 4) # blue white=$(tput setaf 7) # white bldred=${txtbld}${red} # Bold red bldblue=${txtbld}${blue} # Bold blue bldwhite=${txtbld}${white} # Bold white txtrst=$(tput sgr0) # Reset for lang in $LANGS; do lc_lang=`echo $lang | perl -e 'print lc <>;'` if [[ "$lang" == "en" ]]; then srcfile="en.zip" destdir="." continue else srcfile="${lc_lang}.zip" destdir="$lc_lang" echo "$bldwhite==$bldblue Checking for resource ${bldred}$uc_lang${bldblue} $txtrst" set +e check=`curl -s --head "${DLPATH}${srcfile}" | head -n 1 | grep "200 OK" > /dev/null ; echo $?` set -e if [[ "$check" != "0" ]]; then # not found echo "$bldwhite==$bldblue language: ${bldred}$uc_lang${bldblue} NOT available$txtrst" continue else echo "$bldwhite==$bldblue language: ${bldred}$uc_lang${bldblue} available$txtrst" echo "$bldwhite==$bldblue Downloading documentation archive for the language: ${bldred}$uc_lang${bldblue}...$txtrst" wget -c "${DLPATH}${srcfile}" fi tmpdir="tmp_$lang" mkdir $tmpdir mv $srcfile $tmpdir pushd $tmpdir echo "$bldwhite==$bldblue Decompressing...$txtrst" unzip -q $srcfile echo "$bldwhite==$bldblue Sync trunk documentation...$txtrst" rsync -a --exclude="*.zip" . ../$lang/ popd echo "$bldwhite==$bldblue Removing temporary directory...$txtrst" rm -fr $tmpdir echo "" fi done echo -e "$bldwhite==$bldblue WAIT BEFORE COMMITTING\nSee what's changed:$txtrst" git status echo -e "$bldwhite==$bldblue Completed\n $bldwhite==$bldblue Please$bldred check$bldblue the English files in Calenco very well\n$bldwhite==$bldblue and download them manually" exit 0