added file dependency check, switched back to english, smaller fix and improvements

This commit is contained in:
fatalerrors
2021-11-18 14:53:11 +01:00
parent 9fc9b96165
commit b71a0c2ee8
21 changed files with 360 additions and 173 deletions

View File

@@ -24,23 +24,24 @@ backupdist()
local tmstmp=$(stdtime)
if [[ -L ${file} ]]; then
# With symbolik links we call again backupdist to treat target
prnt I "Following the symbolic link $file to do a proper backup..."
backupdist $(readlink -f ${file})
elif [[ -f ${file} ]]; then
prnt I "Création d'une sauvegarde de ${file} du $tmstmp..."
prnt I "Creating a backup of ${file} on $tmstmp..."
cp -av $file ${file}.dist.${tmstmp}
if [[ $? -ne 0 ]]; then
prnt E "backupdist(): Échec de copie du fichier."
prnt E "backupdist(): Failed copying file."
die 12
fi
elif [[ -d ${file} ]]; then
prnt I "Création d'une sauvegarde du répertoire ${file} du $tmstmp..."
prnt I "Creation a backup of the directory ${file} on $tmstmp..."
cp -av $file ${file}.dist.${tmstmp}
if [[ $? -ne 0 ]]; then
prnt E "backupdist(): Échec de copie du répertoire."
prnt E "backupdist(): Failed copyind directory recursively."
die 12
fi
else
prnt W "backupdist(): $file n'existe pas, rien à faire."
prnt W "backupdist(): $file don't exists, nothing to do."
fi
unset tmstmp
done
@@ -103,14 +104,14 @@ installfile()
unset file
if [[ -d $(dirname $i) ]]; then
prnt I "Création du répertoire $(dirname $i) d'accueil..."
prnt I "Creating required target directory $(dirname $i)..."
mkdir -pv $(dirname $i)
if [[ $? -ne 0 ]]; then
prnt E "installfile(): Can't create target dirrectory!"
prnt E "installfile(): Can't create target directory!"
die 12
fi
fi
prnt I "Copie des fichiers ${filelist}..."
prnt I "Copying files ${filelist} to target directory $(dirname $i)..."
cp -av $filelist
if [[ $? -ne 0 ]]; then
prnt E "installfile(): Couldn't copy some required files!"
@@ -135,7 +136,7 @@ appendfile()
die 13
fi
prnt I "Ajout de contenu au fichier $dstfile..."
prnt I "Adding content to file $dstfile..."
cat $srcfile >> $dstfile
if [[ $? -ne 0 ]]; then
prnt E "appendfile(): Couldn't append a file!"
@@ -176,7 +177,7 @@ patchfile()
local workfile=${dstfile}.work
if [[ ! -s $srcfile ]]; then
prnt E "Le fichier source est vide, n'est pas un fichier ou n'existe pas"
prnt E "The source file is empty, is not a file or don't exists!"
die 10
fi
@@ -210,4 +211,17 @@ patchfile()
unset rights dstfile
}
# ------------------------------------------------------------------------------
# check a file exists and return error if not
file_exists()
{
prnt I "Checking $@ files existance..."
for f in $@; do
if [[ ! -f $(select_file $f) ]]; then
prnt E "The $f file is missing, cannot continue."
die 10
fi
done
}
# EOF