Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usrbinkat/e6740552de768ed9e87b03c8d0f92ce4 to your computer and use it in GitHub Desktop.
Save usrbinkat/e6740552de768ed9e87b03c8d0f92ce4 to your computer and use it in GitHub Desktop.
Extracts a filesystem from an ignition file
#!/usr/bin/env python3
import json
import os
import sys
import base64
ign_file = open(sys.argv[1])
ign_json = json.load(ign_file)
ign_file.close()
for file in ign_json['storage']['files']:
path = file['path']
contents = file['contents']['source'].split(',')[1]
os.makedirs('ign-root' + os.path.dirname(path), exist_ok=True)
out_file = open('ign-root' + path, "wb+")
out_file.write(base64.b64decode(contents))
out_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment