Revision 22a6d232 image_creator/os_type/linux.py
b/image_creator/os_type/linux.py | ||
---|---|---|
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 | 34 |
from image_creator.os_type.unix import Unix |
35 |
from image_creator.util import warn |
|
36 |
|
|
37 |
from clint.textui import puts, indent |
|
38 |
|
|
35 | 39 |
import re |
36 | 40 |
|
37 | 41 |
|
... | ... | |
53 | 57 |
self._uuid[dev] = attr[1] |
54 | 58 |
return attr[1] |
55 | 59 |
|
56 |
def sysprep(self): |
|
57 |
"""Prepere system for image creation.""" |
|
58 |
self.sysprep_acpid() |
|
59 |
self.sysprep_persistent_net_rules() |
|
60 |
self.sysprep_persistent_devs() |
|
61 |
|
|
62 | 60 |
def sysprep_acpid(self): |
63 | 61 |
"""Replace acpid powerdown action scripts to automatically shutdown |
64 | 62 |
the system without checking if a GUI is running. |
65 | 63 |
""" |
64 |
|
|
65 |
puts('* Fixing acpid powerdown action') |
|
66 |
|
|
66 | 67 |
action = '#!/bin/sh\n\nPATH=/sbin:/bin:/usr/bin\n shutdown -h now ' |
67 | 68 |
'\"Power button pressed\"' |
68 | 69 |
|
... | ... | |
71 | 72 |
elif self.g.is_file('/etc/acpi/actions/power.sh'): |
72 | 73 |
self.g.write('/etc/acpi/actions/power.sh', action) |
73 | 74 |
else: |
74 |
print "Warning: No acpid action file found" |
|
75 |
with indent(2): |
|
76 |
warn("No acpid action file found") |
|
75 | 77 |
|
76 | 78 |
def sysprep_persistent_net_rules(self): |
77 | 79 |
"""Remove udev rules that will keep network interface names persistent |
78 | 80 |
after hardware changes and reboots. Those rules will be created again |
79 | 81 |
the next time the image runs. |
80 | 82 |
""" |
83 |
|
|
84 |
puts('* Removing persistent network interface names') |
|
85 |
|
|
81 | 86 |
rule_file = '/etc/udev/rules.d/70-persistent-net.rules' |
82 | 87 |
if self.g.is_file(rule_file): |
83 | 88 |
self.g.rm(rule_file) |
... | ... | |
86 | 91 |
"""Scan fstab and grub configuration files and replace all |
87 | 92 |
non-persistent device appearences with UUIDs. |
88 | 93 |
""" |
94 |
|
|
95 |
puts('* Replacing fstab & grub non-persistent device appearences') |
|
96 |
|
|
89 | 97 |
# convert all devices in fstab to persistent |
90 | 98 |
persistent_root = self._persistent_fstab() |
91 | 99 |
|
... | ... | |
146 | 154 |
|
147 | 155 |
entry = line.split() |
148 | 156 |
if len(entry) != 6: |
149 |
print "Warning: detected abnorman entry in fstab"
|
|
157 |
warn("Detected abnormal entry in fstab")
|
|
150 | 158 |
return orig, "", "" |
151 | 159 |
|
152 | 160 |
dev = entry[0] |
Also available in: Unified diff