File:  [LON-CAPA] / doc / loncapafiles / removenolongerused.piml
Revision 1.1.2.8: download - view: text, annotated - select for diffs
Fri Jun 20 21:33:06 2014 UTC (9 years, 10 months ago) by raeburn
Branches: version_2_11_X
CVS tags: version_2_11_1, version_2_11_0
- For 2.11
  - Backport 1.11

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

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