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

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

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