File:  [LON-CAPA] / doc / loncapafiles / removenolongerused.piml
Revision 1.1.2.9: download - view: text, annotated - select for diffs
Fri Aug 5 14:37:53 2016 UTC (7 years, 8 months ago) by raeburn
Branches: version_2_11_X
- For 2.11
  Backport 1.12, 1.13

    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:                                   'res/adm/pages/reactionresponse',
   32:                                   adm/jsMath'],
   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}}) {
   41:                 if (($file ne '') && (-f $paths{$key}.'/'.$file)) {
   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}}) {
   53:                 if (($dir ne '') && (-d $paths{$key}.'/'.$dir)) {
   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) {
   64:         next if (($dir =~/\*/) || ($dir eq '') || ($dir eq '/'));  
   65:         print "$dir  -- delete? Enter: Y or N:\n";
   66:         my $choice=&lt;&gt;;
   67:         chomp($choice);
   68:         $choice =~ s/\s+//g;
   69:         if ($choice eq 'Y') {
   70:             File::Path::rmtree($dir);
   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) {
   78:         next if (($file =~/\*/) || ($file eq '') || ($file eq '/'));
   79:         print "$file -- remove? Enter? Y or N:\n";
   80:         my $choice=&lt;&gt;;
   81:         chomp($choice);
   82:         $choice =~ s/\s+//g;
   83:         if ($choice eq 'Y') {
   84:             unlink($file);
   85:         }
   86:     }
   87: }
   88: 
   89: </perlscript>
   90: </file>
   91: </files>
   92: </piml>

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