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