Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function verifierScript {
- echo $1
- if [ ! -x $1 ] || [ -d $1 ]; then
- return 1
- fi
- local var_head=$(head -n 1 $1)
- if [ ! "$var_head" = "#!/bin/bash" ]; then
- return 2
- fi
- return 0
- }
- touch ~/var/script$(date +"%y%b%d")_$$.log
- log=~/var/script$(date +"%y%b%d")_$$.log
- if [ ! $# -eq 1 ]; then
- echo "Usage : verifierScript.sh fichier | arborescence"
- exit 2
- fi
- if [ -f $1 ]; then
- if echo "$1" | grep -q ".sh"; then
- verifierScript $1
- echo $1 ok
- exit $?
- fi
- echo "$1 ne termine pas par .sh"
- echo $file >> $log
- exit 4
- fi
- if [ -d $1 ]; then
- valeur_retour=1
- for file in $(find $1 -type f); do
- verifierScript $file
- if [ $? -eq 0 ]; then
- valeur_retour=0
- echo $file ok
- else
- echo $file >> $log
- echo $file ko
- fi
- done
- exit $valeur_retour
- fi
- echo "Pas valide"
- exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement