File:  [LON-CAPA] / doc / loncapafiles / removenolongerused.piml
Revision 1.1.2.12: download - view: text, annotated - select for diffs
Fri Dec 24 16:09:09 2021 UTC (2 years, 4 months ago) by raeburn
Branches: version_2_11_X
CVS tags: version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4
- For 2.11
  Backport 1.15

    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:                                'adm/jQuery/js/jquery-1.3.2.min.js',
   26:                                'adm/jQuery/js/jquery-1.6.2.min.js',
   27:                                'adm/jQuery/js/jquery-1.11.3.min.js',
   28:                                'adm/jQuery/js/jquery-ui-1.7.2.custom.min.js',
   29:                                'adm/jQuery/js/jquery-ui-1.8.16.custom.min.js',
   30:                                'adm/jQuery/js/jquery-ui-1.11.4.custom.min.js',
   31:                                'adm/jQuery/css/smoothness/jquery-ui-1.7.2.custom.css',
   32:                                'adm/jQuery/css/smoothness/jquery-ui-1.8.16.custom.css',
   33:                                'adm/jQuery/js/css/smoothness/jquery-ui-1.11.4.custom.css',
   34:                                'adm/reactionresponse/reaction_frame.html',
   35:                                'adm/reactionresponse/reaction_window.html'],
   36:               'debug'      =&gt; ['archive_coursedata_tables.pl'],
   37:             );
   38: 
   39: my %dirs = (
   40:               'londocroot' =&gt; ['htmlarea',
   41:                                   'res/adm/pages/bookmarkmenu',
   42:                                   'res/adm/pages/reactionresponse',
   43:                                   'adm/jsMath',
   44:                                   'adm/jQuery/css/ui-lightness'],
   45:            );
   46: 
   47: my @filestodelete = ();
   48: my @dirstodelete = ();
   49: foreach my $key (sort(keys(%files))) {
   50:     if ($paths{$key} ne '') {
   51:         if (ref($files{$key}) eq 'ARRAY') {
   52:             foreach my $file (@{$files{$key}}) {
   53:                 if (($file ne '') && (-f $paths{$key}.'/'.$file)) {
   54:                     push(@filestodelete,$paths{$key}.'/'.$file);
   55:                 }
   56:             }
   57:         }
   58:     }
   59: }
   60: 
   61: foreach my $key (sort(keys(%dirs))) {
   62:     if ($paths{$key} ne '') {
   63:         if (ref($dirs{$key}) eq 'ARRAY') {
   64:             foreach my $dir (@{$dirs{$key}}) {
   65:                 if (($dir ne '') && (-d $paths{$key}.'/'.$dir)) {
   66:                     push(@dirstodelete,$paths{$key}.'/'.$dir);
   67:                 }
   68:             }
   69:         }
   70:     }
   71: }
   72: 
   73: if (@dirstodelete > 0) {
   74:     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";
   75:     foreach my $dir (@dirstodelete) {
   76:         next if (($dir =~/\*/) || ($dir eq '') || ($dir eq '/'));  
   77:         print "$dir  -- delete? Enter: Y or N:\n";
   78:         my $choice=&lt;&gt;;
   79:         chomp($choice);
   80:         $choice =~ s/\s+//g;
   81:         if ($choice eq 'Y') {
   82:             File::Path::rmtree($dir);
   83:         }
   84:     }
   85: }
   86: 
   87: if (@filestodelete > 0) {
   88:    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";
   89:     foreach my $file (@filestodelete) {
   90:         next if (($file =~/\*/) || ($file eq '') || ($file eq '/'));
   91:         print "$file -- remove? Enter? Y or N:\n";
   92:         my $choice=&lt;&gt;;
   93:         chomp($choice);
   94:         $choice =~ s/\s+//g;
   95:         if ($choice eq 'Y') {
   96:             unlink($file);
   97:         }
   98:     }
   99: }
  100: 
  101: </perlscript>
  102: </file>
  103: </files>
  104: </piml>

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