7 |
|
|
8 |
import os |
import os |
9 |
import iutil |
import iutil |
10 |
|
import string |
11 |
import partRequests |
import partRequests |
12 |
import partedUtils |
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): |
class InstallClass(BaseInstallClass): |
56 |
name = N_("Install SME Server") |
id = "smeserver" |
57 |
|
name = N_("New _SME Server Install") |
58 |
|
pixmap = "smeserver.png" |
59 |
sortPriority = 1 |
sortPriority = 1 |
60 |
|
|
61 |
parentClass = ( _("SMEServer"), "" ) |
parentClass = ( _("Install SME Server"), "smeserver.png" ) |
62 |
|
|
63 |
def requiredDisplayMode(self): |
def requiredDisplayMode(self): |
64 |
return 't' |
return 't' |
70 |
"findrootparts", |
"findrootparts", |
71 |
"partitionobjinit", |
"partitionobjinit", |
72 |
"autopartitionexecute", |
"autopartitionexecute", |
73 |
|
"partition", |
74 |
"partitiondone", |
"partitiondone", |
75 |
"bootloadersetup", |
"bootloadersetup", |
76 |
"languagesupport", |
"languagesupport", |
95 |
"complete" |
"complete" |
96 |
) |
) |
97 |
|
|
98 |
|
# '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 |
def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1): |
def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1): |
108 |
diskset = partedUtils.DiskSet() |
diskset = partedUtils.DiskSet() |
109 |
drives = diskset.driveList() |
drives = diskset.driveList() |
148 |
partitions.autoPartitionRequests.append(request) |
partitions.autoPartitionRequests.append(request) |
149 |
|
|
150 |
request = partRequests.VolumeGroupRequestSpec(vgname="vg_primary", physvols=[200], |
request = partRequests.VolumeGroupRequestSpec(vgname="vg_primary", physvols=[200], |
151 |
pesize=4096, format=1) |
pesize=32768, format=1) |
152 |
request.uniqueID = 201 |
request.uniqueID = 201 |
153 |
partitions.autoPartitionRequests.append(request) |
partitions.autoPartitionRequests.append(request) |
154 |
|
|
170 |
grpset.selectGroup("Base") |
grpset.selectGroup("Base") |
171 |
|
|
172 |
def postAction(self, rootPath, serial): |
def postAction(self, rootPath, serial): |
173 |
if serial: |
script = "/sbin/syslogd &\nsleep 2\n/sbin/e-smith/signal-event post-install\n" |
174 |
messages = "/tmp/postinstall.log" |
s = Script(script, interp="/bin/sh", inChroot=1) |
175 |
else: |
log("%s", s) |
176 |
messages = "/dev/tty3" |
s.run(rootPath, serial) |
|
|
|
|
path = rootPath + "/tmp/postinstall.sh" |
|
|
cmds = ["/sbin/syslogd &\n", |
|
|
"sleep 2\n", |
|
|
"/sbin/e-smith/signal-event post-install\n"] |
|
|
|
|
|
f = open(path, "w") |
|
|
f.writelines(cmds) |
|
|
f.close |
|
|
os.chmod(path, 0700) |
|
|
|
|
|
rc = iutil.execWithRedirect("/bin/sh", ["/bin/sh", "/tmp/postinstall.sh"], |
|
|
stdout=messages, stderr=messages, root=rootPath) |
|
|
if rc != 0: |
|
|
log("WARNING - Error code %s encountered running postinstall script", rc) |
|
|
# os.unlink(path) |
|
177 |
|
|
178 |
def setInstallData(self, id, intf = None): |
def setInstallData(self, id, intf = None): |
179 |
BaseInstallClass.setInstallData(self, id) |
BaseInstallClass.setInstallData(self, id) |