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"; } }
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"; } }
function fixDataBaseIssues() { log_cleanup("Fix Database Issues"); log_cleanup("- Fix admin account database settings"); $sq = new Sqlite(null, 'domain'); $sq->rawQuery("update domain set priv_q_php_flag = 'on'"); $sq->rawQuery("update web set priv_q_php_flag = 'on'"); $sq->rawQuery("update client set priv_q_php_flag = 'on'"); $sq->rawQuery("update client set priv_q_addondomain_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_rubyrails_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_rubyfcgiprocess_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_mysqldb_usage = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_phpfcgi_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_phpfcgiprocess_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_subdomain_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_totaldisk_usage = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_php_manage_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_installapp_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_cron_minute_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_document_root_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_runstats_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_webhosting_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update ticket set parent_clname = 'client-admin' where subject = 'Welcome to Kloxo'"); $sq->rawQuery("update domain set dtype = 'maindomain' where dtype = 'domain'"); log_cleanup("- Set default database settings"); db_set_default('mmail', 'remotelocalflag', 'local'); db_set_default('mmail', 'syncserver', 'localhost'); db_set_default('dns', 'syncserver', 'localhost'); db_set_default('pserver', 'coma_psrole_a', ',web,dns,mmail,mysqldb,'); db_set_default('web', 'syncserver', 'localhost'); db_set_default('uuser', 'syncserver', 'localhost'); db_set_default('client', 'syncserver', 'localhost'); db_set_default('addondomain', 'mail_flag', 'on'); db_set_default('client', 'priv_q_can_change_limit_flag', 'on'); db_set_default('web', 'priv_q_installapp_flag', 'on'); db_set_default('client', 'priv_q_installapp_flag', 'on'); db_set_default('client', 'websyncserver', 'localhost'); db_set_default('client', 'mmailsyncserver', 'localhost'); db_set_default('client', 'mysqldbsyncserver', 'localhost'); db_set_default('client', 'priv_q_can_change_password_flag', 'on'); db_set_default('client', 'coma_dnssyncserver_list', ',localhost,'); db_set_default('domain', 'priv_q_installapp_flag', 'on'); db_set_default('domain', 'dtype', 'domain'); db_set_default('domain', 'priv_q_php_manage_flag', 'on'); db_set_default('web', 'priv_q_php_manage_flag', 'on'); db_set_default('client', 'priv_q_php_manage_flag', 'on'); db_set_default('client', 'priv_q_webhosting_flag', 'on'); db_set_default_variable_diskusage('client', 'priv_q_totaldisk_usage', 'priv_q_disk_usage'); db_set_default_variable_diskusage('domain', 'priv_q_totaldisk_usage', 'priv_q_disk_usage'); db_set_default_variable('web', 'docroot', 'nname'); db_set_default_variable('client', 'used_q_maindomain_num', 'used_q_domain_num'); db_set_default_variable('client', 'priv_q_maindomain_num', 'priv_q_domain_num'); db_set_default("servermail", "domainkey_flag", "on"); log_cleanup("- Fix resourceplan settings in database"); migrateResourceplan('domain'); $sq->rawQuery("update resourceplan set realname = nname where realname = ''"); $sq->rawQuery("update resourceplan set realname = nname where realname is null"); lxshell_php("../bin/common/fixresourceplan.php"); log_cleanup("- Alter some database tables to fit that of Kloxo"); // TODO: Check if this is still longer needed! $sq->rawQuery("alter table sslcert change text_ca_content text_ca_content longtext"); $sq->rawQuery("alter table sslcert change text_key_content text_key_content longtext"); $sq->rawQuery("alter table sslcert change text_csr_content text_csr_content longtext"); $sq->rawQuery("alter table sslcert change text_crt_content text_crt_content longtext"); $sq->rawQuery("alter table mailaccount change ser_forward_a ser_forward_a longtext"); $sq->rawQuery("alter table dns change ser_dns_record_a ser_dns_record_a longtext"); $sq->rawQuery("alter table installsoft change ser_installappmisc_b ser_installappmisc_b longtext"); $sq->rawQuery("alter table web change ser_redirect_a ser_redirect_a longtext"); log_cleanup("- Set default welcome text at Kloxo login page"); initDbLoginPre(); log_cleanup("- Remove default db password if exists"); critical_change_db_pass(); }