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 thi program to $Workdir/sbin
#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=210722
    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 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}
#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 $1/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"
	  if [ "$1" = "/usr/local" ]; then echo "copy all files and directories to /usr/local :"; echo "  sudo cp -R Add_appendix/* $1/. "; fi
	fi
    
    echo

#O Copy this program to $Workdir/sbin
    cp -P $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

test_users_install_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.

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=210722
    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 : $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_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 $1 directory
    if test -d ~/$1; then rm -R ~/$1; else echo "~/$1 not found"; fi

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.