Esempio n. 1
0
/**
 * cPanel4J
 * sql_install.php
 * Author: Vivek Soni (contact@viveksoni.net)
 * Instructions & More Info: www.cpanel4j.com
 * Released under the GNU General Public License
 */
namespace cPanel4jCore;

//CRON JOBS TO BE RUN AS ROOT
require_once "DBWrapper.php";
require_once "Tomcat.php";
$dbWrapper = new DBWrapper();
$tomCat = new Tomcat();
$records = $dbWrapper->getRecordForCron();
while ($row = mysqli_fetch_array($records)) {
    if ($row['delete_flag'] == 0) {
        $userName = $row['user_name'];
        $domainName = $row['domain_name'];
        $ajp_port = $row['ajp_port'];
        $tomcatVersion = $row['tomcat_version'];
        if ($row['installed'] == 0) {
            //install instnac
            $catalinaHome = "/cPanel4jCore/tomcat-" . $tomcatVersion . "-engine";
            $userTomcatDir = "/home/" . $userName . "/" . $domainName . "/tomcat-" . $tomcatVersion . "/";
            // Step 4 creating service startup sh file
            $fileName = "/cPanel4jCore/service-files/" . $userName . "-" . $domainName . "-tomcat-" . $tomcatVersion . ".sh";
            exec("rm -f {$fileName}");
            $serviceFileContent = "#!/bin/bash \n#description: Tomcat-" . $domainName . " start stop restart \n#processname: tomcat-" . $userName . "-" . $domainName . " \n\n#chkconfig: 234 20 80 \n CATALINA_HOME=" . $catalinaHome . " \n export CATALINA_BASE=" . $userTomcatDir . " \n\n\t\t\tcase \$1 in \n start) \n sh \$CATALINA_HOME/bin/startup.sh \n ;; \n stop) \n sh \$CATALINA_HOME/bin/shutdown.sh \n ;; \n\n\t\t\trestart) \n sh \$CATALINA_HOME/bin/shutdown.sh \n sh \$CATALINA_HOME/binstartup.sh \n;; \n esac \n exit 0";
            $serviceFile = fopen($fileName, "w");