Beispiel #1
0
def web_container_config(cfg, container):
    print("Configuring web container")
    orderly_container = cfg.containers["orderly"]
    opts = {
        "app.port": str(cfg.web_port),
        "app.name": cfg.web_name,
        "app.email": cfg.web_email,
        "app.url": cfg.web_url,
        "auth.github_org": cfg.web_auth_github_org or "",
        "auth.github_team": cfg.web_auth_github_team or "",
        "auth.fine_grained": str(cfg.web_auth_fine_grained).lower(),
        "auth.provider": "montagu" if cfg.web_auth_montagu else "github",
        "orderly.server": "http://{}:8321".format(orderly_container)
    }
    if cfg.logo_name is not None:
        opts["app.logo"] = cfg.logo_name
    if cfg.web_auth_montagu:
        opts["montagu.url"] = cfg.montagu_url
        opts["montagu.api_url"] = cfg.montagu_api_url
    if cfg.web_auth_github_app:
        opts["auth.github_key"] = cfg.web_auth_github_app["id"]
        opts["auth.github_secret"] = cfg.web_auth_github_app["secret"]

    txt = "".join(["{}={}\n".format(k, v) for k, v in opts.items()])
    exec_safely(container, ["mkdir", "-p", "/etc/orderly/web"])
    string_into_container(txt, container, "/etc/orderly/web/config.properties")
Beispiel #2
0
def orderly_write_env(env, container):
    if not env:
        return
    print("Writing orderly environment")
    dest = "/root/.Renviron"
    txt = "".join(["{}={}\n".format(str(k), str(v)) for k, v in env.items()])
    string_into_container(txt, container, dest)
Beispiel #3
0
def proxy_certificates(cfg, container):
    if cfg.proxy_ssl_self_signed:
        print("Generating self-signed certificates for proxy")
        exec_safely(container, ["self-signed-certificate", "/run/proxy"])
    else:
        print("Copying ssl certificate and key into proxy")
        string_into_container(cfg.proxy_ssl_certificate, container,
                              "/run/proxy/certificate.pem")
        string_into_container(cfg.proxy_ssl_key, container,
                              "/run/proxy/key.pem")
Beispiel #4
0
def orderly_write_ssh_keys(orderly_ssh, container):
    if not orderly_ssh:
        return
    print("Configuring ssh")
    path_private = "/root/.ssh/id_rsa"
    path_public = "/root/.ssh/id_rsa.pub"
    path_known_hosts = "/root/.ssh/known_hosts"
    exec_safely(container, ["mkdir", "-p", "/root/.ssh"])
    string_into_container(orderly_ssh["private"], container, path_private)
    string_into_container(orderly_ssh["public"], container, path_public)
    exec_safely(container, ["chmod", "600", path_private])
    hosts = exec_safely(container, ["ssh-keyscan", "github.com"])
    string_into_container(hosts[1].decode("UTF-8"), container,
                          path_known_hosts)
Beispiel #5
0
 def save(self):
     orderly = self.get_container("orderly")
     txt = base64.b64encode(pickle.dumps(self)).decode("utf8")
     container = self.get_container(PATH_CONFIG["container"])
     path = PATH_CONFIG["path"]
     string_into_container(txt, container, path)