« Auto-éditer un wikilivre/Annexer (Version internationalisée)/cp-src2bin.sh » : différence entre les versions
Contenu supprimé Contenu ajouté
WL:RD : Initialisation de la page |
(Aucune différence)
|
Version du 28 mars 2021 à 19:15
Cet exécutable vient en complément de la création de la structure des répertoires par le fichier de commandes précédent install_annex.sh
#! /bin/bash
#P File : .../sbin/cp-src2bin.sh. This file must be copied into the source directory in executable mode
#P Copy the source files to the executables directory.
#P The bin directory is also used to test bash files from annex programm.
clear
VERSION=210328
echo "cp-src2bin.sh : VERSION "$VERSION
#P Find the current directory
pwd > pwd.txt
read Currentdir < pwd.txt
Workdir=~/Add_appendix
#P If $Currentdir is $Workdir/sbin the Installdir is $Workdir
if [ "$Currentdir" = "$Workdir/sbin" ]; then Installdir=$Workdir; fi
if [ "$Currentdir" = "/usr/local/sbin" ];
then
Installdir="/usr/local";
echo "Execute this program cp-src2bin as super-user; root, su or sudo.";
fi
echo "Install directory is $Installdir"
#T Breakpoint exit 0
#P Make list files.pj
echo "Make files list from src directory in files.pj"
ls $Installdir/src/*.sh > files.pj
#P If files.pj is not empty copy all files *.sh to executable directory
if [ -s "files.pj" ];
then
echo "files in files.pj :"
cat files.pj
else
echo "files.pj is empty, exit from cp-src2bin.sh"
exit 1
fi
#P Copy copy without extension .sh, and make files executables
while read line
do
#T echo "copy the ligne $line from files.pj '.sh' in the file exename without extension .sh"
echo $line | sed s/.sh//g | awk -F "/" '{print $NF}'> exename.txt
#O Affect the value in 'exename.txt' at the variable $Exename
read Exename < exename.txt
echo "copy $Installdir/src/$Exename.sh to $Installdir/bin/$Exename"
cp -f "$Installdir/src/$Exename.sh" "$Installdir/bin/$Exename"
echo "ajoute le mode 755 (exécutable) au fichier de nom $Installdir/bin/$Exename"
chmod 755 $Installdir/bin/$Exename
echo "----"
done < files.pj
#T Breakpoint exit 0
#P clean sbin directory
rm files.pj pwd.txt exename.txt
#P End cp-src2bin
exit 0