Skip to content

Instantly share code, notes, and snippets.

@jmpolom
Last active October 4, 2021 03:34
Show Gist options
  • Save jmpolom/d822665f7042bd9ef70e18c58e158c39 to your computer and use it in GitHub Desktop.
Save jmpolom/d822665f7042bd9ef70e18c58e158c39 to your computer and use it in GitHub Desktop.
Capture kernel IP address boot argument

search generally for an ip= kernel argument. if one does not exist, add it.

r = re.compile(r'(?P<grub_cmdline>^GRUB_CMDLINE_LINUX=(?!.*?ip=)\"[^\"]*?\"$)')

search for an exact match; if none found isolate an existing ip= kernel argument for removal.

r = re.compile(r'^(?P<grub_cmdline_1>GRUB_CMDLINE_LINUX=(?!.*?ip=192.168.1.21::192.168.1.254:255.255.255.0:::)\"[^\"]*?)\s?(?:ip=\S+)\s?(?P<grub_cmdline_2>[^\"]+\")$')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment