Auto-éditer un wikilivre/Annexer (Version internationalisée)/users install annex.sh

Un livre de Wikilivres.
Aller à la navigation Aller à la recherche

users_install_annex.sh[modifier | modifier le wikicode]

Install this executable shell code in sbin ( /usr/local/sbin | ~/Add_appendix/sbin | ~/Annexer/sbin )
Installer ce code shell éxécutable dans sbin
espagnol ; Instale este código de shell ejecutable en sbin
#! /bin/bash
#H File : users_install_annex.sh in ~/Tmp or re-install_annex.sh in /usr/local/sbin directory
#H Origine : https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/users_install_annex.sh
#H Codage UTF-8 without BOM
#H
#D users_install_annex.sh documentation
#D ------------------------------------
#D This program install or re-install the directory structure for the annex
#D   program of wikibooks.
#D Syntax for all annex programs : ~/Tmp/users_install_annex.sh [ OPTIONS ]
#D   Do not use ./users_install_annex.sh
#D   The installation Directories can be ~/Annexer or ~/Add_appendix 
#D OPTIONS : 
#D   *  Annexer, Add_appendix
#D   *  --v to print version
#D   *  ? to print syntax and usage
#D
#D To uninstall see users_uninstall_annex.sh
#D
#P Creation date     : 2021/04/16 by GC
#P Modification date : 2021/04/18 by Clara
#P Modification date : 2021/04/25 by GC
#P Last test date    : 2021/04/19 by Clara
#P Update and tests  : 2021/07/16 by Clara.
#P Update and tests  : 2021/07/21 by JPL for new french program "Annexer" 
#P                     update annex.lib and copy this program to sbin
#P
#D This Documentation is included in source file
#H Header of file included in source file
#O Organigram of program included in source file
#P Comments for programmers included in source file
#S Structure comments of program included in source file
#w Warnings comments in program included in source file
    
#O clean screen
    clear
   
#O Version
    unset $VERSION
    VERSION=210822
    if [ "$1" = "--v" ]; then echo "Version of users_install_annex.sh "$VERSION; exit 0; fi

#O If the first parameter '$1' is '?' print doc or syntax.  
    if [ "$1" = "?" ]
    then 
      if test -z $Workdir/doc/users_install_annex.sh.doc 
      then cat $Workdir/doc/users_install_annex.sh.doc
      else echo "Syntax : $0 [ --v | ? | Add_appendix | Annexer ]"
      fi
      exit 0
    fi
#O If the first parameter '$1' is empty print syntax.
    if [ -z $1 ] 
    then
      echo "Copy users_install_annex.sh in ~/Tmp directory"
      echo "Syntax ~/Tmp/users_install_annex.sh [ --v | ? | Add_appendix | Annexer ]"; exit 0
    fi

#P Do not use sudo
    if [ $USER = "root" ]; then echo "USER = $USER"; echo "Do not use 'sudo' please."; exit -1; fi
      
#O Go to home directory and print the current directory.
    cd ~
    echo; echo -n "current directory = "; pwd; echo
    
#O If the first parameter is not empty  
    if [ $1 ];
    then 
      if [ "$1" = "Annexer" ]; then Installdir=~/Annexer; echo "Installdir = "$Installdir
      elif [ "$1" = "Add_appendix" ]; then Installdir=~/Add_appendix; echo "Installdir = "$Installdir
      else echo "Syntax error ! "
        echo "Copy users_install_annex.sh in ~/Tmp directory"
        echo "Syntax ~/Tmp/users_install_annex.sh [ --v | ? | Add_appendix | Annexer ]"
        exit -1
      fi
    fi
    
#O Test if Install directory exist
    if [ -d $Installdir ];
    then echo " is ok, $Installdir is present."
    else echo " $Installdir not exist, i create it"; mkdir $Installdir;
    fi    

