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 |
|
|
str = ("(s: '%s' i: %s c: %d)") % \ |
21 |
|
|
(self.script, self.interp, self.inChroot) |
22 |
|
|
return string.replace(str, "\n", "|") |
23 |
|
|
|
24 |
|
|
def __init__(self, script, interp, inChroot, logfile = None): |
25 |
|
|
self.script = script |
26 |
|
|
self.interp = interp |
27 |
|
|
self.inChroot = inChroot |
28 |
|
|
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 |
|
|
if rc != 0: |
57 |
|
|
log.error("WARNING - Error code %s encountered running a sme script", rc) |
58 |
|
|
|
59 |
|
|
os.unlink(path) |
60 |
|
|
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 |
|
|
|
72 |
|
|
parentClass = ( _("Install SME Server"), "smeserver.png" ) |
73 |
|
|
|
74 |
|
|
def requiredDisplayMode(self): |
75 |
|
|
return 't' |
76 |
|
|
|
77 |
|
|
def setSteps(self, dispatch): |
78 |
|
|
dispatch.setStepList( |
79 |
|
|
"language", |
80 |
|
|
"keyboard", |
81 |
|
|
"findrootparts", |
82 |
|
|
"findinstall", |
83 |
|
|
"installtype", |
84 |
|
|
"partitionobjinit", |
85 |
|
|
"autopartitionexecute", |
86 |
|
|
"partition", |
87 |
|
|
"partitiondone", |
88 |
|
|
"bootloadersetup", |
89 |
|
|
"languagesupport", |
90 |
|
|
"timezone", |
91 |
|
|
"reposetup", |
92 |
|
|
"basepkgsel", |
93 |
|
|
"postselection", |
94 |
|
|
"readcomps", |
95 |
|
|
"selectlangpackages", |
96 |
|
|
"checkdeps", |
97 |
|
|
"dependencies", |
98 |
|
|
"install", |
99 |
|
|
"enablefilesystems", |
100 |
|
|
"migratefilesystems", |
101 |
|
|
"setuptime", |
102 |
|
|
"preinstallconfig", |
103 |
|
|
"installpackages", |
104 |
|
|
"postinstallconfig", |
105 |
|
|
"writeconfig", |
106 |
|
|
"instbootloader", |
107 |
|
|
"dopostaction", |
108 |
|
|
"methodcomplete", |
109 |
|
|
"copylogs", |
110 |
|
|
"writeksconfig", |
111 |
|
|
"setfilecon", |
112 |
|
|
"complete" |
113 |
|
|
) |
114 |
|
|
|
115 |
|
|
# 'partition' can be used on the command line to force |
116 |
|
|
# verification of partitions. useful in some cases... |
117 |
|
|
if flags.cmdline.has_key("partition"): |
118 |
|
|
dispatch.skipStep("partition", skip = 0) |
119 |
|
|
else: |
120 |
|
|
dispatch.skipStep("partition", skip = 1) |
121 |
|
|
|
122 |
|
|
def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1): |
123 |
|
|
uniqueID = 100 |
124 |
|
|
(swapMin, swapMax) = iutil.swapSuggestion() |
125 |
|
|
diskset = partedUtils.DiskSet() |
126 |
|
|
drives = diskset.driveList() |
127 |
|
|
usedDrives = [] |
128 |
|
|
|
129 |
|
|
spares = 0 |
130 |
|
|
useable = 0 |
131 |
|
|
for drive in drives: |
132 |
|
|
if isys.mediaPresent(drive): |
133 |
|
|
useable = useable + 1 |
134 |
|
|
|
135 |
|
|
log.info("Useable is %d" % useable) |
136 |
|
|
if useable >= 1: |
137 |
|
|
if flags.cmdline.has_key("noraid"): |
138 |
|
|
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 |
|
|
|
146 |
|
|
if flags.cmdline.has_key("nolvm"): |
147 |
|
|
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 useable >= 3 and not flags.cmdline.has_key("nospare"): |
172 |
|
|
useable = useable - 1 |
173 |
|
|
spares = 1 |
174 |
|
|
|
175 |
|
|
if flags.cmdline.has_key("raid1") and useable >= 1: |
176 |
|
|
useable = 1 |
177 |
|
|
raidLevel = "RAID1" |
178 |
|
|
else: |
179 |
|
|
if useable >= 6: |
180 |
|
|
useable = useable - 2 |
181 |
|
|
raidLevel = "RAID6" |
182 |
|
|
elif useable >= 2: |
183 |
|
|
useable = useable - 1 |
184 |
|
|
if useable >= 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 |
|
|
|
200 |
|
|
if flags.cmdline.has_key("nolvm"): |
201 |
|
|
filesystem = fileSystemTypeGet("software RAID") |
202 |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin/useable+10, |
203 |
|
|
maxSizeMB=swapMax/useable, 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/useable, |
210 |
|
|
grow=1, primary=1, format=1) |
211 |
|
|
request.uniqueID = uniqueID + 60 |
212 |
|
|
raid3.append(uniqueID + 60) |
213 |
|
|
partitions.autoPartitionRequests.append(request) |
214 |
|
|
|
215 |
|
|
else: |
216 |
|
|
filesystem = fileSystemTypeGet("software RAID") |
217 |
|
|
if flags.cmdline.has_key("multipart"): |
218 |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+3000)/useable, |
219 |
|
|
grow=1, format=1) |
220 |
|
|
else: |
221 |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+1500)/useable, |
222 |
|
|
grow=1, format=1) |
223 |
|
|
request.uniqueID = uniqueID + 50 |
224 |
|
|
raid2.append(uniqueID + 50) |
225 |
|
|
partitions.autoPartitionRequests.append(request) |
226 |
|
|
|
227 |
|
|
uniqueID = uniqueID + 1 |
228 |
|
|
|
229 |
|
|
if flags.cmdline.has_key("raid1") and len(raid1)-spares >= 2: |
230 |
|
|
break |
231 |
|
|
|
232 |
|
|
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 |
|
|
|
237 |
|
|
if flags.cmdline.has_key("nolvm"): |
238 |
|
|
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 |
|
|
|
255 |
|
|
if not flags.cmdline.has_key("nolvm"): |
256 |
|
|
request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200], |
257 |
|
|
pesize=32768, format=1) |
258 |
|
|
request.uniqueID = 201 |
259 |
|
|
partitions.autoPartitionRequests.append(request) |
260 |
|
|
|
261 |
|
|
if flags.cmdline.has_key("multipart"): |
262 |
|
|
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 |
|
|
|
302 |
|
|
def setAsHeadless(self, dispatch, isHeadless = 0): |
303 |
|
|
if isHeadless == 0: |
304 |
|
|
pass |
305 |
|
|
else: |
306 |
|
|
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 |
|
|
|
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 |
|
|
BaseInstallClass.__init__(self, expert) |
336 |
|
|
self.repopaths = { "base": "%s" %(productPath,) } |
337 |
|
|
self.forceTextMode = 1 |