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 Prochaine révision Les deux révisions suivantes | ||
tuto:ipasserelle:divers:scripts_dokuwiki [08/10/2013 17:20] dani |
tuto:ipasserelle:divers:scripts_dokuwiki [16/01/2019 11:49] dani |
||
---|---|---|---|
Ligne 3: | Ligne 3: | ||
Voilà quelques scripts qui permettent de générer des tableaux au format dokuwiki: | Voilà quelques scripts qui permettent de générer des tableaux au format dokuwiki: | ||
- | * Génère un tableau de tous les dossiers partagés (uniquement via la contrib | + | |
+ | |||
+ | <file perl users.pl> | ||
+ | # | ||
+ | |||
+ | use strict; | ||
+ | use esmith:: | ||
+ | use esmith:: | ||
+ | |||
+ | my $a = esmith:: | ||
+ | my $c = esmith:: | ||
+ | |||
+ | my $main_dom = $c-> | ||
+ | |||
+ | my @fws_accounts = qw( | ||
+ | fws | ||
+ | maillog | ||
+ | backup | ||
+ | mails-partages | ||
+ | scanner | ||
+ | deploiement | ||
+ | auth | ||
+ | ); | ||
+ | |||
+ | print '^ Identifiant ^ Nom ^ Prénom ^ Adresse email principale ^' . " | ||
+ | |||
+ | foreach ($a-> | ||
+ | my $name = $_-> | ||
+ | if (grep { $name eq $_ } @fws_accounts){ | ||
+ | $name = '< | ||
+ | } elsif (($_-> | ||
+ | $name = '< | ||
+ | } | ||
+ | print ' | ||
+ | ' | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | | ||
<file perl shares.pl> | <file perl shares.pl> | ||
# | # | ||
Ligne 25: | Ligne 64: | ||
} | } | ||
elsif ($remote eq ' | elsif ($remote eq ' | ||
- | $rem = ' | + | $rem = ' |
} | } | ||
elsif ($remote eq ' | elsif ($remote eq ' | ||
- | $rem = ' | + | $rem = ' |
} | } | ||
elsif ($remote eq ' | elsif ($remote eq ' | ||
- | $rem = ' | + | $rem = ' |
} | } | ||
elsif ($remote eq ' | elsif ($remote eq ' | ||
- | $rem = ' | + | $rem = ' |
} | } | ||
elsif ($remote eq ' | elsif ($remote eq ' | ||
Ligne 41: | Ligne 80: | ||
my $com = ''; | my $com = ''; | ||
if ($name eq ' | if ($name eq ' | ||
- | $com = " | + | $com = " |
} | } | ||
elsif ($name eq ' | elsif ($name eq ' | ||
- | $com = " | + | $com = " |
} | } | ||
elsif ($name eq ' | elsif ($name eq ' | ||
- | $com = " | + | $com = " |
} | } | ||
elsif ($name eq ' | elsif ($name eq ' | ||
- | $com = " | + | $com = " |
} | } | ||
print ' | print ' | ||
+ | } | ||
+ | foreach my $ibay ($a-> | ||
+ | my $name = $ibay-> | ||
+ | my $access = $ibay-> | ||
+ | my $remote = $ibay-> | ||
+ | my $group = $ibay-> | ||
+ | my $com = $ibay-> | ||
+ | my $w = ''; | ||
+ | my $r = ''; | ||
+ | my $rem = ''; | ||
+ | if ($access eq ' | ||
+ | $w = $group; | ||
+ | } | ||
+ | elsif ($access eq ' | ||
+ | $w = $group; | ||
+ | $r = 'Tous les utilisateurs'; | ||
+ | } | ||
+ | elsif ($access eq ' | ||
+ | $w = ' | ||
+ | $w = $group; | ||
+ | } | ||
+ | if ($remote eq ' | ||
+ | $rem = ' | ||
+ | } | ||
+ | elsif ($remote eq ' | ||
+ | $rem = ' | ||
+ | } | ||
+ | elsif ($remote eq ' | ||
+ | $rem = ' | ||
+ | } | ||
+ | elsif ($remote eq ' | ||
+ | $rem = ' | ||
+ | } | ||
+ | elsif ($remote eq ' | ||
+ | $rem = ' | ||
+ | } | ||
+ | elsif ($remote eq ' | ||
+ | $rem = ' | ||
+ | } | ||
+ | print ' | ||
} | } | ||
</ | </ | ||
Ligne 96: | Ligne 175: | ||
print ' | print ' | ||
+ | </ | ||
+ | |||
+ | * Génère un tableau avec les groupes (et leur pseudo pointant dessus) et la liste des utilisateurs qui recevront les mails | ||
+ | <file perl grpmail.pl> | ||
+ | # | ||
+ | |||
+ | use esmith:: | ||
+ | use esmith:: | ||
+ | |||
+ | my $a = esmith:: | ||
+ | my $c = esmith:: | ||
+ | my $domain = $c-> | ||
+ | |||
+ | print ' | ||
+ | |||
+ | foreach my $group ($a-> | ||
+ | my $name = $group-> | ||
+ | my $addr = $name . ' | ||
+ | foreach my $pseudo ($a-> | ||
+ | my $target = $pseudo-> | ||
+ | if ($target eq $name){ | ||
+ | my $p = $pseudo-> | ||
+ | $p .= ($pseudo-> | ||
+ | $addr .= '\\\\ ' . $p; | ||
+ | } | ||
+ | } | ||
+ | my @members = split ',', | ||
+ | my $str = ' | ||
+ | foreach my $member (@members){ | ||
+ | $member .= ($member =~ m/\@/) ? '' | ||
+ | $str .= $member . ', '; | ||
+ | } | ||
+ | $str =~ s/, $//; | ||
+ | $str .= ' |' . " | ||
+ | print $str; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | * Rapports de sauvegardes BackupPC | ||
+ | |||
+ | <file perl backups.pl> | ||
+ | # | ||
+ | |||
+ | use lib "/ | ||
+ | use BackupPC:: | ||
+ | use BackupPC:: | ||
+ | use POSIX; | ||
+ | use List::Util qw(min); | ||
+ | use Data:: | ||
+ | |||
+ | # We need to switch to backuppc UID/GID | ||
+ | my $uid = getuid(); | ||
+ | my $gid = getgid(); | ||
+ | my (undef, | ||
+ | setuid($bkpuid) if ($uid ne $bkpuid); | ||
+ | setgid($bkpgid) if ($gid ne $bkpgid); | ||
+ | |||
+ | my $bpc = BackupPC:: | ||
+ | my $hosts = $bpc-> | ||
+ | my $mainConf = $bpc-> | ||
+ | |||
+ | print '^ Jeux de sauvegarde ^ Description ^ Fréquence (jours) ^ volume complète (Go) ^ Volume incrémental (Go) ^ Durée moyenne (minutes) ^' . " | ||
+ | |||
+ | foreach my $host (sort keys %$hosts){ | ||
+ | my $hostConf = $bpc-> | ||
+ | my $conf = { %$mainConf, %$hostConf }; | ||
+ | my @backups = $bpc-> | ||
+ | my ($nb_bkp, | ||
+ | |||
+ | foreach my $backup (@backups){ | ||
+ | $nb_bkp += 1; | ||
+ | $duration += $backup-> | ||
+ | if ($backup-> | ||
+ | $nb_full += 1; | ||
+ | $size_full = $backup-> | ||
+ | } else { | ||
+ | $nb_incr += 1; | ||
+ | } | ||
+ | # The size of new files can be computed for full or incr | ||
+ | $size_incr += $backup-> | ||
+ | } | ||
+ | |||
+ | if ($nb_bkp > 0){ | ||
+ | $duration = sprintf(' | ||
+ | $size_incr = sprintf(' | ||
+ | } | ||
+ | $size_full = sprintf(' | ||
+ | my $freq = ($conf-> | ||
+ | |||
+ | print " | ||
+ | } | ||
</ | </ |