Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
|
scripts:list-config_modif_quota.pl [2016/09/23 17:17] catherine.balleydier@grenoble-inp.fr |
scripts:list-config_modif_quota.pl [2017/04/12 13:46] (Version actuelle) catherine.balleydier@grenoble-inp.fr |
||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ====== list-config_modif_quota.pl ====== | ====== list-config_modif_quota.pl ====== | ||
| - | <code> | + | <code perl> |
| #!/usr/bin/perl -w | #!/usr/bin/perl -w | ||
| # | # | ||
| Ligne 12: | Ligne 12: | ||
| ######################################################################## | ######################################################################## | ||
| # | # | ||
| - | # modifier les quotas des archives | + | # modifier les quotas des archives $nvquota = "4000" |
| + | # supprimer les quotas des archives $nvquota = "NON" | ||
| # | # | ||
| ######################################################################## | ######################################################################## | ||
| Ligne 20: | Ligne 21: | ||
| use File::Copy; | use File::Copy; | ||
| - | my $REP="/home/sympa/list_data/listes.grenoble-inp.fr/" ; | + | my $REProbot = "/home/sympa/list_data/" ; |
| + | my $REP ; | ||
| + | my $robot ; | ||
| my $fichier ; | my $fichier ; | ||
| my @CONFIG ; | my @CONFIG ; | ||
| + | my @liste ; | ||
| my $entree ; | my $entree ; | ||
| my $nvfichier ; | my $nvfichier ; | ||
| my $LIGNE ; | my $LIGNE ; | ||
| - | my $nvquota = "4000"; | + | #my $nvquota = "4000"; |
| + | my $nvquota = "NON"; | ||
| # | # | ||
| # date | # date | ||
| Ligne 34: | Ligne 39: | ||
| # | # | ||
| - | # lister le contenu du repertoire /home/sympa/expl/inpg.fr | + | # lister les robots du repertoire /home/sympa/list_data |
| # | # | ||
| - | opendir(DIR, $REP) || die "Impossible de lire $REP : $!\n"; | + | opendir(DIR, $REProbot) || die "Impossible de lire $REProbot : $!\n"; |
| - | my @liste = grep { /^[^\.]/ && -r "$REP/$_" } readdir(DIR); | + | my @robots = grep { /^[^\.]/ && -r "$REProbot/$_" } readdir(DIR); |
| closedir(DIR); | closedir(DIR); | ||
| - | # traiter pour chaque liste le fichier config | ||
| # | # | ||
| - | foreach $entree (@liste) | + | # traiter pour chaque robot |
| + | # | ||
| + | ETIQ : foreach $robot (@robots) | ||
| { | { | ||
| + | if ( $robot =~ /blacklist/ ) { next ETIQ ;} | ||
| + | $REP = "$REProbot"."$robot"."/"; | ||
| + | # | ||
| + | # lister le contenu du repertoire /home/sympa/list_data/robot | ||
| + | # | ||
| + | opendir(DIR, $REP) || die "Impossible de lire $REP : $!\n"; | ||
| + | @liste = grep { /^[^\.]/ && -r "$REP/$_" } readdir(DIR); | ||
| + | closedir(DIR); | ||
| + | |||
| + | # | ||
| + | # traiter pour chaque liste le fichier config | ||
| + | # | ||
| + | foreach $entree (@liste) | ||
| + | { | ||
| # | # | ||
| # ouverture du fichier config | # ouverture du fichier config | ||
| # | # | ||
| - | $fichier = "$REP"."$entree"."/config" ; | + | $fichier = "$REP"."$entree"."/config" ; |
| - | copy ("$fichier", "$fichier"."."."$marque") ; | + | copy ("$fichier", "$fichier"."."."$marque") ; |
| - | open (FICH,"$fichier") ||die "probleme fichier config"; | + | open (FICH,"$fichier") ||die "probleme fichier config"; |
| - | @CONFIG = <FICH> ; | + | @CONFIG = <FICH> ; |
| - | close (FICH); | + | close (FICH); |
| - | $nvfichier = "$REP"."$entree"."/nvconfig" ; | + | $nvfichier = "$REP"."$entree"."/nvconfig" ; |
| - | open (NVFICH,">$nvfichier") ||die "probleme nvfichier"; | + | open (NVFICH,">$nvfichier") ||die "probleme nvfichier"; |
| # | # | ||
| # chercher les quotas | # chercher les quotas | ||
| Ligne 63: | Ligne 83: | ||
| if ( $LIGNE =~ /quota/) | if ( $LIGNE =~ /quota/) | ||
| { | { | ||
| - | $LIGNE = " quota "."$nvquota" ; | + | if ( $nvquota ne "NON") |
| - | print " $LIGNE \n" ; | + | { |
| + | $LIGNE = "quota "."$nvquota" ; | ||
| + | chomp $LIGNE ; | ||
| + | print NVFICH "$LIGNE\n" ; | ||
| + | } | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | chomp $LIGNE ; | ||
| + | print NVFICH "$LIGNE\n" ; | ||
| } | } | ||
| - | chomp $LIGNE ; | ||
| - | print NVFICH "$LIGNE\n" ; | ||
| } | } | ||
| close (NVFICH) ; | close (NVFICH) ; | ||
| rename ("$nvfichier","$fichier") ; | rename ("$nvfichier","$fichier") ; | ||
| chown "503" , "503", "$fichier" ; | chown "503" , "503", "$fichier" ; | ||
| + | } | ||
| } | } | ||
| </code> | </code> | ||
