/[smeserver]/cdrom.image/sme7/product/installclasses/smeinstallclass.py
ViewVC logotype

Contents of /cdrom.image/sme7/product/installclasses/smeinstallclass.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Sat Jun 6 23:51:54 2009 UTC (15 years, 6 months ago) by slords
Branch: MAIN
Content type: text/x-python
Split trees

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
8 from autopart import getAutopartitionBoot, autoCreatePartitionRequests, autoCreateLVMPartitionRequests
9 from rhpl.log import log
10 import string
11 import partRequests
12 import partedUtils
13
14 class Script:
15 def __repr__(self):
16 str = ("(s: '%s' i: %s c: %d)") % \
17 (self.script, self.interp, self.inChroot)
18 return string.replace(str, "\n", "|")
19
20 def __init__(self, script, interp, inChroot, logfile = None):
21 self.script = script
22 self.interp = interp
23 self.inChroot = inChroot
24 self.logfile = logfile
25
26 def run(self, chroot, serial):
27 scriptRoot = "/"
28 if self.inChroot:
29 scriptRoot = chroot
30
31 path = scriptRoot + "/tmp/sme-script"
32
33 f = open(path, "w")
34 f.write(self.script)
35 f.close()
36 os.chmod(path, 0700)
37
38 if self.logfile is not None:
39 messages = self.logfile
40 elif serial:
41 messages = "/tmp/sme-script.log"
42 else:
43 messages = "/dev/tty3"
44
45 rc = iutil.execWithRedirect(self.interp,
46 [self.interp,"/tmp/sme-script"],
47 stdout = messages, stderr = messages,
48 root = scriptRoot)
49
50 if rc != 0:
51 log("WARNING - Error code %s encountered running a sme script", rc)
52
53 os.unlink(path)
54
55 class InstallClass(BaseInstallClass):
56 id = "smeserver"
57 name = N_("New _SME Server Install")
58 pixmap = "smeserver.png"
59 description = N_("This option performs a new install of "
60 "SME Server. All attached hard drives "
61 "will be repartitioned and formated.")
62 sortPriority = 1
63 useabledrives = 0
64
65 parentClass = ( _("Install SME Server"), "smeserver.png" )
66
67 def requiredDisplayMode(self):
68 return 't'
69
70 def setSteps(self, dispatch):
71 dispatch.setStepList(
72 "language",
73 "keyboard",
74 "findrootparts",
75 "betanag",
76 "installtype",
77 "partitionobjinit",
78 "autopartitionexecute",
79 "parttype",
80 "partition",
81 "partitiondone",
82 "bootloadersetup",
83 "languagesupport",
84 "timezone",
85 "readcomps",
86 "selectlangpackages",
87 "checkdeps",
88 "dependencies",
89 "install",
90 "enablefilesystems",
91 "migratefilesystems",
92 "setuptime",
93 "preinstallconfig",
94 "installpackages",
95 "postinstallconfig",
96 "writeconfig",
97 "instbootloader",
98 "dopostaction",
99 "writeksconfig",
100 "methodcomplete",
101 "copylogs",
102 "setfilecon",
103 "complete"
104 )
105
106 # 'partition' can be used on the command line to force
107 # verification of partitions. useful in some cases...
108 cmdline = open("/proc/cmdline", "r").read()
109 cmdline = cmdline.split()
110 if self.useabledrives == 0 or "partition" in cmdline:
111 dispatch.skipStep("parttype", skip = 0)
112 dispatch.skipStep("partition", skip = 0)
113 else:
114 dispatch.skipStep("parttype", skip = 1)
115 dispatch.skipStep("partition", skip = 1)
116
117 def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1):
118 uniqueID = 100
119 (swapMin, swapMax) = iutil.swapSuggestion()
120 diskset = partedUtils.DiskSet()
121 drives = diskset.driveList()
122 usedDrives = []
123
124 spares = 0
125 self.useabledrives = 0
126 for drive in drives:
127 if not isys.driveIsRemovable(drive):
128 self.useabledrives = self.useabledrives + 1
129
130 log.info("Found %d useable drives" % self.useabledrives)
131 if self.useabledrives >= 1:
132 if "noraid" in cmdline:
133 for drive in drives:
134 if not isys.driveIsRemovable(drive):
135 filesystem = fileSystemTypeGet("ext3")
136 request = partRequests.PartitionSpec(filesystem, mountpoint="/boot", drive=[drive],
137 size=100, primary=1, format=1)
138 partitions.autoPartitionRequests.append(request)
139 usedDrives.append(drive);
140
141 if "nolvm" in cmdline:
142 filesystem = fileSystemTypeGet("ext3")
143 request = partRequests.PartitionSpec(filesystem, mountpoint="/", drive=[drive],
144 size=1300, grow=1, primary=1, format=1)
145 partitions.autoPartitionRequests.append(request)
146
147 filesystem = fileSystemTypeGet("swap")
148 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin,
149 maxSizeMB=swapMax, grow=1, primary=1, format=1)
150 partitions.autoPartitionRequests.append(request)
151
152 else:
153 filesystem = fileSystemTypeGet("physical volume (LVM)")
154 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500,
155 grow=1, primary=1, format=1)
156 request.uniqueID = 200
157 partitions.autoPartitionRequests.append(request)
158
159 break
160
161 else:
162 raid1 = []
163 raid2 = []
164 raid3 = []
165
166 if self.useabledrives >= 3 and "nospare" not in cmdline:
167 self.useabledrives = self.useabledrives - 1
168 spares = 1
169
170 if "raid1" in cmdline and self.useabledrives >= 1:
171 self.useabledrives = 1
172 raidLevel = "RAID1"
173 else:
174 if self.useabledrives >= 6:
175 self.useabledrives = self.useabledrives - 2
176 raidLevel = "RAID6"
177 elif self.useabledrives >= 2:
178 self.useabledrives = self.useabledrives - 1
179 if self.useabledrives >= 2:
180 raidLevel = "RAID5"
181 else:
182 raidLevel = "RAID1"
183 else:
184 raidLevel = "RAID1"
185
186 for drive in drives:
187 if not isys.driveIsRemovable(drive):
188 filesystem = fileSystemTypeGet("software RAID")
189 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=100, primary=1, format=1)
190 request.uniqueID = uniqueID
191 raid1.append(uniqueID)
192 partitions.autoPartitionRequests.append(request)
193 usedDrives.append(drive);
194
195 if "nolvm" in cmdline:
196 filesystem = fileSystemTypeGet("software RAID")
197 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin/self.useabledrives+10,
198 maxSizeMB=swapMax/self.useabledrives, grow=1, primary=1, format=1)
199 request.uniqueID = uniqueID + 30
200 raid2.append(uniqueID + 30)
201 partitions.autoPartitionRequests.append(request)
202
203 filesystem = fileSystemTypeGet("software RAID")
204 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=1500/self.useabledrives,
205 grow=1, primary=1, format=1)
206 request.uniqueID = uniqueID + 60
207 raid3.append(uniqueID + 60)
208 partitions.autoPartitionRequests.append(request)
209
210 else:
211 filesystem = fileSystemTypeGet("software RAID")
212 if "multipart" in cmdline:
213 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+3000)/self.useabledrives,
214 grow=1, format=1)
215 else:
216 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+1500)/self.useabledrives,
217 grow=1, format=1)
218 request.uniqueID = uniqueID + 50
219 raid2.append(uniqueID + 50)
220 partitions.autoPartitionRequests.append(request)
221
222 uniqueID = uniqueID + 1
223
224 if "raid1" in cmdline and len(raid1)-spares >= 2:
225 break
226
227 filesystem = fileSystemTypeGet("ext3")
228 request = partRequests.RaidRequestSpec(filesystem, mountpoint="/boot", raidminor=1,
229 raidmembers=raid1, raidlevel="RAID1", format=1, raidspares=spares)
230 partitions.autoPartitionRequests.append(request)
231
232 if "nolvm" in cmdline:
233 filesystem = fileSystemTypeGet("swap")
234 request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2,
235 raidlevel=raidLevel, format=1, raidspares=spares)
236 partitions.autoPartitionRequests.append(request)
237
238 filesystem = fileSystemTypeGet("ext3")
239 request = partRequests.RaidRequestSpec(filesystem, mountpoint="/", raidmembers=raid3, raidminor=3,
240 raidlevel=raidLevel, format=1, raidspares=spares)
241 partitions.autoPartitionRequests.append(request)
242
243 else:
244 filesystem = fileSystemTypeGet("physical volume (LVM)")
245 request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2,
246 raidlevel=raidLevel, format=1, raidspares=spares)
247 request.uniqueID = 200
248 partitions.autoPartitionRequests.append(request)
249
250 if not "nolvm" in cmdline:
251 request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200],
252 pesize=32768, format=1)
253 request.uniqueID = 201
254 partitions.autoPartitionRequests.append(request)
255
256 if "multipart" in cmdline:
257 filesystem = fileSystemTypeGet("ext3")
258 request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=2048,
259 maxSizeMB=4096, volgroup=201, lvname="root", grow=1, format=1)
260 partitions.autoPartitionRequests.append(request)
261
262 filesystem = fileSystemTypeGet("ext3")
263 request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/var", size=1024,
264 maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1)
265 partitions.autoPartitionRequests.append(request)
266
267 filesystem = fileSystemTypeGet("ext3")
268 request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/home/e-smith/files", size=1024,
269 maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1)
270 partitions.autoPartitionRequests.append(request)
271
272 filesystem = fileSystemTypeGet("ext3")
273 request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/tmp", size=512,
274 maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1)
275 partitions.autoPartitionRequests.append(request)
276
277 filesystem = fileSystemTypeGet("swap")
278 request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax,
279 volgroup=201, lvname="swap", grow=1, format=1)
280 partitions.autoPartitionRequests.append(request)
281 else:
282 filesystem = fileSystemTypeGet("ext3")
283 request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=1300,
284 volgroup=201, lvname="root", grow=1, format=1)
285 partitions.autoPartitionRequests.append(request)
286
287 filesystem = fileSystemTypeGet("swap")
288 request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax,
289 volgroup=201, lvname="swap", grow=1, format=1)
290 partitions.autoPartitionRequests.append(request)
291
292 partitions.autoClearPartDrives = usedDrives
293 else:
294 BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear)
295
296 def setAsHeadless(self, dispatch, isHeadless = 0):
297 if isHeadless == 0:
298 pass
299 else:
300 dispatch.skipStep("handleX11pkgs", permanent = 1)
301 dispatch.skipStep("videocard", permanent = 1)
302 dispatch.skipStep("monitor", permanent = 1)
303 dispatch.skipStep("xcustom", permanent = 1)
304 dispatch.skipStep("writexconfig", permanent = 1)
305
306 def setGroupSelection(self, grpset, intf):
307 grpset.unselectAll()
308 grpset.selectGroup("Base")
309
310 def postAction(self, rootPath, serial, intf):
311 win = intf.waitWindow(_("Post Install Script"),
312 _("The post installation script is running..."))
313
314 script = ( "/sbin/syslogd &\n"
315 "sleep 2\n"
316 "/sbin/e-smith/signal-event post-install\n" )
317 s = Script(script, interp="/bin/sh", inChroot=1)
318 log("%s", s)
319 s.run(rootPath, serial)
320 win.pop()
321
322 def setInstallData(self, id, intf = None):
323 BaseInstallClass.setInstallData(self, id)
324 self.setAuthentication(id, useShadow=1, salt="md5")
325 self.setRootPassword(id, pw="ThisIsGoingToBeDisabledAnyway", isCrypted=0)
326 self.setZeroMbr(id, zeroMbr=1)
327 self.setClearParts(id, clear=CLEARPART_TYPE_ALL, initAll=1)
328 self.setDefaultPartitioning(id.partitions, doClear=0)
329 self.setBootloader(id, useLilo=0, location="mbr", linear=1)
330
331 def __init__(self, expert):
332 BaseInstallClass.__init__(self, expert)

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed