+ event_exp = re.compile('event=(.+)', re.I)
+ action_exp = re.compile('action=(.+)', re.I)
+ for f in self.g.readdir(events_dir):
+ if f['ftyp'] != 'r':
+ continue
+
+ fullpath = "%s/%s" % (events_dir, f['name'])
+ event = ""
+ action = ""
+ for line in self.g.cat(fullpath).splitlines():
+ m = event_exp.match(line)
+ if m:
+ event = m.group(1)
+ continue
+ m = action_exp.match(line)
+ if m:
+ action = m.group(1)
+ continue
+
+ if event.strip() in ("button[ /]power", "button/power.*"):
+ if action:
+ if not self.g.is_file(action):
+ self.out.warn("Acpid action file: %s does not exist" %
+ action)
+ return
+ self.g.copy_file_to_file(action,
+ "%s.orig.snf-image-creator-%d" %
+ (action, time.time()))
+ self.g.write(action, powerbtn_action)
+ return
+ else:
+ self.out.warn("Acpid event file %s does not contain and "
+ "action")
+ return
+ elif event.strip() == ".*":
+ self.out.warn("Found action `.*'. Don't know how to handle "
+ "this. Please edit `%s' image file manually to "
+ "make the system immediatelly shutdown when an "
+ "power button acpi event occures." %
+ action.strip().split()[0])
+ return
+
+ self.out.warn("No acpi power button event found!")
+
+ @sysprep()
+ def remove_persistent_net_rules(self, print_header=True):