Example #1
0
    def install(self, package):
        p = self.ctx.props
        r = self.ctx.r
        rv = self.ctx.rv
        # Unfortunately, Python's built-in unzip does not seem
        # to preserve executable permissions. We need those permissions
        # for the shell scripts we're going to run. As a workaround,
        # we'll call out to the os's unzip call.
        ## r(extract_package_as_dir, package, p.config_port.home)
        parent_dir = os.path.dirname(p.config_port.home)
        if not self.ctx.dry_run:
            file_path = package.get_file() # this might download the file!
        else:
            file_path = None
        r(run_program, ["/usr/bin/unzip", file_path],
          cwd=parent_dir)
        JASPER_EXTRACTED_DIR="jasperreports-server-cp-4.2.1-bin"
        if JASPER_EXTRACTED_DIR!=os.path.basename(p.config_port.home) and \
           not self.ctx.dry_run:
            os.rename(os.path.join(parent_dir, JASPER_EXTRACTED_DIR),
                      p.config_port.home)

        r(copy_file, p.input_ports.jdbc_driver_file.jar_file_path,
          p.jdbc_target_path)
        r(copy_file, p.template_properties_file,
          p.properties_file)
        esc = re.escape
        replacements = [
            (esc(r"appServerDir = C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0"),
             "appServerDir = %s" % p.input_ports.tomcat.home),
            (esc("dbPassword=password"),
             "dbPassword=%s" % self._get_password(p.input_ports.mysql_admin.admin_password))
        ]
        cnt = rv(subst_in_file, p.properties_file, replacements)
        assert cnt == len(replacements) or self.ctx.dry_run, "Properties file %s might be wrong - expecting %d replacements, got %d" % (p.properties_file, len(replacements), cnt)
        tomcat_utils.ensure_tomcat_stopped(self.ctx, p.input_ports.tomcat)
        # TODO: should check that the jasper reports database doesn't
        # already exist in mysql. Otherwise, will get an infinite loop in
        # script as it tries to ask you whether to delete the existing db
        # TODO: should use run_and_scan_results and check for
        # BUILD SUCCESSFUL or BUILD FAILED
        r(run_program, [p.install_shell_script],
          cwd=os.path.dirname(p.install_shell_script))
        tomcat_utils.ensure_tomcat_running(self.ctx, p.input_ports.tomcat)
Example #2
0
 def stop(self):
     tomcat_utils.ensure_tomcat_stopped(self.ctx,
                                        self.ctx.props.output_ports.tomcat)