Annotation of doc/loncapafiles/removenolongerused.piml, revision 1.1.2.10

1.1       raeburn     1: <piml>
                      2: <targetroot>/</targetroot>
                      3: <files>
                      4: <file>
                      5: <target dist="default"></target>
                      6: <perlscript mode="fg">
                      7: 
1.1.2.2   raeburn     8: use File::Path();
1.1       raeburn     9: 
                     10: my %paths = (
                     11:               'londaemons' =&gt; '/home/httpd/perl',
                     12:               'apache'     =&gt; '/home/httpd/lib/perl/Apache',
                     13:               'londocroot' =&gt; '/home/httpd/html',
1.1.2.7   raeburn    14:               'debug'      =&gt; '/home/httpd/perl/debug',
1.1       raeburn    15:             );
                     16:  
                     17: my %files = (
1.1.2.4   raeburn    18:               'londaemons' =&gt; ['lonManage','lchtmldir','lonhttpd','lcuseradd','lonc'],
1.1       raeburn    19:               'apache'     =&gt; ['londropadd.pm','lonconstruct.pm',
1.1.2.5   raeburn    20:                                'admbookmarks.pm','lonassignments.pm'],
1.1       raeburn    21:               'londocroot' =&gt; ['adm/rat/extpickcode.html',
1.1.2.6   raeburn    22:                                'adm/rat/extpickframe.html',
                     23:                                'adm/help/gif/vbkm.gif',
                     24:                                'adm/help/eps/vbkm.eps'],
1.1.2.7   raeburn    25:               'debug'      =&gt; ['archive_coursedata_tables.pl'],
1.1       raeburn    26:             );
                     27: 
                     28: my %dirs = (
1.1.2.7   raeburn    29:               'londocroot' =&gt; ['htmlarea',
1.1.2.9   raeburn    30:                                   'res/adm/pages/bookmarkmenu',
                     31:                                   'res/adm/pages/reactionresponse',
1.1.2.10! raeburn    32:                                   'adm/jsMath'],
1.1       raeburn    33:            );
                     34: 
                     35: my @filestodelete = ();
                     36: my @dirstodelete = ();
                     37: foreach my $key (sort(keys(%files))) {
                     38:     if ($paths{$key} ne '') {
                     39:         if (ref($files{$key}) eq 'ARRAY') {
                     40:             foreach my $file (@{$files{$key}}) {
1.1.2.7   raeburn    41:                 if (($file ne '') && (-f $paths{$key}.'/'.$file)) {
1.1       raeburn    42:                     push(@filestodelete,$paths{$key}.'/'.$file);
                     43:                 }
                     44:             }
                     45:         }
                     46:     }
                     47: }
                     48: 
                     49: foreach my $key (sort(keys(%dirs))) {
                     50:     if ($paths{$key} ne '') {
                     51:         if (ref($dirs{$key}) eq 'ARRAY') {
                     52:             foreach my $dir (@{$dirs{$key}}) {
1.1.2.7   raeburn    53:                 if (($dir ne '') && (-d $paths{$key}.'/'.$dir)) {
1.1       raeburn    54:                     push(@dirstodelete,$paths{$key}.'/'.$dir);
                     55:                 }
                     56:             }
                     57:         }
                     58:     }
                     59: }
                     60: 
                     61: if (@dirstodelete > 0) {
                     62:     print "\nThe following directories were installed for an earlier version of LON-CAPA, and are no longer needed. It is recommended that you delete them. For each one, enter Y if you would the directory to be deleted.\n\n";
                     63:     foreach my $dir (@dirstodelete) {
1.1.2.2   raeburn    64:         next if (($dir =~/\*/) || ($dir eq '') || ($dir eq '/'));  
1.1       raeburn    65:         print "$dir  -- delete? Enter: Y or N:\n";
                     66:         my $choice=&lt;&gt;;
                     67:         chomp($choice);
1.1.2.2   raeburn    68:         $choice =~ s/\s+//g;
                     69:         if ($choice eq 'Y') {
1.1.2.8   raeburn    70:             File::Path::rmtree($dir);
1.1       raeburn    71:         }
                     72:     }
                     73: }
                     74: 
                     75: if (@filestodelete > 0) {
                     76:    print "\nThe following files were installed for an earlier version of LON-CAPA, and are no longer needed. It is recommended that you delete them. For each one, enter Y if you would the file to be deleted.\n\n";
                     77:     foreach my $file (@filestodelete) {
1.1.2.2   raeburn    78:         next if (($file =~/\*/) || ($file eq '') || ($file eq '/'));
1.1       raeburn    79:         print "$file -- remove? Enter? Y or N:\n";
                     80:         my $choice=&lt;&gt;;
                     81:         chomp($choice);
1.1.2.2   raeburn    82:         $choice =~ s/\s+//g;
                     83:         if ($choice eq 'Y') {
1.1       raeburn    84:             unlink($file);
                     85:         }
                     86:     }
                     87: }
                     88: 
                     89: </perlscript>
                     90: </file>
                     91: </files>
                     92: </piml>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>