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 initDbLoginPre() { $log_pre = "<p> Welcome to <%programname%> </p><p>Use a valid username and password to gain access to the console. </p> "; db_set_default('general', 'login_pre', $log_pre); }
function fixExtraDB() { print "Fix database\n"; $sq = new Sqlite(null, 'client'); $sq->rawQuery("update monitorserver set priv_q_monitorport_num = 'Unlimited'"); $sq->rawQuery("update client set priv_q_monitorport_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_monitorserver_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_vmipaddress_a_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_backup_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_process_usage = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_realmem_usage = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_backup_num = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_ncpu_usage = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_ioprio_usage = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_cpuunit_usage = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_swap_usage = 'Unlimited' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_backup_flag = 'On' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_ip_manage_flag = 'on' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_iptables_flag = 'On' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_vps_add_flag = 'On' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_vps_limit_flag = 'On' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_secondlevelquota_flag = 'On' where nname = 'admin'"); $sq->rawQuery("update client set priv_q_centralbackup_flag = 'On' where nname = 'admin'"); $sq->rawQuery("update pserver set parent_clname = 'client-admin'"); $sq->rawQuery("update vps set iid = vpsid where iid is null"); $sq->rawQuery("update vps set iid = vpsid where iid = ''"); $sq->rawQuery("update vps set priv_q_swap_usage = 2 * priv_q_realmem_usage where priv_q_swap_usage = ''"); $sq->rawQuery("update vps set priv_q_swap_usage = 2 * priv_q_realmem_usage where priv_q_swap_usage is null"); $sq->rawQuery("update vps set priv_q_swap_usage = 'Unlimited' where priv_q_swap_usage = 0"); $sq->rawQuery("update vps set priv_q_centralbackup_flag = centralbackup_flag where priv_q_centralbackup_flag = ''"); $sq->rawQuery("update vps set priv_q_centralbackup_flag = centralbackup_flag where priv_q_centralbackup_flag is null"); db_set_default('vps', 'kloxo_flag', 'off'); db_set_default('vps', 'priv_q_managedns_flag', 'on'); db_set_default('vps', 'priv_q_managereversedns_flag', 'on'); db_set_default('vps', 'priv_q_rebuildvps_flag', 'on'); db_set_default('client', 'priv_q_managedns_flag', 'on'); db_set_default('client', 'priv_q_managereversedns_flag', 'on'); db_set_default('client', 'priv_q_centralbackup_flag', 'on'); db_set_default('client', 'priv_q_rebuildvps_flag', 'on'); db_set_default('ippool', 'freeflag', 'on'); db_set_default('vps', 'ttype', 'openvz'); 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'"); db_set_default('pserver', 'coma_psrole_a', 'vps'); initDbLoginPre(); print "Fix database (Resource plans)\n"; migrateResourceplan('vps'); $sq->rawQuery("update resourceplan set realname = nname where realname = ''"); $sq->rawQuery("update resourceplan set realname = nname where realname is null"); $sq->rawQuery("alter table dns change ser_dns_record_a ser_dns_record_a longtext"); lxshell_php("../bin/common/fixresourceplan.php"); print "Fix database (Favorites)\n"; call_with_flag("convert_favorite"); lxfile_touch($file); }
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(); }