-
Notifications
You must be signed in to change notification settings - Fork 16
/
live-image-post-update-version.py
executable file
·39 lines (33 loc) · 1.21 KB
/
live-image-post-update-version.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python3
import os
import sys
INSTALLER_VERSION = "6000"
def append_installer_rootwait(path):
"""Add a delay to the installer kernel commandline"""
entry_path = path + "/boot/loader/entries/"
entry_file = os.listdir(entry_path)
if len(entry_file) != 1:
raise Exception("Unable to find specific entry file in {0}, "
"found {1} instead".format(entry_path, entry_file))
file_full_path = entry_path + entry_file[0]
with open(file_full_path, "r") as entry:
entry_content = entry.readlines()
options_line = entry_content[-1]
if not options_line.startswith("options "):
raise Exception("Last line of entry file is not the kernel "
"commandline options")
# Account for newline at the end of the line
options_line = options_line[:-1] + " rootwait\n"
entry_content[-1] = options_line
os.unlink(file_full_path)
with open(file_full_path, "w") as entry:
entry.writelines(entry_content)
if __name__ == '__main__':
if len(sys.argv) != 2:
sys.exit(-1)
try:
append_installer_rootwait(sys.argv[1])
except Exception as exep:
print(exep)
sys.exit(-1)
sys.exit(0)