/[smeserver]/cdrom.image/sme9/product/installclasses/server.py
ViewVC logotype

Annotation of /cdrom.image/sme9/product/installclasses/server.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download) (as text)
Mon Mar 11 18:03:05 2013 UTC (11 years, 8 months ago) by slords
Branch: MAIN
Content type: text/x-python
New sme9 tree

1 slords 1.1 #
2     # server.py
3     #
4    
5     import os, iutil
6    
7     from installclass import BaseInstallClass
8     from rhel import InstallClass as SMEInstallClass
9     from kickstart import AnacondaKSScript as Script
10    
11     from flags import flags
12     from constants import *
13     from pykickstart.constants import *
14    
15     import gettext
16     _ = lambda x: gettext.ldgettext("anaconda", x)
17    
18     import logging
19     log = logging.getLogger("anaconda")
20    
21     class Script:
22     def __repr__(self):
23     str = ("(s: '%s' i: %s c: %d)") % \
24     (self.script, self.interp, self.inChroot)
25     return string.replace(str, "\n", "|")
26    
27     def __init__(self, script, interp = '/bin/sh', inChroot = 1, logfile = None):
28     self.script = script
29     self.interp = interp
30     self.inChroot = inChroot
31     self.logfile = logfile
32    
33     def run(self, chroot, serial, intf = None):
34     import tempfile
35     import os.path
36    
37     if self.inChroot:
38     scriptRoot = chroot
39     else:
40     scriptRoot = "/"
41    
42     (fd, path) = tempfile.mkstemp("", "sme-script-", scriptRoot + "/tmp")
43    
44     os.write(fd, self.script)
45     os.close(fd)
46     os.chmod(path, 0700)
47    
48     if self.logfile:
49     if self.inChroot:
50     messages = "%s/%s" % (scriptRoot, self.logfile)
51     else:
52     messages = self.logfile
53    
54     d = os.path.dirname(messages)
55     if not os.path.exists(d):
56     os.makedirs(d)
57     elif serial:
58     messages = "%s.log" % path
59     else:
60     messages = "/dev/tty3"
61    
62     if intf:
63     intf.suspend()
64     rc = iutil.execWithRedirect(self.interp, ["/tmp/%s" % os.path.basename(path)],
65     stdin = messages, stdout = messages, stderr = messages,
66     root = scriptRoot)
67     if intf:
68     intf.resume()
69    
70     if rc != 0:
71     log.error("ERROR - Error code %s encountered running a sme script", rc)
72    
73     os.unlink(path)
74     if serial or self.logfile:
75     os.chmod("%s" % messages, 0600)
76    
77     class InstallClass(SMEInstallClass):
78     # make sure the translation data is read from product.img tree
79     if os.path.isdir("/tmp/product/locale"):
80     import gettext
81     gettext.bindtextdomain("comps", localedir="/tmp/product/locale")
82     _ = lambda x: gettext.ldgettext("comps", x)
83     N_ = lambda x: x
84    
85     # name has underscore used for mnemonics, strip if you dont need it
86     id = "server"
87     name = N_("SME Server")
88     _description = N_("The default installation of %s is a basic server install. "
89     "You can optionally select a different set of software "
90     "now.")
91     sortPriority = 90000
92     hidden = 0
93    
94     tasks = [(N_("Basic Server"),
95     ["base", "core"]),
96     (N_("Minimal"),
97     ["core"])]
98    
99     def _get_description(self):
100     return gettext.ldgettext("comps", self._description) % self._descriptionFields
101     description = property(_get_description)
102    
103     def postAction(self, anaconda):
104     if anaconda.id.getUpgrade():
105     w = anaconda.intf.waitWindow(_("Post Upgrade"),
106     _("Performing post-upgrade configuration"))
107     log.info("Running post-upgrade action script")
108     script = Script( "#!/bin/sh\n/sbin/rsyslogd ; sleep 2; /sbin/e-smith/signal-event post-upgrade\n" )
109     else:
110     w = anaconda.intf.waitWindow(_("Post Installation"),
111     _("Performing post-installation configuration"))
112     log.info("Running post-install action script")
113     script = Script( "#!/bin/sh\n/sbin/rsyslogd ; sleep 2; /sbin/e-smith/signal-event post-install\n" )
114    
115     script.run(anaconda.rootPath, flags.serial, anaconda.intf)
116     if anaconda.intf is not None:
117     w.pop()
118    
119     SMEInstallClass.postAction(self, anaconda)
120    
121     def setSteps(self, anaconda):
122     BaseInstallClass.setSteps(self, anaconda)
123     #anaconda.dispatch.skipStep("welcome")
124     #anaconda.dispatch.skipStep("filtertype")
125     anaconda.dispatch.skipStep("network")
126     anaconda.dispatch.skipStep("accounts")
127     anaconda.dispatch.skipStep("partition")
128     anaconda.dispatch.skipStep("tasksel")
129     anaconda.dispatch.skipStep("firstboot")
130    
131     def setDefaultPartitioning(self, storage, platform):
132     autorequests = [PartSpec(mountpoint="/", fstype=storage.defaultFSType,
133     size=1024, maxSize=50*1024, grow=True, asVol=True)]
134    
135     bootreq = platform.setDefaultPartitioning()
136     if bootreq:
137     autorequests.extend(bootreq)
138    
139     (minswap, maxswap) = iutil.swapSuggestion()
140     autorequests.append(PartSpec(fstype="swap", size=minswap, maxSize=maxswap,
141     grow=True, asVol=True))
142    
143     storage.autoPartitionRequests = autorequests
144    
145     def setInstallData(self, anaconda):
146     SMEInstallClass.setInstallData(self, anaconda)
147     anaconda.id.security.setSELinux(SELINUX_DISABLED)
148     anaconda.id.storage.clearPartType = CLEARPART_TYPE_ALL
149    
150     def productMatches(self, oldprod):
151     if oldprod is None:
152     return False
153    
154     if oldprod.startswith(productName):
155     return True
156    
157     return False
158    
159     def __init__(self):
160     SMEInstallClass.__init__(self)

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed