ltsp-cluster-lbagent-2.0.2/0000755000175000017500000000000011354202356015773 5ustar stgraberstgraberltsp-cluster-lbagent-2.0.2/setup.py0000644000175000017500000000065011354202356017506 0ustar stgraberstgraber#!/usr/bin/env python from distutils.core import setup setup(name="lbagent", version="2.0.0", description="ltsp-cluster-lbagent", author="Stephane Graber", author_email="stgraber@ubuntu.com", packages = ['lbagent'], package_dir = {'LBagent':'lbagent'}, data_files=[ ('/etc/ltsp', ['lbaconfig.xml']), ('/usr/sbin', ['ltsp-cluster-lbagent']) ] ) ltsp-cluster-lbagent-2.0.2/lbaconfig.xml0000644000175000017500000000507011354202356020443 0ustar stgraberstgraber free | grep ^Mem | awk '{print $2}' cat /proc/cpuinfo | grep "cpu MHz" | awk '{print $4}' | head -1 cat /proc/cpuinfo | grep "model name" | wc -l lsb_release -d -s ip route get 1.2.3.4 | awk 'NR>1{exit};1{print $NF}' hostname ip addr show | grep "inet " | grep -v 127.0.0.1 | sed "s/.*inet //" | sed "s/\/.*//" free | grep "^-/+" | awk '{print $4}' free | grep "^-/+" | awk '{print $3}' cat /proc/loadavg | awk '{print $1}' who -u | cut -d" " -f1 | sort | uniq who -u | cut -d" " -f1 | sort | uniq | wc -l who -u | cut -d" " -f1 | sort | uniq | wc -l ltsp-cluster-lbagent-2.0.2/ltsp-cluster-lbagent0000755000175000017500000000044311354202356021775 0ustar stgraberstgraber#!/usr/bin/python # Wrapper to start ltsp-cluster-lbagent import sys from lbagent import main from lbagent import utils if __name__=="__main__": utils.get_pidfile_lock('/var/run/ltsp-cluster-lbagent.pid') if "--daemon" in sys.argv[1:]: utils.daemonize() main.main() ltsp-cluster-lbagent-2.0.2/lbagent/0000755000175000017500000000000011354202356017407 5ustar stgraberstgraberltsp-cluster-lbagent-2.0.2/lbagent/__init__.py0000644000175000017500000000002311354202356021513 0ustar stgraberstgraberVersion = '1.0.0' ltsp-cluster-lbagent-2.0.2/lbagent/main.py0000644000175000017500000001207711354202356020714 0ustar stgraberstgraber#!/usr/bin/env python """ LBAgent is a service to be executed on the nodes of the cluster. It give a xmlrpc access to hardware specifications and to the current status of the node. A tread is responsible to refresh status information of all variables """ import SimpleXMLRPCServer from threading import Thread from lbagentfactory import LBAgentFactory from lbagent import * def execCommand(command): """ Execute a shell command Returns a string or a table of strings """ import os fd = os.popen(command) consoleOutput = fd.readlines() fd.close() for i in range(len(consoleOutput)): consoleOutput[i]=consoleOutput[i].replace('\n','') if len(consoleOutput) == 1: consoleOutput = consoleOutput[0] return consoleOutput class LogFile: """ Log file wrapper """ def __init__(self,file): self.file=file def close(self): self.file.close() def flush(self): self.file.flush() def write(self,str): self.file.write(str) self.flush() def writelines(self,sequence): self.file.write(sequence) self.flush() def isatty(self): return False class XMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer): """ XMLRPCServer XMLRPC Server overrided to support custom options """ # Override of TIME_WAIT allow_reuse_address = True class LBAgentContainer: """ LBAgentContainer Manage LBAgent instance and configuration """ def __init__(self,configFile): self.loading=False self._configFile = configFile self._loadConfigFile(self._configFile) def _loadConfigFile(self,fileName): # Create new lbAgent with config import os print "Config change, reload LBAgent" self.loading=True try: factory = LBAgentFactory(fileName) lbAgent = factory.newLBAgent() lbAgent.reloadAll() # Save last modification time self._lastm = os.stat(fileName).st_mtime self._lbAgent = lbAgent finally: self.loading=False def _checkConfigChange(self): # Check for changes in config file import os if not(self.loading) and self._lastm != os.stat(self._configFile).st_mtime: self._loadConfigFile(self._configFile) def getLBAgent(self): self._checkConfigChange() return self._lbAgent def getSpecsStruct(self): return self._lbAgent.getSpecsStruct() def getStatusStruct(self): return self._lbAgent.getStatusStruct() def getValuesStruct(self): return self._lbAgent.getSpecsStruct() + self._lbAgent.getStatusStruct() class StatusMonitor(Thread): """ StatusMonitor Refresh periodicaly status information of the node """ global container def __init__(self): self._count = 0 Thread.__init__(self) def reloadVariables(self): for var in container.getLBAgent().variables: if self._count % var.refresh == 0: print "Reload variable : %s at %s"%(var.name,self._count) var.reload() def run(self): import time while True: try: self._count+=1 self.reloadVariables() time.sleep(1) except: traceback.print_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) def main(): import sys import os global container # Parse parameters logFile = None configFile = 'lbaconfig.xml' for arg in sys.argv[1:]: if arg.startswith("--logfile="): logFile=arg.split('=')[1] elif len(arg)>2: configFile=arg if not os.path.exists(configFile): print "Config file not found. Please specify config file as last argument." sys.exit(1) # Init logs if (logFile != None): try: logObject = LogFile(open(logFile,'a',0)) sys.stderr = logObject sys.stdout = logObject except: pass # Create LBAgent Container container = LBAgentContainer(configFile) # Launch status monitor statusMonitor = StatusMonitor() statusMonitor.setDaemon(True) print "Start StatusMonitor..." statusMonitor.start() # Init xmlrpc server print "Start XMLRPC Service..." xmlrpcServer = XMLRPCServer(container.getLBAgent().listen) xmlrpcServer.register_function(container.getSpecsStruct,'get_specs') xmlrpcServer.register_function(container.getStatusStruct,'get_status') xmlrpcServer.register_function(container.getValuesStruct,'get_values') # Launch xmlrpc server try: xmlrpcServer.serve_forever() finally: xmlrpcServer.server_close() if __name__ == "__main__": import utils utils.get_pidfile_lock('/var/run/ltsp-cluster-lbagent.pid') if "--daemon" in sys.argv[1:]: utils.daemonize() main() ltsp-cluster-lbagent-2.0.2/lbagent/lbagent.py0000644000175000017500000000711011354202356021374 0ustar stgraberstgraber#!/usr/bin/env python """ LBAgent is a service to be executed on the nodes of the cluster. It give a xmlrpc access to hardware specifications and to the current status of the node. A tread is responsible to refresh status information of all variables """ import re import sys import string def execCommand(command): import os fd = os.popen(command) consoleOutput = fd.readlines() fd.close() for i in range(len(consoleOutput)): consoleOutput[i]=string.strip(consoleOutput[i].replace('\n','')) try: consoleOutput[i]=eval(consoleOutput[i]) except: pass if len(consoleOutput) == 1: consoleOutput = consoleOutput[0] return consoleOutput class LBAgent: """ LBAgent Manage constants and variables """ def __init__(self): self.listen=('',8000) self.constants = [] self.variables = [] def reloadAll(self): for c in self.constants: c.reload() for v in self.variables: v.reload() def parseString(self,s): # Sort by name length sTab = [] + self.constants + self.variables sTab.sort(lambda v1, v2: cmp(len(v2.name),len(v1.name))) # Replace value in string for x in sTab: if not(isinstance(x.value,list)): s = s.replace('$'+x.name,str(x.value)) return s def getSpecsStruct(self): return [c.getStruct() for c in self.constants] def getStatusStruct(self): return [v.getStruct() for v in self.variables] class LBConstant: """ Constant Contains hardware specification """ def __init__(self,lbAgent): self._lbAgent=lbAgent self.name=None self.value=None self.command=None self.eval=None def reload(self): if self.command != None: self.value = execCommand(self.command) elif self.eval != None: self.value = eval(self._lbAgent.parseString(self.eval)) def getStruct(self): strt = {} strt["name"] = self.name strt["value"] = self.value return strt class LBVariable: """ Variable Contains status information """ def __init__(self,lbAgent): self._lbAgent=lbAgent self.name=None self.value=None self.command=None self.eval=None self.capacity=None self.critical=None self.capacityValue=None self.criticalValue=None self.refresh=60 def reload(self): if self.command != None: self.value = execCommand(self.command) elif self.eval != None: try: self.value = eval(self._lbAgent.parseString(self.eval)) except: print "ERROR: Variable :%s eval=%s, eval(%s) except %s"%(self.name,self.eval,str(self._lbAgent.parseString(self.eval)),str(sys.exc_info()[0])) if self.capacity!=None: self.capacityValue=eval(self._lbAgent.parseString(self.capacity)) if self.critical!=None: self.criticalValue=eval(self._lbAgent.parseString(self.critical)) def getStruct(self): strt = {} strt["name"] = self.name strt["value"] = self.value if self.capacityValue != None: strt["capacity"] = self.capacityValue if self.criticalValue != None: strt["critical"] = self.criticalValue return strt def main(): pass if __name__ == "__main__": main() ltsp-cluster-lbagent-2.0.2/lbagent/testexec.py0000644000175000017500000000114711354202356021610 0ustar stgraberstgraber#!/usr/bin/env python def main(): print 'Start...' import os cmd="for X in redhat SuSE mandrake debian knoppix fedora mandriva ; do \n" + \ "if [ -f /etc/$X-release ]; then \n" + \ " cat /etc/$X-release ; \n" + \ " break ; \n" + \ " fi ; \n" + \ " done ; " fd = os.popen("who") consoleOutput = fd.readlines() fd.close() for i in range(len(consoleOutput)): consoleOutput[i]=consoleOutput[i].replace('\n','') print consoleOutput if __name__ == "__main__": main() ltsp-cluster-lbagent-2.0.2/lbagent/lbagentfactory.py0000644000175000017500000001040011354202356022760 0ustar stgraberstgraber#!/usr/bin/env python from lbagent import * def splitHostPort(s): h,p = s.split(':') p = int(p) if h == '*': h = '' return h,p class ConfigError(Exception): pass class LBAgentFactory: def __init__(self, filename=None, xml=None): dom = self._loadDOM(filename, xml) if dom.nodeName != 'lbaconfig': raise ConfigError, "expected top level 'lbaconfig', got '%s'"%(dom.nodeName) def _loadDOM(self, filename, xml): from xml.dom.minidom import parseString if filename is not None: xml = open(filename).read() elif xml is None: raise ConfigError, "need filename or xml" self.dom = parseString(xml) return self.dom.childNodes[0] def _createLBAgent(self): return LBAgent() def _loadLBAgent(self, elem): lbAgent = self._createLBAgent() for item in elem.childNodes: if item.nodeName in ("#text", "#comment"): continue if item.nodeName == u'lbaservice': if item.hasAttribute('listen'): lbAgent.listen = splitHostPort(item.getAttribute('listen')) elif item.nodeName == u'specs': lbAgent.constants=self._loadConstants(lbAgent,item) elif item.nodeName == u'status': lbAgent.variables=self._loadVariables(lbAgent,item) else: raise ConfigError, "expected 'lbaservice', 'specs' or 'status', got '%s'"%item.nodeName return lbAgent def _loadConstants(self,lbAgent,elem): constants = [] for item in elem.childNodes: if item.nodeName in ("#text", "#comment"): continue if item.nodeName == u'constant': constants.append(self._loadConstant(lbAgent,item)) else: raise ConfigError, "expected 'constant' got '%s'"%item.nodeName return constants def _loadConstant(self,lbAgent,elem): constant = LBConstant(lbAgent) if elem.hasAttribute('name'): constant.name = elem.getAttribute('name') for item in elem.childNodes: if item.nodeName in ("#text", "#comment"): continue if item.nodeName == u'value': constant.value = self._loadText(item) elif item.nodeName == u'command': constant.command = self._loadText(item) elif item.nodeName == u'eval': constant.eval = self._loadText(item) else: raise ConfigError, "expected 'value', 'command' or 'eval' got '%s'"%item.nodeName return constant def _loadVariables(self,lbAgent,elem): variables = [] for item in elem.childNodes: if item.nodeName in ("#text", "#comment"): continue if item.nodeName == u'variable': variables.append(self._loadVariable(lbAgent,item)) else: raise ConfigError, "expected 'variable' got '%s'"%item.nodeName return variables def _loadVariable(self,lbAgent,elem): variable = LBVariable(lbAgent) if elem.hasAttribute('name'): variable.name = elem.getAttribute('name') if elem.hasAttribute('refresh-delay'): variable.refresh = int(elem.getAttribute('refresh-delay')) if elem.hasAttribute('capacity'): variable.capacity = elem.getAttribute('capacity') if elem.hasAttribute('critical'): variable.critical = elem.getAttribute('critical') for item in elem.childNodes: if item.nodeName in ("#text", "#comment"): continue if item.nodeName == u'command': variable.command = self._loadText(item) elif item.nodeName == u'eval': variable.eval = self._loadText(item) else: raise ConfigError, "expected 'command' or 'eval' got '%s'"%item.nodeName return variable def _loadText(self,elem): text = '' for item in elem.childNodes: if item.nodeName == "#text": text=text+item.nodeValue return text def newLBAgent(self): lbAgent = self._loadLBAgent(self.dom.childNodes[0]) return lbAgent def main(): pass if __name__ == "__main__": main() ltsp-cluster-lbagent-2.0.2/lbagent/utils.py0000644000175000017500000001077611354202356021134 0ustar stgraberstgraber# -*- coding: utf-8 -*- # # $Revision: 1.64 $ # $Date: 2005/09/26 19:58:43 $ # $Author: dwelch $ # # (c) Copyright 2001-2005 Hewlett-Packard Development Company, L.P. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Author: Don Welch # # Thanks to Henrique M. Holschuh for various security patches # from __future__ import generators # Std Lib import sys, os, fnmatch, tempfile, socket, struct, select, time import fcntl, errno, stat, string, xml.parsers.expat, commands # Local #from g import * #from codes import * # For pidfile locking (must be "static" and global to the whole app) prv_pidfile = None prv_pidfile_name = "" def get_pidfile_lock ( a_pidfile_name="" ): """ Call this to either lock the pidfile, or to update it after a fork() Credit: Henrique M. Holschuh """ global prv_pidfile global prv_pidfile_name if prv_pidfile_name == "": try: prv_pidfile_name = a_pidfile_name prv_pidfile = os.fdopen(os.open(prv_pidfile_name, os.O_RDWR | os.O_CREAT, 0644), 'r+') fcntl.fcntl(prv_pidfile.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC) while 1: try: fcntl.flock(prv_pidfile.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB) except (OSError, IOError), e: if e.errno == errno.EINTR: continue elif e.errno == errno.EWOULDBLOCK: try: prv_pidfile.seek(0) otherpid = int(prv_pidfile.readline(), 10) sys.stderr.write ("can't lock %s, running daemon's pid may be %d\n" % (prv_pidfile_name, otherpid)) except (OSError, IOError), e: sys.stderr.write ("error reading pidfile %s: (%d) %s\n" % (prv_pidfile_name, e.errno, e.strerror)) sys.exit(1) sys.stderr.write ("can't lock %s: (%d) %s\n" % (prv_pidfile_name, e.errno, e.strerror)) sys.exit(1) break except (OSError, IOError), e: sys.stderr.write ("can't open pidfile %s: (%d) %s\n" % (prv_pidfile_name, e.errno, e.strerror)) sys.exit(1) try: prv_pidfile.seek(0) prv_pidfile.write("%d\n" % (os.getpid())) prv_pidfile.flush() prv_pidfile.truncate() except (OSError, IOError), e: log.error("can't update pidfile %s: (%d) %s\n" % (prv_pidfile_name, e.errno, e.strerror)) def daemonize ( stdin='/dev/null', stdout='/dev/null', stderr='/dev/null' ): """ Credit: Jürgen Hermann, Andy Gimblett, and Noah Spurrier http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 Proper pidfile support: Henrique M. Holschuh """ # Try to lock pidfile if not locked already if prv_pidfile_name != '' or prv_pidfile_name != "": get_pidfile_lock( prv_pidfile_name ) # Do first fork. try: pid = os.fork() if pid > 0: sys.exit(0) # Exit first parent. except OSError, e: sys.stderr.write ("fork #1 failed: (%d) %s\n" % (e.errno, e.strerror) ) sys.exit(1) # Decouple from parent environment. os.chdir("/") os.umask(0) os.setsid() # Do second fork. try: pid = os.fork() if pid > 0: sys.exit(0) # Exit second parent. except OSError, e: sys.stderr.write ("fork #2 failed: (%d) %s\n" % (e.errno, e.strerror) ) sys.exit(1) if prv_pidfile_name != "": get_pidfile_lock() # Now I am a daemon! # Redirect standard file descriptors. si = file(stdin, 'r') so = file(stdout, 'a+') se = file(stderr, 'a+', 0) os.dup2(si.fileno(), sys.stdin.fileno()) os.dup2(so.fileno(), sys.stdout.fileno()) os.dup2(se.fileno(), sys.stderr.fileno()) ltsp-cluster-lbagent-2.0.2/AUTHORS0000644000175000017500000000176411354202356017053 0ustar stgraberstgraberCopyright (applies if no explicit header in the file): This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Authors: * Stephane Bond , 2006 CRIM * Ivan Arsenault , 2006 CRIM * Francis Giraldeau , 2006-2008 Revolution Linux * Stephane Graber , 2008-2009 Revolution Linux ltsp-cluster-lbagent-2.0.2/release.conf0000644000175000017500000000005011354202356020255 0ustar stgraberstgraberNAME=ltsp-cluster-lbagent VERSION=2.0.2 ltsp-cluster-lbagent-2.0.2/COPYING0000644000175000017500000004307611354202356017040 0ustar stgraberstgraber GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.