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.5 |
str = ("(s: '%s' i: %s c: %d)") % \ |
21 |
|
|
(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.5 |
useabledrives = 0 |
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 |
|
|
"bootloadersetup", |
91 |
|
|
"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.5 |
if self.useabledrives == 0 or flags.cmdline.has_key("partition"): |
116 |
|
|
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 |
|
|
uniqueID = 100 |
124 |
slords |
1.1.2.5 |
(swapMin, swapMax) = iutil.swapSuggestion() |
125 |
|
|
diskset = partedUtils.DiskSet() |
126 |
|
|
drives = diskset.driveList() |
127 |
|
|
usedDrives = [] |
128 |
|
|
|
129 |
|
|
spares = 0 |
130 |
|
|
self.useabledrives = 0 |
131 |
|
|
for drive in drives: |
132 |
|
|
if isys.mediaPresent(drive): |
133 |
|
|
self.useabledrives = self.useabledrives + 1 |
134 |
slords |
1.1.2.1 |
|
135 |
slords |
1.1.2.5 |
log.info("Found %d useable drives" % self.useabledrives) |
136 |
|
|
if self.useabledrives >= 1: |
137 |
slords |
1.1.2.1 |
if flags.cmdline.has_key("noraid"): |
138 |
slords |
1.1.2.5 |
for drive in drives: |
139 |
|
|
if isys.mediaPresent(drive): |
140 |
|
|
filesystem = fileSystemTypeGet("ext3") |
141 |
|
|
request = partRequests.PartitionSpec(filesystem, mountpoint="/boot", drive=[drive], |
142 |
|
|
size=100, primary=1, format=1) |
143 |
|
|
partitions.autoPartitionRequests.append(request) |
144 |
|
|
usedDrives.append(drive); |
145 |
slords |
1.1.2.1 |
|
146 |
|
|
if flags.cmdline.has_key("nolvm"): |
147 |
slords |
1.1.2.5 |
filesystem = fileSystemTypeGet("ext3") |
148 |
|
|
request = partRequests.PartitionSpec(filesystem, mountpoint="/", drive=[drive], |
149 |
|
|
size=1300, grow=1, primary=1, format=1) |
150 |
|
|
partitions.autoPartitionRequests.append(request) |
151 |
|
|
|
152 |
|
|
filesystem = fileSystemTypeGet("swap") |
153 |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin, |
154 |
|
|
maxSizeMB=swapMax, grow=1, primary=1, format=1) |
155 |
|
|
partitions.autoPartitionRequests.append(request) |
156 |
|
|
|
157 |
|
|
else: |
158 |
|
|
filesystem = fileSystemTypeGet("physical volume (LVM)") |
159 |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500, |
160 |
|
|
grow=1, primary=1, format=1) |
161 |
|
|
request.uniqueID = 200 |
162 |
|
|
partitions.autoPartitionRequests.append(request) |
163 |
|
|
|
164 |
|
|
break |
165 |
|
|
|
166 |
|
|
else: |
167 |
|
|
raid1 = [] |
168 |
|
|
raid2 = [] |
169 |
|
|
raid3 = [] |
170 |
|
|
|
171 |
|
|
if self.useabledrives >= 3 and not flags.cmdline.has_key("nospare"): |
172 |
|
|
self.useabledrives = self.useabledrives - 1 |
173 |
|
|
spares = 1 |
174 |
|
|
|
175 |
|
|
if flags.cmdline.has_key("raid1") and self.useabledrives >= 1: |
176 |
|
|
self.useabledrives = 1 |
177 |
|
|
raidLevel = "RAID1" |
178 |
|
|
else: |
179 |
|
|
if self.useabledrives >= 6: |
180 |
|
|
self.useabledrives = self.useabledrives - 2 |
181 |
|
|
raidLevel = "RAID6" |
182 |
|
|
elif self.useabledrives >= 2: |
183 |
|
|
self.useabledrives = self.useabledrives - 1 |
184 |
|
|
if self.useabledrives >= 2: |
185 |
|
|
raidLevel = "RAID5" |
186 |
|
|
else: |
187 |
|
|
raidLevel = "RAID1" |
188 |
|
|
else: |
189 |
|
|
raidLevel = "RAID1" |
190 |
|
|
|
191 |
|
|
for drive in drives: |
192 |
|
|
if isys.mediaPresent(drive): |
193 |
|
|
filesystem = fileSystemTypeGet("software RAID") |
194 |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=100, primary=1, format=1) |
195 |
|
|
request.uniqueID = uniqueID |
196 |
|
|
raid1.append(uniqueID) |
197 |
|
|
partitions.autoPartitionRequests.append(request) |
198 |
|
|
usedDrives.append(drive); |
199 |
slords |
1.1.2.1 |
|
200 |
|
|
if flags.cmdline.has_key("nolvm"): |
201 |
slords |
1.1.2.5 |
filesystem = fileSystemTypeGet("software RAID") |
202 |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin/self.useabledrives+10, |
203 |
|
|
maxSizeMB=swapMax/self.useabledrives, grow=1, primary=1, format=1) |
204 |
|
|
request.uniqueID = uniqueID + 30 |
205 |
|
|
raid2.append(uniqueID + 30) |
206 |
|
|
partitions.autoPartitionRequests.append(request) |
207 |
|
|
|
208 |
|
|
filesystem = fileSystemTypeGet("software RAID") |
209 |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=1500/self.useabledrives, |
210 |
|
|
grow=1, primary=1, format=1) |
211 |
|
|
request.uniqueID = uniqueID + 60 |
212 |
|
|
raid3.append(uniqueID + 60) |
213 |
|
|
partitions.autoPartitionRequests.append(request) |
214 |
slords |
1.1.2.1 |
|
215 |
slords |
1.1.2.5 |
else: |
216 |
|
|
filesystem = fileSystemTypeGet("software RAID") |
217 |
slords |
1.1.2.1 |
if flags.cmdline.has_key("multipart"): |
218 |
slords |
1.1.2.5 |
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+3000)/self.useabledrives, |
219 |
|
|
grow=1, format=1) |
220 |
|
|
else: |
221 |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+1500)/self.useabledrives, |
222 |
|
|
grow=1, format=1) |
223 |
|
|
request.uniqueID = uniqueID + 50 |
224 |
|
|
raid2.append(uniqueID + 50) |
225 |
|
|
partitions.autoPartitionRequests.append(request) |
226 |
slords |
1.1.2.1 |
|
227 |
slords |
1.1.2.5 |
uniqueID = uniqueID + 1 |
228 |
slords |
1.1.2.1 |
|
229 |
|
|
if flags.cmdline.has_key("raid1") and len(raid1)-spares >= 2: |
230 |
slords |
1.1.2.5 |
break |
231 |
slords |
1.1.2.1 |
|
232 |
slords |
1.1.2.5 |
filesystem = fileSystemTypeGet("ext3") |
233 |
|
|
request = partRequests.RaidRequestSpec(filesystem, mountpoint="/boot", raidminor=1, |
234 |
|
|
raidmembers=raid1, raidlevel="RAID1", format=1, raidspares=spares) |
235 |
|
|
partitions.autoPartitionRequests.append(request) |
236 |
slords |
1.1.2.1 |
|
237 |
|
|
if flags.cmdline.has_key("nolvm"): |
238 |
slords |
1.1.2.5 |
filesystem = fileSystemTypeGet("swap") |
239 |
|
|
request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2, |
240 |
|
|
raidlevel=raidLevel, format=1, raidspares=spares) |
241 |
|
|
partitions.autoPartitionRequests.append(request) |
242 |
|
|
|
243 |
|
|
filesystem = fileSystemTypeGet("ext3") |
244 |
|
|
request = partRequests.RaidRequestSpec(filesystem, mountpoint="/", raidmembers=raid3, raidminor=3, |
245 |
|
|
raidlevel=raidLevel, format=1, raidspares=spares) |
246 |
|
|
partitions.autoPartitionRequests.append(request) |
247 |
|
|
|
248 |
|
|
else: |
249 |
|
|
filesystem = fileSystemTypeGet("physical volume (LVM)") |
250 |
|
|
request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2, |
251 |
|
|
raidlevel=raidLevel, format=1, raidspares=spares) |
252 |
|
|
request.uniqueID = 200 |
253 |
|
|
partitions.autoPartitionRequests.append(request) |
254 |
slords |
1.1.2.1 |
|
255 |
|
|
if not flags.cmdline.has_key("nolvm"): |
256 |
slords |
1.1.2.5 |
request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200], |
257 |
|
|
pesize=32768, format=1) |
258 |
|
|
request.uniqueID = 201 |
259 |
|
|
partitions.autoPartitionRequests.append(request) |
260 |
slords |
1.1.2.1 |
|
261 |
|
|
if flags.cmdline.has_key("multipart"): |
262 |
slords |
1.1.2.5 |
filesystem = fileSystemTypeGet("ext3") |
263 |
|
|
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=2048, |
264 |
|
|
maxSizeMB=4096, volgroup=201, lvname="root", grow=1, format=1) |
265 |
|
|
partitions.autoPartitionRequests.append(request) |
266 |
|
|
|
267 |
|
|
filesystem = fileSystemTypeGet("ext3") |
268 |
|
|
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/var", size=1024, |
269 |
|
|
maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1) |
270 |
|
|
partitions.autoPartitionRequests.append(request) |
271 |
|
|
|
272 |
|
|
filesystem = fileSystemTypeGet("ext3") |
273 |
|
|
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/home/e-smith/files", size=1024, |
274 |
|
|
maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1) |
275 |
|
|
partitions.autoPartitionRequests.append(request) |
276 |
|
|
|
277 |
|
|
filesystem = fileSystemTypeGet("ext3") |
278 |
|
|
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/tmp", size=512, |
279 |
|
|
maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1) |
280 |
|
|
partitions.autoPartitionRequests.append(request) |
281 |
|
|
|
282 |
|
|
filesystem = fileSystemTypeGet("swap") |
283 |
|
|
request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax, |
284 |
|
|
volgroup=201, lvname="swap", grow=1, format=1) |
285 |
|
|
partitions.autoPartitionRequests.append(request) |
286 |
|
|
else: |
287 |
|
|
filesystem = fileSystemTypeGet("ext3") |
288 |
|
|
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=1300, |
289 |
|
|
volgroup=201, lvname="root", grow=1, format=1) |
290 |
|
|
partitions.autoPartitionRequests.append(request) |
291 |
|
|
|
292 |
|
|
filesystem = fileSystemTypeGet("swap") |
293 |
|
|
request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax, |
294 |
|
|
volgroup=201, lvname="swap", grow=1, format=1) |
295 |
|
|
partitions.autoPartitionRequests.append(request) |
296 |
|
|
|
297 |
|
|
partitions.autoClearPartType = clear |
298 |
|
|
partitions.autoClearPartDrives = usedDrives |
299 |
|
|
else: |
300 |
|
|
BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear) |
301 |
slords |
1.1.2.1 |
|
302 |
|
|
def setAsHeadless(self, dispatch, isHeadless = 0): |
303 |
|
|
if isHeadless == 0: |
304 |
|
|
pass |
305 |
|
|
else: |
306 |
slords |
1.1.2.5 |
dispatch.skipStep("handleX11pkgs", permanent = 1) |
307 |
|
|
dispatch.skipStep("videocard", permanent = 1) |
308 |
|
|
dispatch.skipStep("monitor", permanent = 1) |
309 |
|
|
dispatch.skipStep("xcustom", permanent = 1) |
310 |
|
|
dispatch.skipStep("writexconfig", permanent = 1) |
311 |
slords |
1.1.2.1 |
|
312 |
|
|
def postAction(self, anaconda, serial): |
313 |
|
|
win = anaconda.intf.waitWindow(_("Post Install Script"), |
314 |
|
|
_("The post installation script is running...")) |
315 |
|
|
|
316 |
|
|
script = ( "#!/bin/sh\nmkdir -p /var/lib/dhcp; /sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-install\n" ) |
317 |
|
|
s = Script(script, interp="/bin/sh", inChroot=1) |
318 |
|
|
log.info("%s", s) |
319 |
|
|
s.run(anaconda.rootPath, serial) |
320 |
|
|
win.pop() |
321 |
|
|
|
322 |
|
|
def setInstallData(self, anaconda): |
323 |
|
|
BaseInstallClass.setInstallData(self, anaconda) |
324 |
|
|
self.setDefaultPartitioning(anaconda.id.partitions, CLEARPART_TYPE_ALL) |
325 |
|
|
self.setSELinux(anaconda.id, SELINUX_DISABLED) |
326 |
|
|
|
327 |
|
|
def setGroupSelection(self, anaconda): |
328 |
|
|
BaseInstallClass.__init__(self, anaconda.backend) |
329 |
|
|
anaconda.backend.selectGroup("Base") |
330 |
|
|
anaconda.backend.selectGroup("Core") |
331 |
|
|
anaconda.backend.selectGroup("Extras") |
332 |
|
|
anaconda.backend.selectGroup("SME Server") |
333 |
|
|
|
334 |
|
|
def __init__(self, expert): |
335 |
slords |
1.1.2.5 |
BaseInstallClass.__init__(self, expert) |
336 |
|
|
self.repopaths = { "base": "%s" %(productPath,) } |
337 |
slords |
1.1.2.1 |
self.forceTextMode = 1 |