#O Create variables : Workdir, Bindir
    if [ $1 = "Add_appendix" ] && [ $1 != "Annexer" ]; then Workdir=~/Add_appendix; echo "Workdir = "$Workdir; fi
    if [ $1 = "Annexer" ] && [ $1 != "Add_appendix" ]; then Workdir=~/Annexer; echo "Workdir = "$Workdir; fi
    if [ -d $Workdir ]; then echo " $Workdir is present."; else echo " $Workdir is not present, i create it."; mkdir $Workdir; fi
    
    Bindir="$Installdir/bin"; echo "Bindir : "$Bindir 
    if test -d $Bindir
    then echo " is ok." 
    else echo " not present, create it"; mkdir $Bindir 
    fi
#T Breakpoint exit 0

#O Create or recreate directory hierarchy
    cd $Workdir
    echo -n "The current directory to create $Workdir sub directories = "; pwd
    mkdir bin books datas lib man lib/src resources sbin share src temp tests vars
    cd $Workdir/tests
    echo "$Workdir/tests is the current directory to create sub tests directories."; pwd
    mkdir 00-install_annex 0-pre-annex.sh 1-annex.lib 2-annex.sh 3-header.inc.sh 4-list.sh 5-download.sh 6-add_sclt.sh
    mkdir 7-scli.inc.sh 8-add_sclic.sh 9-add_sclipco.sh 10-add_sclipwb.sh 11-annexer.sh 12-add_appendix.sh

    cd $Workdir/share
    echo "$Workdir/share is the current directory to create sub share directories."; pwd
    mkdir man doc doc/html 
    mkdir -p man man/{man1,fr,fr/man1,fr.UTF8,fr.UTF8/man1,es,es/man1}
    mkdir -p locale locale/{en,en/LC_MESSAGES,fr,fr/LC_MESSAGES,es,es/LC_MESSAGES}
#T Breakpoint exit 0

#O If findbook.sh, ecfpb.sh, ecfpc.sh, exist in the lib/src directory, build the annex.lib file
    if test -e $Workdir/lib/src/findbook.sh && test -e $Workdir/lib/src/ecfpb.sh && test -e $Wordir/lib/src/ecfpc
    then
      cat $Workdir/lib/src/findbook.sh | grep -v "#O\|#P\|#T" > $Workdir/lib/annex.lib
      cat $Workdir/lib/src/ecfpb.sh | grep -v "#O\|#P\|#T" >> $Workdir/lib/annex.lib
      cat $Workdir/lib/src/ecfpc.sh | grep -v "#O\|#P\|#T" >> $Workdir/lib/annex.lib
    else echo "annex.lib is not builded or not updated in $Workdir/lib/annex.lib"
    fi

#O If file annex.lib not exist in $Libdir and if file annex.lib.sh exist in $Libdir/src, 
    if test -z $Workdir/lib/annex.lib && test -e $Workdir/src/annex.lib.sh
    then cat $Workdir/src/annex.lib.sh | grep -v "#O\|#P\|#T" > $Workdir/lib/annex.lib
    fi
      
    rm $Workdir/vars/installdir.var
    echo "Installdir=$Installdir" > $Workdir/vars/installdir.var
    echo "Workdir=$Workdir" >> $Workdir/vars/installdir.var    
    echo; echo "Content of file $Workdir/vars/installdir.var"
    cat $Workdir/vars/installdir.var
	
	if [ "$1" = "Annexer" ]
	then 
	  echo; echo "First param = $1"
	  echo; echo "Se connecter à l'url :"
	  echo "https://fr.wikibooks.org/wiki/Autoéditer_un_wikilivre/Annexer_(Version_internationalisée)#src.orig_en_français"
	  echo "Copier les pages de codes, les coller dans un éditeur de texte et les enregistrer dans les répertoires spécialisés"
	  echo "Les fichiers : "
	  echo " sources, dans le répertoire $1/src"
	  echo " de données dans $1/datas"
	  echo " de librairies, dans $1/lib"
	  echo " d'exécutables de maintenance, dans  $1/sbin (chmod 755 * dans sbin)"
	  echo " de documentation dans $1/share/doc"
	  echo " de manuels dans $1/share/man"
	  echo "Utiliser cette version imprimable : "
	  echo "   https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/Version_imprimable"
	  echo "   pour copier les codes bash"
	  echo; echo "Finalement rééxécuter cette commande ~/Annexer/sbin/users_install_annex.sh"
	fi
	  
	if [ "$1" = "Add_appendix" ] 
	then 
	  echo; echo "First param = $1"
	  echo; echo "Login to url :"
	  echo "https://fr.wikibooks.org/wiki/Autoéditer_un_wikilivre/Annexer_(Version_internationalisée)#Codes_sources_(internationalized_source_code)"
	  echo "Copy code pages in memory, paste them in a text editor and save in the specialized directory"
	  echo "The files :"
	  echo " sources in the directory Add_appendix/src"
	  echo " datas in Add_appendix/datas"
	  echo " library in Add_appendix/lib"
	  echo " executable for maintenance, in Add_appendix/sbin (chmod 755 * in sbin)"
	  echo " documentation in Add_appendix/share/doc"
	  echo " manuals in Add_appendix/share/man"
	  echo "Use this printable version : " 
	  echo "   https://fr.wikibooks.org/wiki/Auto-éditer_un_wikilivre/Annexer_(Version_internationalisée)/Version_imprimable"
	  echo "   to copy the bash code"
	  echo; echo "Finaly reexecute this command ~/Add_appendix/sbin/users_install_annex.sh"
	fi    
    echo

