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

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

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


Revision 1.5 - (show annotations) (download) (as text)
Thu Oct 31 15:56:37 2013 UTC (11 years, 1 month ago) by charliebrady
Branch: MAIN
Changes since 1.4: +5 -0 lines
Content type: text/x-python
Add versionMatches method to installclass file, to allow upgrade.
Bug 7954.

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

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