13 |
|
|
14 |
class Script: |
class Script: |
15 |
def __repr__(self): |
def __repr__(self): |
16 |
str = ("(s: '%s' i: %s c: %d)") % \ |
str = ("(s: '%s' i: %s c: %d)") % \ |
17 |
(self.script, self.interp, self.inChroot) |
(self.script, self.interp, self.inChroot) |
18 |
return string.replace(str, "\n", "|") |
return string.replace(str, "\n", "|") |
19 |
|
|
59 |
description = N_("This option performs a new install of " |
description = N_("This option performs a new install of " |
60 |
"SME Server. All attached hard drives " |
"SME Server. All attached hard drives " |
61 |
"will be repartitioned and formated.") |
"will be repartitioned and formated.") |
62 |
|
|
63 |
sortPriority = 1 |
sortPriority = 1 |
64 |
useabledrives = 0 |
doPartition = False |
65 |
|
cmdline = {} |
66 |
|
|
67 |
parentClass = ( _("Install SME Server"), "smeserver.png" ) |
parentClass = ( _("Install SME Server"), "smeserver.png" ) |
68 |
|
|
69 |
def requiredDisplayMode(self): |
def requiredDisplayMode(self): |
70 |
return 't' |
return 't' |
71 |
|
|
72 |
|
def createCmdlineDict(self): |
73 |
|
cmdlineDict = {} |
74 |
|
cmdline = open("/proc/cmdline", "r").read().strip() |
75 |
|
|
76 |
|
for i in cmdline.split(): |
77 |
|
try: |
78 |
|
(key, val) = i.split("=", 1) |
79 |
|
except: |
80 |
|
key = i |
81 |
|
val = True |
82 |
|
|
83 |
|
cmdlineDict[key] = val |
84 |
|
|
85 |
|
return cmdlineDict |
86 |
|
|
87 |
|
def mediaPresent(self, device): |
88 |
|
try: |
89 |
|
fd = os.open("/dev/%s" % device, os.O_RDONLY) |
90 |
|
except OSError, (errno, strerror): |
91 |
|
# error 123 = No medium found |
92 |
|
if errno == 123: |
93 |
|
return False |
94 |
|
else: |
95 |
|
return True |
96 |
|
else: |
97 |
|
os.close(fd) |
98 |
|
return True |
99 |
|
|
100 |
def setSteps(self, dispatch): |
def setSteps(self, dispatch): |
101 |
dispatch.setStepList( |
dispatch.setStepList( |
102 |
"language", |
"language", |
106 |
"installtype", |
"installtype", |
107 |
"partitionobjinit", |
"partitionobjinit", |
108 |
"autopartitionexecute", |
"autopartitionexecute", |
|
"parttype", |
|
109 |
"partition", |
"partition", |
110 |
"partitiondone", |
"partitiondone", |
111 |
"bootloadersetup", |
"bootloadersetup", |
112 |
"languagesupport", |
"languagesupport", |
113 |
"timezone", |
"timezone", |
114 |
"readcomps", |
"readcomps", |
132 |
"complete" |
"complete" |
133 |
) |
) |
134 |
|
|
135 |
# 'partition' can be used on the command line to force |
# 'partition' can be used on the command line to force |
136 |
# verification of partitions. useful in some cases... |
# verification of partitions. useful in some cases... |
137 |
cmdline = open("/proc/cmdline", "r").read() |
if self.doPartition or self.cmdline.has_key("partition"): |
|
cmdline = cmdline.split() |
|
|
if self.useabledrives == 0 or "partition" in cmdline: |
|
|
dispatch.skipStep("parttype", skip = 0) |
|
138 |
dispatch.skipStep("partition", skip = 0) |
dispatch.skipStep("partition", skip = 0) |
139 |
else: |
else: |
|
dispatch.skipStep("parttype", skip = 1) |
|
140 |
dispatch.skipStep("partition", skip = 1) |
dispatch.skipStep("partition", skip = 1) |
141 |
|
|
142 |
def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1): |
def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1): |
143 |
uniqueID = 100 |
self.cmdline = self.createCmdlineDict() |
|
(swapMin, swapMax) = iutil.swapSuggestion() |
|
144 |
diskset = partedUtils.DiskSet() |
diskset = partedUtils.DiskSet() |
|
drives = diskset.driveList() |
|
|
usedDrives = [] |
|
145 |
|
|
146 |
spares = 0 |
if self.cmdline.has_key("exclude"): |
147 |
self.useabledrives = 0 |
alldrives = filter(lambda x:not x in self.cmdline["exclude"].split(","), diskset.driveList()) |
148 |
for drive in drives: |
else: |
149 |
if not isys.driveIsRemovable(drive): |
alldrives = diskset.driveList() |
|
self.useabledrives = self.useabledrives + 1 |
|
|
|
|
|
log.info("Found %d useable drives" % self.useabledrives) |
|
|
if self.useabledrives >= 1: |
|
|
if "noraid" in cmdline: |
|
|
for drive in drives: |
|
|
if not isys.driveIsRemovable(drive): |
|
|
filesystem = fileSystemTypeGet("ext3") |
|
|
request = partRequests.PartitionSpec(filesystem, mountpoint="/boot", drive=[drive], |
|
|
size=100, primary=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
usedDrives.append(drive); |
|
150 |
|
|
151 |
if "nolvm" in cmdline: |
if self.cmdline.has_key("drives"): |
152 |
filesystem = fileSystemTypeGet("ext3") |
if self.cmdline["drives"] == "all": |
153 |
request = partRequests.PartitionSpec(filesystem, mountpoint="/", drive=[drive], |
drives = filter(lambda x:self.mediaPresent(x), alldrives) |
154 |
size=1300, grow=1, primary=1, format=1) |
else: |
155 |
partitions.autoPartitionRequests.append(request) |
drives = filter(lambda x:self.mediaPresent(x) and |
156 |
|
x in self.cmdline["drives"].split(","), alldrives) |
157 |
filesystem = fileSystemTypeGet("swap") |
else: |
158 |
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin, |
drives = filter(lambda x:not isys.driveIsRemovable(x) and |
159 |
maxSizeMB=swapMax, grow=1, primary=1, format=1) |
self.mediaPresent(x) and |
160 |
partitions.autoPartitionRequests.append(request) |
not isys.driveUsesModule(x, ["usb-storage", "ub", "sbp2"]), alldrives) |
161 |
|
|
162 |
else: |
if self.cmdline.has_key("spares"): |
163 |
filesystem = fileSystemTypeGet("physical volume (LVM)") |
if self.cmdline["spares"] == "none": |
164 |
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500, |
spares = 0 |
165 |
grow=1, primary=1, format=1) |
else: |
166 |
request.uniqueID = 200 |
try: |
167 |
partitions.autoPartitionRequests.append(request) |
spares = max(0,min(int(self.cmdline["spares"]),len(drives)-2)) |
168 |
|
except: |
169 |
|
spares = (len(drives)+4)/7 |
170 |
|
else: |
171 |
|
spares = (len(drives)+4)/7 |
172 |
|
|
173 |
break |
if self.cmdline.has_key("raid") and self.cmdline["raid"] in ["none","0","1","5","6"]: |
174 |
|
if self.cmdline["raid"] == "none": |
175 |
|
level = 0 |
176 |
|
else: |
177 |
|
level = int(self.cmdline["raid"]) |
178 |
|
if level == 0: |
179 |
|
del drives[1:] |
180 |
|
spares = 0 |
181 |
|
if level == 6 and len(drives)-spares < 4: |
182 |
|
level = 5 |
183 |
|
if level == 5 and len(drives)-spares < 3: |
184 |
|
level = 1 |
185 |
|
if level == 1: |
186 |
|
if spares > 1 and not self.cmdline.has_key("spares"): |
187 |
|
spares = 1 |
188 |
|
del drives[2+spares:] |
189 |
|
else: |
190 |
|
if len(drives) - spares >= 6: |
191 |
|
level = 6 |
192 |
|
elif len(drives) - spares >= 3: |
193 |
|
level = 5 |
194 |
|
else: |
195 |
|
level = 1 |
196 |
|
|
197 |
|
if len(drives) >= 1: |
198 |
|
excluded = filter(lambda x:x not in drives, diskset.driveList()) |
199 |
|
log("Using the following drives: %s" % drives) |
200 |
|
log("Excluding the following drives: %s" % excluded) |
201 |
|
if level >= 1: |
202 |
|
log("Installing using RAID%s" % level) |
203 |
|
log("Using %s spare drives" % spares) |
204 |
else: |
else: |
205 |
|
log("Installing without using RAID") |
206 |
|
|
207 |
|
(swapMin, swapMax) = iutil.swapSuggestion() |
208 |
|
if level >= 1: |
209 |
raid1 = [] |
raid1 = [] |
210 |
raid2 = [] |
raid2 = [] |
211 |
raid3 = [] |
raid3 = [] |
212 |
|
uniqueID = 100 |
213 |
|
|
214 |
if self.useabledrives >= 3 and "nospare" not in cmdline: |
for drive in drives: |
215 |
self.useabledrives = self.useabledrives - 1 |
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
216 |
spares = 1 |
drive=[drive], size=100, primary=1, format=1) |
217 |
|
request.uniqueID = uniqueID |
218 |
|
raid1.append(uniqueID) |
219 |
|
partitions.autoPartitionRequests.append(request) |
220 |
|
|
221 |
if "raid1" in cmdline and self.useabledrives >= 1: |
if not self.cmdline.has_key("nolvm"): |
222 |
self.useabledrives = 1 |
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
223 |
raidLevel = "RAID1" |
size=(swapMin+4096)/(len(drives)-spares-max(0,level-4)), |
224 |
else: |
drive=[drive], primary=1, grow=1, format=1) |
225 |
if self.useabledrives >= 6: |
request.uniqueID = uniqueID + 50 |
226 |
self.useabledrives = self.useabledrives - 2 |
raid2.append(uniqueID + 50) |
227 |
raidLevel = "RAID6" |
partitions.autoPartitionRequests.append(request) |
|
elif self.useabledrives >= 2: |
|
|
self.useabledrives = self.useabledrives - 1 |
|
|
if self.useabledrives >= 2: |
|
|
raidLevel = "RAID5" |
|
|
else: |
|
|
raidLevel = "RAID1" |
|
228 |
else: |
else: |
229 |
raidLevel = "RAID1" |
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
230 |
|
drive=[drive], size=swapMin/(len(drives)-spares-max(0,level-4))+10, grow=1, |
231 |
|
maxSizeMB=swapMax/(len(drives)-spares-max(0,level-4)), format=1, primary=1) |
232 |
|
request.uniqueID = uniqueID + 30 |
233 |
|
raid2.append(uniqueID + 30) |
234 |
|
partitions.autoPartitionRequests.append(request) |
235 |
|
|
236 |
for drive in drives: |
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
237 |
if not isys.driveIsRemovable(drive): |
size=1500/(len(drives)-spares-max(0,level-4)), |
238 |
filesystem = fileSystemTypeGet("software RAID") |
drive=[drive], grow=1, primary=1, format=1) |
239 |
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=100, primary=1, format=1) |
request.uniqueID = uniqueID + 60 |
240 |
request.uniqueID = uniqueID |
raid3.append(uniqueID + 60) |
|
raid1.append(uniqueID) |
|
241 |
partitions.autoPartitionRequests.append(request) |
partitions.autoPartitionRequests.append(request) |
|
usedDrives.append(drive); |
|
242 |
|
|
243 |
if "nolvm" in cmdline: |
uniqueID = uniqueID + 1 |
|
filesystem = fileSystemTypeGet("software RAID") |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin/self.useabledrives+10, |
|
|
maxSizeMB=swapMax/self.useabledrives, grow=1, primary=1, format=1) |
|
|
request.uniqueID = uniqueID + 30 |
|
|
raid2.append(uniqueID + 30) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
|
|
|
filesystem = fileSystemTypeGet("software RAID") |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=1500/self.useabledrives, |
|
|
grow=1, primary=1, format=1) |
|
|
request.uniqueID = uniqueID + 60 |
|
|
raid3.append(uniqueID + 60) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
|
|
|
else: |
|
|
filesystem = fileSystemTypeGet("software RAID") |
|
|
if "multipart" in cmdline: |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+3000)/self.useabledrives, |
|
|
grow=1, format=1) |
|
|
else: |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+1500)/self.useabledrives, |
|
|
grow=1, format=1) |
|
|
request.uniqueID = uniqueID + 50 |
|
|
raid2.append(uniqueID + 50) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
|
|
|
uniqueID = uniqueID + 1 |
|
|
|
|
|
if "raid1" in cmdline and len(raid1)-spares >= 2: |
|
|
break |
|
|
|
|
|
filesystem = fileSystemTypeGet("ext3") |
|
|
request = partRequests.RaidRequestSpec(filesystem, mountpoint="/boot", raidminor=1, |
|
|
raidmembers=raid1, raidlevel="RAID1", format=1, raidspares=spares) |
|
|
partitions.autoPartitionRequests.append(request) |
|
244 |
|
|
245 |
if "nolvm" in cmdline: |
partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"), |
246 |
filesystem = fileSystemTypeGet("swap") |
mountpoint="/boot", raidmembers=raid1, raidlevel="RAID1", raidminor=1, format=1, |
247 |
request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2, |
raidspares=0)) |
248 |
raidlevel=raidLevel, format=1, raidspares=spares) |
|
249 |
|
if not self.cmdline.has_key("nolvm"): |
250 |
|
request = partRequests.RaidRequestSpec(fileSystemTypeGet("physical volume (LVM)"), |
251 |
|
raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, |
252 |
|
raidspares=spares) |
253 |
|
request.uniqueID = 200 |
254 |
partitions.autoPartitionRequests.append(request) |
partitions.autoPartitionRequests.append(request) |
255 |
|
else: |
256 |
|
partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("swap"), |
257 |
|
raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, raidspares=spares)) |
258 |
|
|
259 |
filesystem = fileSystemTypeGet("ext3") |
partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"), |
260 |
request = partRequests.RaidRequestSpec(filesystem, mountpoint="/", raidmembers=raid3, raidminor=3, |
mountpoint="/", raidmembers=raid3, raidlevel="RAID"+str(level), raidminor=3, format=1, |
261 |
raidlevel=raidLevel, format=1, raidspares=spares) |
raidspares=spares)) |
|
partitions.autoPartitionRequests.append(request) |
|
262 |
|
|
263 |
else: |
else: |
264 |
filesystem = fileSystemTypeGet("physical volume (LVM)") |
for drive in drives: |
265 |
request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2, |
partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"), |
266 |
raidlevel=raidLevel, format=1, raidspares=spares) |
mountpoint="/boot", drive=[drive], size=100, primary=1, format=1)) |
267 |
request.uniqueID = 200 |
|
268 |
partitions.autoPartitionRequests.append(request) |
if not self.cmdline.has_key("nolvm"): |
269 |
|
request = partRequests.PartitionSpec(fileSystemTypeGet("physical volume (LVM)"), |
270 |
|
drive=[drive], size=swapMin+4096, grow=1, primary=1, format=1) |
271 |
|
request.uniqueID = 200 |
272 |
|
partitions.autoPartitionRequests.append(request) |
273 |
|
else: |
274 |
|
partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"), |
275 |
|
mountpoint="/", drive=[drive], size=4096, grow=1, primary=1, format=1)) |
276 |
|
|
277 |
|
partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("swap"), |
278 |
|
drive=[drive], size=swapMin, maxSizeMB=swapMax, grow=1, primary=1, format=1)) |
279 |
|
|
280 |
if not "nolvm" in cmdline: |
if not self.cmdline.has_key("nolvm"): |
281 |
request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200], |
request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200], pesize=32768, format=1) |
|
pesize=32768, format=1) |
|
282 |
request.uniqueID = 201 |
request.uniqueID = 201 |
283 |
partitions.autoPartitionRequests.append(request) |
partitions.autoPartitionRequests.append(request) |
284 |
|
|
285 |
if "multipart" in cmdline: |
if not self.cmdline.has_key("multipart"): |
286 |
filesystem = fileSystemTypeGet("ext3") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
287 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=2048, |
mountpoint="/", size=1300, volgroup=201, lvname="root", grow=1, format=1)) |
|
maxSizeMB=4096, volgroup=201, lvname="root", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
288 |
|
|
289 |
filesystem = fileSystemTypeGet("ext3") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"), |
290 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/var", size=1024, |
size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1)) |
291 |
maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1) |
else: |
292 |
partitions.autoPartitionRequests.append(request) |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
293 |
|
mountpoint="/", size=2048, maxSizeMB=4096, volgroup=201, lvname="root", grow=1, format=1)) |
294 |
|
|
295 |
filesystem = fileSystemTypeGet("ext3") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
296 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/home/e-smith/files", size=1024, |
mountpoint="/var", size=1024, maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1)) |
|
maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
297 |
|
|
298 |
filesystem = fileSystemTypeGet("ext3") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
299 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/tmp", size=512, |
mountpoint="/home/e-smith/files", size=1024, maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1)) |
|
maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
300 |
|
|
301 |
filesystem = fileSystemTypeGet("swap") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
302 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax, |
mountpoint="/tmp", size=512, maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1)) |
|
volgroup=201, lvname="swap", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
else: |
|
|
filesystem = fileSystemTypeGet("ext3") |
|
|
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=1300, |
|
|
volgroup=201, lvname="root", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
303 |
|
|
304 |
filesystem = fileSystemTypeGet("swap") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"), |
305 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax, |
size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1)) |
|
volgroup=201, lvname="swap", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
306 |
|
|
307 |
partitions.autoClearPartDrives = usedDrives |
partitions.autoClearPartType = CLEARPART_TYPE_ALL |
308 |
|
partitions.autoClearPartDrives = drives |
309 |
|
self.doPartition = False |
310 |
else: |
else: |
311 |
|
log("Not useable drives found. Enabling manual partitioning.") |
312 |
|
self.doPartition = True |
313 |
BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear) |
BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear) |
314 |
|
|
315 |
def setAsHeadless(self, dispatch, isHeadless = 0): |
def setAsHeadless(self, dispatch, isHeadless = 0): |