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

1.1       raeburn     1: <piml>
                      2: <targetroot>/</targetroot>
                      3: <files>
                      4: <file>
                      5: <target dist="default"></target>
                      6: <perlscript mode="fg">
                      7: 
                      8: use File::Path qw(remove_tree);
                      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 = (
                     17:               'londaemons' =&gt; ['lonManage','lchtmldir','lonhttpd'],
                     18:               'apache'     =&gt; ['londropadd.pm','lonconstruct.pm',
1.1.2.1 ! raeburn    19:                                'admbookmarks.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) {
                     58:         next if (($dir =~/*/) || ($dir eq '') || ($dir eq '/'));  
                     59:         print "$dir  -- delete? Enter: Y or N:\n";
                     60:         my $choice=&lt;&gt;;
                     61:         chomp($choice);
                     62:         if ($choice==Y) {
                     63:             remove_tree($dir);
                     64:         }
                     65:     }
                     66: }
                     67: 
                     68: if (@filestodelete > 0) {
                     69:    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";
                     70:     foreach my $file (@filestodelete) {
                     71:         next if (($file =~/*/) || ($file eq '') || ($file eq '/'));
                     72:         print "$file -- remove? Enter? Y or N:\n";
                     73:         my $choice=&lt;&gt;;
                     74:         chomp($choice);
                     75:         if ($choice==Y) {
                     76:             unlink($file);
                     77:         }
                     78:     }
                     79: }
                     80: 
                     81: </perlscript>
                     82: </file>
                     83: </files>
                     84: </piml>

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