Skip to content
Newer
Older
100644 62 lines (49 sloc) 1.85 KB
926ed2e add fill_users_with_ustatus
k authored
1 #!/usr/bin/perl -w
2
3 =pod
4
5 We just added two fields to table users:
6
7 ustatus enum('unused','active','delete') NOT NULL default 'unused',
8 ustatus_ch datetime NOT NULL default '0000-00-00 00:00:00',
9
10 Now we must see the backpan and change ustatus to active for all
11 existing directories userdirectories.
12
13 In mldistwatch, too, we must check for new userdirectories and mark
14 them.
15
16 =cut
17
18 use strict;
19 use lib "/home/k/PAUSE/lib";
20 use PAUSE;
21 use DBI;
22
95d756b fill_users_with_ustatus: property
k authored
23 my $Rev = q$Rev$;
926ed2e add fill_users_with_ustatus
k authored
24 print "$Rev\n";
25
b59e245 fill_users_with_ustatus: about to run
k authored
26 my $sharp = 1;
926ed2e add fill_users_with_ustatus
k authored
27
28 my $db = DBI->connect(
29 $PAUSE::Config->{MOD_DATA_SOURCE_NAME},
30 $PAUSE::Config->{MOD_DATA_SOURCE_USER},
31 $PAUSE::Config->{MOD_DATA_SOURCE_PW},
32 {RaiseError => 0}
33 );
34
1abb5a2 fill_users_with_ustatus: bugfix
k authored
35 my $U = $db->selectall_hashref("SELECT userid,ustatus FROM users","userid");
926ed2e add fill_users_with_ustatus
k authored
36 my $sth = $db->prepare("UPDATE users SET ustatus='active', ustatus_ch=NOW() WHERE userid=?");
37
38 my $backpan = "/home/ftp/pub/backpan/authors/id";
39 opendir my $dh, $backpan or die $!;
40 for my $de1 (readdir $dh) {
52f96ec fill_users_with_ustatus: bugfix
k authored
41 next if $de1 =~ /^\.\.?$/;
42 die "Illegal directory $backpan/$de1" unless $de1=~/^[A-Z]$/;
b52c942 fill_users_with_ustatus: bugfix
k authored
43 opendir my $dh2, "$backpan/$de1" or die $!;
926ed2e add fill_users_with_ustatus
k authored
44 for my $de2 (readdir $dh2) {
52f96ec fill_users_with_ustatus: bugfix
k authored
45 next if $de2 =~ /^\.\.?$/;
46 die "Illegal directory $backpan/$de1/$de2" unless $de2=~/^[A-Z][-A-Z]$/;
b52c942 fill_users_with_ustatus: bugfix
k authored
47 opendir my $dh3, "$backpan/$de1/$de2" or die $!;
926ed2e add fill_users_with_ustatus
k authored
48 for my $de3 (readdir $dh3) {
52f96ec fill_users_with_ustatus: bugfix
k authored
49 next if $de3 =~ /^\.\.?$/;
b59e245 fill_users_with_ustatus: about to run
k authored
50 # we *have* accepted NI-S and IBMTORDB2:
51 die "Illegal directory $backpan/$de1/$de2/$de3"
52 unless $de3=~/^[A-Z][-A-Z]*[A-Z0-9]+$/;
1abb5a2 fill_users_with_ustatus: bugfix
k authored
53 die "Illegal userdirectory $de3" unless $U->{$de3};
54 die "Deleted userdirectory $de3" if $U->{$de3}{ustatus} eq 'delete';
55 next if $U->{$de3}{ustatus} eq 'active';
56 print "Setting $de3 to active\n";
b70116c fill_users_with_ustatus: bugfix
k authored
57 next unless $sharp;
926ed2e add fill_users_with_ustatus
k authored
58 $sth->execute($de3);
59 }
60 }
61 }
Something went wrong with that request. Please try again.