#O Initialize $Conversions variable
    Datasdir=$Workdir/datas; echo "Datadir = $Datasdir"
    Conversions=$Datasdir/conversions.dat; echo "Conversion file = $Conversions" 

#O Create or recreate the conversions.dat file in datas directory
    if test -e $Conversions
    then echo "The $Conversions file is present and will not be updated"
    else 
    {
      echo "s/%24/\$/g;s/%21/\!/g;s/%25/%/g;s/%2B/+/g;s/%3C/\\\&lt\;/g;s/%3E/\&gt\;/g;" > $Conversions
      echo "s/%5C/\\\/g;s/%B0/°/g" >> $Conversions
      echo "s/%E0/à/g;s/%E2/â/g" >> $Conversions
      echo "s/%E8/è/g;s/%E9/é/g;s/%EA/ê/g;s/%EB/ë/g" >> $Conversions
      echo "s/%EE/î/g;s/%EF/ï/g" >> $Conversions
      echo "s/%F4/ô/g" >> $Conversions
      echo "s/%F9/ù/g;s/%FB/û/g" >> $Conversions
      echo "s/%25/%/g;" >> $Conversions
      echo "s/%28/(/g;s/%29/)/g;" >> $Conversions
      echo "s/%2B/+/g;" >> $Conversions
      echo "s/%3A/:/g;" >> $Conversions
      echo "s/%3D/=/g;" >> $Conversions
      echo "s/%5B/[/g;" >> $Conversions
      echo "s/%5D/]/g" >> $Conversions
      echo "s/%3B/;/g;s/%2F/\//g;s/%27/'/g" >> $Conversions
      echo 's/%22/"/g' >> $Conversions
      echo "s/%C3%A7/ç/g;s/%E7/ç/g" >> $Conversions
      echo "s/%C3%A0/à/g;s/%C3%A2/â/g" >> $Conversions
      echo "s/%C3%A9/é/g;s/%C3%A8/è/g;s/%C3%AA/ê/g" >> $Conversions
      echo "s/%C3%AE/î/g;s/%C3%AF/ï/g" >> $Conversions
      echo "s/%C3%B4/ô/g" >> $Conversions
      echo "s/%C3%B9/ù/g;s/%C3%BB/û/g" >> $Conversions
      echo "s/%C2%B7/-/g;s/%C2%AB/«/g;s/%C2%BB/»/g" >> $Conversions
    }
    fi
    echo "----"

#O Initialize $Content_cleaner variable
    Content_cleaner=$Datasdir/content_cleaner.dat 
    echo "Content_cleaner = $Content_cleaner"
