1 |
from installclass import BaseInstallClass |
2 |
from autopart import getAutopartitionBoot, autoCreatePartitionRequests, autoCreateLVMPartitionRequests |
3 |
from fsset import * |
4 |
from rhpl.translate import N_, _ |
5 |
from rhpl.log import log |
6 |
from constants import * |
7 |
|
8 |
import os |
9 |
import iutil |
10 |
import partRequests |
11 |
import partedUtils |
12 |
|
13 |
class InstallClass(BaseInstallClass): |
14 |
name = N_("Install SME Server") |
15 |
sortPriority = 1 |
16 |
|
17 |
parentClass = ( _("SMEServer"), "" ) |
18 |
|
19 |
def requiredDisplayMode(self): |
20 |
return 't' |
21 |
|
22 |
def setSteps(self, dispatch): |
23 |
dispatch.setStepList( |
24 |
"language", |
25 |
"keyboard", |
26 |
"findrootparts", |
27 |
"partitionobjinit", |
28 |
"autopartitionexecute", |
29 |
"partitiondone", |
30 |
"bootloadersetup", |
31 |
"languagesupport", |
32 |
"timezone", |
33 |
"readcomps", |
34 |
"selectlangpackages", |
35 |
"checkdeps", |
36 |
"dependencies", |
37 |
"install", |
38 |
"enablefilesystems", |
39 |
"migratefilesystems", |
40 |
"setuptime", |
41 |
"preinstallconfig", |
42 |
"installpackages", |
43 |
"postinstallconfig", |
44 |
"writeconfig", |
45 |
"instbootloader", |
46 |
"dopostaction", |
47 |
"methodcomplete", |
48 |
"copylogs", |
49 |
"setfilecon", |
50 |
"complete" |
51 |
) |
52 |
|
53 |
def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1): |
54 |
diskset = partedUtils.DiskSet() |
55 |
drives = diskset.driveList() |
56 |
if len(drives) > 0: |
57 |
uniqueID = 100 |
58 |
raid1 = [] |
59 |
raid2 = [] |
60 |
(swapMin, swapMax) = iutil.swapSuggestion() |
61 |
|
62 |
for drive in drives: |
63 |
filesystem = fileSystemTypeGet("software RAID") |
64 |
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=100, primary=1, format=1) |
65 |
request.uniqueID = uniqueID |
66 |
raid1.append(uniqueID) |
67 |
partitions.autoPartitionRequests.append(request) |
68 |
|
69 |
filesystem = fileSystemTypeGet("software RAID") |
70 |
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500, |
71 |
grow=1, format=1); |
72 |
request.uniqueID = uniqueID + 10 |
73 |
raid2.append(uniqueID + 10) |
74 |
partitions.autoPartitionRequests.append(request) |
75 |
|
76 |
uniqueID = uniqueID + 1 |
77 |
|
78 |
filesystem = fileSystemTypeGet("ext3") |
79 |
request = partRequests.RaidRequestSpec(filesystem, mountpoint="/boot", raidminor=1, |
80 |
raidmembers=raid1, raidlevel="RAID1", format=1, raidspares=0) |
81 |
partitions.autoPartitionRequests.append(request) |
82 |
|
83 |
if len(drives) > 5: |
84 |
raidLevel = "RAID6" |
85 |
elif len(drives) > 2: |
86 |
raidLevel = "RAID5" |
87 |
else: |
88 |
raidLevel = "RAID1" |
89 |
|
90 |
filesystem = fileSystemTypeGet("physical volume (LVM)") |
91 |
request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2, |
92 |
raidlevel=raidLevel, format=1, raidspares=0) |
93 |
request.uniqueID = 200 |
94 |
partitions.autoPartitionRequests.append(request) |
95 |
|
96 |
request = partRequests.VolumeGroupRequestSpec(vgname="vg_primary", physvols=[200], |
97 |
pesize=4096, format=1) |
98 |
request.uniqueID = 201 |
99 |
partitions.autoPartitionRequests.append(request) |
100 |
|
101 |
filesystem = fileSystemTypeGet("swap") |
102 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, format=1, grow=1, |
103 |
size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="lv_swap") |
104 |
partitions.autoPartitionRequests.append(request) |
105 |
|
106 |
filesystem = fileSystemTypeGet("ext3") |
107 |
(size, maxSizeMB) = iutil.swapSuggestion() |
108 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, format=1, grow=1, |
109 |
mountpoint="/", size=1300, volgroup=201, lvname="lv_root") |
110 |
partitions.autoPartitionRequests.append(request) |
111 |
else: |
112 |
BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear) |
113 |
|
114 |
def setGroupSelection(self, grpset, intf): |
115 |
grpset.unselectAll() |
116 |
grpset.selectGroup("Base") |
117 |
|
118 |
def postAction(self, rootPath, serial): |
119 |
if serial: |
120 |
messages = "/tmp/postinstall.log" |
121 |
else: |
122 |
messages = "/dev/tty3" |
123 |
|
124 |
path = rootPath + "/tmp/postinstall.sh" |
125 |
cmds = ["/sbin/syslogd &\n", |
126 |
"sleep 2\n", |
127 |
"/sbin/e-smith/signal-event post-install\n"] |
128 |
|
129 |
f = open(path, "w") |
130 |
f.writelines(cmds) |
131 |
f.close |
132 |
os.chmod(path, 0700) |
133 |
|
134 |
rc = iutil.execWithRedirect("/bin/sh", ["/bin/sh", "/tmp/postinstall.sh"], |
135 |
stdout=messages, stderr=messages, root=rootPath) |
136 |
if rc != 0: |
137 |
log("WARNING - Error code %s encountered running postinstall script", rc) |
138 |
# os.unlink(path) |
139 |
|
140 |
def setInstallData(self, id, intf = None): |
141 |
BaseInstallClass.setInstallData(self, id) |
142 |
self.setSELinux(id, sel=0) |
143 |
self.setAuthentication(id, useShadow=1, useMd5=1) |
144 |
self.setRootPassword(id, pw="ThisIsGoingToBeDisabledAnyway", isCrypted=0) |
145 |
self.setZeroMbr(id, zeroMbr=1) |
146 |
self.setClearParts(id, clear=CLEARPART_TYPE_ALL, initAll=1) |
147 |
self.setDefaultPartitioning(id.partitions, doClear=0) |
148 |
self.setBootloader(id, useLilo=0, location="mbr", linear=1) |
149 |
|
150 |
def __init__(self, expert): |
151 |
BaseInstallClass.__init__(self, expert) |