legos version of repo path management

This commit is contained in:
fatalerrors
2021-06-02 15:47:51 +02:00
parent 93d93a1123
commit c9e657800d
2 changed files with 21 additions and 16 deletions

11
init.sh
View File

@@ -1,12 +1,13 @@
#!/bin/bash #!/bin/bash
# Remember the running path
MYPATH=$(dirname $0)
# Load libraries # Load libraries
. lib/display.sh . $MYPATH/lib/display.sh
. lib/filefct.sh . $MYPATH/lib/filefct.sh
# Check gestparc native directory
#export REPO="/share/services/gestparc"
# Important global variables
export HOSTNAME=$(hostname) export HOSTNAME=$(hostname)
export DATEFORMAT=${DATEFORMAT:-"+%Y/%m/%d-%H:%M:%S-%N"} export DATEFORMAT=${DATEFORMAT:-"+%Y/%m/%d-%H:%M:%S-%N"}

View File

@@ -1,13 +1,17 @@
# Backup original installation files (or any old files if runned several time on same file) # Backup original installation files
# (or any old files if runned several time on same file)
backupdist() backupdist()
{ {
[[ $# -lt 1 ]] && prnt E "backupdist(): Au moins un argument requis." && return 1 [[ $# -lt 1 ]] &&
prnt E "backupdist(): Au moins un argument requis." &&
exit 129
for file in $@; do for file in $@; do
if [[ -e ${file} ]]; then if [[ -e ${file} ]]; then
prnt I "Création d'une copie de sauvegarde de ${file}..." tmpstmp=$(date --rfc-3339=seconds | sed -e 's/ /-/' -e 's/://g')
cp -av $file $file.dist.$(date --rfc-3339=seconds | sed -e 's/ /-/' -e 's/://g') prnt I "Création d'une sauvegarde de ${file} du $tmpstmp..."
cp -av $file $file.dist.$tmpstmp
fi fi
done done
} }
@@ -21,18 +25,18 @@ installfile()
[[ $# -lt 2 ]] && ( [[ $# -lt 2 ]] && (
prnt E "installfile(): Au moins deux arguments requis." prnt E "installfile(): Au moins deux arguments requis."
return 1 exit 129
) )
[[ $(echo $@ | grep "\*\|\?") ]] && ( [[ $(echo $@ | grep "\*\|\?") ]] && (
prnt E "installfile(): Les wildcards sont interdits." prnt E "installfile(): Les wildcards sont interdits."
return 2 exit 10
) )
for arg in $@; do for arg in $@; do
if [[ -f $BASEGPDIR/profile/$HOSTNAME/$arg ]]; then if [[ -f $MYPATH/repo/hosts/$HOSTNAME/$arg ]]; then
filelist="$filelist $BASEGPDIR/profile/$HOSTNAME/$arg" filelist="$filelist $MYPATH/repo/hosts/$HOSTNAME/$arg"
elif [[ -f $BASEGPDIR/profile/$arg ]]; then elif [[ -f $MYPATH/repo/common/$arg ]]; then
filelist="$filelist $BASEGPDIR/profile/$arg" filelist="$filelist $MYPATH/repo/common/$arg"
else else
filelist="$filelist $arg" filelist="$filelist $arg"
fi fi
@@ -42,7 +46,7 @@ installfile()
prnt E "installfile(): Target must be on the root filesystem." prnt E "installfile(): Target must be on the root filesystem."
exit 3 exit 3
fi fi
prnt I "Création su répertoire $(dirname $i) si nécessaire..." prnt I "Création du répertoire $(dirname $i) si nécessaire..."
mkdir -pv $(dirname $i) mkdir -pv $(dirname $i)
prnt I "Copie des fichiers ${filelist}..." prnt I "Copie des fichiers ${filelist}..."
cp -av $filelist cp -av $filelist