#O If not exist create the content_cleaner.dat  in datas directory
    if test -e $Content_cleaner
    then echo "The $Content_cleaner file is present and will not be updated"
    else 
    {
      echo "s/: \[/\[/g;s/:\[/\[/g" > $Content_cleaner
      echo "s/# \[/[/g;s/#\[/\[/g" >> $Content_cleaner
      echo "s/* \[/[/g;s/*\[/\[/g" >> $Content_cleaner
      echo "s/; /;/g" >> $Content_cleaner
    }
    fi
    echo "----"  
    
#O Initialize $Unrecognized_links variable
    Unrecognized_links=$Datasdir/unrecognized_links.dat
    echo "Unrecognized_links = $Unrecognized_links"
#O If not exist, create the file Unrecognized_links.dat
    #O If not exist create the content_cleaner.dat  in datas directory
    if test -e $Unrecognized_links
    then echo "The $Unrecognized_links file is present and will not be updated"
    else
    {
      echo "fr.wikibooks.org: unrecognized_link.dat ignore les liens non contenus dans les pages Résumé ou Sommaire"
      echo "title" > $Unrecognized_links
      echo "Spécial" >> $Unrecognized_links
      echo "Accueil" >> $Unrecognized_links
      echo "Vitrine" >> $Unrecognized_links
      echo "Tous_les_livres" >> $Unrecognized_links
      echo "Rechercher_un_livre" >> $Unrecognized_links
      echo "Wikijunior" >> $Unrecognized_links
      echo "Portail_communautaire" >> $Unrecognized_links
      echo "Le_Bistro" >> $Unrecognized_links
      echo "Special:" >> $Unrecognized_links
      echo "Aide:Accueil" >> $Unrecognized_links
      echo "propos_de" >> $Unrecognized_links
      echo "https://fr.wikibooks.org/wiki/Wikilivres" >> $Unrecognized_links
      echo "Wikilivres:" >> $Unrecognized_links
      echo "Catégorie:" >> $Unrecognized_links
      echo "en.wikibooks.org: unrecognized_link.dat ignore the uncontained Links in the Summary or Contents pages"
      echo "Main_Page" >> $Unrecognized_links
      echo "Help:Contents" >> $Unrecognized_links
      echo "Card_Catalog_Office" >> $Unrecognized_links
      echo "Cookbook:Table_of_Contents" >> $Unrecognized_links
      echo "Featured_books" >> $Unrecognized_links
      echo "Using_Wikibooks" >> $Unrecognized_links
      echo "Reading_room" >> $Unrecognized_links
      echo "Community_Portal" >> $Unrecognized_links
      echo "Reading_room/Bulletin_Board" >> $Unrecognized_links
      echo "Maintenance" >> $Unrecognized_links
      echo "Policies_and_guidelines" >> $Unrecognized_links
      echo "Contact_us" >> $Unrecognized_links
      echo "Welcome" >> $Unrecognized_links
      echo "General_disclaimer" >> $Unrecognized_links
      echo "Category:" >> $Unrecognized_links
    }
    fi
    echo "----"  
 
#O Write README in bin directory
#T echo "param 1 = $1"
    if [ "$1" = "Add_appendix" ]
    then
    echo "*** Write bin/README file "
    echo "README to use bin directory" > $Workdir/bin/README
    echo "This directory is reserved for commands without a '.sh' file suffix." >> $Workdir/bin/README
    echo "Commands without '.sh' are stripped of comments. They come from the" >> $Workdir/bin/README 
    echo "  'src' directory or from the 'tests' subdirectories." >> $Workdir/bin/README
    echo "Executables commands with '.sh', '.x' or .exe suffix are commands for" >> $Workdir/bin/README
    echo "  maintainers in 'sbin' directory" >> $Workdir/bin/README
    echo "*** Write README in Add_appendix"
    echo "README file in Add_apperdix" > $Workdir/README
    echo "Type ~/Add_appendix/bin/annex to launch the application" >> $Workdir/README
    fi
    
    if [ "$1" = "Annexer" ]
    then
    echo "*** écriture du fichier bin/LISEZ-MOI"
    echo "LISEZ-MOI pour l'utilisation du répertoire 'bin'" > $Workdir/bin/LISEZ-MOI
    echo "Ce répertoire est réservé aux commandes shell sans l'extension '.sh'." >> $Workdir/bin/LISEZ-MOI
    echo "Les commandes sans '.sh' proviennent du répertoire 'src' ou des sous-répertoires" >> $Workdir/bin/LISEZ-MOI
    echo "  des 'tests', dépouillées des commentaires." >> $Workdir/bin/README
    echo "Les exécutables avec l'extension 'sh', '.x' ou .exe sont des commandes" >> $Workdir/bin/LISEZ-MOI
    echo "  pour les mainteneurs dans le répertoire'sbin'" >> $Workdir/bin/LISEZ-MOI
    echo "*** écriture du fichier LISEZ-MOI dans Annexer"
    echo "Fichier LISEZ-MOI dans Annexer" > $Workdir/LISEZ-MOI
    echo "Taper ~/Annexer/bin/annex pour lancer l'application" >> $Workdir/LISEZ-MOI
    fi
    
