opus-nt/scripts/main.py

93 lines
2.6 KiB
Python
Raw Normal View History

2019-12-21 04:37:38 +00:00
import sys
2019-12-26 06:20:41 +00:00
import os
import shutil
2019-12-27 04:38:59 +00:00
import time
2019-12-21 04:37:38 +00:00
pJoin = os.path.join
2019-12-27 04:38:59 +00:00
opus.time = int(time.time())
2019-12-21 04:37:38 +00:00
opus.version = Munch()
opus.version.distro = "opus-nt"
opus.version.major = 0
2019-12-27 04:39:12 +00:00
opus.version.median = 2
2019-12-21 04:37:38 +00:00
opus.version.minor = 0
opus.version.state = "dev"
opus.version.string = \
opus.version.distro + " " +\
str(opus.version.major) + "." +\
str(opus.version.median) + "." +\
str(opus.version.minor) + " " +\
opus.version.state
opus.path = Munch()
opus.path.main = os.path.dirname(os.path.realpath(__file__))
opus.path.api = pJoin(opus.path.main,"scripts","api")
2019-12-26 06:20:41 +00:00
opus.path.tweaks = pJoin(opus.path.main,"tweaks")
2019-12-27 04:38:59 +00:00
opus.path.temp = pJoin(opus.path.main,"tmp-" +str(opus.time))
2019-12-26 06:20:41 +00:00
opus.path.wim = pJoin(opus.path.temp,"wim")
2019-12-27 01:37:35 +00:00
opus.path.target = os.path.realpath(sys.argv[1])
2019-12-26 06:20:41 +00:00
opus.verbosity = 2
2019-12-21 04:37:38 +00:00
with open(pJoin(opus.path.main,"scripts","api","main.py")) as script:
exec(script.read())
2019-12-26 06:20:41 +00:00
opus.main.output("\nmain-api loaded!",1)
opus.script.execute(pJoin(opus.path.main,"scripts","hello.py"))
opus.main.output("",1)
2019-12-21 04:37:38 +00:00
if opus.verbosity > 0:
2019-12-26 06:20:41 +00:00
opus.main.output("-- paths --")
2019-12-21 04:37:38 +00:00
for path in opus.path:
2019-12-26 06:20:41 +00:00
opus.main.output(path + ": " +opus.path[path])
opus.main.output("")
opus.main.output("-- loading misc APIs --", 1)
opus.script.execute(pJoin(opus.path.api,"path.py"))
opus.script.execute(pJoin(opus.path.api,"wim.py"))
opus.script.execute(pJoin(opus.path.api,"registry.py"))
opus.script.execute(pJoin(opus.path.api,"detection.py"))
opus.script.execute(pJoin(opus.path.api,"tweak.py"))
opus.main.output("",1)
opus.script.execute(pJoin(opus.path.main,"scripts","path.py"))
opus.main.output("",1)
if os.path.isdir(opus.path.temp):
opus.main.output("clearing temp directory...",1)
try:
opus.reg.unmount()
except:
pass
shutil.rmtree(opus.path.temp)
2019-12-27 04:36:43 +00:00
os.makedirs(pJoin(opus.path.temp,"wim"))
2019-12-26 06:20:41 +00:00
opus.wim.location = pJoin(opus.path.target,"sources","install.wim")
opus.wim.index = int(input("\nwim index: "))
opus.main.output("",1)
opus.wim.extractFiles([
pJoin("Windows","System32","config","SOFTWARE"),
pJoin("Windows","System32","config","SYSTEM"),
pJoin("Users","Default","NTUSER.DAT")
])
opus.main.output("",1)
opus.os = opus.detect.os(opus.wim.path())
for tag in opus.os.tags:
if not os.path.isdir(pJoin(opus.path.tweaks,tag)): continue
2019-12-27 01:37:35 +00:00
opus.tweak.apply.reg(tag,"SOFTWARE",pJoin("Windows","System32","config","SOFTWARE"))
opus.tweak.apply.reg(tag,"SYSTEM",pJoin("Windows","System32","config","SYSTEM"))
opus.tweak.apply.reg(tag,"NTUSER",pJoin("Users","Default","NTUSER.DAT"))
opus.tweak.apply.wim(tag)
opus.tweak.apply.iso(tag)
2019-12-21 04:37:38 +00:00
2019-12-26 06:20:41 +00:00
opus.main.output("\nif you'd like to make manual changes, please do so now. press enter to finalize or ctrl+c to cancel.")
input()
opus.wim.update()