Ejemplo n.º 1
0
function updatecleanup_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    $program = $sgbl->__var_program_name;
    $opt = parse_opt($argv);
    if ($opt['type'] === 'master') {
        initProgram('admin');
        $flg = "__path_program_start_vps_flag";
        if (!lxfile_exists($flg)) {
            set_login_skin_to_feather();
        }
    } else {
        $login = new Client(null, null, 'update');
    }
    print "Executing UpdateCleanup. This can take a long time. Please be patient\n";
    log_log("update", "Executing Updatecleanup");
    //
    // Cleanup old lxlabs.repo file
    //
    print "Fixing Repo's\n";
    if (lxfile_exists("/etc/yum.repos.d/lxcenter.repo")) {
        if (lxfile_exists("/etc/yum.repos.d/lxlabs.repo")) {
            lxfile_mv("/etc/yum.repos.d/lxlabs.repo", "/etc/yum.repos.d/lxlabs.repo.lxsave");
            system("rm -f /etc/yum.repos.d/lxlabs.repo");
        }
    }
    if (lxfile_exists("CVS")) {
        print "Found Development version, we just go on.\n";
        //		exit;
    }
    if ($opt['type'] === 'master') {
        $sgbl->slave = false;
        if (!is_secondary_master()) {
            print "Update database\n";
            updateDatabaseProperly();
            print "Fix Extra database issues\n";
            fixExtraDB();
            print "Update extra issues\n";
            doUpdateExtraStuff();
            print "Get Driver info\n";
            lxshell_return("__path_php_path", "../bin/common/driverload.php");
        }
        print "Starting Update all slaves\n";
        update_all_slave();
        print "Fix main {$program} databasefile\n";
        cp_dbfile();
    } else {
        $sgbl->slave = true;
    }
    if (!is_secondary_master()) {
        print "Starting update cleanups\n";
        updatecleanup();
    }
    lxfile_touch("__path_program_start_vps_flag");
}
Ejemplo n.º 2
0
function updatecleanup_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    $prognameNice = $sgbl->__var_program_name_nice;
    $opt = parse_opt($argv);
    if ($opt['type'] === 'master') {
        initProgram('admin');
        $flg = "__path_program_start_vps_flag";
        if (!lxfile_exists($flg)) {
            set_login_skin_to_feather();
        }
    } else {
        $login = new Client(null, null, 'update');
    }
    print "Executing UpdateCleanup. This can take a long time. Please be patient\n";
    log_log("update", "Executing Updatecleanup");
    // Do things that is needed before the cleanup starts.
    print "########################################\n";
    print "##        Executing PreCleanup        ##\n";
    print "########################################\n";
    doBeforeUpdate();
    print "########################################\n";
    print "##        Finished PreCleanup         ##\n";
    print "########################################\n";
    if ($opt['type'] === 'master') {
        $sgbl->slave = false;
        if (!is_secondary_master()) {
            print "Update database (if needed)\n";
            updateDatabaseProperly();
            if (call_with_flag("fixExtraDB")) {
                print "- Fixed\n";
            }
            print "Update extra issues (if any)\n";
            doUpdateExtraStuff();
            print "Get Driver info\n";
            lxshell_return("__path_php_path", "../bin/common/driverload.php");
        }
        print "Starting Update all slaves\n";
        update_all_slave();
        print "Fix main {$prognameNice} databasefile\n";
        cp_dbfile();
    } else {
        $sgbl->slave = true;
    }
    if (!is_secondary_master()) {
        print "Starting update cleanups\n";
        cleanupUpdate();
    }
    if (!lxfile_exists($flg)) {
        lxfile_touch($flg);
    }
}
Ejemplo n.º 3
0
/** 
* @return void 
* @param 
* @param 
* @desc Remote takes two type of command. When called as "get", it executes a given function in the The other machine and returns the return value.  When called as "set", it clones the third argument (an lxclass object), clears all the children And sends the object to the other end, where the 'dosynctosystem' method in the object Is executed.
*/
function remote_exec($machine, $cmd)
{
    global $gbl, $sgbl, $login, $ghtml;
    $version = $sgbl->__ver_major_minor_release;
    if (isLocalhost($machine)) {
        if (is_secondary_master()) {
            throw new lxException('you_are_on_secondary_master', '');
        }
        if (os_isSelfSystemUser()) {
            return do_local_action($cmd);
        }
    }
    if ($cmd->action === "set" || $cmd->action === 'dowas') {
        $cmdtype = get_class($cmd->robject);
        $robject = $cmd->robject;
        $nname = $robject->nname;
        $dbaction = $robject->dbaction;
    } else {
        if ($cmd->action === 'get') {
            $cmdtype = $cmd->func;
            if (is_array($cmdtype)) {
                $cmdtype = implode("::", $cmdtype);
            }
            $nname = "";
            $dbaction = "";
        } else {
            $cmdtype = null;
            $nname = "";
            $dbaction = "";
        }
    }
    print_time('remote_exec');
    $rmt = do_remote_exec($machine, $cmd, $cmdtype, $nname, $dbaction);
    $class = 'get_action';
    $subaction = "get";
    if ($cmd->action === 'set') {
        $class = $cmd->robject->get__table();
        $subaction = $cmd->robject->subaction;
    }
    print_time('remote_exec', "<b> Remote Exec {$machine}: type: {$cmdtype}, class: {$class} name: {$nname} action: {$dbaction}; subaction {$subaction} </b>");
    if (!$rmt) {
        return null;
    }
    // If the slave server is upgrading try once more. Don't!!!!!!!!!!!!!!
    /*
    	if ($rmt->state === 'upgrade') {
    		print("Slave Server Upgraded. Trying Again....<br> ");
    		flush();
    		sleep(20);
    		$rmt = do_remote_exec($machine, $password, $cmd, $cmdtype, $nname, $dbaction);
    	}
    	if (!$rmt) {
    		return null;
    	}
    	if ($rmt->state === 'upgrade') {
    		dprint("Slave Server Upgrade. Has failed...<br> ");
    		throw new lxException("slave_server_upgrade_failed");
    	}
    */
    if ($rmt->exception) {
        //$exc = new Exception("syncserver:$machine <br> " . $rmt->exception->getMessage());
        $rmt->exception->syncserver = $machine;
        throw $rmt->exception;
        //throw $exc;
    }
    return $rmt->ddata;
}
Ejemplo n.º 4
0
function updatecleanup_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    $program = $sgbl->__var_program_name;
    $opt = parse_opt($argv);
    if ($opt['type'] === 'master') {
        initProgram('admin');
        $flg = "__path_program_start_vps_flag";
        if (!lxfile_exists($flg)) {
            set_login_skin_to_feather();
        }
    } else {
        $login = new Client(null, null, 'update');
    }
    log_cleanup("*** Executing Update (cleanup) - BEGIN ***");
    //
    // Check for lxlabs yum repo file and if exists
    // Change to lxcenter repo file
    //
    if (lxfile_exists("/etc/yum.repos.d/lxlabs.repo")) {
        log_cleanup("- Deleting old lxlabs yum repo");
        lxfile_mv("/etc/yum.repos.d/lxlabs.repo", "/etc/yum.repos.d/lxlabs.repo.lxsave");
        exec("rm -f /etc/yum.repos.d/lxlabs.repo");
        log_cleanup("- Removed lxlabs.repo");
        log_cleanup("- Installing lxcenter.repo");
        exec("wget -O /etc/yum.repos.d/lxcenter.repo http://download.lxcenter.org/lxcenter.repo");
        log_cleanup("- Installing yum-protectbase plugin");
        exec("yum install -y -q yum-protectbase");
    }
    // Fix #388 - phpMyAdmin config.inc.php permission
    $correct_perm = "0644";
    $check_perm = substr(decoct(fileperms("/usr/local/lxlabs/{$program}/httpdocs/thirdparty/phpMyAdmin/config.inc.php")), 2);
    if ($check_perm != $correct_perm) {
        lxfile_unix_chmod("/usr/local/lxlabs/{$program}/httpdocs/thirdparty/phpMyAdmin/config.inc.php", "0644");
    }
    //
    if (lxfile_exists(".svn")) {
        log_cleanup("- SVN Found... Exiting");
        exit;
    }
    if ($opt['type'] === 'master') {
        $sgbl->slave = false;
        if (!is_secondary_master()) {
            updateDatabaseProperly();
            fixDataBaseIssues();
            doUpdates();
            lxshell_return("__path_php_path", "../bin/common/driverload.php");
        }
        update_all_slave();
        cp_dbfile();
    } else {
        $sgbl->slave = true;
    }
    if (!is_secondary_master()) {
        updatecleanup();
    }
    if ($opt['type'] === 'master') {
        lxfile_touch("__path_program_start_vps_flag");
    }
    // issue #716 -- [beta] Unresolved dependency on Apache version
    // --- remove httpd-itk rpm (from webtatic.repo or others) because may conflict with
    // httpd 2.2.21 that include mpm itk beside mpm worker and event
    exec("rpm -q httpd-itk | grep -i 'not installed'", $out, $ret);
    // --- not work with !$ret
    if ($ret !== 0) {
        log_cleanup("Remove httpd-itk rpm package");
        log_cleanup("- Remove httpd-itk");
        exec("rpm -e httpd-itk --nodeps");
        exec("rpm -q httpd | grep -i 'not installed'", $out2, $ret2);
        if ($ret2 === 0) {
            log_cleanup("- Reinstall httpd");
            exec("yum reinstall httpd -y");
        }
    }
    // MR -- mysql not start after kloxo slave install
    log_cleanup("Preparing MySQL service");
    log_cleanup("- MySQL activated");
    exec("chkconfig mysqld on");
    log_cleanup("- MySQL restarted");
    exec("service mysqld restart");
    // MR -- importance for update from 6.1.6 or previous where change apache/lighttpd structure
    // or others for next version
    $slist = array("httpd*", "lighttpd*", "bind*", "djbdns*", "pure-ftpd*", "php*", "vpopmail", "courier-imap-toaster", "courier-authlib-toaster", "qmail", "safecat", "spamassassin", "bogofilter", "ezmlm-toaster", "autorespond-toaster", "clamav-toaster");
    setUpdateServices($slist);
    // MR -- use this trick for qmail non-daemontools based
    log_cleanup("Preparing some services again");
    log_cleanup("- courier-imap enabled and restart queue");
    exec("chkconfig courier-imap on");
    createRestartFile("courier-imap");
    log_cleanup("- qmail enabled and restart queue");
    exec("chkconfig qmail on");
    createRestartFile("qmail");
    $fixapps = array("dns", "web", "php", "mail", "ftpuser", "vpop");
    setUpdateConfigWithVersionCheck($fixapps, $opt['type']);
    // --- for anticipate change xinetd listing
    exec("service xinetd restart");
}
Ejemplo n.º 5
0
function exit_if_secondary_master()
{
    if (is_secondary_master()) {
        print "This is secondary Master\n";
        exit;
    }
}
Ejemplo n.º 6
0
function updatecleanup_main()
{
    global $argc, $argv;
    global $gbl, $sgbl, $login, $ghtml;
    $program = $sgbl->__var_program_name;
    $opt = parse_opt($argv);
    if ($opt['type'] === 'master') {
        initProgram('admin');
        $flg = "__path_program_start_vps_flag";
        if (!lxfile_exists($flg)) {
            set_login_skin_to_feather();
        }
    } else {
        $login = new Client(null, null, 'update');
    }
    log_cleanup("*** Executing Update (cleanup) - BEGIN ***");
    // Do things that is needed before the cleanup starts.
    print "########################################\n";
    print "##        Executing PreCleanup        ##\n";
    print "########################################\n";
    doBeforeUpdate();
    print "########################################\n";
    print "##        Finished PreCleanup         ##\n";
    print "########################################\n";
    if (lxfile_exists('.git')) {
        log_cleanup('- Development found!');
    }
    if ($opt['type'] === 'master') {
        $sgbl->slave = false;
        if (!is_secondary_master()) {
            updateDatabaseProperly();
            fixDataBaseIssues();
            doUpdates();
            lxshell_return("__path_php_path", "../bin/common/driverload.php");
        }
        update_all_slave();
        cp_dbfile();
    } else {
        $sgbl->slave = true;
    }
    if (!is_secondary_master()) {
        updatecleanup();
    }
    if ($opt['type'] === 'master') {
        lxfile_touch("__path_program_start_vps_flag");
    }
    // issue #716 -- [beta] Unresolved dependency on Apache version
    // --- remove httpd-itk rpm (from webtatic.repo or others) because may conflict with
    // httpd 2.2.21 that include mpm itk beside mpm worker and event
    exec("rpm -q httpd-itk | grep -i 'not installed'", $out, $ret);
    // --- not work with !$ret
    if ($ret !== 0) {
        log_cleanup("Remove httpd-itk rpm package");
        log_cleanup("- Remove httpd-itk");
        exec("rpm -e httpd-itk --nodeps");
        exec("rpm -q httpd | grep -i 'not installed'", $out2, $ret2);
        if ($ret2 === 0) {
            log_cleanup("- Reinstall httpd");
            exec("yum reinstall httpd -y");
        }
    }
    // MR -- mysql not start after kloxo slave install
    log_cleanup("Preparing MySQL service");
    log_cleanup("- MySQL activated");
    exec("chkconfig mysqld on");
    log_cleanup("- MySQL restarted");
    exec("service mysqld restart");
    // MR -- importance for update from 6.1.6 or previous where change apache/lighttpd structure
    // or others for next version
    $slist = array("httpd*", "lighttpd*", "bind*", "djbdns*", "pure-ftpd*", "php*", "vpopmail", "courier-imap-toaster", "courier-authlib-toaster", "qmail", "safecat", "spamassassin", "bogofilter", "ezmlm-toaster", "autorespond-toaster", "clamav-toaster");
    setUpdateServices($slist);
    // MR -- use this trick for qmail non-daemontools based
    log_cleanup("Preparing some services again");
    log_cleanup("- courier-imap enabled and restart queue");
    exec("chkconfig courier-imap on");
    createRestartFile("courier-imap");
    log_cleanup("- qmail enabled and restart queue");
    exec("chkconfig qmail on");
    createRestartFile("qmail");
    $fixapps = array("dns", "web", "php", "mail", "ftpuser", "vpop");
    setUpdateConfigWithVersionCheck($fixapps, $opt['type']);
    // --- for anticipate change xinetd listing
    exec("service xinetd restart");
}