Revision 9cbb5794 image_creator/os_type/linux.py
b/image_creator/os_type/linux.py | ||
---|---|---|
20 | 20 |
self._uuid[dev] = attr[1] |
21 | 21 |
return attr[1] |
22 | 22 |
|
23 |
def remove_persistent_net(self): |
|
24 |
persistent_net_rule = '/etc/udev/rules.d/70-persistent-net.rules' |
|
25 |
if self.g.is_file(persistent_net_rule): |
|
26 |
self.g.rm(persistent_net_rule) |
|
27 |
|
|
28 |
def convert_to_persistent_dev(self): |
|
23 |
def sysprep(self): |
|
24 |
"""Prepere system for image creation.""" |
|
25 |
self.sysprep_acpid() |
|
26 |
self.sysprep_persistent_net_rules() |
|
27 |
self.sysprep_persistent_devs() |
|
28 |
|
|
29 |
def sysprep_acpid(self): |
|
30 |
"""Replace acpid powerdown action scripts to automatically shutdown |
|
31 |
the system without checking if a GUI is running. |
|
32 |
""" |
|
33 |
action = '#!/bin/sh\n\nPATH=/sbin:/bin:/usr/bin\n shutdown -h now ' |
|
34 |
'\"Power button pressed\"' |
|
35 |
|
|
36 |
if self.g.is_file('/etc/acpi/powerbtn.sh'): |
|
37 |
self.g.write(action, '/etc/acpi/powerbtn.sh') |
|
38 |
elif self.g.is_file('/etc/acpi/actions/power.sh'): |
|
39 |
self.g.write(actions, '/etc/acpi/actions/power.sh') |
|
40 |
else: |
|
41 |
print "Warning: No acpid action file found" |
|
42 |
|
|
43 |
def sysprep_persistent_net_rules(self): |
|
44 |
"""Remove udev rules that will keep network interface names persistent |
|
45 |
after hardware changes and reboots. Those rules will be created again |
|
46 |
the next time the image runs. |
|
47 |
""" |
|
48 |
rule_file = '/etc/udev/rules.d/70-persistent-net.rules' |
|
49 |
if self.g.is_file(rule_file): |
|
50 |
self.g.rm(rule_file) |
|
51 |
|
|
52 |
def sysprep_persistent_devs(self): |
|
53 |
"""Scan fstab and grub configuration files and replace all |
|
54 |
non-persistent device appearences with UUIDs. |
|
55 |
""" |
|
29 | 56 |
# convert all devices in fstab to persistent |
30 | 57 |
persistent_root = self._persistent_fstab() |
31 | 58 |
|
32 | 59 |
# convert all devices in grub1 to persistent |
33 | 60 |
self._persistent_grub1(persistent_root) |
34 | 61 |
|
35 |
def _persistent_grub1(self, conf, new_root):
|
|
62 |
def _persistent_grub1(self, new_root): |
|
36 | 63 |
if self.g.is_file('/boot/grub/menu.lst'): |
37 | 64 |
grub1 = '/boot/grub/menu.lst' |
38 | 65 |
elif self.g.is_file('/etc/grub.conf'): |
Also available in: Unified diff