INGit for Is Not GIT
Rédigé par BeHuman
3 commentaires
Classé dans : Shell/Bash

Is Not GIT mais il l'utilise
Dans l'idée de HScript, Ingit est basé sur ce dernier. j'ai juste ajouté une routine pour commiter tranquille avec GIT et ainsi avoir à disposition mes sauvegardes de fichier modifier couplet au gestionnaire de version GIT.
#! /bin/bash _help() { printf " INGit for Is Not GIT GNU/GPL v3 by BeHuman (craft at ckdevelop dot org) Utilisation : ingeet <directory backup> <directory scan> <no display> Help: -h Exemple : ingeet backups WWW '.jpg|.png|.gif|.pdf|.swf|atos-[0-9]*|.csv|.bz2|.zip|.log|.rar|.mp4|.mp3|.eot' " exit } _veriffiles() { commit='no' find "$2" | egrep -v "$3" | grep -v ".git" | while read filename; do if [ -f "$filename" ]; then modif=$(stat -c '%y' "$filename") tim=${modif#* } tim=${tim%.*} hour=${tim%%:*} year=${modif%%-*} base=${modif%% *} day=${base##*-} month=${base#*-} month=${month%-*} pfile=`echo $filename | sed -e 's/\//_/g'` if [ -d "$1/$year" ]; then if [ -d "$1/$year/$month" ]; then if [ -d "$1/$year/$month/$day" ]; then if [ -d "$1/$year/$month/$day/$hour" ]; then if [ ! -f "$1/$year/$month/$day/$hour/[$tim]-$pfile" ]; then echo "Copie de $filename" commit='ok' cp -p "$filename" "$1/$year/$month/$day/$hour/[$tim]-$pfile" oldy=$PWD cd "$2" echo "Commit en cours..." #git pull git commit -a -m "`date`" cd $oldy fi fi fi fi fi fi done } _verifdir() { if [ -d "$1" ]; then cd "$1" else echo "création du repertoire $1" mkdir "$1" cd "$1" fi } _history() { _verifdir "$1" _verifdir `date +%Y` _verifdir `date +%m` _verifdir `date +%d` _verifdir `date +%H` cd "$3" if [ ! -d "$2/.git" ]; then cd $2 git init git add . echo "Commit en cours..." git commit -a -m "Initial import" #git pull fi cd $3 _veriffiles "$1" "$2" "$4" sleep 5 _history "$1" "$2" "$3" "$4" } if [ "$1" == "-h" ];then _help else _history "$1" "$2" "$PWD" "$3" fi