Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:glaubitz:branches:devel:languages:python:aws
ec2-hibernate-linux-agent
ehla_handle-missing-grub-legacy.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ehla_handle-missing-grub-legacy.patch of Package ec2-hibernate-linux-agent
From 0f995e803483acbf87ddb04c62960c30e837afce Mon Sep 17 00:00:00 2001 From: Robert Schweikert <rjschwei@suse.com> Date: Mon, 22 Oct 2018 09:14:08 -0400 Subject: [PATCH] - Do not attempt to modify non existent GRUB config file + Distributions either use GRUB or GRUB2, we need to guard against attempts to modify menu.lst on GRUB2 distributions --- agent/hibagent | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/agent/hibagent b/agent/hibagent index 02e2b03..f076220 100755 --- a/agent/hibagent +++ b/agent/hibagent @@ -100,30 +100,32 @@ def get_swap_space(): def patch_grub_config(swap_device, offset, grub_file, grub2_dir): - log("Updating GRUB to use the device %s with offset %d for resume" % (swap_device, offset)) - lines = [] - with open(grub_file) as fl: - for ln in fl.readlines(): - params = ln.split() - if not params or params[0] != 'kernel': - lines.append(ln) - continue - - new_params = [] - for param in params: - if "resume_offset=" in param or "resume=" in param: + log("Updating GRUB to use the device %s with offset %d for resume" + % (swap_device, offset)) + if grub_file and os.path.exists(grub_file): + lines = [] + with open(grub_file) as fl: + for ln in fl.readlines(): + params = ln.split() + if not params or params[0] != 'kernel': + lines.append(ln) continue - new_params.append(param) - - if "no_console_suspend=" not in ln: - new_params.append("no_console_suspend=1") - new_params.append("resume_offset=%d" % offset) - new_params.append("resume=%s" % swap_device) - - lines.append(" ".join(new_params)+"\n") - - with open(grub_file, "w") as fl: - fl.write("".join(lines)) + + new_params = [] + for param in params: + if "resume_offset=" in param or "resume=" in param: + continue + new_params.append(param) + + if "no_console_suspend=" not in ln: + new_params.append("no_console_suspend=1") + new_params.append("resume_offset=%d" % offset) + new_params.append("resume=%s" % swap_device) + + lines.append(" ".join(new_params)+"\n") + + with open(grub_file, "w") as fl: + fl.write("".join(lines)) # Do GRUB2 update as well if grub2_dir and os.path.exists(grub2_dir): -- 2.13.7
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor