Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- REP="."
- NOM_BD="md5.db"
- if [ -f $NOM_BD ]; then
- : NOOP
- else
- sqlite3 $NOM_BD "create table sig(lig varchar(255),md char(32),fic varchar(255));"
- fi
- find "$REP/" -iname '*' -not -name "$NOM_BD" -type f -exec md5sum {} >md.md5 \;
- sqlite3 $NOM_BD "delete from sig;"
- while read ligne
- do
- sql="INSERT into sig(lig,md,fic) VALUES ('$ligne',substr('$ligne',1,32),trim(substr('$ligne',35)));"
- sqlite3 $NOM_BD "$sql"
- done < md.md5
- rm -f md.md5
- sqlite3 -header -column $NOM_BD "SELECT * FROM sig;"
- #! /bin/bash
- REP="."
- BKP_PATH="/chemin/vers/bkp"
- NOM_BD="md5.db"
- VERT="\\033[1;32m"
- NORMAL="\\033[0;39m"
- ROUGE="\\033[1;31m"
- JAUNE="\\033[1;33m"
- nb_lignes=$((`sqlite3 $NOM_BD "SELECT count(*) from sig"` -1))
- i=0
- while [ "$i" -le "$nb_lignes" ]; do
- echo -n "$(($i + 1))~"
- ligne=`sqlite3 $NOM_BD "SELECT * FROM sig LIMIT $i,1"`
- fic= `echo $ligne | cut -d"|"-f3`
- md5_enreg= `echo $ligne | cut -d"|" -f3`
- if [[ -f $fic ]]; then
- md5_actuel=` md5sum "$fic"|cut -d" " -f1`
- echo -n "$fic : $md5_enreg = $md5_actuel"
- if [ $md5_actuel == $md5_enreg ]; then
- echo -e " : ${VERT}OK${NORMAL}"
- else
- echo -e " : ${ROUGE}KO - cp -f $BKP_PATH/$fic $fic${NORMAL}"
- fi
- else
- echo -e "$fic : md5_enreg = --- : ${JAUNE}KO - le fichier n'existe plus!!!${NORMAL}"
- fi
- i=$(($i + 1))
- done
Advertisement
Add Comment
Please, Sign In to add comment