Esempio n. 1
0
function doUpdateExtraStuff()
{
    global $gbl, $sgbl, $login, $ghtml;
    lxfile_mkdir("__path_program_etc/flag");
    convertIpaddressToComa();
    print "Fix extra database\n";
    fixExtraDB();
    print "Set some defaults\n";
    db_set_default('vps', 'ttype', 'openvz');
    db_set_default('pserver', 'coma_psrole_a', 'vps');
    db_set_default("vps", "swapdiskname", "vm.swap", "ttype = 'xen'");
    db_set_default("vps", "maindiskname", "root.img", "ttype = 'xen'");
    db_set_default('vps', 'corerootdir', '/vz/private', "ttype = 'openvz'");
    db_set_default("vps", "corerootdir", "/home/xen", "ttype = 'xen'");
    print "Fixing database passwords\n";
    $a = null;
    fix_mysql_root_password('localhost');
    $dbadmin = new Dbadmin(null, 'localhost', "mysql___localhost");
    $dbadmin->get();
    $pass = $dbadmin->dbpassword;
    $a['mysql']['dbpassword'] = $pass;
    slave_save_db("dbadmin", $a);
    print "Fixing OS template permissions\n";
    lxfile_unix_chmod_rec("/vz/template/cache/", "0755");
    lxfile_unix_chmod_rec("/home/hypervm/xen/template/", "0755");
    call_with_flag("dofixParentClname");
    print "Check License\n";
    passthru("{$sgbl->__path_php_path} htmllib/lbin/getlicense.php");
    print "Fix OpenVZ resources\n";
    fixOpenVZResource();
    print "Move clients to client of needed\n";
    move_clients_to_client();
    print "create backup dirs\n";
    add_vps_backup_dir();
    print "Parse SQL Data\n";
    parse_sql_data();
    print "Fix IP POOL\n";
    lxshell_return("__path_php_path", "../bin/fix/fixippool.php");
    print "Fix IP adresses in database\n";
    fix_ipaddress_column_type();
    fix_vmipaddress();
    print "Checking HIB template\n";
    get_kloxo_ostemplate();
    print "Set admin email\n";
    save_admin_email();
    print "Checking Skin Images\n";
    copy_image();
    system("mysql -u hypervm -p`cat ../etc/conf/hypervm.pass` hypervm1_0 < ../file/interface/interface_template.dump");
    if (lxfile_exists("/etc/init.d/libvirtd")) {
        print "Make sure libvirtd is not started after reboot\n";
        system("chkconfig libvirtd off 2>/dev/null");
    }
    if (is_openvz()) {
        print "Fixing Base OS templates\n";
        if (!lxfile_real("/vz/template/cache/centos-5-i386-afull.tar.gz")) {
            system("mkdir -p /vz/template/cache/ ; cd /vz/template/cache/ ; rm centos-5-i386-afull.tar.gz; wget download.lxcenter.org/download/openvztemplates/base/centos-5-i386-afull.tar.gz ");
            system("rm /vz/template/cache/index.html* 2>/dev/null");
        }
    } else {
        if (!lxfile_real("/home/hypervm/xen/template/centos-5-i386-afull.tar.gz")) {
            system("mkdir -p /home/hypervm/xen/template ; cd /home/hypervm/xen/template/ ; rm centos-5-i386-afull.tar.gz;  wget download.lxcenter.org/download/xentemplates/base/centos-5-i386-afull.tar.gz ");
            system("rm /home/hypervm/xen/template/index.html* 2>/dev/null");
        }
    }
    print "Fix SSL\n";
    fix_self_ssl();
    print "Fix database password\n";
    critical_change_db_pass();
    print "Delete old repo's\n";
    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");
        print "Removed lxlabs.repo\n";
    }
}
Esempio n. 2
0
function doUpdateExtraStuff()
{
    global $gbl, $sgbl, $login, $ghtml;
    lxfile_mkdir("__path_program_etc/flag");
    print "Check database password\n";
    $a = null;
    fix_mysql_root_password('localhost');
    $dbadmin = new Dbadmin(null, 'localhost', "mysql___localhost");
    $dbadmin->get();
    $pass = $dbadmin->dbpassword;
    $a['mysql']['dbpassword'] = $pass;
    slave_save_db("dbadmin", $a);
    print "Check the core database\n";
    parse_sql_data();
    if (call_with_flag("convertIpaddressToComa")) {
        print "Converted IP addresses in database\n";
    }
    if (call_with_flag("fixExtraDB")) {
        print "- Fixed\n";
    }
    print "Set OS template permissions\n";
    if (is_openvz()) {
        lxfile_unix_chmod_rec("/vz/template/cache/", "0755");
    } else {
        lxfile_unix_chmod_rec("/home/hypervm/xen/template/", "0755");
    }
    call_with_flag("dofixParentClname");
    print "Get License\n";
    // ToDo: Why is this called this way....
    passthru("{$sgbl->__path_php_path} htmllib/lbin/getlicense.php");
    if (is_openvz()) {
        print "Check OpenVZ resources\n";
        if (call_with_flag("fixOpenVZResource")) {
            print "- Fixed\n";
        }
    }
    if (move_clients_to_client()) {
        print "Renamed clients directory to client.\n";
    }
    print "Checking backup dirs\n";
    if (!add_vps_backup_dir()) {
        print "- Everything is fine.\n";
    }
    print "Fix IP POOL\n";
    lxshell_return("__path_php_path", "../bin/fix/fixippool.php");
    if (call_with_flag("fix_ipaddress_column_type")) {
        print "Fixed IP address column in database\n";
    }
    if (call_with_flag("fix_vmipaddress")) {
        print "Fixed VM IP addresses in database\n";
    }
    print "Checking HIB template\n";
    get_kloxo_ostemplate();
    if (db_get_value("client", "admin", "contactemail")) {
        print "Set admin email\n";
        save_admin_email();
    }
    // Unknown usage within HyperVM, anyone can tell what this is doing?
    $file = "__path_program_root/etc/fixed_interface_template_sql";
    if (lxfile_exists($file)) {
        lxfile_touch($file);
        print "Check Interface Template (database)\n";
        system("mysql -u hypervm -p`cat ../etc/conf/hypervm.pass` hypervm1_0 < ../file/interface/interface_template.sql");
    }
    if (lxfile_exists("/etc/init.d/libvirtd")) {
        print "Make sure libvirtd is not started after reboot\n";
        system("chkconfig libvirtd off 2>/dev/null");
    }
    if (is_openvz()) {
        print "Checking for Base default OS template\n";
        $OSTemplateDir = "/vz/template/cache";
        $defaultOSTemplate = "centos-6-x86.tar.gz";
        $defaultOSTemplateName = "centos-6-x86";
        if (!lxfile_exists($OSTemplateDir)) {
            lxfile_mkdir($OSTemplateDir);
        }
        if (!lxfile_real("{$OSTemplateDir}/{$defaultOSTemplate}")) {
            lxfile_rm("{$OSTemplateDir}/{$defaultOSTemplate}");
            system("cd {$OSTemplateDir}/ ; wget http://download.hypervm-ng.org/download/openvztemplates/base/{$defaultOSTemplate}");
            system("rm {$OSTemplateDir}/index.html* 2>/dev/null");
            system("rm {$OSTemplateDir}/robots.txt* 2>/dev/null");
        }
        // Added in HyperVM 2.1.0
        if (lxfile_exists("/usr/sbin/vztmpl-dl")) {
            print "Checking for latest version of {$defaultOSTemplateName} at OpenVZ.org website\n";
            $res = system("/usr/sbin/vztmpl-dl --update {$defaultOSTemplateName} 2>/dev/null");
            dprint("res: {$res}\n");
        }
    } else {
        if (!lxfile_real("/home/hypervm/xen/template/centos-6-x86-pygrub-sda-latest.tar.gz")) {
            system("mkdir -p /home/hypervm/xen/template ; cd /home/hypervm/xen/template/ ; rm centos-6-i386.tar.gz; rm centos-5-i386.tar.gz; rm centos-5-i386-afull.tar.gz; rm centos-6-x86-pygrub-sda-latest.tar.gz; wget http://download.hypervm-ng.org/download/xentemplates/base/centos-6-x86-pygrub-sda-latest.tar.gz");
            system("rm /home/hypervm/xen/template/index.html* 2>/dev/null");
            system("rm /home/hypervm/xen/template/robots.txt* 2>/dev/null");
        }
    }
    print "Check for old critical database password bug\n";
    if (critical_change_db_pass()) {
        print "- Fixed critical database password bug!!!\n";
    } else {
        print "- Good! Already bug free :-)\n";
    }
    if (lxfile_exists("/etc/yum.repos.d/lxlabs.repo")) {
        print "Delete old repo's\n";
        lxfile_mv("/etc/yum.repos.d/lxlabs.repo", "/etc/yum.repos.d/lxlabs.repo.lxsave");
        system("rm -f /etc/yum.repos.d/lxlabs.repo");
        print "Removed lxlabs.repo\n";
    }
}