import os
import subprocess

def install(url):
    if not url:
        print("Please provide the URL of the tar.gz file")
        return

    os.chdir("/tmp")
    subprocess.run(["wget", "-O", "download.tgz", url])
    os.mkdir("download")

    subprocess.run(["tar", "xzvf", "download.tgz", "-C", "download"])

    for i in os.listdir("download"):
        os.chdir(f"download/{i}")
        if os.path.exists("configure"):
            subprocess.run(["./configure"])
        subprocess.run(["make"])
        subprocess.run(["make", "install"])
        os.chdir("-")
        subprocess.run(["rm", "-fr", "download*"])

def mbuffer():
    if os.path.exists("/opt/git/opengnsys/client/engine/ToolsGNUc.py"):
        subprocess.run(["python", "/opt/git/opengnsys/client/engine/ToolsGNUc.py"])
    else:
        return
    
def ms_sys():
    if os.path.exists("/opt/git/opengnsys/client/engine/ToolsGNUc.py"):
        subprocess.run(["python", "/opt/git/opengnsys/client/engine/ToolsGNUc.py"])
    else:
        return

def ctorrent():
    if os.path.exists("/opt/git/opengnsys/client/engine/ToolsGNUc.py"):
        subprocess.run(["python", "/opt/git/opengnsys/client/engine/ToolsGNUc.py", "install"])
    else:
        return
    
def udpcast():
    if len(sys.argv) > 1 and sys.argv[1] == "install":
        install("http://udpcast.linux.lu/download/udpcast-20100130.tar.gz")
    else:
        return
    
def ntfs_3g():
    if len(sys.argv) > 1 and sys.argv[1] == "install":
        install("http://tuxera.com/opensource/ntfs-3g-2011.1.15.tgz")
    else:
        return
    
def partitionsaving():
    return

def awk():
    return

def chntpw():
    return

def fdisk():
    return

def fsck():
    return

def kexec():
    return

def lshw():
    return

def mkfs():
    return

def mount():
    return

def parted():
    return

def partimage():
    return

def partprobe():
    return

def sfdisk():
    return

def umount():
    return