File:  [LON-CAPA] / doc / loncapafiles / langcheck.piml
Revision 1.33: download - view: text, annotated - select for diffs
Wed May 10 10:22:09 2023 UTC (11 months, 3 weeks ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Add $Id for version number and boilerplate for GPL2.

    1: <!DOCTYPE piml PUBLIC "-//TUX/DTD piml 1.0 Final//EN"
    2:         "http://lpml.sourceforge.net/DTD/piml.dtd">
    3: <!-- langcheck.piml -->
    4: 
    5: <!-- $Id: langcheck.piml,v 1.33 2023/05/10 10:22:09 raeburn Exp $ -->
    6: 
    7: <!--
    8: 
    9: This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   10: 
   11: LON-CAPA is free software; you can redistribute it and/or modify
   12: it under the terms of the GNU General Public License as published by
   13: the Free Software Foundation; either version 2 of the License, or
   14: (at your option) any later version.
   15: 
   16: LON-CAPA is distributed in the hope that it will be useful,
   17: but WITHOUT ANY WARRANTY; without even the implied warranty of
   18: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19: GNU General Public License for more details.
   20: 
   21: You should have received a copy of the GNU General Public License
   22: along with LON-CAPA; if not, write to the Free Software
   23: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24: 
   25: /home/httpd/html/adm/gpl.txt
   26: 
   27: http://www.lon-capa.org/
   28: 
   29: -->
   30: <piml>
   31: <targetroot>/</targetroot>
   32: <files>
   33: <file>
   34: <target dist="default"></target>
   35: <perlscript mode="fg">
   36: 
   37: if (open(PIPE,"locale |")) {
   38:     my @lines = &lt;PIPE&gt;;
   39:     close(PIPE);
   40:     print "Checking root bash language";
   41:     my ($is_english,$is_posix);
   42:     foreach my $line (@lines) {
   43:         if ($line =~ /^LANG=en/) {
   44:             $is_english = 1;
   45:             print "... OK\n";
   46:             last;
   47:         } elsif ($line =~ /^LANG=POSIX/) {
   48:             $is_posix = 1;
   49:         }
   50:         if ($is_posix) {
   51:             if ($line =~ /^LC_CTYPE=en/) {
   52:                 $is_english = 1;
   53:                 print "... OK\n";
   54:                 last;
   55:             }
   56:         }
   57:     }
   58:     if (!$is_english) {
   59:         print "\n**** WARNING: You seem to have a non-English root bash. This can cause incorrect error messages.\n".
   60:         "    It is recommended that you set your bash language to English by setting LANG=en_US.UTF-8 in /root/.bashrc\n";
   61:     }
   62: }
   63: 
   64: my $osmsg = "\n**** WARNING: You seem to have a non-English operating system.\n";
   65: 
   66: if ('<DIST />' eq 'sles9' || '<DIST />' eq 'sles10' || '<DIST />' eq 'sles11' || '<DIST />' eq 'sles12' ||
   67:     '<DIST />' eq 'suse11.1' || '<DIST />' eq 'suse11.2' || '<DIST />' eq 'suse11.3' ||
   68:     '<DIST />' eq 'suse11.4' || '<DIST />' eq 'suse12.1' || '<DIST />' eq 'suse12.2' ||
   69:     '<DIST />' eq 'suse12.3' || '<DIST />' eq 'suse13.1' || '<DIST />' eq 'suse13.2') {
   70:     if (open(PIPE,"cat /etc/sysconfig/language |grep '^RC_LANG' |")) {
   71:         print "Checking OS language";
   72:         if (&lt;PIPE&gt; =~ /^RC_LANG="en/) {
   73:             print "... OK\n";
   74:         } else {
   75:             print $osmsg.
   76:                   "It is recommended that you set LANG=\"en_US.UTF-8\" in /etc/sysconfig/language\n";
   77:         }
   78:         close(PIPE);
   79:     }
   80: } elsif ('<DIST />' eq 'debian5' || '<DIST />' eq 'debian6' || '<DIST />' eq 'ubuntu6' ||
   81:          '<DIST />' eq 'ubuntu8' || '<DIST />' eq 'ubuntu10' || '<DIST />' eq 'ubuntu12' ||
   82:          '<DIST />' eq 'ubuntu14' || '<DIST />' eq 'ubuntu16' || '<DIST />' eq 'ubuntu18' || 
   83:          '<DIST />' eq 'ubuntu20' || '<DIST />' eq 'ubuntu22') {
   84:     if (open(PIPE,"cat /etc/default/locale |grep '^LANG' |")) {
   85:         print "Checking OS language";
   86:         if (&lt;PIPE&gt; =~ /^LANG=en/) {
   87:             print "... OK\n";
   88:         } else {
   89:             print $osmsg.
   90:                   "It is recommended that you set LANG=en_US.UTF-8 in /etc/default/locale\n";
   91:         }
   92:         close(PIPE);
   93:     }
   94: } elsif ('<DIST />' eq 'fedora18' || '<DIST />' eq 'fedora19' || '<DIST />' eq 'fedora20' ||
   95:          '<DIST />' eq 'fedora21' || '<DIST />' eq 'fedora22' || '<DIST />' eq 'fedora23' ||
   96:          '<DIST />' eq 'fedora24' || '<DIST />' eq 'fedora25' || '<DIST />' eq 'fedora26' ||
   97:          '<DIST />' eq 'fedora27' || '<DIST />' eq 'fedora28' || '<DIST />' eq 'fedora29' ||
   98:          '<DIST />' eq 'fedora30' || '<DIST />' eq 'fedora31' || '<DIST />' eq 'fedora32' ||
   99:          '<DIST />' eq 'fedora33' || '<DIST />' eq 'fedora34' || '<DIST />' eq 'fedora35' || 
  100:          '<DIST />' eq 'fedora36' || '<DIST />' eq 'fedora37' || '<DIST />' eq 'fedora38' ||
  101:          '<DIST />' eq 'rhes7'    || '<DIST />' eq 'centos7'  || '<DIST />' eq 'scientific7' ||
  102:          '<DIST />' eq 'rhes8'    || '<DIST />' eq 'centos8'  || '<DIST />' eq 'oracle7'  ||
  103:          '<DIST />' eq 'oracle8'  || '<DIST />' eq 'rocky8'   || '<DIST />' eq 'alma8'    ||
  104:          '<DIST />' eq 'centos8-stream' || '<DIST />' eq 'centos9-stream' || '<DIST />' eq 'rhes9' ||
  105:          '<DIST />' eq 'oracle9'  || '<DIST />' eq 'rocky9'  || '<DIST />' eq 'alma9')  {
  106:     if (open(PIPE,"cat /etc/locale.conf |grep '^LANG' |")) {
  107:         print "Checking OS language";
  108:         if (&lt;PIPE&gt; =~ /^LANG="en/) {
  109:             print "... OK\n";
  110:         } else {
  111:             print $osmsg.
  112:                   "It is recommended that you set LANG=\"en_US.UTF-8\" in /etc/locale.conf\n";
  113:         }
  114:         close(PIPE);
  115:     }
  116: } elsif ('<DIST />' eq 'sles15') {
  117:     if (open(PIPE,"cat /etc/locale.conf |grep '^LANG' |")) {
  118:         print "Checking OS language";
  119:         if (&lt;PIPE&gt; =~ /^LANG=en/) {
  120:             print "... OK\n";
  121:         } else {
  122:             print $osmsg.
  123:                   "It is recommended that you set LANG=en_US.UTF-8 in /etc/locale.conf\n";
  124:         }
  125:         close(PIPE);
  126:     }
  127: } else {
  128:     if (open(PIPE,"cat /etc/sysconfig/i18n |grep '^LANG' |")) {
  129:         print "Checking OS language";
  130:         if (&lt;PIPE&gt; =~ /^LANG="en/) {
  131:             print "... OK\n";
  132:         } else {
  133:             print $osmsg.
  134:                   "It is recommended that you set LANG=\"en_US.UTF-8\" in /etc/sysconfig/i18n.\n";
  135:         }
  136:         close(PIPE);
  137:     }
  138: }
  139: 
  140: </perlscript>
  141: </file>
  142: </files>
  143: </piml>
  144: 

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