1 |
slords |
1.1 |
# |
2 |
|
|
# server.py |
3 |
|
|
# |
4 |
|
|
|
5 |
|
|
import os, iutil |
6 |
|
|
|
7 |
charliebrady |
1.3 |
import yuminstall |
8 |
|
|
|
9 |
slords |
1.1 |
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 |
charliebrady |
1.3 |
from storage.partspec import * |
16 |
slords |
1.1 |
|
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 |
charliebrady |
1.3 |
class InstallClass(BaseInstallClass): |
80 |
slords |
1.1 |
# 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 |
wellsi |
1.8 |
bootloaderTimeoutDefault = 5 |
97 |
slords |
1.1 |
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 |
slords |
1.2 |
script = Script( "#!/bin/sh\n/sbin/rsyslogd; sleep 2; /sbin/e-smith/signal-event post-upgrade; touch /forcequotacheck\n" ) |
112 |
slords |
1.1 |
else: |
113 |
|
|
w = anaconda.intf.waitWindow(_("Post Installation"), |
114 |
|
|
_("Performing post-installation configuration")) |
115 |
|
|
log.info("Running post-install action script") |
116 |
slords |
1.2 |
script = Script( "#!/bin/sh\n/sbin/rsyslogd; sleep 2; /sbin/e-smith/signal-event post-install; touch /forcequotacheck\n" ) |
117 |
slords |
1.1 |
|
118 |
|
|
script.run(anaconda.rootPath, flags.serial, anaconda.intf) |
119 |
|
|
if anaconda.intf is not None: |
120 |
|
|
w.pop() |
121 |
|
|
|
122 |
charliebrady |
1.3 |
BaseInstallClass.postAction(self, anaconda) |
123 |
slords |
1.1 |
|
124 |
|
|
def setSteps(self, anaconda): |
125 |
|
|
BaseInstallClass.setSteps(self, anaconda) |
126 |
charliebrady |
1.4 |
anaconda.dispatch.skipStep("welcome") |
127 |
slords |
1.1 |
#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 |
charliebrady |
1.3 |
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 |
wellsi |
1.10 |
if flags.cmdline.has_key("noraid"): |
146 |
|
|
raidLevel = "none" |
147 |
|
|
else: |
148 |
|
|
raidLevel = "1" |
149 |
|
|
if flags.cmdline.has_key("raid") and flags.cmdline["raid"] in ["none","0","1","5","6"]: |
150 |
|
|
raidLevel = flags.cmdline["raid"] |
151 |
charliebrady |
1.3 |
|
152 |
wellsi |
1.6 |
fstype = "ext4" |
153 |
|
|
if flags.cmdline.has_key("ext3"): |
154 |
|
|
fstype = "ext3" |
155 |
slords |
1.1 |
|
156 |
charliebrady |
1.3 |
# /boot |
157 |
wellsi |
1.7 |
# Manually specify fstype = ext3/ext4 and size = 250 MB |
158 |
charliebrady |
1.3 |
# (Platform default is fstype ext4 and size = 500 MB) |
159 |
|
|
|
160 |
wellsi |
1.10 |
autorequests.append(PartSpec(mountpoint="/boot", fstype=fstype, size=250, raidLevel=raidLevel, |
161 |
charliebrady |
1.3 |
weight=platform.weight(mountpoint="/boot"))) |
162 |
|
|
|
163 |
|
|
# / |
164 |
|
|
# Manually specify fstype = ext3/ext4 and size = 2048 MB, but growable |
165 |
|
|
|
166 |
wellsi |
1.10 |
autorequests.append(PartSpec(mountpoint="/", fstype=fstype, size=2048, raidLevel=raidLevel, |
167 |
charliebrady |
1.3 |
grow=True, asVol=asVol_flag)) |
168 |
|
|
|
169 |
|
|
# swap |
170 |
|
|
# Manually specify fstype = swap and minswap < size < maxswap (growable) |
171 |
slords |
1.1 |
|
172 |
|
|
(minswap, maxswap) = iutil.swapSuggestion() |
173 |
wellsi |
1.10 |
autorequests.append(PartSpec(fstype="swap", size=minswap, maxSize=maxswap, raidLevel=raidLevel, |
174 |
charliebrady |
1.3 |
grow=True, asVol=asVol_flag)) |
175 |
slords |
1.1 |
|
176 |
|
|
storage.autoPartitionRequests = autorequests |
177 |
|
|
|
178 |
|
|
def setInstallData(self, anaconda): |
179 |
charliebrady |
1.3 |
BaseInstallClass.setInstallData(self, anaconda) |
180 |
slords |
1.1 |
anaconda.id.security.setSELinux(SELINUX_DISABLED) |
181 |
charliebrady |
1.3 |
self.setDefaultPartitioning( |
182 |
|
|
anaconda.id.storage, |
183 |
|
|
anaconda.platform) |
184 |
slords |
1.1 |
|
185 |
|
|
def productMatches(self, oldprod): |
186 |
charliebrady |
1.5 |
log.info("oldprod %s productName %s" % (oldprod, productName)); |
187 |
slords |
1.1 |
if oldprod is None: |
188 |
|
|
return False |
189 |
|
|
|
190 |
|
|
if oldprod.startswith(productName): |
191 |
|
|
return True |
192 |
|
|
|
193 |
wellsi |
1.9 |
productUpgrades = { |
194 |
|
|
"SME Server": ("Mitel Networks", "SME Server", "e-smith server", ), |
195 |
|
|
} |
196 |
|
|
|
197 |
|
|
if productUpgrades.has_key(productName): |
198 |
|
|
acceptable = productUpgrades[productName] |
199 |
|
|
else: |
200 |
|
|
acceptable = () |
201 |
|
|
|
202 |
|
|
for p in acceptable: |
203 |
|
|
if oldprod.startswith(p): |
204 |
|
|
return True |
205 |
|
|
|
206 |
slords |
1.1 |
return False |
207 |
|
|
|
208 |
charliebrady |
1.5 |
def versionMatches(self, oldver): |
209 |
|
|
log.info("oldver %s productVersion %s" % (oldver, productVersion)); |
210 |
|
|
return True; |
211 |
|
|
|
212 |
charliebrady |
1.3 |
def getBackend(self): |
213 |
|
|
return yuminstall.YumBackend |
214 |
|
|
|
215 |
slords |
1.1 |
def __init__(self): |
216 |
charliebrady |
1.3 |
BaseInstallClass.__init__(self) |