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