1 |
slords |
1.1.2.1 |
from installclass import BaseInstallClass |
2 |
|
|
from rhpl.translate import N_, _ |
3 |
|
|
from constants import * |
4 |
|
|
import os |
5 |
|
|
import iutil |
6 |
|
|
from fsset import * |
7 |
|
|
from flags import flags |
8 |
|
|
|
9 |
|
|
from autopart import getAutopartitionBoot, autoCreatePartitionRequests, autoCreateLVMPartitionRequests |
10 |
|
|
|
11 |
|
|
import logging |
12 |
|
|
log = logging.getLogger("anaconda") |
13 |
|
|
|
14 |
|
|
import string |
15 |
|
|
import partRequests |
16 |
|
|
import partedUtils |
17 |
|
|
|
18 |
|
|
class Script: |
19 |
|
|
def __repr__(self): |
20 |
slords |
1.1.2.7 |
str = ("(s: '%s' i: %s c: %d)") % \ |
21 |
slords |
1.1.2.5 |
(self.script, self.interp, self.inChroot) |
22 |
|
|
return string.replace(str, "\n", "|") |
23 |
slords |
1.1.2.1 |
|
24 |
|
|
def __init__(self, script, interp, inChroot, logfile = None): |
25 |
slords |
1.1.2.5 |
self.script = script |
26 |
|
|
self.interp = interp |
27 |
|
|
self.inChroot = inChroot |
28 |
slords |
1.1.2.1 |
self.logfile = logfile |
29 |
|
|
|
30 |
|
|
def run(self, chroot, serial): |
31 |
|
|
import tempfile |
32 |
|
|
import os.path |
33 |
|
|
|
34 |
|
|
if self.inChroot: |
35 |
|
|
scriptRoot = chroot |
36 |
|
|
else: |
37 |
|
|
scriptRoot = "/" |
38 |
|
|
|
39 |
|
|
(fd, path) = tempfile.mkstemp("", "sme-script-", scriptRoot + "/tmp") |
40 |
|
|
|
41 |
|
|
os.write(fd, self.script) |
42 |
|
|
os.close(fd) |
43 |
|
|
os.chmod(path, 0700) |
44 |
|
|
|
45 |
|
|
if self.logfile is not None: |
46 |
|
|
messages = self.logfile |
47 |
|
|
elif serial: |
48 |
|
|
messages = "%s.log" % path |
49 |
|
|
else: |
50 |
|
|
messages = "/dev/tty3" |
51 |
|
|
|
52 |
|
|
rc = iutil.execWithRedirect(self.interp, ["/tmp/%s" % os.path.basename(path)], |
53 |
|
|
stdin = messages, stdout = messages, stderr = messages, |
54 |
|
|
root = scriptRoot) |
55 |
|
|
|
56 |
slords |
1.1.2.5 |
if rc != 0: |
57 |
|
|
log.error("WARNING - Error code %s encountered running a sme script", rc) |
58 |
slords |
1.1.2.1 |
|
59 |
slords |
1.1.2.5 |
os.unlink(path) |
60 |
slords |
1.1.2.1 |
if serial or self.logfile is not None: |
61 |
|
|
os.chmod("%s" % messages, 0600) |
62 |
|
|
|
63 |
|
|
class InstallClass(BaseInstallClass): |
64 |
|
|
id = "smeserver" |
65 |
|
|
name = N_("New _SME Server Install") |
66 |
|
|
pixmap = "smeserver.png" |
67 |
|
|
description = N_("This option performs a new install of " |
68 |
|
|
"SME Server. All attached hard drives " |
69 |
|
|
"will be repartitioned and formated.") |
70 |
|
|
sortPriority = 1 |
71 |
slords |
1.1.2.7 |
doPartition = False |
72 |
slords |
1.1.2.1 |
|
73 |
|
|
parentClass = ( _("Install SME Server"), "smeserver.png" ) |
74 |
|
|
|
75 |
|
|
def requiredDisplayMode(self): |
76 |
|
|
return 't' |
77 |
|
|
|
78 |
|
|
def setSteps(self, dispatch): |
79 |
|
|
dispatch.setStepList( |
80 |
slords |
1.1.2.4 |
"language", |
81 |
|
|
"keyboard", |
82 |
slords |
1.1.2.1 |
"findrootparts", |
83 |
slords |
1.1.2.4 |
"betanag", |
84 |
|
|
"installtype", |
85 |
slords |
1.1.2.1 |
"partitionobjinit", |
86 |
|
|
"autopartitionexecute", |
87 |
slords |
1.1.2.5 |
"parttype", |
88 |
slords |
1.1.2.1 |
"partition", |
89 |
slords |
1.1.2.4 |
"partitiondone", |
90 |
slords |
1.1.2.7 |
"bootloadersetup", |
91 |
slords |
1.1.2.4 |
"timezone", |
92 |
slords |
1.1.2.1 |
"reposetup", |
93 |
|
|
"basepkgsel", |
94 |
slords |
1.1.2.4 |
"postselection", |
95 |
|
|
"confirminstall", |
96 |
|
|
"install", |
97 |
|
|
"enablefilesystems", |
98 |
slords |
1.1.2.1 |
"migratefilesystems", |
99 |
|
|
"setuptime", |
100 |
|
|
"preinstallconfig", |
101 |
slords |
1.1.2.4 |
"installpackages", |
102 |
slords |
1.1.2.1 |
"postinstallconfig", |
103 |
slords |
1.1.2.4 |
"writeconfig", |
104 |
|
|
"instbootloader", |
105 |
slords |
1.1.2.1 |
"dopostaction", |
106 |
slords |
1.1.2.4 |
"writeksconfig", |
107 |
slords |
1.1.2.1 |
"methodcomplete", |
108 |
|
|
"copylogs", |
109 |
|
|
"setfilecon", |
110 |
slords |
1.1.2.4 |
"complete" |
111 |
slords |
1.1.2.1 |
) |
112 |
|
|
|
113 |
|
|
# 'partition' can be used on the command line to force |
114 |
|
|
# verification of partitions. useful in some cases... |
115 |
slords |
1.1.2.7 |
if self.doPartition or flags.cmdline.has_key("partition"): |
116 |
slords |
1.1.2.5 |
dispatch.skipStep("parttype", skip = 0) |
117 |
slords |
1.1.2.1 |
dispatch.skipStep("partition", skip = 0) |
118 |
|
|
else: |
119 |
slords |
1.1.2.5 |
dispatch.skipStep("parttype", skip = 1) |
120 |
slords |
1.1.2.1 |
dispatch.skipStep("partition", skip = 1) |
121 |
|
|
|
122 |
|
|
def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1): |
123 |
slords |
1.1.2.5 |
diskset = partedUtils.DiskSet() |
124 |
|
|
|
125 |
slords |
1.1.2.7 |
alldrives = diskset.driveList() |
126 |
|
|
if flags.cmdline.has_key("drives"): |
127 |
|
|
drives = filter(lambda x:isys.mediaPresent(x) and x in flags.cmdline["drives"].split(","), alldrives) |
128 |
|
|
else: |
129 |
|
|
drives = filter(lambda x:isys.mediaPresent(x) and not isys.driveUsesModule(x, ["usb-storage", "sbp2"]), alldrives) |
130 |
slords |
1.1.2.5 |
|
131 |
slords |
1.1.2.7 |
if flags.cmdline.has_key("spares"): |
132 |
|
|
spares = max(0,len(drives)-int(flags.cmdline["spares"])-2) |
133 |
|
|
else: |
134 |
|
|
spares = (len(drives)+4)/7 |
135 |
slords |
1.1.2.5 |
|
136 |
slords |
1.1.2.7 |
if flags.cmdline.has_key("raid") and flags.cmdline["raid"] in ["none","0","1","5","6"]: |
137 |
|
|
if flags.cmdline["raid"] == "none": |
138 |
|
|
level = 0 |
139 |
slords |
1.1.2.5 |
else: |
140 |
slords |
1.1.2.7 |
level = int(flags.cmdline["raid"]) |
141 |
|
|
if level == 0: |
142 |
|
|
del drives[1:] |
143 |
|
|
spares = 0 |
144 |
|
|
if level == 6 and len(drives)-spares < 4: |
145 |
|
|
level = 5 |
146 |
|
|
if level == 5 and len(drives)-spares < 3: |
147 |
|
|
level = 1 |
148 |
|
|
if level == 1: |
149 |
|
|
del drives[2+spares:] |
150 |
|
|
else: |
151 |
|
|
if len(drives) - spares >= 6: |
152 |
|
|
level = 6 |
153 |
|
|
elif len(drives) - spares >= 3: |
154 |
|
|
level = 5 |
155 |
|
|
else: |
156 |
|
|
level = 1 |
157 |
slords |
1.1.2.5 |
|
158 |
slords |
1.1.2.7 |
log.info("Using the following drives: %s" % drives) |
159 |
|
|
log.info("Installing using RAID%s" % level) |
160 |
|
|
log.info("Using %s spare drives" % spares) |
161 |
|
|
|
162 |
|
|
(swapMin, swapMax) = iutil.swapSuggestion() |
163 |
|
|
if len(drives) >= 1: |
164 |
|
|
if level >= 1: |
165 |
|
|
uniqueID = 100 |
166 |
slords |
1.1.2.5 |
for drive in drives: |
167 |
slords |
1.1.2.7 |
raid1 = [] |
168 |
|
|
raid2 = [] |
169 |
|
|
raid3 = [] |
170 |
|
|
|
171 |
|
|
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
172 |
|
|
drive=[drive], size=100, primary=1, format=1) |
173 |
|
|
request.uniqueID = uniqueID |
174 |
|
|
raid1.append(uniqueID) |
175 |
|
|
partitions.autoPartitionRequests.append(request) |
176 |
|
|
|
177 |
|
|
if not flags.cmdline.has_key("nolvm"): |
178 |
|
|
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
179 |
|
|
size=(swapMin+4096)/(len(drives)-spares-max(0,level-4)), |
180 |
|
|
drive=[drive], primary=1, grow=1, format=1) |
181 |
|
|
request.uniqueID = uniqueID + 50 |
182 |
|
|
raid2.append(uniqueID + 50) |
183 |
|
|
partitions.autoPartitionRequests.append(request) |
184 |
|
|
else: |
185 |
|
|
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
186 |
|
|
drive=[drive], size=swapMin/(len(drives)-spares-max(0,level-4))+10, grow=1, |
187 |
|
|
maxSizeMB=swapMax/(len(drives)-spares-max(0,level-4)), format=1, primary=1) |
188 |
|
|
request.uniqueID = uniqueID + 30 |
189 |
|
|
raid2.append(uniqueID + 30) |
190 |
slords |
1.1.2.5 |
partitions.autoPartitionRequests.append(request) |
191 |
slords |
1.1.2.1 |
|
192 |
slords |
1.1.2.7 |
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
193 |
|
|
size=1500/(len(drives)-spares-max(0,level-4)), |
194 |
|
|
drive=[drive], grow=1, primary=1, format=1) |
195 |
|
|
request.uniqueID = uniqueID + 60 |
196 |
|
|
raid3.append(uniqueID + 60) |
197 |
|
|
partitions.autoPartitionRequests.append(request) |
198 |
slords |
1.1.2.1 |
|
199 |
slords |
1.1.2.7 |
uniqueID = uniqueID + 1 |
200 |
slords |
1.1.2.5 |
|
201 |
slords |
1.1.2.7 |
partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"), |
202 |
|
|
mountpoint="/boot", raidmembers=raid1, raidlevel="RAID1", raidminor=1, format=1)) |
203 |
slords |
1.1.2.5 |
|
204 |
slords |
1.1.2.7 |
if not flags.cmdline.has_key("nolvm"): |
205 |
|
|
request = partRequests.RaidRequestSpec(fileSystemTypeGet("physical volume (LVM)"), |
206 |
|
|
raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, |
207 |
|
|
raidspares=spares) |
208 |
slords |
1.1.2.5 |
request.uniqueID = 200 |
209 |
|
|
partitions.autoPartitionRequests.append(request) |
210 |
slords |
1.1.2.7 |
else: |
211 |
|
|
partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("swap"), |
212 |
|
|
raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, raidspares=spares)) |
213 |
|
|
|
214 |
|
|
partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"), |
215 |
|
|
mountpoint="/", raidmembers=raid3, raidlevel="RAID"+str(level), raidminor=3, format=1, |
216 |
|
|
raidspares=spares)) |
217 |
|
|
|
218 |
|
|
else: |
219 |
|
|
for drive in drives: |
220 |
|
|
partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"), |
221 |
|
|
mountpoint="/boot", drive=[drive], size=100, primary=1, format=1)) |
222 |
|
|
|
223 |
|
|
if not flags.cmdline.has_key("nolvm"): |
224 |
|
|
request = partRequests.PartitionSpec(fileSystemTypeGet("physical volume (LVM)"), |
225 |
|
|
drive=[drive], size=swapMin+4096, grow=1, primary=1, format=1) |
226 |
|
|
request.uniqueID = 200 |
227 |
|
|
partitions.autoPartitionRequests.append(request) |
228 |
|
|
else: |
229 |
|
|
partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"), |
230 |
|
|
mountpoint="/", drive=[drive], size=4096, grow=1, primary=1, format=1)) |
231 |
|
|
|
232 |
|
|
partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("swap"), |
233 |
|
|
drive=[drive], size=swapMin, maxSizeMB=swapMax, grow=1, primary=1, format=1)) |
234 |
slords |
1.1.2.1 |
|
235 |
|
|
if not flags.cmdline.has_key("nolvm"): |
236 |
slords |
1.1.2.7 |
request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200], pesize=32768, format=1) |
237 |
slords |
1.1.2.5 |
request.uniqueID = 201 |
238 |
|
|
partitions.autoPartitionRequests.append(request) |
239 |
slords |
1.1.2.1 |
|
240 |
slords |
1.1.2.7 |
if not flags.cmdline.has_key("multipart"): |
241 |
|
|
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
242 |
|
|
mountpoint="/", size=1300, volgroup=201, lvname="root", grow=1, format=1)) |
243 |
slords |
1.1.2.5 |
|
244 |
slords |
1.1.2.7 |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"), |
245 |
|
|
size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1)) |
246 |
|
|
else: |
247 |
|
|
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
248 |
|
|
mountpoint="/", size=2048, maxSizeMB=4096, volgroup=201, lvname="root", grow=1, format=1)) |
249 |
slords |
1.1.2.5 |
|
250 |
slords |
1.1.2.7 |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
251 |
|
|
mountpoint="/var", size=1024, maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1)) |
252 |
slords |
1.1.2.5 |
|
253 |
slords |
1.1.2.7 |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
254 |
|
|
mountpoint="/home/e-smith/files", size=1024, maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1)) |
255 |
slords |
1.1.2.5 |
|
256 |
slords |
1.1.2.7 |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
257 |
|
|
mountpoint="/tmp", size=512, maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1)) |
258 |
slords |
1.1.2.5 |
|
259 |
slords |
1.1.2.7 |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"), |
260 |
|
|
size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1)) |
261 |
slords |
1.1.2.5 |
|
262 |
|
|
partitions.autoClearPartType = clear |
263 |
slords |
1.1.2.7 |
partitions.autoClearPartDrives = drives |
264 |
|
|
self.doPartition = False |
265 |
slords |
1.1.2.5 |
else: |
266 |
slords |
1.1.2.7 |
log.info("Not useable drives found. Enabling manual partitioning.") |
267 |
|
|
self.doPartition = True |
268 |
slords |
1.1.2.5 |
BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear) |
269 |
slords |
1.1.2.1 |
|
270 |
|
|
def setAsHeadless(self, dispatch, isHeadless = 0): |
271 |
|
|
if isHeadless == 0: |
272 |
|
|
pass |
273 |
|
|
else: |
274 |
slords |
1.1.2.5 |
dispatch.skipStep("handleX11pkgs", permanent = 1) |
275 |
|
|
dispatch.skipStep("videocard", permanent = 1) |
276 |
|
|
dispatch.skipStep("monitor", permanent = 1) |
277 |
|
|
dispatch.skipStep("xcustom", permanent = 1) |
278 |
|
|
dispatch.skipStep("writexconfig", permanent = 1) |
279 |
slords |
1.1.2.1 |
|
280 |
|
|
def postAction(self, anaconda, serial): |
281 |
|
|
win = anaconda.intf.waitWindow(_("Post Install Script"), |
282 |
|
|
_("The post installation script is running...")) |
283 |
|
|
|
284 |
|
|
script = ( "#!/bin/sh\nmkdir -p /var/lib/dhcp; /sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-install\n" ) |
285 |
|
|
s = Script(script, interp="/bin/sh", inChroot=1) |
286 |
|
|
log.info("%s", s) |
287 |
|
|
s.run(anaconda.rootPath, serial) |
288 |
|
|
win.pop() |
289 |
|
|
|
290 |
|
|
def setInstallData(self, anaconda): |
291 |
|
|
BaseInstallClass.setInstallData(self, anaconda) |
292 |
|
|
self.setDefaultPartitioning(anaconda.id.partitions, CLEARPART_TYPE_ALL) |
293 |
|
|
self.setSELinux(anaconda.id, SELINUX_DISABLED) |
294 |
|
|
|
295 |
|
|
def setGroupSelection(self, anaconda): |
296 |
|
|
BaseInstallClass.__init__(self, anaconda.backend) |
297 |
|
|
anaconda.backend.selectGroup("Base") |
298 |
|
|
anaconda.backend.selectGroup("Core") |
299 |
|
|
anaconda.backend.selectGroup("Extras") |
300 |
|
|
anaconda.backend.selectGroup("SME Server") |
301 |
|
|
|
302 |
|
|
def __init__(self, expert): |
303 |
slords |
1.1.2.5 |
BaseInstallClass.__init__(self, expert) |
304 |
|
|
self.repopaths = { "base": "%s" %(productPath,) } |
305 |
slords |
1.1.2.1 |
self.forceTextMode = 1 |