/[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.6 - (hide annotations) (download) (as text)
Fri Aug 19 04:34:56 2005 UTC (19 years, 2 months ago) by slords
Branch: MAIN
Changes since 1.5: +5 -1 lines
Content type: text/x-python
remove selinux stuff and set default language

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

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