def orderly_init_demo(container): print("Initialising orderly with demo data") args = [ "Rscript", "-e", "orderly:::create_orderly_demo('/orderly', git = TRUE)" ] exec_safely(container, args)
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")
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")
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)
def web_start(container): print("Starting orderly server") exec_safely(container, ["touch", "/etc/orderly/web/go_signal"])
def worker_start(container): print("Starting worker {}".format(container.name)) exec_safely(container, ["touch", "/go_signal"])
def orderly_start(container): print("Starting orderly server") exec_safely(container, ["touch", "/go_signal"])
def orderly_check_schema(container): print("Checking orderly schema is current") exec_safely(container, ["orderly", "rebuild", "--if-schema-changed"])
def orderly_init_clone(container, url): print("Initialising orderly by cloning") args = ["git", "clone", url, "/orderly"] exec_safely(container, args)