Exemple #1
0
    def do(self):
        table = Texttable(max_width=get_terminal_size().columns - 2)
        table.header(("id", "name", "status", "XmX"))
        table.set_header_align(("c", "c", "c", "c"))
        table.set_cols_align(("r", "l", "l", "r"))
        table.set_deco(Texttable.HEADER | Texttable.VLINES)

        for _id, settings in self.context.instances_settings.items():
            active_state = external_command("systemctl",
                                            "is-active",
                                            f"existdb@{_id}",
                                            capture_output=True,
                                            check=False,
                                            text=True).stdout.strip()
            enabled_state = external_command("systemctl",
                                             "is-enabled",
                                             f"existdb@{_id}",
                                             capture_output=True,
                                             check=False,
                                             text=True).stdout.strip()

            table.add_row(
                (_id, settings["name"], f"{enabled_state}\n{active_state}",
                 settings["xmx"]))

        print("\n" + table.draw())
        print("\nThe XmX values refer to the configuration, "
              "not necessarily the currently effective.")
Exemple #2
0
 def do(self):
     with ConcludedMessage("Setting up log folder."):
         self.base_dir.mkdir(mode=0o770, parents=True)
         external_command("chown", f"{self.args.user}:{self.args.group}",
                          self.base_dir)
         (self.base_dir / "jetty").symlink_to(
             self.context.installation_dir / "tools" / "jetty" / "logs")
         (self.base_dir / "existdb").symlink_to(
             self.context.installation_dir / "webapp" / "WEB-INF" / "logs")
Exemple #3
0
 def do(self):
     unwanted_tokens = [
         x for x in self.config.get(
             "exist-db",
             "unwanted_jetty_configs",
             fallback="jetty-ssl.xml,jetty-ssl-context.xml,jetty-https.xml",
         ).split(",") if x
     ]
     config_path = (self.context.installation_dir / "tools" / "jetty" /
                    "etc" / "standard.enabled-jetty-configs")
     with ConcludedMessage("Disabling unwanted parts of the Jetty config."):
         for token in unwanted_tokens:
             external_command("sed", "-i", f"/{token}/d", config_path)
Exemple #4
0
    def do(self):
        snippet = NGINX_MAPPING_ROUTE
        trusted_clients = [
            x for x in self.config.get("nginx", "trusted_clients",
                                       fallback="").split(",") if x
        ]
        if trusted_clients:
            snippet += NGINX_MAPPING_STATUS_FILTER

        snippet = snippet.replace("<instance_id>", str(self.args.id))
        snippet = snippet.replace("<instance_name>", self.args.name)
        snippet = snippet.replace(
            "allow <trusted_client>;",
            " ".join(f"allow {x};" for x in trusted_clients))

        with ConcludedMessage("Writing instance specific nginx config."):
            with self.mapping_path.open("wt") as f:
                print(snippet, file=f)
            external_command("chown", f"root:{self.args.group}",
                             self.mapping_path)
            external_command("chmod", "ug=rw,o=r", self.mapping_path)
Exemple #5
0
    def do(self):
        with ConcludedMessage("Adjusting file access permissions."):
            external_command(
                "chown",
                "-R",
                f"{self.args.user}.{self.args.group}",
                self.context.instance_dir,
            )
            external_command(
                "chmod",
                "g+w",
                self.context.instance_dir,
                self.context.installation_dir,
                self.context.backup_dir,
                self.context.data_dir,
            )

        with ConcludedMessage(
                "Allow write access to all xml-files for group-members in the "
                "application directory."):
            for xml_file in self.context.installation_dir.glob("**/*.xml"):
                external_command("chmod", "g+w", xml_file)
Exemple #6
0
 def undo(self):
     with ConcludedMessage("Stopping systemd unit for instance."):
         external_command("systemctl", "stop", f"existdb@{self.args.id}")
Exemple #7
0
 def do(self):
     external_command("java", "-jar", self.context.installer_location,
                      "-console")
Exemple #8
0
 def do(self):
     with ConcludedMessage("Reloading nginx configuration."):
         external_command("systemctl", "reload", "nginx")
Exemple #9
0
 def do(self):
     with ConcludedMessage("Enabling systemd unit for instance."):
         external_command("systemctl", "enable", f"existdb@{self.args.id}")