#O When you run this script again, the message translation .pot files will be updated.
    if test -e $Installdir/bin/header.inc; then
      xgettext -L shell -o $Installdir/share/locale/header.inc.pot --from-code=UTF-8 $Installdir/bin/header.inc; fi
    if test -e $Installdir/bin/annex; then
      xgettext -L shell -o $Installdir/share/locale/annex.pot --from-code=UTF-8 $Installdir/bin/annex; fi
    echo "-----"    
    echo -e "\033[1;33mYou find Pot-files in $Workdir/share/locale for translations with 'Poedit':\033[0m"
    ls -R $Workdir/share/locale
    echo -e "\033[1;33mWhen you run this script again, the message translation .pot files will be updated.\033[0m"

    
#O Copy this program to $Workdir/sbin
    cp -Pu $0 $Workdir/sbin/users_install_annex.sh
    
#O Create the documentation of this program
    if test -e $Workdir/sbin/users_install_annex.sh; then cat $Workdir/sbin/users_install_annex.sh | grep -e "#D" | grep -v "if test" | sed 's/#D//g' > $Workdir/share/doc/users_install_annex.sh.doc; fi

#O Clean tmpfiles
    if test -d ~/tmp; then rm -r ~/tmp; fi
    
#O End of users_install_annex.sh

test_users_install_annex.sh[modifier | modifier le wikicode]

Install this executable shell code in ~/Tmp directory
#!/bin/bash
#H File : test_users_intall.sh
#H Usage : ~/Tmp/test_users_install_annex.sh [ --v | ? | Annexer | Add_appendix ]
#H

#P Creation date     : 2021/07/27 by GC
#P Update and tests  : 2021/07/27 by GC
#P

#D This Documentation is included in source file
#H Header of file
#O Organigram of program
#P Comments for programmers
#S Structure comments of program
#w Warnings comments in program

#O clean screen
    clear
   
#O Version
    unset $VERSION
    VERSION=210728
    if [ "$1" = "--v" ]; then echo "Version of test_users_install_annex.sh "$VERSION; exit 0; fi

#O If the first parameter '$1' is '?' print syntax.  
    if [ "$1" = "?" ]
    then 
    echo "~/Tmp/test_users_install_annex.sh [ --v | ? | Annexer | Add_appendix ]"; exit 0
    fi
    
#O If the first parameter '$1' is empty print syntax.
#T echo "param 0 = $0; param 1 = $1" exit 0
    if [ "$0" != "~/Tmp/test_users_install_annex.sh" ] || [ -z $1 ]
    then
      echo "Copy test_users_install_annex.sh in ~/Tmp directory"
      echo "Syntax ~/Tmp/test_users_install_annex.sh [ --v | ? | Add_appendix | Annexer ]"
    fi
#T Test break  exit 0 
#O Test whishout firstparam
    ~/Tmp/users_install_annex.sh
    sleep 10
#O Test --v
    ~/Tmp/users_install_annex.sh --v
    sleep 10
#O Test ?
    ~/Tmp/users_install_annex.sh ?
    sleep 10
