1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| #!/bin/bash
VERT="\\033[1;32m"
NORMAL="\\033[0;39m"
ROUGE="\\033[1;31m"
ROSE="\\033[1;35m"
BLEU="\\033[1;34m"
BLANC="\\033[0;02m"
BLANCLAIR="\\033[1;08m"
JAUNE="\\033[1;33m"
CYAN="\\033[1;36m"
DIR_SAV="/root/script_shell"
EXTENSION_SAV=".sav"
#while read LIGNE ; do
# if [[ ${LIGNE} = `echo ${LIGNE} | grep ^[^#]` ]] ; then
# echo ${LIGNE}
# echo ${DIR_SAV}
# fi
#done < ${CONF_FILE}
echo -e "$VERT" "DEBUT DE LA PROCEDURE DE SAUVEGARDE"
for VAR in ${DIR_SAV}/*${EXTENSION_SAV} ; do
echo -e "$BLEU" "TEST SI LA MACHINE DISTANCE EST ACCESSIBLE"
HOST=${VAR/$EXTENSION_SAV/} ; HOST=${HOST/$DIR_SAV/} ; HOST=${HOST/\//}
echo -e "$BLEU" "TEST DE CONNEXION SUR ${HOST}"
ssh ${HOST} ping -c 1 127.0.0.1
if [ $? = 0 ] ; then
echo "OK POUR ${HOST} - LECTURE DU FICHIER"
while read LIGNE ; do
if [[ ${LIGNE} = `echo ${LIGNE} | grep ^[^#]` ]] ; then
echo -e "$JAUNE" "LECTURE DE LA LIGNE ${LIGNE}"
ssh ${HOST} "
if [ -f ${LIGNE} ] ; then
echo "0"
else
echo "1"
fi"
fi
done < ${VAR}
else
echo -e "$ROUGE" "${HOST} N'EST PAS ACCESSIBLE"
fi
done
echo -e "$VERT" "FIN DE LA PROCEDURE DE SAUVEGARDE"
echo -e "$NORMAL" |
Partager