Forked from sjenning/extract-ignition-filesystem.py
Created
October 20, 2020 03:58
-
-
Save usrbinkat/e6740552de768ed9e87b03c8d0f92ce4 to your computer and use it in GitHub Desktop.
Extracts a filesystem from an ignition file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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