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

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

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


Revision 1.3 - (show annotations) (download) (as text)
Sun Jul 31 16:38:15 2005 UTC (19 years, 3 months ago) by slords
Branch: MAIN
Changes since 1.2: +6 -1 lines
Content type: text/x-python
Cleanup and descriptions

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 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
64 parentClass = ( _("Install SME Server"), "smeserver.png" )
65
66 def requiredDisplayMode(self):
67 return 't'
68
69 def setSteps(self, dispatch):
70 dispatch.setStepList(
71 "language",
72 "keyboard",
73 "findrootparts",
74 "partitionobjinit",
75 "autopartitionexecute",
76 "partition",
77 "partitiondone",
78 "bootloadersetup",
79 "languagesupport",
80 "timezone",
81 "readcomps",
82 "selectlangpackages",
83 "checkdeps",
84 "dependencies",
85 "install",
86 "enablefilesystems",
87 "migratefilesystems",
88 "setuptime",
89 "preinstallconfig",
90 "installpackages",
91 "postinstallconfig",
92 "writeconfig",
93 "instbootloader",
94 "dopostaction",
95 "methodcomplete",
96 "copylogs",
97 "setfilecon",
98 "complete"
99 )
100
101 # 'partition' can be used on the command line to force
102 # verification of partitions. useful in some cases...
103 cmdline = open("/proc/cmdline", "r").read()
104 cmdline = cmdline.split()
105 if "partition" in cmdline:
106 dispatch.skipStep("partition", skip = 0)
107 else:
108 dispatch.skipStep("partition", skip = 1)
109
110 def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1):
111 diskset = partedUtils.DiskSet()
112 drives = diskset.driveList()
113 if len(drives) > 0:
114 uniqueID = 100
115 raid1 = []
116 raid2 = []
117 (swapMin, swapMax) = iutil.swapSuggestion()
118
119 for drive in drives:
120 filesystem = fileSystemTypeGet("software RAID")
121 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=100, primary=1, format=1)
122 request.uniqueID = uniqueID
123 raid1.append(uniqueID)
124 partitions.autoPartitionRequests.append(request)
125
126 filesystem = fileSystemTypeGet("software RAID")
127 request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500,
128 grow=1, format=1);
129 request.uniqueID = uniqueID + 10
130 raid2.append(uniqueID + 10)
131 partitions.autoPartitionRequests.append(request)
132
133 uniqueID = uniqueID + 1
134
135 filesystem = fileSystemTypeGet("ext3")
136 request = partRequests.RaidRequestSpec(filesystem, mountpoint="/boot", raidminor=1,
137 raidmembers=raid1, raidlevel="RAID1", format=1, raidspares=0)
138 partitions.autoPartitionRequests.append(request)
139
140 if len(drives) > 5:
141 raidLevel = "RAID6"
142 elif len(drives) > 2:
143 raidLevel = "RAID5"
144 else:
145 raidLevel = "RAID1"
146
147 filesystem = fileSystemTypeGet("physical volume (LVM)")
148 request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2,
149 raidlevel=raidLevel, format=1, raidspares=0)
150 request.uniqueID = 200
151 partitions.autoPartitionRequests.append(request)
152
153 request = partRequests.VolumeGroupRequestSpec(vgname="vg_primary", physvols=[200],
154 pesize=32768, format=1)
155 request.uniqueID = 201
156 partitions.autoPartitionRequests.append(request)
157
158 filesystem = fileSystemTypeGet("swap")
159 request = partRequests.LogicalVolumeRequestSpec(filesystem, format=1, grow=1,
160 size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="lv_swap")
161 partitions.autoPartitionRequests.append(request)
162
163 filesystem = fileSystemTypeGet("ext3")
164 (size, maxSizeMB) = iutil.swapSuggestion()
165 request = partRequests.LogicalVolumeRequestSpec(filesystem, format=1, grow=1,
166 mountpoint="/", size=1300, volgroup=201, lvname="lv_root")
167 partitions.autoPartitionRequests.append(request)
168 else:
169 BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear)
170
171 def setGroupSelection(self, grpset, intf):
172 grpset.unselectAll()
173 grpset.selectGroup("Base")
174
175 def postAction(self, rootPath, serial):
176 script = ( "/sbin/syslogd &\n"
177 "sleep 2\n"
178 "/sbin/e-smith/signal-event post-install\n" )
179 s = Script(script, interp="/bin/sh", inChroot=1)
180 log("%s", s)
181 s.run(rootPath, serial)
182
183 def setInstallData(self, id, intf = None):
184 BaseInstallClass.setInstallData(self, id)
185 self.setSELinux(id, sel=0)
186 self.setAuthentication(id, useShadow=1, useMd5=1)
187 self.setRootPassword(id, pw="ThisIsGoingToBeDisabledAnyway", isCrypted=0)
188 self.setZeroMbr(id, zeroMbr=1)
189 self.setClearParts(id, clear=CLEARPART_TYPE_ALL, initAll=1)
190 self.setDefaultPartitioning(id.partitions, doClear=0)
191 self.setBootloader(id, useLilo=0, location="mbr", linear=1)
192
193 def __init__(self, expert):
194 BaseInstallClass.__init__(self, expert)

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