/[corp_html]/.data/save_perm.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /.data/save_perm.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Thu Mar 21 09:43:52 2002 UTC (20 years, 8 months ago) by dpavlin
Branch: MAIN
File MIME type: text/plain
save permissions

1 dpavlin 1.1 #!/usr/local/bin/perl -w
2    
3     use English;
4    
5     my @dirs = ("/data/corp_html");
6    
7     while (@dirs) {
8     my $curr_dir=shift @dirs;
9     opendir(DIR,$curr_dir) || warn "opendir: $!";
10     my @ignore = ('.', '..', 'CVS');
11     if (-f "$curr_dir/.cvsignore") {
12     open(I,"$curr_dir/.cvsignore");
13     while(<I>) {
14     chomp;
15     push @ignore,$_;
16     }
17     close(I);
18     }
19     print STDERR "ignore: ",join("|",@ignore);
20     @clutter = readdir(DIR);
21     foreach my $file (@clutter) {
22     if (-l "$curr_dir/$file" && grep(/^\Q$file\E$/,@ignore) == 0) {
23     my $dest=readlink("$curr_dir/$file");
24     $dest="$curr_dir/$dest" if (substr($dest,0,1) ne "/");
25     print "ln -sf $dest $curr_dir/$file\n";
26     } elsif ((-f "$curr_dir/$file" || -d "$curr_dir/$file") && grep(/^\Q$file\E$/,@ignore) == 0) {
27     my (undef,undef,$mode,undef,$uid,$gid) = stat("$curr_dir/$file");
28     if ($uid != $UID || $gid != $GID) {
29     print "chown ",scalar(getpwuid($uid)),":",scalar(getpwuid($gid))," $curr_dir/$file\n";
30     printf "chmod %04o %s\n", ($mode & 07777), "$curr_dir/$file";
31     }
32     push @dirs,"$curr_dir/$file" if (-d "$curr_dir/$file");
33     } else {
34     print STDERR "skip: $curr_dir/$file\n";
35     }
36     }
37     }

  ViewVC Help
Powered by ViewVC 1.1.26