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

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',
                     14:             );
                     15:  
                     16: my %files = (
1.1.2.4   raeburn    17:               'londaemons' =&gt; ['lonManage','lchtmldir','lonhttpd','lcuseradd','lonc'],
1.1       raeburn    18:               'apache'     =&gt; ['londropadd.pm','lonconstruct.pm',
1.1.2.5   raeburn    19:                                'admbookmarks.pm','lonassignments.pm'],
1.1       raeburn    20:               'londocroot' =&gt; ['adm/rat/extpickcode.html',
1.1.2.6 ! raeburn    21:                                'adm/rat/extpickframe.html',
        !            22:                                'adm/help/gif/vbkm.gif',
        !            23:                                'adm/help/eps/vbkm.eps'],
1.1       raeburn    24:             );
                     25: 
                     26: my %dirs = (
1.1.2.1   raeburn    27:               'londocroot' =&gt; 'htmlarea',
1.1       raeburn    28:                               'res/adm/pages/bookmarkmenu',
                     29:            );
                     30: 
                     31: my @filestodelete = ();
                     32: my @dirstodelete = ();
                     33: foreach my $key (sort(keys(%files))) {
                     34:     if ($paths{$key} ne '') {
                     35:         if (ref($files{$key}) eq 'ARRAY') {
                     36:             foreach my $file (@{$files{$key}}) {
                     37:                 if (-f $paths{$key}.'/'.$file) {
                     38:                     push(@filestodelete,$paths{$key}.'/'.$file);
                     39:                 }
                     40:             }
                     41:         }
                     42:     }
                     43: }
                     44: 
                     45: foreach my $key (sort(keys(%dirs))) {
                     46:     if ($paths{$key} ne '') {
                     47:         if (ref($dirs{$key}) eq 'ARRAY') {
                     48:             foreach my $dir (@{$dirs{$key}}) {
                     49:                 if (-d $paths{$key}.'/'.$dir) {
                     50:                     push(@dirstodelete,$paths{$key}.'/'.$dir);
                     51:                 }
                     52:             }
                     53:         }
                     54:     }
                     55: }
                     56: 
                     57: if (@dirstodelete > 0) {
                     58:     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";
                     59:     foreach my $dir (@dirstodelete) {
1.1.2.2   raeburn    60:         next if (($dir =~/\*/) || ($dir eq '') || ($dir eq '/'));  
1.1       raeburn    61:         print "$dir  -- delete? Enter: Y or N:\n";
                     62:         my $choice=&lt;&gt;;
                     63:         chomp($choice);
1.1.2.2   raeburn    64:         $choice =~ s/\s+//g;
                     65:         if ($choice eq 'Y') {
                     66:             File::Path::remove_tree($dir);
1.1       raeburn    67:         }
                     68:     }
                     69: }
                     70: 
                     71: if (@filestodelete > 0) {
                     72:    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";
                     73:     foreach my $file (@filestodelete) {
1.1.2.2   raeburn    74:         next if (($file =~/\*/) || ($file eq '') || ($file eq '/'));
1.1       raeburn    75:         print "$file -- remove? Enter? Y or N:\n";
                     76:         my $choice=&lt;&gt;;
                     77:         chomp($choice);
1.1.2.2   raeburn    78:         $choice =~ s/\s+//g;
                     79:         if ($choice eq 'Y') {
1.1       raeburn    80:             unlink($file);
                     81:         }
                     82:     }
                     83: }
                     84: 
                     85: </perlscript>
                     86: </file>
                     87: </files>
                     88: </piml>

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