File:  [LON-CAPA] / doc / loncapafiles / removenolongerused.piml
Revision 1.1.2.5: download - view: text, annotated - select for diffs
Sat Aug 31 00:29:28 2013 UTC (10 years, 6 months ago) by raeburn
Branches: version_2_11_X
CVS tags: version_2_11_0_RC1
- For 2.11
  - Backport 1.6

    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:             );
   15:  
   16: my %files = (
   17:               'londaemons' =&gt; ['lonManage','lchtmldir','lonhttpd','lcuseradd','lonc'],
   18:               'apache'     =&gt; ['londropadd.pm','lonconstruct.pm',
   19:                                'admbookmarks.pm','lonassignments.pm'],
   20:               'londocroot' =&gt; ['adm/rat/extpickcode.html',
   21:                                'adm/rat/extpickframe.html'],
   22:             );
   23: 
   24: my %dirs = (
   25:               'londocroot' =&gt; 'htmlarea',
   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:         $choice =~ s/\s+//g;
   63:         if ($choice eq 'Y') {
   64:             File::Path::remove_tree($dir);
   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) {
   72:         next if (($file =~/\*/) || ($file eq '') || ($file eq '/'));
   73:         print "$file -- remove? Enter? Y or N:\n";
   74:         my $choice=&lt;&gt;;
   75:         chomp($choice);
   76:         $choice =~ s/\s+//g;
   77:         if ($choice eq 'Y') {
   78:             unlink($file);
   79:         }
   80:     }
   81: }
   82: 
   83: </perlscript>
   84: </file>
   85: </files>
   86: </piml>

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