75 lines
2.2 KiB
Python
75 lines
2.2 KiB
Python
"""
|
|
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()
|
|
f.close()
|
|
with open("./verinfo.txt", "r") as f:
|
|
ver = f.read()
|
|
f.close()
|
|
print("Welcome to the PyJail install wizard.")
|
|
print(f"You are about to install version {ver} with manager {kver}")
|
|
y_n_question = input("Do you want to install PyJail? [Y/n] ")
|
|
if y_n_question.lower() == "n":
|
|
print("Installation cancelled!")
|
|
input("Press <Enter> to exit ")
|
|
exit(-1)
|
|
print("Preparing installation...")
|
|
os.mkdir(os.getcwd() + "/vfs")
|
|
shutil.move("./main.py", "./vfs/main.py")
|
|
shutil.move("./runner.py", "./main.py")
|
|
shutil.move("./sh.py", "./vfs/sh.py")
|
|
shutil.move("./ledit.py", "./vfs/ledit.py")
|
|
shutil.move("./autoconvert.py" "./vfs/autoconvert.py")
|
|
os.chdir(os.getcwd() + "/vfs")
|
|
print("Gathering info...")
|
|
usrname = input("Please enter your username: [usr1] ")
|
|
if usrname == "":
|
|
usrname = "usr1"
|
|
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", "./usr/bin/shell.py")
|
|
shutil.move("./ledit.py", "./usr/bin/ledit.py")
|
|
shutil.move("./autoconvert.py", "./usr/bin/autoconvert.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 process!")
|
|
input("Press <Enter> to exit! ")
|