[LON-CAPA-cvs] cvs: loncom /debugging_tools make_user_ca.pl make_user_cc.pl

matthew lon-capa-cvs@mail.lon-capa.org
Sun, 12 Sep 2004 21:27:05 -0000


matthew		Sun Sep 12 17:27:05 2004 EDT

  Added files:                 
    /loncom/debugging_tools	make_user_ca.pl make_user_cc.pl 
  Log:
  Some debugging tools that have been sitting around for a while.
  
  

Index: loncom/debugging_tools/make_user_ca.pl
+++ loncom/debugging_tools/make_user_ca.pl
#!/usr/bin/perl -w
#
use strict;
use GDBM_File;
my %roles;

my $user      = shift;
my $userdom   = shift;
my $target    = shift; # The account to make $user a co-author on
my $targetdom = shift;
my $days      = shift; # The number of days to have the role last

if (! defined($user)) {
    die "usage: make_user_ca.pl user userdom course coursedom daysuntilexpire";
}

my $endtime = time + 24*60*60*$days;

print "user      = $user\n";
print "userdom   = $userdom\n";
print "target    = $target\n";
print "targetdom = $targetdom\n";
print "days      = $days\n";
print "endtime   = $endtime\n";

my ($a,$b,$c,undef) = split(//,$user,4);
my $dbfile = "/home/httpd/lonUsers/$userdom/$a/$b/$c/$user/roles.db";

print "dbfile = $dbfile\n";

tie (%roles,'GDBM_File',$dbfile,
	&GDBM_WRCREAT(),0640);
$roles{'/'.$targetdom.'/'.$target.'_ca'}='ca_'.$endtime.'_'.time;
open OUT, ">/home/httpd/lonUsers/$userdom/$a/$b/$c/$user/roles.hist";
foreach (keys(%roles)) {
    print OUT $_.' : '.$roles{$_}."\n";
}
close OUT;

untie %roles;
`chown www:www /home/httpd/lonUsers/$userdom/$a/$b/$c/$user/roles.hist`;
`chown www:www /home/httpd/lonUsers/$userdom/$a/$b/$c/$user/roles.db`;


Index: loncom/debugging_tools/make_user_cc.pl
+++ loncom/debugging_tools/make_user_cc.pl
#!/usr/bin/perl -w
#
use strict;
use GDBM_File;
my %roles;

my $user      = shift;
my $userdom   = shift;
my $course    = shift; # The account to make $user a course coordinator on
my $coursedom = shift;
my $days      = shift; # The number of days to have the role last

if (! defined($user)) {
    die "usage: make_user_cc.pl user userdom course coursedom daysuntilexpire";
}

my $endtime = time + 24*60*60*$days;

print "user      = $user\n";
print "userdom   = $userdom\n";
print "target    = $course\n";
print "targetdom = $coursedom\n";
print "days      = $days\n";
print "endtime   = $endtime\n";

my ($a,$b,$c,undef) = split(//,$user,4);
my $dbfile   = "/home/httpd/lonUsers/$userdom/$a/$b/$c/$user/roles.db";
my $histfile = "/home/httpd/lonUsers/$userdom/$a/$b/$c/$user/roles.hist";

tie (%roles,'GDBM_File',$dbfile,&GDBM_WRCREAT(),0640);
$roles{'/'.$coursedom.'/'.$course.'_cc'}='cc';

open OUT, ">".$histfile;
foreach (keys(%roles)) {
    print OUT $_.' : '.$roles{$_}."\n";
}
close OUT;

untie %roles;

system ("chown www:www $histfile");
system ("chown www:www $dbfile");