/[gli]/trunk/src/fe/dialog/dialogfe.py
Gentoo

Contents of /trunk/src/fe/dialog/dialogfe.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 268 - (show annotations) (download) (as text)
Wed Jan 19 06:17:03 2005 UTC (15 years, 10 months ago) by codeman
File MIME type: text/x-python
File size: 27196 byte(s)
Various fixes related to the add_users function.  Still not yet finished.

1 #!/usr/bin/python
2
3 import dialog
4 import GLIInstallProfile
5 import GLIClientConfiguration
6 import GLIClientController
7 import GLIUtility
8 import sys
9 import crypt
10 import random
11 import commands
12 import string
13 import copy
14 import signal
15 #import pprint
16 import time
17
18 d = dialog.Dialog()
19 client_profile = GLIClientConfiguration.ClientConfiguration()
20 install_profile = GLIInstallProfile.InstallProfile()
21 cc = GLIClientController.GLIClientController(pretend=True)
22 exception_waiting = None
23 next_step_waiting = False
24 install_done = False
25
26 DLG_OK = 0
27 DLG_YES = 0
28 DLG_CANCEL = 1
29 DLG_NO = 1
30 DLG_ESC = 2
31 DLG_ERROR = 3
32 DLG_EXTRA = 4
33 DLG_HELP = 5
34
35 def dmenu_list_to_choices(list):
36 choices = []
37 for i in range(0, len(list)):
38 choices.append((str(i + 1), list[i]))
39
40 return choices
41
42 def run(cmd):
43 output_string = commands.getoutput(cmd)
44 output_list = []
45 while output_string.find("\n") != -1:
46 index = output_string.find("\n") + 1
47 output_list.append(output_string[:index])
48 output_string = output_string[index:]
49
50 return output_list
51
52 def get_random_salt():
53 chars = "./abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
54 chars = list(chars)
55 c1 = chars[random.randint(0,len(chars)-1)]
56 c2 = chars[random.randint(0,len(chars)-1)]
57 return c1 + c2
58
59 def set_partitions():
60 import string, re
61 try:
62 import GLIStorageDevice
63 except:
64 d.msgbox("Sorry, you don't have agaffney's kickass GLIStorageDevice module")
65 return
66
67 if d.yesno("If you continue, your previous changes (if any) will be reset. Continue?") != DLG_YES: return
68 use_existing = (d.yesno("Do you want to use the existing disk partitions?") == DLG_YES)
69
70 devices = {}
71 drives = GLIStorageDevice.detect_devices()
72 drives.sort()
73 for drive in drives:
74 devices[drive] = GLIStorageDevice.Device(drive)
75 if use_existing: devices[drive].set_partitions_from_disk()
76 while 1:
77 code, drive_to_partition = d.menu("Which drive would you like to partition?", choices=dmenu_list_to_choices(drives), cancel="Done")
78 if code != DLG_OK: break
79 drive_to_partition = drives[int(drive_to_partition)-1]
80 while 1:
81 partitions = devices[drive_to_partition].get_partitions()
82 partsmenu = devices[drive_to_partition].get_ordered_partition_list()
83 code, part_to_edit = d.menu("Which partition would you like to edit?", choices=dmenu_list_to_choices(partsmenu), cancel="Back")
84 if code != DLG_OK: break
85 part_to_edit = partsmenu[int(part_to_edit)-1]
86 if re.compile("^Free Space").match(part_to_edit) != None:
87 new_start, new_end = re.compile("^Free Space \((\d+)\s*-\s*(\d+)\)").match(part_to_edit).groups()
88 code, new_start2 = d.inputbox("New partition start (minimum " + new_start + ")?", init=new_start)
89 code, new_end2 = d.inputbox("New partition end (maximum " + new_end + ")?", init=new_end)
90 minor = devices[drive_to_partition].get_partition_at(int(new_start) - 1) + 1
91 code, id = d.inputbox("New partition's type?", init="ext3")
92 if (int(new_start2) < int(new_start)) or (int(new_end2) > int(new_end)):
93 d.msgbox("Cannot create new partition because it is not within the bounds of the selected free space.")
94 continue
95 devices[drive_to_partition].add_partition(devices[drive_to_partition].get_free_minor_at(int(new_start2), int(new_end2)), int(new_start2), int(new_end2), id)
96 else:
97 while 1:
98 tmpdevice, tmpminor = re.compile("^(/dev/[a-zA-Z]+)(\d+):").search(part_to_edit).groups()
99 tmppart = partitions[int(tmpminor)]
100 tmptitle = tmpdevice + tmpminor + ": " + str(tmppart.get_start()) + "-" + str(tmppart.get_end())
101 menulist = ["Delete", "Resize", "Change type (linux, swap, etc.)"]
102 code, part_action = d.menu(tmptitle, choices=dmenu_list_to_choices(menulist), cancel="Back")
103 if code != DLG_OK: break
104 part_action = menulist[int(part_action)-1]
105 if part_action == "Delete":
106 answer = (d.yesno("Are you sure you want to delete the partition " + tmpdevice + tmpminor + "?") == DLG_YES)
107 if answer == True:
108 tmpdev = tmppart.get_device()
109 tmpdev.remove_partition(int(tmpminor))
110 break
111 elif part_action == "Resize":
112 min_end = tmppart.get_min_cylinders_for_resize()
113 max_end = tmppart.get_max_cylinders_for_resize()
114 tmptitle = "Resize " + part_to_edit + " (minimum end: " + str(min_end) + ", maximum end: " + str(max_end) + ")"
115 tmpinit = str(tmppart.get_start()) + "-" + str(tmppart.get_end())
116 code, answer = d.inputbox(tmptitle, init=tmpinit)
117 if answer == None: continue
118 new_start, new_end = re.compile("^(\d+)\s*-\s*(\d+)$").match(answer).groups()
119 if int(new_end) < min_end:
120 d.msgbox("New end specified is too small")
121 continue
122 if int(new_end) > max_end:
123 d.msgbox("New end specified is too large")
124 continue
125 if not tmppart.resize(int(new_start), int(new_end)):
126 d.msgbox("Cannot resize partition because the new size conflicts with an existing partition.")
127 continue
128 elif part_action == "Change type (linux, swap, etc.)":
129 code, answer = d.inputbox("Enter a type for partition" + str(tmpminor), init=tmppart.get_type())
130 if code == DLG_OK: tmppart.set_type(answer)
131 if d.yesno("Would you like to save changes?") == DLG_YES:
132 parts_tmp = install_profile.get_partition_tables()
133 for part in devices.keys():
134 if GLIUtility.is_file(part) and parts_tmp.has_key(part): del parts_tmp[part]
135 parts_tmp[part] = devices[part].get_install_profile_structure()
136 install_profile.set_partition_tables(parts_tmp)
137
138 def set_nfs_mounts():
139 # This is where any NFS mounts will be specified
140 nfs_mounts = copy.deepcopy(install_profile.get_partition_tables())
141 for i in nfs_mounts.keys():
142 if GLIUtility.is_file(i): del nfs_mounts[i]
143 while 1:
144 menulist = []
145 for host in nfs_mounts.keys():
146 for export in nfs_mounts[host].keys():
147 menulist.append(host + ":" + export)
148 menulist.append("Add new NFS mount")
149 choices = dmenu_list_to_choices(menulist)
150 code, menuitem = d.menu("Select a NFS mount", choices=choices, cancel="Done")
151 if code:
152 if d.yesno("Do you want to save changes?") == DLG_YES:
153 parts_tmp = install_profile.get_partition_tables()
154 for part in parts_tmp.keys():
155 if not GLIUtility.is_file(part): del parts_tmp[part]
156 for host in nfs_mounts.keys():
157 parts_tmp[host] = nfs_mounts[host]
158 install_profile.set_partition_tables(parts_tmp)
159 break
160 menuitem = menulist[int(menuitem)-1]
161 if menuitem == "Add new NFS mount":
162 code, nfsmount = d.inputbox("Enter NFS mount or just enter the IP/hostname to search for available mounts")
163 if code != DLG_OK: continue
164 if not GLIUtility.is_nfs(nfsmount):
165 if GLIUtility.is_ip(nfsmount) or GLIUtility.is_hostname(nfsmount):
166 remotemounts = run("/usr/sbin/showmount -e " + nfsmount + " 2>&1 | egrep '^/' | cut -d ' ' -f 1 && echo")
167 if not len(remotemounts):
168 d.msgbox("No NFS exports detected on " + nfsmount)
169 continue
170 for i in range(0, len(remotemounts)):
171 remotemounts[i] = string.strip(remotemounts[i])
172 code, nfsmount2 = d.menu("Select a NFS export", choices=dmenu_list_to_choices(remotemounts), cancel="Back")
173 if code != DLG_OK: continue
174 nfsmount2 = remotemounts[int(nfsmount2)-1]
175 if not nfs_mounts.has_key(nfsmount):
176 nfs_mounts[nfsmount] = {}
177 if nfs_mounts[nfsmount].has_key(nfsmount2):
178 if not d.yesno("There is already an entry for " + nfsmount + ":" + nfsmount2 + ". Do you want to overwrite it?") == DLG_YES:
179 continue
180 nfs_mounts[nfsmount][nfsmount2] = { 'mountpoint': '', 'mountopts': '', 'type': 'nfs', 'mb': 0, 'start': 0, 'end': 0, 'format': False, 'minor': 0 }
181 menuitem = nfsmount + ":" + nfsmount2
182 else:
183 d.msgbox("Enter '" + nfsmount + "' is not a valid IP or hostname")
184 if menuitem.find(':') != -1:
185 colon_location = menuitem.find(':')
186 host = menuitem[:colon_location]
187 export = menuitem[colon_location+1:]
188 tmppart = nfs_mounts[host][export]
189 code, mountpoint = d.inputbox("Enter a mountpoint", init=tmppart['mountpoint'])
190 if code == DLG_OK: tmppart['mountpoint'] = mountpoint
191 code, mountopts = d.inputbox("Enter mount options", init=tmppart['mountopts'])
192 if code == DLG_OK: tmppart['mountopts'] = mountopts
193 nfs_mounts[host][export] = tmppart
194
195
196 def set_install_stage():
197 # The install stage and stage tarball will be selected here
198 install_stages = ("1","2","3","3 + GRP (use binary packages)")
199 code, install_stage = d.menu("Which stage do you want to start at?", choices=dmenu_list_to_choices(install_stages))
200 if code == DLG_OK:
201 install_stage = install_stages[int(install_stage)-1]
202 if install_stage == "3 + GRP (use binary packages)":
203 install_stage = "3"
204 install_profile.set_grp_install(None, True, None)
205 install_profile.set_install_stage(None, install_stage, None)
206 code, stage_tarball = d.inputbox("Where is the stage tarball located (URL or local file)?", init=install_profile.get_stage_tarball_uri())
207 try:
208 if code == DLG_OK: install_profile.set_stage_tarball_uri(None, stage_tarball, None)
209 except:
210 d.msgbox("The specified URI is invalid")
211
212 def set_portage_tree():
213 # This section will ask whether to sync the tree, whether to use a snapshot, etc.
214 menulist = ["Normal 'emerge sync'", "Webrsync (rsync is firewalled)", "None (snapshot or NFS mount)"]
215 code, portage_tree_sync = d.menu("How do you want to sync the portage tree?", choices=dmenu_list_to_choices(menulist))
216 if code != DLG_OK: return
217 portage_tree_sync = menulist[int(portage_tree_sync)-1]
218 if portage_tree_sync == "Normal 'emerge sync'": install_profile.set_portage_tree_sync_type(None, "sync", None)
219 if portage_tree_sync == "Webrsync (rsync is firewalled)": install_profile.set_portage_tree_sync_type(None, "webrsync", None)
220 if portage_tree_sync == "None (snapshot or NFS mount)": install_profile.set_portage_tree_sync_type(None, "custom", None)
221 if portage_tree_sync == "None (snapshot or NFS mount)":
222 if d.yesno("Do you want to use a portage tree snapshot?") == DLG_YES:
223 code, snapshot = d.inputbox("Enter portage tree snapshot URI", init=install_profile.get_portage_tree_snapshot_uri())
224 try:
225 if code == DLG_OK: install_profile.set_portage_tree_snapshot_uri(None, snapshot, None)
226 except:
227 d.msgbox("The specified URI is invalid")
228
229 def set_make_conf():
230 # This section will be for setting things like CFLAGS, ACCEPT_KEYWORDS, and USE
231 make_conf = install_profile.get_make_conf()
232 while 1:
233 menulist = ["ACCEPT_KEYWORDS", "CFLAGS", "CHOST", "MAKEOPTS", "FEATURES", "USE"]
234 code, menuitem = d.menu("Choose a variable to edit", choices=dmenu_list_to_choices(menulist), cancel="Done")
235 if code != DLG_OK: break
236 menuitem = menulist[int(menuitem)-1]
237 oldval = ""
238 if make_conf.has_key(menuitem): oldval = make_conf[menuitem]
239 code, newval = d.inputbox("Enter new value for " + menuitem, init=oldval)
240 if code == DLG_OK:
241 make_conf[menuitem] = newval
242 install_profile.set_make_conf(make_conf)
243
244 def set_kernel():
245 # This section will be for choosing kernel sources, choosing (and specifying) a custom config or genkernel, modules to load at startup, etc.
246 kernel_sources = ("vanilla-sources", "gentoo-sources", "development-sources", "gentoo-dev-sources", "hardened-sources")
247 code, menuitem = d.menu("Choose a kernel sources package", choices=dmenu_list_to_choices(kernel_sources))
248 if code != DLG_OK: return
249 menuitem = kernel_sources[int(menuitem)-1]
250 install_profile.set_kernel_source_pkg(None, menuitem, None)
251
252 def set_boot_loader():
253 boot_loaders = ("grub", "lilo")
254 code, menuitem = d.menu("Choose a boot loader", choices=dmenu_list_to_choices(boot_loaders))
255 if code != DLG_OK: return
256 menuitem = boot_loaders[int(menuitem)-1]
257 install_profile.set_boot_loader_pkg(None, menuitem, None)
258 if d.yesno("Do you want the boot loader installed in the MBR?") == DLG_YES:
259 install_profile.set_boot_loader_mbr(None, True, None)
260 else:
261 install_profile.set_boot_loader_mbr(None, False, None)
262
263 def set_timezone():
264 # This section will be for setting the timezone. It will eventually pull from /usr/share/zoneinfo or something
265 code, timezone = d.inputbox("Enter a timezone", init=install_profile.get_time_zone())
266 if code == DLG_OK: install_profile.set_time_zone(None, timezone, None)
267
268 def set_networking():
269 # This section will be for setting up network interfaces, defining DNS servers, default routes/gateways, etc.
270 while 1:
271 menulist = ["Edit Interfaces", "DNS Servers", "Default Gateway"]
272 code, menuitem = d.menu("Choose an option", choices=dmenu_list_to_choices(menulist), cancel="Done")
273 if code != DLG_OK: break
274 menuitem = menulist[int(menuitem)-1]
275 if menuitem == "Edit Interfaces":
276 while 1:
277 interfaces = install_profile.get_network_interfaces()
278 menu_list = interfaces.keys()
279 menu_list.sort()
280 menu_list.append("Add new interface")
281 code, menuitem = d.menu("Select an interface", choices=dmenu_list_to_choices(menu_list), cancel="Back")
282 if code != DLG_OK: break
283 menuitem = menu_list[int(menuitem)-1]
284 newnic = None
285 if menuitem == "Add new interface":
286 code, newnic = d.inputbox("Enter name for new interface (eth0, ppp0, etc.)")
287 if code != DLG_OK: continue
288 if newnic in interfaces:
289 d.msgbox("An interface with the name is already defined.")
290 continue
291 interfaces[newnic] = ("", "", "")
292 menuitem = newnic
293 menuitem2 = ""
294 menulist = ["Edit", "Rename", "Delete"]
295 if newnic == None:
296 menuitem2 = d.menu("What do you want to do with interface " + menuitem + "?", choices=dmenu_list_to_choices(menulist), cancel="Back")
297 if code != DLG_OK: continue
298 else:
299 menuitem2 = "1"
300 menuitem2 = menulist[int(menuitem2)-1]
301 if menuitem2 == "Edit":
302 tmpnic = [interfaces[menuitem][0], interfaces[menuitem][1], interfaces[menuitem][2]]
303 code, ip = d.inputbox("Enter an IP address for " + menuitem + " or 'dhcp' for DHCP", init=tmpnic[0])
304 if code != DLG_OK: continue
305 tmpnic[0] = ip
306 if ip == "dhcp" or ip == "DHCP":
307 tmpnic[1] = ""
308 tmpnic[2] = ""
309 else:
310 code, netmask = d.inputbox("Enter the netmask", init=tmpnic[2])
311 if code == DLG_OK: tmpnic[2] = netmask
312 code, broadcast = d.inputbox("Enter a broadcast", init=tmpnic[1])
313 if code == DLG_OK: tmpnic[1] = broadcast
314 interfaces[menuitem] = (tmpnic[0], tmpnic[1], tmpnic[2])
315 elif menuitem2 == "Rename":
316 d.msgbox("Not implimented yet")
317 elif menuitem2 == "Delete":
318 if d.yesno("Are you sure you want to remove the interface " + menuitem + "?") == DLG_YES:
319 del interfaces[menuitem]
320 install_profile.set_network_interfaces(interfaces)
321 elif menuitem == "DNS Servers":
322 d.msgbox("DNS Servers")
323 elif menuitem == "Default Gateway":
324 d.msgbox("Default Gateway")
325
326 def set_cron_daemon():
327 cron_daemons = ("vixie-cron", "fcron", "dcron", "None")
328 code, menuitem = d.menu("Choose a cron daemon", choices=dmenu_list_to_choices(cron_daemons))
329 if code == DLG_OK:
330 menuitem = cron_daemons[int(menuitem)-1]
331 if menuitem == "None": menuitem == ""
332 install_profile.set_cron_daemon_pkg(None, menuitem, None)
333
334 def set_logger():
335 loggers = ("syslog-ng", "metalog", "syslogkd")
336 code, menuitem = d.menu("Choose a system logger", choices=dmenu_list_to_choices(loggers))
337 if code == DLG_OK:
338 menuitem = loggers[int(menuitem)-1]
339 install_profile.set_logging_daemon_pkg(None, menuitem, None)
340
341 def set_extra_packages():
342 #d.msgbox("This section is for selecting extra packages (pcmcia-cs, rp-pppoe, xorg-x11, etc.) and setting them up")
343 code, install_packages = d.inputbox("Enter a space-separated list of extra packages to install on the system")
344 if code == DLG_OK: install_profile.set_install_packages(None, install_packages, None)
345
346 def set_rc_conf():
347 # This section is for editing /etc/rc.conf
348 rc_conf = install_profile.get_rc_conf()
349 menulist = ["KEYMAP", "SET_WINDOWSKEYS", "EXTENDED_KEYMAPS", "CONSOLEFONT", "CONSOLETRANSLATION", "CLOCK", "EDITOR", "PROTOCOLS", "DISPLAYMANAGER", "XSESSION"]
350 while 1:
351 code, menuitem = d.menu("Choose a variable to edit", choices=dmenu_list_to_choices(menulist), cancel="Done")
352 if code != DLG_OK: break
353 menuitem = menulist[int(menuitem)-1]
354 oldval = ""
355 if rc_conf.has_key(menuitem): oldval = rc_conf[menuitem]
356 code, newval = d.inputbox("Enter new value for " + menuitem, init=oldval)
357 if code == DLG_OK:
358 rc_conf[menuitem] = newval
359 install_profile.set_rc_conf(rc_conf)
360
361 def set_root_password():
362 # The root password will be set here
363 code, passwd1 = d.passwordbox("Enter the new root password")
364 if code != DLG_OK: return
365 code, passwd2 = d.passwordbox("Enter the new root password again")
366 if code != DLG_OK: return
367 if passwd1 != passwd2:
368 d.msgbox("The passwords do not match")
369 return
370 install_profile.set_root_pass_hash(None, crypt.crypt(passwd1, get_random_salt()), None)
371
372 def set_additional_users():
373 # This section will be for adding non-root users
374 users = copy.deepcopy(install_profile.get_users())
375 if type(users) == "list":
376 tmpusers = {}
377 # for user in users:
378 # tmpusers[user[0]] = [user[0], user[1], user[2], user[3]
379 while 1:
380 menu_list = []
381 for user in users:
382 menu_list.append(user[0])
383 menu_list.sort()
384 menu_list.append("Add user")
385 code, menuitem = d.menu("Choose a user to edit", choices=dmenu_list_to_choices(menu_list), cancel="Done")
386 if code != DLG_OK:
387 if d.yesno("Do you want to save changes?") == DLG_YES:
388 install_profile.set_users(users)
389 break
390 menuitem = menu_list[int(menuitem)-1]
391 if menuitem == "Add user":
392 code, newuser = d.inputbox("Enter the username for the new user")
393 if code != DLG_OK: continue
394 for user in users:
395 if newuser == user[0]:
396 d.msgbox("A user with that name already exists")
397 continue
398 new_user = [newuser, '', ('users'), '/bin/bash', '/home' + newuser, '', '']
399 users.append(new_user)
400 menuitem = newuser
401 while 1:
402 menulist = ["Password", "Group Membership", "Shell", "Home Directory", "UID", "Comment", "Delete"]
403 code, menuitem2 = d.menu("Choose an option for user " + menuitem, choices=dmenu_list_to_choices(menulist), cancel="Back")
404 if code != DLG_OK: break
405 menuitem2 = menulist[int(menuitem2)-1]
406 if menuitem2 == "Password":
407 code, passwd1 = d.passwordbox("Enter the new password")
408 if code != DLG_OK: continue
409 code, passwd2 = d.passwordbox("Enter the new password again")
410 if code != DLG_OK: continue
411 if passwd1 != passwd2:
412 d.msgbox("The passwords do not match")
413 continue
414 for user in users:
415 if user[0] == menuitem: user[1] = crypt.crypt(passwd1, get_random_salt())
416 continue
417 elif menuitem2 == "Group Membership":
418 code, groups = d.inputbox("Enter a space-separated list of groups the user is to be in")
419 if code != DLG_OK: continue
420 newgroups = []
421 groups = string.split(groups)
422 for group in groups:
423 new_groups.append(group)
424 for user in users:
425 if user[0] == menuitem:
426 user[2] = new_groups
427 continue
428
429 elif menuitem2 == "Shell":
430 d.msgbox("Shell")
431 elif menuitem2 == "Home Directory":
432 d.msgbox("homedir")
433 elif menuitem2 == "UID":
434 d.msgbox("UID")
435 elif menuitem2 == "Comment":
436 d.msgbox("Comment")
437 elif menuitem2 == "Delete":
438 if d.yesno("Are you sure you want to delete the user " + menuitem + "?") == DLG_YES:
439 for i in range(0, len(users)):
440 if users[i][0] == menuitem:
441 users.pop(i)
442 break
443 break
444
445 def set_services():
446 code, services = d.inputbox("Enter a space-separated list of services to start on boot")
447 if code == DLG_OK: install_profile.set_services(None, services, None)
448 def save_install_profile(xmlfilename="", askforfilename=True):
449 code = 0
450 filename = xmlfilename
451 if askforfilename:
452 code, filename = d.inputbox("Enter a filename for the XML file", init=xmlfilename)
453 if code != DLG_OK: return None
454 if GLIUtility.is_file(filename):
455 if not d.yesno("The file " + filename + " already exists. Do you want to overwrite it?") == DLG_YES:
456 return None
457 configuration = open(filename ,"w")
458 configuration.write(install_profile.serialize())
459 configuration.close()
460 return filename
461
462
463 #----------------------------Now for the client_config functions
464 def set_arch_template():
465 template_choices = ("x86", "amd64","sparc", "alpha", "hppa", "ppc")
466 code, menuitem = d.menu("Please Select Architecture Template:",choices=dmenu_list_to_choices(template_choices))
467 if code == DLG_OK:
468 menuitem = template_choices[int(menuitem)-1]
469 client_profile.set_architecture_template(None, menuitem, None)
470 def set_logfile():
471 code, logfile = d.inputbox("Enter the desired path for the install log:", init="/var/log/install.log")
472 if code == DLG_OK: client_profile.set_log_file(None, logfile, None)
473 def set_root_mount_point():
474 code, rootmountpoint = d.inputbox("Enter the mount point for the chroot enviornment:", init="/mnt/gentoo")
475 if code == DLG_OK: client_profile.set_root_mount_point(None, rootmountpoint, None)
476 def set_client_networking():
477 d.msgbox("You shall have no networking for the install until samyron writes this function (please bug him to!).")
478 def set_livecd_password():
479 # The root password will be set here
480 code, passwd1 = d.passwordbox("Enter the new LIVECD root password")
481 if code != DLG_OK: return
482 code, passwd2 = d.passwordbox("Enter the new LIVECD root password again")
483 if code != DLG_OK: return
484 if passwd1 != passwd2:
485 d.msgbox("The passwords do not match")
486 return
487 client_profile.set_root_passwd(None, crypt.crypt(passwd1, get_random_salt()), None)
488 def set_enable_ssh():
489 if d.yesno("Do you want SSH enabled during the install?") == DLG_YES:
490 client_profile.set_enable_ssh(None, True, None)
491 else:
492 client_profile.set_enable_ssh(None, False, None)
493 def set_client_kernel_modules():
494 code, kernel_modules_list = d.inputbox("Enter a list of kernel modules you want loaded before installation:", init="")
495 if code == DLG_OK: client_profile.set_kernel_modules(None, kernel_modules_list, None)
496 def save_client_profile(xmlfilename="", askforfilename=True):
497 code = 0
498 filename = xmlfilename
499 if askforfilename:
500 code, filename = d.inputbox("Enter a filename for the XML file", init=xmlfilename)
501 if code != DLG_OK: return None
502 if GLIUtility.is_file(filename):
503 if not d.yesno("The file " + filename + " already exists. Do you want to overwrite it?") == DLG_YES:
504 return None
505 configuration = open(filename ,"w")
506 configuration.write(client_profile.serialize())
507 configuration.close()
508 return filename
509 # ------------------------------------------------------------------
510 d.setBackgroundTitle("Gentoo Linux Installer")
511 d.msgbox("Welcome to The Gentoo Linux Installer. This is a TESTING release. If your system dies a horrible, horrible death, don't come crying to us (okay, you can cry to klieber).", height=10, width=50, title="Welcome")
512
513 if d.yesno("Do you want to use the ClientController?") == DLG_YES:
514 client_config_xml_file = None
515 while 1:
516 if d.yesno("Do you have a previously generated XML file for the ClientConfiguration?") == DLG_YES:
517 code, client_config_xml_file = d.inputbox("Enter the filename of the XML file")
518 if code != DLG_OK: break
519 if GLIUtility.is_file(client_config_xml_file): break
520 d.msgbox("Cannot open file " + client_config_xml_file, height=7, width=50)
521 client_config_xml_file = None
522 continue
523 break
524 if client_config_xml_file != None:
525 client_profile.parse(client_config_xml_file)
526 # code to actually run the client_controller functions
527 else:
528 set_arch_template()
529 set_logfile()
530 set_root_mount_point()
531 set_client_networking()
532 set_livecd_password()
533 set_enable_ssh()
534 set_client_kernel_modules()
535 if d.yesno("Do you want to save the ClientConfiguration XML file?") == DLG_YES:
536 if client_config_xml_file == None: client_config_xml_file = ""
537 client_config_xml_file = save_client_profile(xmlfilename=client_config_xml_file)
538
539 d.msgbox("ClientController done")
540
541 client_profile.set_interactive(None, True, None)
542 cc.set_configuration(client_profile)
543
544 cc.start_pre_install()
545
546 install_profile_xml_file = None
547 fn = (
548 { 'text': "Partitioning", 'fn': set_partitions },
549 { 'text': "NFS mounts", 'fn': set_nfs_mounts },
550 { 'text': "Install Stage", 'fn': set_install_stage },
551 { 'text': "Portage Tree", 'fn': set_portage_tree },
552 { 'text': "make.conf", 'fn': set_make_conf },
553 { 'text': "Kernel", 'fn': set_kernel },
554 { 'text': "Bootloader", 'fn': set_boot_loader },
555 { 'text': "Timezone", 'fn': set_timezone },
556 { 'text': "Networking", 'fn': set_networking },
557 { 'text': "Cron daemon", 'fn': set_cron_daemon },
558 { 'text': "Logging daemon", 'fn': set_logger },
559 { 'text': "Extra packages", 'fn': set_extra_packages },
560 { 'text': "Services", 'fn': set_services },
561 { 'text': "rc.conf", 'fn': set_rc_conf },
562 { 'text': "Root password", 'fn': set_root_password },
563 { 'text': "Additional Users", 'fn': set_additional_users },
564 )
565 while 1:
566 if d.yesno("Do you have a previously generated InstallProfile XML file?") == DLG_YES:
567 code, install_profile_xml_file = d.inputbox("Enter the filename of the XML file")
568 if code != DLG_OK: break
569 if GLIUtility.is_file(install_profile_xml_file): break
570 d.msgbox("Cannot open file " + install_profile_xml_file, height=7, width=50)
571 install_profile_xml_file = None
572 continue
573 break
574 if install_profile_xml_file != None:
575 install_profile.parse(install_profile_xml_file)
576 while 1:
577 menu_list = []
578 for item in fn:
579 menu_list.append(item['text'])
580 menu_list.append("Install!")
581 code, menuitem = d.menu("Choose an option", choices=dmenu_list_to_choices(menu_list), height=20, menu_height=13, cancel="Exit")
582 if code != DLG_OK:
583 if d.yesno("Do you really want to exit before the install is complete?") == DLG_YES:
584 if d.yesno("Do you want to save the InstallProfile XML file?") == DLG_YES:
585 if install_profile_xml_file == None: install_profile_xml_file = ""
586 install_profile_xml_file = save_install_profile(xmlfilename=install_profile_xml_file)
587 sys.exit()
588 continue
589 menuitem = menu_list[int(menuitem)-1]
590 for item in fn:
591 if menuitem == item['text']:
592 item['fn']()
593 continue
594 if menuitem == "Install!":
595 if install_profile_xml_file == None or install_profile_xml_file == "":
596 install_profile_xml_file = "tmp_install_profile.xml"
597 save_install_profile(xmlfilename=install_profile_xml_file, askforfilename=False)
598 cc.set_install_profile(install_profile)
599 cc.start_install()
600 # This next line gives the ClientController time to actually get to the install step loop
601 # while 1:
602 # notification = cc.getNotification()
603 # if notification == None:
604 # time.sleep(1)
605 # continue
606 # if notification.get_type() == "int" and notification.get_data() == GLIClientController.NEXT_STEP_READY:
607 # break
608 while 1:
609 notification = cc.getNotification()
610 if notification == None:
611 time.sleep(1)
612 continue
613 type = notification.get_type()
614 data = notification.get_data()
615 if type == "exception":
616 print "Exception received:"
617 print data
618 elif type == "int":
619 if data == GLIClientController.NEXT_STEP_READY:
620 next_step_waiting = False
621 next_step = cc.get_next_step_info()
622 print "Next step: " + next_step
623 if cc.has_more_steps():
624 cc.next_step()
625 continue
626 if data == GLIClientController.INSTALL_DONE:
627 print "Install done!"
628 sys.exit(0)

Properties

Name Value
svn:eol-style native
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20