Formatting and some completion to install script
This commit is contained in:
114
install.py
114
install.py
@@ -2,10 +2,12 @@
|
||||
Install script for the Python jailer.
|
||||
Version: 0.3.0-main1
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
with open("./kverinfo.txt", "r") as f:
|
||||
kver = f.read()
|
||||
kver = f.read()
|
||||
f.close()
|
||||
with open("./verinfo.txt", "r") as f:
|
||||
ver = f.read()
|
||||
@@ -28,77 +30,43 @@ print("Gathering info...")
|
||||
usrname = input("Please enter your username: [usr1] ")
|
||||
if usrname == "":
|
||||
usrname = "usr1"
|
||||
setup_posix = input("Do you wish to setup a mostly-POSIX compliant environment? [y/N] ")
|
||||
if setup_posix.lower() == "y":
|
||||
print("Creating directories...")
|
||||
with open("./bin", "a+") as f:
|
||||
f.write("symlnk /usr/bin/")
|
||||
f.close()
|
||||
with open("./sbin", "a+") as f:
|
||||
f.write("symlnk /usr/sbin/")
|
||||
f.close()
|
||||
with open("./lib", "a+") as f:
|
||||
f.write("symlnk /usr/lib/")
|
||||
f.close()
|
||||
with open("./lib64", "a+") as f:
|
||||
f.write("symlnk /usr/lib64/")
|
||||
f.close()
|
||||
with open("./usr/bin/sh", "a+") as f:
|
||||
f.write("symlnk /usr/bin/shell.py")
|
||||
f.close()
|
||||
os.mkdir("./sys")
|
||||
os.mkdir("./usr")
|
||||
os.mkdir("./proc")
|
||||
os.mkdir(f"./home/{usrname}")
|
||||
os.mkdir("./usr/bin/")
|
||||
os.mkdir("./usr/sbin/")
|
||||
os.mkdir("./usr/lib/")
|
||||
os.mkdir("./usr/lib64/")
|
||||
print("Copying files...")
|
||||
shutil.move("./main.py", "./sys/jail_mgr.py")
|
||||
shutil.move("./sh.py", "./bin/shell.py")
|
||||
shutil.move("./ledit.py", "./bin/ledit.py")
|
||||
print("Creating system configuration files...")
|
||||
with open("./sys/usr.conf", "a+") as f:
|
||||
f.write(usrname)
|
||||
f.close()
|
||||
with open("./sys/procinfo", "a+") as f:
|
||||
f.write("proc: vfs(/proc/)\nkernel: vfs(/proc/kcore)")
|
||||
f.close()
|
||||
with open("./proc/kcore", "a+") as f:
|
||||
f.write("/sys/jail_mgr.py")
|
||||
f.close()
|
||||
else: # POSIX and NO-POSIX have a firm split now.
|
||||
print("Creating directories...")
|
||||
os.mkdir("./bin")
|
||||
os.mkdir("./sys")
|
||||
os.mkdir("./usr")
|
||||
os.mkdir("./proc")
|
||||
os.mkdir(f"./home/{usrname}")
|
||||
os.mkdir("./sys/krnl/")
|
||||
print("Copying files...")
|
||||
try:
|
||||
shutil.move("./nps/main.py", "./sys/jail_mgr.py")
|
||||
shutil.move("./nps/sh.py", "./bin/shell.py")
|
||||
shutil.move("./nps/ledit.py", "./bin/ledit.py")
|
||||
except Exception as e:
|
||||
print("Failure to install! Non-POSIX files are most likely not present! Aborting install...")
|
||||
shutil.move("../main.py", "../runner.py")
|
||||
shutil.move("./main.py", "../main.py")
|
||||
shutil.move("./sh.py", "../sh.py")
|
||||
shutil.move("./ledit.py", "../ledit.py")
|
||||
os.rmdir("./bin")
|
||||
os.rmdir("./sys/krnl/")
|
||||
os.rmdir("./sys")
|
||||
os.rmdir("./usr")
|
||||
os.rmdir("./proc")
|
||||
os.rmdir(f"./home/{usrname}")
|
||||
os.chdir("../")
|
||||
shutil.rmtree("./vfs/")
|
||||
exit(-1)
|
||||
print("Creating system configuration files...")
|
||||
with open("./sys/usr.conf", "a+") as f:
|
||||
f.write(usrname)
|
||||
f.close()
|
||||
print("Creating directories...")
|
||||
with open("./bin", "a+") as f:
|
||||
f.write("symlnk /usr/bin/")
|
||||
f.close()
|
||||
with open("./sbin", "a+") as f:
|
||||
f.write("symlnk /usr/sbin/")
|
||||
f.close()
|
||||
with open("./lib", "a+") as f:
|
||||
f.write("symlnk /usr/lib/")
|
||||
f.close()
|
||||
with open("./lib64", "a+") as f:
|
||||
f.write("symlnk /usr/lib64/")
|
||||
f.close()
|
||||
with open("./usr/bin/sh", "a+") as f:
|
||||
f.write("symlnk /usr/bin/shell.py")
|
||||
f.close()
|
||||
os.mkdir("./sys")
|
||||
os.mkdir("./usr")
|
||||
os.mkdir("./proc")
|
||||
os.mkdir(f"./home/{usrname}")
|
||||
os.mkdir("./usr/bin/")
|
||||
os.mkdir("./usr/sbin/")
|
||||
os.mkdir("./usr/lib/")
|
||||
os.mkdir("./usr/lib64/")
|
||||
print("Copying files...")
|
||||
shutil.move("./main.py", "./sys/jail_mgr.py")
|
||||
shutil.move("./sh.py", "./bin/shell.py")
|
||||
shutil.move("./ledit.py", "./bin/ledit.py")
|
||||
print("Creating system configuration files...")
|
||||
with open("./sys/usr.conf", "a+") as f:
|
||||
f.write(usrname)
|
||||
f.close()
|
||||
with open("./sys/procinfo", "a+") as f:
|
||||
f.write("proc: vfs(/proc/)\nkernel: vfs(/proc/kcore)")
|
||||
f.close()
|
||||
with open("./proc/kcore", "a+") as f:
|
||||
f.write("/sys/jail_mgr.py")
|
||||
f.close()
|
||||
print("Install completed! Run ./main.py to start the kernel!")
|
||||
input("Press <Enter> to exit! ")
|
||||
|
Reference in New Issue
Block a user