Exemplo n.º 1
0
Arquivo: iso.py Projeto: ri0t/isomer
def main():
    """Try to load the tool and launch it. If it can't be loaded, try to install
    all required things first."""

    try:
        from isomer.tool.tool import isotool
    except ImportError as import_exception:
        print(
            "\033[1;33;41mIsomer startup error! Please check your Isomer/Python installation.\033[0m"
        )
        print(type(import_exception), ":", import_exception, "\n")

        if not ask(
                "Maybe the dependencies not installed, do you want to try to install them",
                default=False,
                data_type="bool",
                show_hint=True,
        ):
            abort(EXIT_CANNOT_IMPORT_TOOL)

        install_isomer()
        print("Please restart the tool now.")
        sys.exit()

    isotool(obj={}, auto_envvar_prefix="ISOMER")
Exemplo n.º 2
0
def dependencies(ctx):
    """Install Isomer platform dependencies"""

    log("Installing platform dependencies")

    install_isomer(
        ctx.obj["platform"],
        ctx.obj["use_sudo"],
        show=ctx.obj["log_actions"],
        omit_platform=ctx.obj['platform'],
        omit_common=True,
    )

    finish(ctx)
Exemplo n.º 3
0
def _system_all(ctx):

    use_sudo = ctx.obj["use_sudo"]

    config_path = get_etc_path()
    log("Generating configuration at", config_path)
    if os.path.exists(config_path):
        abort(EXIT_NOT_OVERWRITING_CONFIGURATION)
    ctx = create_configuration(ctx)

    log("Installing Isomer system wide")
    install_isomer(ctx.obj["platform"],
                   use_sudo,
                   show=ctx.obj["log_actions"],
                   omit_platform=ctx.obj['omit_platform'],
                   omit_common=True)

    log("Adding Isomer system user")
    _add_system_user(use_sudo)

    log("Creating Isomer filesystem locations")
    _create_system_folders(use_sudo)
Exemplo n.º 4
0
def install_remote(ctx, archive, setup):
    """Installs Isomer (Management) on a remote host"""

    shell = ctx.obj["shell"]
    platform = ctx.obj["platform"]
    host_config = ctx.obj["host_config"]
    use_sudo = host_config["use_sudo"]
    username = host_config["login"]["username"]
    existing = ctx.obj["existing"]
    remote_home = get_remote_home(username)
    target = os.path.join(remote_home, "isomer")

    log(remote_home)

    if shell is None:
        log("Remote was not configured properly.", lvl=warn)
        abort(5000)

    if archive:
        log("Renaming remote isomer copy")
        success, result = run_process(
            remote_home,
            ["mv", target,
             os.path.join(remote_home, "isomer_" + std_now())],
            shell=shell,
        )
        if not success:
            log("Could not rename remote copy:",
                result,
                pretty=True,
                lvl=error)
            abort(5000)

    if existing is None:
        url = ctx.obj["url"]
        if url is None:
            url = host_config.get("url", None)

        source = ctx.obj["source"]
        if source is None:
            source = host_config.get("source", None)

        if url is None or source is None:
            log('Need a source and url to install. Try "iso remote --help".')
            abort(5000)

        get_isomer(source,
                   url,
                   target,
                   upgrade=ctx.obj["upgrade"],
                   shell=shell)
        destination = os.path.join(remote_home, "isomer")
    else:
        destination = existing

    install_isomer(platform, use_sudo, shell=shell, cwd=destination)

    if setup:
        log("Setting up system user and paths")
        success, result = run_process(remote_home, ["iso", "system", "all"])
        if not success:
            log(
                "Setting up system failed:",
                format_result(result),
                pretty=True,
                lvl=error,
            )