/[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.2 - (hide annotations) (download) (as text)
Sun Jul 31 16:24:51 2005 UTC (19 years, 3 months ago) by slords
Branch: MAIN
Changes since 1.1: +61 -23 lines
Content type: text/x-python
Second major pass as anaconda installer
- Install/Upgrade both functional in text & gui
- Added upgrade warning for systems < 21:6.0-11
- TODO: raid migration for upgrades
- TODO: status message for post-{install,upgrade}

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

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