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

Annotation of /cdrom.image/product/installclasses/smeinstallclass.py

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


Revision 1.22 - (hide annotations) (download) (as text)
Fri Dec 8 22:47:16 2006 UTC (17 years, 11 months ago) by slords
Branch: MAIN
Changes since 1.21: +5 -2 lines
Content type: text/x-python
Don't wipe drives we aren't partitioning

1 slords 1.1 from installclass import BaseInstallClass
2 slords 1.13 from rhpl.translate import N_, _
3 slords 1.12 from constants import *
4     import os
5     import iutil
6 slords 1.13 from fsset import *
7 slords 1.12
8 slords 1.1 from autopart import getAutopartitionBoot, autoCreatePartitionRequests, autoCreateLVMPartitionRequests
9     from rhpl.log import log
10 slords 1.2 import string
11 slords 1.1 import partRequests
12     import partedUtils
13    
14 slords 1.2 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 slords 1.1 class InstallClass(BaseInstallClass):
56 slords 1.2 id = "smeserver"
57     name = N_("New _SME Server Install")
58     pixmap = "smeserver.png"
59 slords 1.3 description = N_("This option performs a new install of "
60     "SME Server. All attached hard drives "
61     "will be repartitioned and formated.")
62 slords 1.1 sortPriority = 1
63    
64 slords 1.2 parentClass = ( _("Install SME Server"), "smeserver.png" )
65 slords 1.1
66     def requiredDisplayMode(self):
67     return 't'
68    
69     def setSteps(self, dispatch):
70     dispatch.setStepList(
71     "language",
72     "keyboard",
73     "findrootparts",
74 slords 1.4 "findinstall",
75     "installtype",
76 slords 1.1 "partitionobjinit",
77     "autopartitionexecute",
78 slords 1.2 "partition",
79 slords 1.1 "partitiondone",
80     "bootloadersetup",
81 slords 1.7 "languagesupport",
82 slords 1.1 "timezone",
83     "readcomps",
84     "selectlangpackages",
85     "checkdeps",
86     "dependencies",
87     "install",
88     "enablefilesystems",
89     "migratefilesystems",
90     "setuptime",
91     "preinstallconfig",
92     "installpackages",
93     "postinstallconfig",
94     "writeconfig",
95     "instbootloader",
96     "dopostaction",
97     "methodcomplete",
98     "copylogs",
99 slords 1.11 "writeksconfig",
100 slords 1.1 "setfilecon",
101     "complete"
102     )
103    
104 slords 1.2 # 'partition' can be used on the command line to force
105     # verification of partitions. useful in some cases...
106     cmdline = open("/proc/cmdline", "r").read()
107     cmdline = cmdline.split()
108     if "partition" in cmdline:
109     dispatch.skipStep("partition", skip = 0)
110     else:
111     dispatch.skipStep("partition", skip = 1)
112    
113 slords 1.1 def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1):
114 slords 1.15 uniqueID = 100
115 slords 1.16 (swapMin, swapMax) = iutil.swapSuggestion()
116     diskset = partedUtils.DiskSet()
117     drives = diskset.driveList()
118 slords 1.22 usedDrives = []
119 slords 1.16
120 slords 1.18 spares = 0
121     useable = 0
122     for drive in drives:
123     if not isys.driveIsRemovable(drive):
124     useable = useable + 1
125    
126     if useable > 0:
127     if "noraid" in cmdline:
128     for drive in drives:
129     if not isys.driveIsRemovable(drive):
130 slords 1.16 filesystem = fileSystemTypeGet("ext3")
131 slords 1.18 request = partRequests.PartitionSpec(filesystem, mountpoint="/boot", drive=[drive],
132     size=100, primary=1, format=1)
133 slords 1.16 partitions.autoPartitionRequests.append(request)
134 slords 1.22 usedDrives.append(drive);
135 slords 1.16
136 slords 1.18 if "nolvm" in cmdline:
137     filesystem = fileSystemTypeGet("ext3")
138     request = partRequests.PartitionSpec(filesystem, mountpoint="/", drive=[drive],
139     size=1300, grow=1, primary=1, format=1)
140     partitions.autoPartitionRequests.append(request)
141    
142     filesystem = fileSystemTypeGet("swap")
143     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin,
144     maxSizeMB=swapMax, grow=1, primary=1, format=1)
145     partitions.autoPartitionRequests.append(request)
146    
147     else:
148     filesystem = fileSystemTypeGet("physical volume (LVM)")
149     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500,
150     grow=1, primary=1, format=1)
151     request.uniqueID = 200
152     partitions.autoPartitionRequests.append(request)
153 slords 1.16
154 slords 1.18 break
155 slords 1.16
156 slords 1.18 else:
157     raid1 = []
158     raid2 = []
159     raid3 = []
160    
161     if "raid1" in cmdline and useable > 0:
162     if useable > 2 and "spare" in cmdline:
163     spares = 1
164     useable = 1
165     raidLevel = "RAID1"
166    
167     else:
168     if useable > 2 and "spare" in cmdline:
169     useable = useable - 1
170     spares = 1
171    
172     if useable > 5:
173     useable = useable - 2
174     raidLevel = "RAID6"
175     elif useable > 1:
176     useable = useable - 1
177     if useable > 2:
178     raidLevel = "RAID5"
179     else:
180     raidLevel = "RAID1"
181 slords 1.19 else:
182     raidLevel = "RAID1"
183 slords 1.16
184 slords 1.18 for drive in drives:
185     if not isys.driveIsRemovable(drive):
186 slords 1.16 filesystem = fileSystemTypeGet("software RAID")
187 slords 1.18 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=100, primary=1, format=1)
188     request.uniqueID = uniqueID
189     raid1.append(uniqueID)
190     partitions.autoPartitionRequests.append(request)
191 slords 1.22 usedDrives.append(drive);
192 slords 1.18
193     if "nolvm" in cmdline:
194     filesystem = fileSystemTypeGet("software RAID")
195 slords 1.20 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin/useable+10,
196     maxSizeMB=swapMax/useable, grow=1, primary=1, format=1)
197 slords 1.18 request.uniqueID = uniqueID + 30
198 slords 1.21 raid2.append(uniqueID + 30)
199     partitions.autoPartitionRequests.append(request)
200 slords 1.20
201 slords 1.18 filesystem = fileSystemTypeGet("software RAID")
202 slords 1.20 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=1500/useable,
203     grow=1, primary=1, format=1)
204 slords 1.18 request.uniqueID = uniqueID + 60
205 slords 1.21 raid3.append(uniqueID + 60)
206 slords 1.18 partitions.autoPartitionRequests.append(request)
207    
208     else:
209     filesystem = fileSystemTypeGet("software RAID")
210     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+1500)/useable,
211     grow=1, format=1)
212     request.uniqueID = uniqueID + 50
213     raid2.append(uniqueID + 50)
214     partitions.autoPartitionRequests.append(request)
215 slords 1.16
216 slords 1.18 uniqueID = uniqueID + 1
217 slords 1.16
218 slords 1.18 if "raid1" in cmdline and len(raid1)-spares > 1:
219     break
220 slords 1.16
221     filesystem = fileSystemTypeGet("ext3")
222 slords 1.18 request = partRequests.RaidRequestSpec(filesystem, mountpoint="/boot", raidminor=1,
223     raidmembers=raid1, raidlevel="RAID1", format=1, raidspares=spares)
224 slords 1.16 partitions.autoPartitionRequests.append(request)
225    
226 slords 1.18 if "nolvm" in cmdline:
227 slords 1.20 filesystem = fileSystemTypeGet("swap")
228     request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2,
229 slords 1.18 raidlevel=raidLevel, format=1, raidspares=spares)
230     partitions.autoPartitionRequests.append(request)
231    
232 slords 1.20 filesystem = fileSystemTypeGet("ext3")
233     request = partRequests.RaidRequestSpec(filesystem, mountpoint="/", raidmembers=raid3, raidminor=3,
234 slords 1.18 raidlevel=raidLevel, format=1, raidspares=spares)
235     partitions.autoPartitionRequests.append(request)
236 slords 1.16
237 slords 1.18 else:
238     filesystem = fileSystemTypeGet("physical volume (LVM)")
239     request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2,
240     raidlevel=raidLevel, format=1, raidspares=spares)
241     request.uniqueID = 200
242     partitions.autoPartitionRequests.append(request)
243 slords 1.16
244     if not "nolvm" in cmdline:
245     request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200],
246     pesize=32768, format=1)
247     request.uniqueID = 201
248     partitions.autoPartitionRequests.append(request)
249    
250     filesystem = fileSystemTypeGet("ext3")
251     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=1300,
252     volgroup=201, lvname="root", grow=1, format=1)
253     partitions.autoPartitionRequests.append(request)
254    
255     filesystem = fileSystemTypeGet("swap")
256     request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax,
257     volgroup=201, lvname="swap", grow=1, format=1)
258     partitions.autoPartitionRequests.append(request)
259 slords 1.22
260     partitions.autoClearPartDrives = usedDrives
261 slords 1.16 else:
262     dispatch.skipStep("partition", skip = 0)
263     BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear)
264    
265 slords 1.14 def setAsHeadless(self, dispatch, isHeadless = 0):
266     if isHeadless == 0:
267     pass
268     else:
269     dispatch.skipStep("handleX11pkgs", permanent = 1)
270     dispatch.skipStep("videocard", permanent = 1)
271     dispatch.skipStep("monitor", permanent = 1)
272     dispatch.skipStep("xcustom", permanent = 1)
273     dispatch.skipStep("writexconfig", permanent = 1)
274    
275 slords 1.1 def setGroupSelection(self, grpset, intf):
276     grpset.unselectAll()
277     grpset.selectGroup("Base")
278    
279 gordonr 1.10 def postAction(self, rootPath, serial, intf):
280     win = intf.waitWindow(_("Post Install Script"),
281     _("The post installation script is running..."))
282    
283 slords 1.3 script = ( "/sbin/syslogd &\n"
284     "sleep 2\n"
285     "/sbin/e-smith/signal-event post-install\n" )
286 slords 1.2 s = Script(script, interp="/bin/sh", inChroot=1)
287     log("%s", s)
288     s.run(rootPath, serial)
289 gordonr 1.10 win.pop()
290 slords 1.1
291     def setInstallData(self, id, intf = None):
292     BaseInstallClass.setInstallData(self, id)
293     self.setAuthentication(id, useShadow=1, useMd5=1)
294     self.setRootPassword(id, pw="ThisIsGoingToBeDisabledAnyway", isCrypted=0)
295     self.setZeroMbr(id, zeroMbr=1)
296     self.setClearParts(id, clear=CLEARPART_TYPE_ALL, initAll=1)
297     self.setDefaultPartitioning(id.partitions, doClear=0)
298     self.setBootloader(id, useLilo=0, location="mbr", linear=1)
299    
300     def __init__(self, expert):
301 slords 1.12 BaseInstallClass.__init__(self, expert)

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