#O Test Annexer
    ~/Tmp/users_install_annex.sh Annexer
    echo "Contenu du répertoire Annexer :" 
    ls -al ~/Annexer
    echo "Contenu des sous-répertoires"
    ls -al ~/Annexer/lib ~/Annexer/lib/src ~/Annexer/sbin ~/Annexer/share/doc ~/Annexer/vars
    exit 0
#O Test Add_appendix
    ~/Tmp/users_install_annex.sh Add_appendix
    echo "Add_appendix directory :"
    ls -al ~/Add_appendix
    echo "Contents of sub-directories :"
    ls -al ~/Add_appendix/lib ~/Add_appendix/lib/src ~/Add_appendix/sbin ~/Add_appendix/share/doc ~/Add_appendix/vars
    exit 0    
    
#O End of test_users_install_annex.sh

users_uninstall_annex.sh[modifier | modifier le wikicode]

Install this executable shell code in sbin ( /usr/local/sbin | ~/Add_appendix/sbin | ~/Annexer/sbin )
Installer ce code shell éxécutable dans sbin
espagnol ; Instale este código de shell ejecutable en sbin
#!/bin/bash
#H File : users_uninstall_annex.sh
#H Origine : https://fr.wikibooks.org/wiki/Auto-%C3%A9diter_un_wikilivre/Annexer_(Version_internationalis%C3%A9e)/users_install_annex.sh#users_install_annex.sh
#H Codage UTF-8 without BOM
#H
#D users_uninstall_annex.sh documentation
#D --------------------------------------
#D This program uninstalls the directory structure of the annex
#D   program of wikibooks.
#D   this program use $Workdir/vars/installdir.var
#D Syntax : ~/Tmp/users_uninstall_annex.sh [OPTIONS]
#D OPTIONS : --v, ?, Annexer, Add_appendix
#D
#D To re-install see users_uninstall_annex.sh
#D
#P Creation date     : 2021/07/22 by GC
#P Update and tests  : 2021/07/22 by GC
#P

#D This Documentation is included in source file
#H Header of file
#O Organigram of program
#P Comments for programmers
#S Structure comments of program
#w Warnings comments in program

#O clean screen
    clear
   
#O Version
    unset $VERSION
    VERSION=210726
    if [ "$1" = "--v" ]; then echo "Version of users_uninstall_annex.sh "$VERSION; exit 0; fi

#O If the first parameter '$1' is '?' print doc or syntax.  
    if [ "$1" = "?" ]
    then 
      if test -z $Workdir/doc/users_uninstall_annex.sh.doc 
      then cat $Workdir/doc/users_install_annex.sh.doc
      else echo "Syntax : ~/Tmp/users_uninstall_annex.sh [ --v | ? | Add_appendix | Annexer ]"
      fi
      exit 0
    fi
#O If the first parameter '$1' is empty print syntax.
    if [ "$0" != "~/Tmp/users_uninstall_annex.sh" ] || [ -z $1 ]
    then
      echo "Copy users_uninstall_annex.sh in ~/Tmp directory"
      echo "Syntax ~/Tmp/users_uninstall_annex.sh [ --v | ? | Add_appendix | Annexer ]"; exit 0
    fi
    
#O Include installdir.var
   if [ "$1" == "Annexer" ]; then source ~/Annexer/vars/installdir.var
   elif [ "$1" == "Add_appendix" ]; then source ~/Add_apendix/vars/installdir.var
   else echo "installdir.var is not found. see syntax of users_uninstall_annex.sh program."; exit -1
   fi
    
#O Uninstall user $Installdir directory
    if test -d $Installdir; then rm -R $Installdir; else echo "$Installdir not found"; fi
    
#O End of users_uninstall_annex.sh

test_users_uninstall_annex.sh[modifier | modifier le wikicode]

Install this executable shell code in tests directory or in ~/Tmp
En travauxlink={{{link}}}

Cette page est en travaux. Tant que cet avis n'aura pas disparu, veuillez en considérer le plan et le contenu encore incomplets, temporaires et sujets à caution. Si vous souhaitez participer, il vous est recommandé de consulter sa page de discussion au préalable, où des informations peuvent être données sur l'avancement des travaux.