/[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.9 - (show annotations) (download) (as text)
Tue Mar 18 14:54:09 2014 UTC (10 years, 7 months ago) by wellsi
Branch: MAIN
Changes since 1.8: +13 -0 lines
Content type: text/x-python
Installer shows warning about "too old version" [SME: 8038]

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 bootloaderTimeoutDefault = 5
97 tasks = [(N_("Basic Server"),
98 ["base", "core"]),
99 (N_("Minimal"),
100 ["core"])]
101
102 def _get_description(self):
103 return gettext.ldgettext("comps", self._description) % self._descriptionFields
104 description = property(_get_description)
105
106 def postAction(self, anaconda):
107 if anaconda.id.getUpgrade():
108 w = anaconda.intf.waitWindow(_("Post Upgrade"),
109 _("Performing post-upgrade configuration"))
110 log.info("Running post-upgrade action script")
111 script = Script( "#!/bin/sh\n/sbin/rsyslogd; sleep 2; /sbin/e-smith/signal-event post-upgrade; touch /forcequotacheck\n" )
112 else:
113 w = anaconda.intf.waitWindow(_("Post Installation"),
114 _("Performing post-installation configuration"))
115 log.info("Running post-install action script")
116 script = Script( "#!/bin/sh\n/sbin/rsyslogd; sleep 2; /sbin/e-smith/signal-event post-install; touch /forcequotacheck\n" )
117
118 script.run(anaconda.rootPath, flags.serial, anaconda.intf)
119 if anaconda.intf is not None:
120 w.pop()
121
122 BaseInstallClass.postAction(self, anaconda)
123
124 def setSteps(self, anaconda):
125 BaseInstallClass.setSteps(self, anaconda)
126 anaconda.dispatch.skipStep("welcome")
127 #anaconda.dispatch.skipStep("filtertype")
128 anaconda.dispatch.skipStep("network")
129 anaconda.dispatch.skipStep("accounts")
130 anaconda.dispatch.skipStep("partition")
131 anaconda.dispatch.skipStep("tasksel")
132 anaconda.dispatch.skipStep("firstboot")
133
134 def setDefaultPartitioning(self, storage, platform):
135 autorequests = []
136
137 # If user specifies "nolvm", then asVol = False; otherwise, asVol = True
138 # If asVol = False below, then LVM won't be used
139
140 asVol_flag = not flags.cmdline.has_key("nolvm")
141
142 # If user specifies "noraid", then useRAID = False; otherwise, useRAID = True
143 # If useRAID = False below, then RAID1 won't be used
144
145 useRAID_flag = not flags.cmdline.has_key("noraid")
146
147 fstype = "ext4"
148 if flags.cmdline.has_key("ext3"):
149 fstype = "ext3"
150
151 # /boot
152 # Manually specify fstype = ext3/ext4 and size = 250 MB
153 # (Platform default is fstype ext4 and size = 500 MB)
154
155 autorequests.append(PartSpec(mountpoint="/boot", fstype=fstype, size=250, useRAID=useRAID_flag,
156 weight=platform.weight(mountpoint="/boot")))
157
158 # /
159 # Manually specify fstype = ext3/ext4 and size = 2048 MB, but growable
160
161 autorequests.append(PartSpec(mountpoint="/", fstype=fstype, size=2048, useRAID=useRAID_flag,
162 grow=True, asVol=asVol_flag))
163
164 # swap
165 # Manually specify fstype = swap and minswap < size < maxswap (growable)
166
167 (minswap, maxswap) = iutil.swapSuggestion()
168 autorequests.append(PartSpec(fstype="swap", size=minswap, maxSize=maxswap, useRAID=useRAID_flag,
169 grow=True, asVol=asVol_flag))
170
171 storage.autoPartitionRequests = autorequests
172
173 def setInstallData(self, anaconda):
174 BaseInstallClass.setInstallData(self, anaconda)
175 anaconda.id.security.setSELinux(SELINUX_DISABLED)
176 self.setDefaultPartitioning(
177 anaconda.id.storage,
178 anaconda.platform)
179
180 def productMatches(self, oldprod):
181 log.info("oldprod %s productName %s" % (oldprod, productName));
182 if oldprod is None:
183 return False
184
185 if oldprod.startswith(productName):
186 return True
187
188 productUpgrades = {
189 "SME Server": ("Mitel Networks", "SME Server", "e-smith server", ),
190 }
191
192 if productUpgrades.has_key(productName):
193 acceptable = productUpgrades[productName]
194 else:
195 acceptable = ()
196
197 for p in acceptable:
198 if oldprod.startswith(p):
199 return True
200
201 return False
202
203 def versionMatches(self, oldver):
204 log.info("oldver %s productVersion %s" % (oldver, productVersion));
205 return True;
206
207 def getBackend(self):
208 return yuminstall.YumBackend
209
210 def __init__(self):
211 BaseInstallClass.__init__(self)

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