コード例 #1
0
ファイル: lxins.php プロジェクト: digideskio/hypervm
function lxins_main()
{
    global $argv;
    $opt = parse_opt($argv);
    $installtype = $opt['install-type'];
    $highmem = false;
    if (isset($opt['has-highmem'])) {
        $highmem = true;
    }
    if (!isset($opt['virtualization-type'])) {
        print "Need virtualization type --virtualization-type=xen/openvz/NONE\n";
        exit;
    } else {
        $virtualization = $opt['virtualization-type'];
    }
    $skipostemplate = false;
    if (isset($opt['skip-ostemplate'])) {
        $skipostemplate = true;
    }
    if (array_search($virtualization, array("xen", "openvz", "NONE")) === false) {
        print "Only xen/openvz/NONE are curently supported\n";
        exit;
    }
    $dbroot = isset($opt['db-rootuser']) ? $opt['db-rootuser'] : "******";
    $dbpass = isset($opt['db-rootpassword']) ? $opt['db-rootpassword'] : "";
    if (!$dbpass) {
        //$dbpass = slave_get_db_pass("hypervm");
    }
    $osversion = find_os_version();
    if (file_exists("/usr/local/lxlabs/hypervm")) {
        print "HyperVM is installed do you wish to continue?(No/Yes):\n";
        flush();
        $stdin = fopen('php://stdin', 'r');
        $argq = fread($stdin, 5);
        $arg = trim($argq);
        if (!($arg == 'y' || $arg == 'yes' || $arg == 'Yes' || $arg == 'Y' || $arg == 'YES')) {
            print "Exiting.....\n";
            exit;
        }
    }
    if ($virtualization === 'xen') {
        if (!char_search_beg($osversion, "fedora-9") && !char_search_beg($osversion, "centos-5") && !char_search_beg($osversion, "rhel-5")) {
            print "Xen is only supported on Fedora 9 or CentOS 5\n";
            exit;
        }
    }
    if ($virtualization === 'openvz') {
        if (!char_search_beg($osversion, "centos") && !char_search_beg($osversion, "rhel")) {
            print "OpenVZ is only supported on CentOS 4/5, RHEL 4/5 distributions\n";
            exit;
        }
    }
    /*
    	$file = "http://download.lxlabs.com/download/update/$osversion/headers/header.info";
    	$cont = @file_get_contents($file);
    	if (!$cont) {
    		print("This OS is not suported at this moment.... Please contact our Support personnel\n");
    		exit;
    	}
    */
    //install_rhn_sources($osversion);
    install_yum_repo($osversion);
    exec("groupadd lxlabs");
    exec("useradd lxlabs -g lxlabs -s '/sbin/nologin'");
    $list = array("which", "lxlighttpd", "zip", "unzip", "lxphp", "lxzend", "curl");
    if ($installtype !== 'slave') {
        $mysql = array("mysql", "mysql-server", "mysqlclient*");
        $list = array_merge($list, $mysql);
    }
    while (true) {
        run_package_installer($list);
        if (file_exists("/usr/local/lxlabs/ext/php/php")) {
            break;
        } else {
            print "Yum Gave Error... Trying Again...\n";
        }
    }
    if ($installtype !== 'slave') {
        check_default_mysql($dbroot, $dbpass);
    }
    $xenfailed = false;
    exec("killall wget");
    system("mkdir -p /usr/local/lxlabs/hypervm");
    chdir("/usr/local/lxlabs/hypervm");
    system("mkdir -p /usr/local/lxlabs/hypervm/log");
    @unlink("hypervm-current.zip");
    if (file_exists('.git')) {
        echo 'Development GIT version found. Skipping download sources.';
    } else {
        system("wget http://download.lxcenter.org/download/hypervm/production/hypervm/hypervm-current.zip");
    }
    system("unzip -oq hypervm-current.zip", $return);
    if ($return) {
        print "Unzipping the core Failed.. Most likely it is corrupted. Please contact the support personnel\n";
        exit;
    }
    unlink("hypervm-current.zip");
    system("chown -R lxlabs:lxlabs /usr/local/lxlabs/");
    $dir_name = dirname(__FILE__);
    fix_network_forwarding();
    system("mkdir -p /usr/local/lxlabs/hypervm/etc/");
    @unlink("/usr/local/lxlabs/hypervm/etc/install_xen");
    @unlink("/usr/local/lxlabs/hypervm/etc/install_openvz");
    touch("/usr/local/lxlabs/hypervm/etc/install_{$virtualization}");
    chdir("/usr/local/lxlabs/hypervm/httpdocs/");
    system("/bin/cp /usr/local/lxlabs/hypervm/httpdocs/htmllib/filecore/php.ini /usr/local/lxlabs/ext/php/etc/php.ini");
    system("/usr/local/lxlabs/ext/php/php ../bin/install/create.php --install-type={$installtype} --db-rootuser={$dbroot} --db-rootpassword={$dbpass}");
    //@ unlink("/usr/local/lxlabs/lxadmin/bin/install/create.php");
    system("chmod 755 /etc/init.d/hypervm");
    system("/sbin/chkconfig hypervm on");
    system("/sbin/chkconfig iptables off");
    $skiparg = null;
    if ($skipostemplate) {
        $skiparg = "--skipostemplate=true";
    }
    if ($virtualization === "NONE") {
        print "No Virtualization has been chosen. It is assumed that it is an existing installation\n";
    } else {
        print "Virtualization is {$virtualization}. Installing {$virtualization} Components\n";
    }
    //
    // call script to install base OS templates and OpenVZ repo
    //
    passthru("/usr/local/lxlabs/ext/php/php ../bin/install/virt-install.php --install-type={$installtype} --virtualization-type={$virtualization} {$skiparg}");
    print "Congratuations. HyperVM has been installed succesfully on your server as {$installtype} \n";
    if ($installtype === 'master') {
        print "You can connect to the server at https://<ip-address>:8887 or http://<ip-address>:8888\n";
        print "Please note that first is secure ssl connection, while the second is normal one.\n";
        print "The login and password are 'admin' 'admin'. After Logging in, you will have to change your password to something more secure.\n";
        print "Thanks for choosing HyperVM to manage your Server, and allowing us to be of service.\n";
    } else {
        print "You should open the port 8889 on this server, since this is used for the communication between master and slave.\n";
        print "To access this slave, go admin->slaves->add slave, give the ip/machine name of this server. The password is 'admin'. The slave will appear in the list of slaves, and you can access it just like you access localhost.\n";
    }
    if ($virtualization === 'openvz') {
        print "\n***There is one more step you have to do to make this complete. Open /etc/grub.conf, and change the 'default=1' line to 'default=0', and reboot this machine. You will be rebooted into the OpenVZ kernel and will able to manage VPSes from the HyperVM interface.\n";
    } else {
        if ($virtualization === 'xen') {
            print "\n**** You will have to reboot for the XEN kernel to take effect. Once rebooted, you will able to manage XEN virtual machines using the HyperVM interface.\n";
        }
    }
    print "\n\nExtra note:\n";
    print "To install extra XEN and/or OpenVZ OS templates please run:\n\n";
    print "sh /script/install-extra-ostemplates\n";
    print "\nThese template are left out the install process to speed up the HyperVM installation. By default only CentOS 5 and HostInBox(Kloxo) OS templates are installed.";
}
コード例 #2
0
ファイル: lxins.php プロジェクト: zseand/kloxo
function lxins_main()
{
    global $argv, $downloadserver;
    $opt = parse_opt($argv);
    $dir_name = dirname(__FILE__);
    $installtype = $opt['install-type'];
    $dbroot = isset($opt['db-rootuser']) ? $opt['db-rootuser'] : "******";
    $dbpass = isset($opt['db-rootpassword']) ? $opt['db-rootpassword'] : "";
    $osversion = find_os_version();
    $arch = `arch`;
    $arch = trim($arch);
    if (!char_search_beg($osversion, "centos") && !char_search_beg($osversion, "rhel")) {
        print "Kloxo is only supported on CentOS 5 and RHEL 5\n";
        exit;
    }
    if (file_exists("/usr/local/lxlabs/kloxo")) {
        // Ask Reinstall
        if (get_yes_no("Kloxo seems already installed do you wish to continue?") == 'n') {
            print "Installation Aborted.\n";
            exit;
        }
    } else {
        // Ask License
        if (get_yes_no("Kloxo is using AGPL-V3.0 License, do you agree with the terms?") == 'n') {
            print "You did not agree to the AGPL-V3.0 license terms.\n";
            print "Installation aborted.\n\n";
            exit;
        } else {
            print "Installing Kloxo = YES\n\n";
        }
    }
    // Ask for InstallApp
    print "InstallApp: PHP Applications like PHPBB, WordPress, Joomla etc\n";
    print "When you choose Yes, be aware of downloading about 350Mb of data!\n";
    if (get_yes_no("Do you want to install the InstallAPP sotfware?") == 'n') {
        print "Installing InstallApp = NO\n";
        print "You can install it later with /script/installapp-update\n\n";
        $installappinst = false;
    } else {
        print "Installing InstallApp = YES\n\n";
        $installappinst = true;
    }
    print "Adding System users and groups (nouser, nogroup and lxlabs, lxlabs)\n";
    system("groupadd nogroup");
    system("useradd nouser -g nogroup -s '/sbin/nologin'");
    system("groupadd lxlabs");
    system("useradd lxlabs -g lxlabs -s '/sbin/nologin'");
    print "Installing LxCenter yum repository for updates\n";
    install_yum_repo($osversion);
    $packages = array("sendmail", "sendmail-cf", "sendmail-doc", "sendmail-devel", "exim", "vsftpd", "postfix", "vpopmail", "qmail", "lxphp", "lxzend", "pure-ftpd", "imap");
    $list = implode(" ", $packages);
    print "Removing packages {$list}...\n";
    foreach ($packages as $package) {
        exec("rpm -e --nodeps {$package} > /dev/null 2>&1");
    }
    $packages = array("php-mbstring", "php-mysql", "which", "gcc-c++", "php-imap", "php-pear", "php-devel", "lxlighttpd", "httpd", "mod_ssl", "zip", "unzip", "lxphp", "lxzend", "mysql", "mysql-server", "curl", "autoconf", "automake", "libtool", "bogofilter", "gcc", "cpp", "openssl", "pure-ftpd", "yum-protectbase");
    $list = implode(" ", $packages);
    while (true) {
        print "Installing packages {$list}...\n";
        system("PATH=\$PATH:/usr/sbin yum -y install {$list}", $return_value);
        if (file_exists("/usr/local/lxlabs/ext/php/php")) {
            break;
        } else {
            print "Yum Gave Error... Trying Again...\n";
        }
    }
    print "Prepare installation directory\n";
    system("mkdir -p /usr/local/lxlabs/kloxo");
    chdir("/usr/local/lxlabs/kloxo");
    system("mkdir -p /usr/local/lxlabs/kloxo/log");
    @unlink("kloxo-current.zip");
    print "Downloading latest Kloxo release\n";
    system("wget " . $downloadserver . "download/kloxo/production/kloxo/kloxo-current.zip");
    print "\n\nInstalling Kloxo.....\n\n";
    system("unzip -oq kloxo-current.zip", $return);
    if ($return) {
        print "Unzipping the core Failed.. Most likely it is corrupted. Report it at http://forum.lxcenter.org/\n";
        exit;
    }
    unlink("kloxo-current.zip");
    system("chown -R lxlabs:lxlabs /usr/local/lxlabs/");
    chdir("/usr/local/lxlabs/kloxo/httpdocs/");
    system("service mysqld start");
    if ($installtype !== 'slave') {
        check_default_mysql($dbroot, $dbpass);
    }
    $mypass = password_gen();
    print "Prepare defaults and configurations...\n";
    system("/usr/local/lxlabs/ext/php/php {$dir_name}/installall.php");
    our_file_put_contents("/etc/sysconfig/spamassassin", "SPAMDOPTIONS=\" -v -d -p 783 -u lxpopuser\"");
    print "Creating Vpopmail database...\n";
    system("sh {$dir_name}/vpop.sh {$dbroot} \"{$dbpass}\" lxpopuser {$mypass}");
    system("chmod -R 755 /var/log/httpd/");
    system("chmod -R 755 /var/log/httpd/fpcgisock >/dev/null 2>&1");
    system("mkdir -p /var/log/kloxo/");
    system("mkdir -p /var/log/news");
    system("ln -sf /var/qmail/bin/sendmail /usr/sbin/sendmail");
    system("ln -sf /var/qmail/bin/sendmail /usr/lib/sendmail");
    system("echo `hostname` > /var/qmail/control/me");
    system("service qmail restart >/dev/null 2>&1 &");
    system("service courier-imap restart >/dev/null 2>&1 &");
    $dbfile = "/home/kloxo/httpd/webmail/horde/scripts/sql/create.mysql.sql";
    if (file_exists($dbfile)) {
        if ($dbpass == "") {
            system("mysql -u {$dbroot}  <{$dbfile}");
        } else {
            system("mysql -u {$dbroot} -p{$dbpass} <{$dbfile}");
        }
    }
    system("mkdir -p /home/kloxo/httpd");
    chdir("/home/kloxo/httpd");
    @unlink("skeleton-disable.zip");
    system("chown -R lxlabs:lxlabs /home/kloxo/httpd");
    system("/etc/init.d/kloxo restart >/dev/null 2>&1 &");
    chdir("/usr/local/lxlabs/kloxo/httpdocs/");
    system("/usr/local/lxlabs/ext/php/php /usr/local/lxlabs/kloxo/bin/install/create.php --install-type={$installtype} --db-rootuser={$dbroot} --db-rootpassword={$dbpass}");
    system("/usr/local/lxlabs/ext/php/php /usr/local/lxlabs/kloxo/bin/misc/secure-webmail-mysql.phps");
    system("/bin/rm /usr/local/lxlabs/kloxo/bin/misc/secure-webmail-mysql.phps");
    system("/script/centos5-postpostupgrade");
    if ($installappinst) {
        system("/script/installapp-update");
        // First run (gets installappdata)
        system("/script/installapp-update");
        // Second run (gets applications)
    }
    print "Congratulations. Kloxo has been installed succesfully on your server as {$installtype} \n";
    if ($installtype === 'master') {
        print "You can connect to the server at https://<ip-address>:7777 or http://<ip-address>:7778\n";
        print "Please note that first is secure ssl connection, while the second is normal one.\n";
        print "The login and password are 'admin' 'admin'. After Logging in, you will have to change your password to something more secure\n";
        print "We hope you will find managing your hosting with Kloxo refreshingly pleasurable, and also we wish you all the success on your hosting venture\n";
        print "Thanks for choosing Kloxo to manage your hosting, and allowing us to be of service\n";
    } else {
        print "You should open the port 7779 on this server, since this is used for the communication between master and slave\n";
        print "To access this slave, to go admin->servers->add server, give the ip/machine name of this server. The password is 'admin'. The slave will appear in the list of slaves, and you can access it just like you access localhost\n\n";
    }
}
コード例 #3
0
ファイル: kloxo-installer.php プロジェクト: zseand/kloxo
function lxins_main()
{
    global $argv, $downloadserver;
    $opt = parse_opt($argv);
    $dir_name = dirname(__FILE__);
    $installtype = $opt['install-type'];
    $installversion = isset($opt['version']) ? $opt['version'] : null;
    $dbroot = "root";
    $dbpass = "";
    $osversion = find_os_version();
    $arch = `arch`;
    $arch = trim($arch);
    //--- Create temporary flags for install
    system("mkdir -p /var/cache/kloxo/");
    system("echo 1 > /var/cache/kloxo/kloxo-install-firsttime.flg");
    if (!char_search_beg($osversion, "centos") && !char_search_beg($osversion, "rhel")) {
        print "Kloxo is only supported on CentOS 5 and RHEL 5\n";
        exit;
    }
    if (file_exists("/usr/local/lxlabs/kloxo")) {
        //--- Ask Reinstall
        if (get_yes_no("Kloxo seems already installed do you wish to continue?") == 'n') {
            print "Installation Aborted.\n";
            exit;
        }
    } else {
        //--- Ask License
        if (get_yes_no("Kloxo is using AGPL-V3.0 License, do you agree with the terms?") == 'n') {
            print "You did not agree to the AGPL-V3.0 license terms.\n";
            print "Installation aborted.\n\n";
            exit;
        } else {
            print "Installing Kloxo = YES\n\n";
        }
    }
    //--- Ask for InstallApp
    print "InstallApp: PHP Applications like PHPBB, WordPress, Joomla etc\n";
    print "When you choose Yes, be aware of downloading about 350Mb of data!\n";
    if (get_yes_no("Do you want to install the InstallAPP sotfware?") == 'n') {
        print "Installing InstallApp = NO\n";
        print "You can install it later with /script/installapp-update\n\n";
        $installappinst = false;
        //--- Temporary flag so InstallApp won't be installed
        system("echo 1 > /var/cache/kloxo/kloxo-install-disableinstallapp.flg");
    } else {
        print "Installing InstallApp = YES\n\n";
        $installappinst = true;
    }
    print "Adding System users and groups (nouser, nogroup and lxlabs, lxlabs)\n";
    system("groupadd nogroup");
    system("useradd nouser -g nogroup -s '/sbin/nologin'");
    system("groupadd lxlabs");
    system("useradd lxlabs -g lxlabs -s '/sbin/nologin'");
    print "Installing LxCenter yum repository for updates\n";
    install_yum_repo($osversion);
    $packages = array("sendmail", "sendmail-cf", "sendmail-doc", "sendmail-devel", "exim", "vsftpd", "postfix", "vpopmail", "qmail", "lxphp", "lxzend", "pure-ftpd", "imap");
    $list = implode(" ", $packages);
    print "Removing packages {$list}...\n";
    foreach ($packages as $package) {
        exec("rpm -e --nodeps {$package} > /dev/null 2>&1");
    }
    $packages = array("php-mbstring", "php-mysql", "which", "gcc-c++", "php-imap", "php-pear", "php-devel", "lxlighttpd", "httpd", "mod_ssl", "zip", "unzip", "lxphp", "lxzend", "mysql", "mysql-server", "curl", "autoconf", "automake", "libtool", "bogofilter", "gcc", "cpp", "openssl", "pure-ftpd", "yum-protectbase");
    $list = implode(" ", $packages);
    while (true) {
        print "Installing packages {$list}...\n";
        system("PATH=\$PATH:/usr/sbin yum -y install {$list}", $return_value);
        if (file_exists("/usr/local/lxlabs/ext/php/php")) {
            break;
        } else {
            print "YUM Gave Error... Trying Again...\n";
            if (get_yes_no("Try again?") == 'n') {
                print "- EXIT: Fix the problem and install Kloxo again.\n";
                exit;
            }
        }
    }
    print "Prepare installation directory\n";
    system("mkdir -p /usr/local/lxlabs/kloxo");
    if ($installversion) {
        if (substr($installversion, 0, 4) == '6.0.') {
            print "\n*** Need additional files installing {$installversion} (less then 6.1.0)***\n";
            print "      Run 'sh /script/kloxo-installer.sh' (without argument)\n\n";
            exit;
        }
        chdir("/usr/local/lxlabs/kloxo");
        system("mkdir -p /usr/local/lxlabs/kloxo/log");
        @unlink("/usr/local/lxlabs/kloxo/kloxo-current.zip");
        print "Downloading Kloxo {$installversion} release\n";
        system("wget {$downloadserver}download/kloxo/production/kloxo/kloxo-{$installversion}.zip");
        system("mv -f ./kloxo-{$installversion}.zip ./kloxo-current.zip");
    } else {
        if (file_exists("../kloxo-current.zip")) {
            //--- Install from local file if exists
            @unlink("/usr/local/lxlabs/kloxo/kloxo-current.zip");
            print "Local copying Kloxo release\n";
            system("mkdir -p /var/cache/kloxo");
            system("cp -rf ../kloxo-current.zip /usr/local/lxlabs/kloxo");
            //--- The first step - Remove packages
            system("rm -f /var/cache/kloxo/kloxo-thirdparty*.zip");
            system("rm -f /var/cache/kloxo/lxawstats*.tar.gz");
            system("rm -f /var/cache/kloxo/lxwebmail*.tar.gz");
            system("rm -f /var/cache/kloxo/kloxophpsixfour*.tar.gz");
            system("rm -f /var/cache/kloxo/kloxophp*.tar.gz");
            system("rm -f /var/cache/kloxo/*-version");
            //--- The second step - copy from packer script if exist
            system("cp -rf ../kloxo-thirdparty*.zip /var/cache/kloxo");
            system("cp -rf ../lxawstats*.tar.gz /var/cache/kloxo");
            system("cp -rf ../lxwebmail*.tar.gz /var/cache/kloxo");
            system("cp -rf ../kloxo-thirdparty-version /var/cache/kloxo");
            system("cp -rf ../lxawstats-version /var/cache/kloxo");
            system("cp -rf ../lxwebmail-version /var/cache/kloxo");
            if (file_exists("/usr/lib64")) {
                if (!is_link("/usr/lib/kloxophp")) {
                    system("rm -rf /usr/lib/kloxophp");
                }
                system("cp -rf ../kloxophpsixfour*.tar.gz /var/cache/kloxo");
                system("cp -rf ../kloxophpsixfour-version /var/cache/kloxo");
                system("mkdir -p /usr/lib64/kloxophp");
                system("ln -s /usr/lib64/kloxophp /usr/lib/kloxophp");
                system("mkdir -p /usr/lib64/php");
                system("ln -s /usr/lib64/php /usr/lib/php");
                system("mkdir -p /usr/lib64/httpd");
                system("ln -s /usr/lib64/httpd /usr/lib/httpd");
                system("mkdir -p /usr/lib64/lighttpd");
                system("ln -s /usr/lib64/lighttpd /usr/lib/lighttpd");
            } else {
                //--- Needs version checks in the future
                system("rename ../kloxophpsixfour ../_kloxophpsixfour ../kloxophpsixfour*");
                system("cp -rf ../kloxophp*.tar.gz /var/cache/kloxo");
                system("rename ../_kloxophpsixfour ../kloxophpsixfour ../_kloxophpsixfour*");
                system("cp -rf ../kloxophp-version /var/cache/kloxo");
            }
            chdir("/usr/local/lxlabs/kloxo");
            system("mkdir -p /usr/local/lxlabs/kloxo/log");
        } else {
            chdir("/usr/local/lxlabs/kloxo");
            system("mkdir -p /usr/local/lxlabs/kloxo/log");
            @unlink("/usr/local/lxlabs/kloxo/kloxo-current.zip");
            print "Downloading latest Kloxo release\n";
            system("wget {$downloadserver}download/kloxo/production/kloxo/kloxo-current.zip");
        }
    }
    print "\n\nInstalling Kloxo.....\n\n";
    system("unzip -oq kloxo-current.zip", $return);
    if ($return) {
        print "Unzipping the core Failed.. Most likely it is corrupted. Report it at http://forum.lxcenter.org/\n";
        exit;
    }
    unlink("kloxo-current.zip");
    system("chown -R lxlabs:lxlabs /usr/local/lxlabs/");
    chdir("/usr/local/lxlabs/kloxo/httpdocs/");
    system("service mysqld start");
    if ($installtype !== 'slave') {
        check_default_mysql($dbroot, $dbpass);
    }
    $mypass = password_gen();
    print "Prepare defaults and configurations...\n";
    install_main();
    file_put_contents("/etc/sysconfig/spamassassin", "SPAMDOPTIONS=\" -v -d -p 783 -u lxpopuser\"");
    print "\nCreating Vpopmail database...\n";
    system("sh {$dir_name}/kloxo-linux/vpop.sh {$dbroot} \"{$dbpass}\" lxpopuser {$mypass}");
    system("chmod -R 755 /var/log/httpd/");
    system("chmod -R 755 /var/log/httpd/fpcgisock >/dev/null 2>&1");
    system("mkdir -p /var/log/kloxo/");
    system("mkdir -p /var/log/news");
    system("ln -sf /var/qmail/bin/sendmail /usr/sbin/sendmail");
    system("ln -sf /var/qmail/bin/sendmail /usr/lib/sendmail");
    system("echo `hostname` > /var/qmail/control/me");
    system("service qmail restart >/dev/null 2>&1 &");
    system("service courier-imap restart >/dev/null 2>&1 &");
    print "Prepare /home/kloxo/httpd...\n";
    system("mkdir -p /home/kloxo/httpd");
    chdir("/home/kloxo/httpd");
    @unlink("skeleton-disable.zip");
    system("chown -R lxlabs:lxlabs /home/kloxo/httpd");
    system("/etc/init.d/kloxo restart >/dev/null 2>&1 &");
    chdir("/usr/local/lxlabs/kloxo/httpdocs/");
    system("/usr/local/lxlabs/ext/php/php /usr/local/lxlabs/kloxo/bin/install/create.php --install-type={$installtype} --db-rootuser={$dbroot} --db-rootpassword={$dbpass}");
    if ($installappinst) {
        print "Install InstallApp...\n";
        system("/script/installapp-update");
        // First run (gets installappdata)
        system("/script/installapp-update");
        // Second run (gets applications)
    }
    //--- Remove all temporary flags because the end of install
    print "\nRemove Kloxo install flags...\n";
    system("rm -rf /var/cache/kloxo/*-version");
    system("rm -rf /var/cache/kloxo/kloxo-install-*.flg");
    //--- Prevent mysql socket problem (especially on 64bit system)
    if (!file_exists("/var/lib/mysql/mysql.sock")) {
        print "Create mysql.sock...\n";
        system("/etc/init.d/mysqld stop");
        system("mksock /var/lib/mysql/mysql.sock");
        system("/etc/init.d/mysqld start");
    }
    //--- Prevent for Mysql not start after reboot for fresh kloxo slave install
    print "Setting Mysql for always running after reboot and restart now...\n";
    system("chkconfig mysqld on");
    system("service mysqld restart");
    //--- Fix for old thirdparty version
    if (!file_exists("/usr/local/lxlabs/kloxo/httpdocs/thirdparty")) {
        system("cp -rf /var/cache/kloxo/kloxo-thirdparty*.zip /usr/local/lxlabs/kloxo");
        system("cd /usr/local/lxlabs/kloxo; unzip -oq kloxo-thirdparty*.zip");
        system("chown -R lxlabs:lxlabs /usr/local/lxlabs/kloxo/httpdocs/thirdparty");
        system("chown -R lxlabs:lxlabs /usr/local/lxlabs/kloxo/httpdocs/htmllib");
        system("rm -f /usr/local/lxlabs/kloxo/kloxo-thirdparty*.zip");
    }
    //--- Set ownership for Kloxo httpdocs dir
    system("chown -R lxlabs:lxlabs /usr/local/lxlabs/kloxo/httpdocs");
    print "\nCongratulations. Kloxo has been installed succesfully on your server as {$installtype}\n\n";
    if ($installtype === 'master') {
        print "You can connect to the server at:\n";
        print "\thttps://<ip-address>:7777 - secure ssl connection, or\n";
        print "\thttp://<ip-address>:7778 - normal one.\n\n";
        print "The login and password are 'admin' 'admin'. After Logging in, you will have to\n";
        print "change your password to something more secure\n\n";
        print "We hope you will find managing your hosting with Kloxo\n";
        print "refreshingly pleasurable, and also we wish you all the success\n";
        print "on your hosting venture\n\n";
        print "Thanks for choosing Kloxo to manage your hosting, and allowing us to be of\n";
        print "service\n";
    } else {
        print "You should open the port 7779 on this server, since this is used for\n";
        print "the communication between master and slave\n\n";
        print "To access this slave, to go admin->servers->add server,\n";
        print "give the ip/machine name of this server. The password is 'admin'.\n\n";
        print "The slave will appear in the list of slaves, and you can access it\n";
        print "just like you access localhost\n\n";
    }
    print "\n";
    print "---------------------------------------------\n";
}
コード例 #4
0
ファイル: lxins.php プロジェクト: hypervm-ng/hypervm-ng
function lxins_main()
{
    global $argv;
    $opt = parse_opt($argv);
    $installtype = $opt['install-type'];
    $highmem = false;
    if (isset($opt['has-highmem'])) {
        $highmem = true;
    }
    if (!isset($opt['virtualization-type'])) {
        print "Need virtualization type --virtualization-type=xen/openvz/NONE\n";
        exit;
    } else {
        $virtualization = $opt['virtualization-type'];
    }
    $skipostemplate = false;
    if (isset($opt['skip-ostemplate'])) {
        $skipostemplate = true;
    }
    if (array_search($virtualization, array("xen", "openvz", "NONE")) === false) {
        print "Only xen/openvz/NONE are curently supported\n";
        exit;
    }
    $dbroot = isset($opt['db-rootuser']) ? $opt['db-rootuser'] : "******";
    $dbpass = isset($opt['db-rootpassword']) ? $opt['db-rootpassword'] : "";
    $osversion = find_os_version();
    if (file_exists("/usr/local/lxlabs/hypervm")) {
        print "HyperVM is installed do you wish to continue?(No/Yes):\n";
        flush();
        $stdin = fopen('php://stdin', 'r');
        $argq = fread($stdin, 5);
        $arg = trim($argq);
        if (!($arg == 'y' || $arg == 'yes' || $arg == 'Yes' || $arg == 'Y' || $arg == 'YES')) {
            print "Exiting.....\n";
            exit;
        }
    }
    if ($virtualization === 'xen') {
        if (!char_search_beg($osversion, "centos-6") && !char_search_beg($osversion, "centos-5") && !char_search_beg($osversion, "rhel-5") && !char_search_beg($osversion, "rhel-6")) {
            print "Xen is only supported on CentOS 5 and CentOS 6 distributions with HyperVM as management system\n";
            exit;
        }
    }
    if ($virtualization === 'openvz') {
        if (!char_search_beg($osversion, "centos-6") && !char_search_beg($osversion, "centos-5") && !char_search_beg($osversion, "rhel-5") && !char_search_beg($osversion, "rhel-6")) {
            print "OpenVZ is only supported on CentOS 5 and CentOS 6 distributions with HyperVM as management system\n";
            exit;
        }
    }
    //install_rhn_sources($osversion);
    install_yum_repo($osversion);
    exec("groupadd lxlabs");
    exec("useradd lxlabs -g lxlabs -s '/sbin/nologin'");
    // New since HyperVM 2.1.0 hypervm-core-php yum-plugin-replace
    $list = array("which", "lxlighttpd", "zip", "unzip", "hypervm-core-php", "curl", "yum-plugin-replace");
    /* Because our builder is on CentOS-6 the binaries like closeallinput are linked against libssl.so.10
     * To keep backward compatibility with RHEL-5 / CentOS-5 systems HyperVM-NG provides openssl10 package
     */
    if (char_search_beg($osversion, "centos-5") && char_search_beg($osversion, "rhel-5")) {
        $libssl = array("openssl10");
        $list = array_merge($list, $libssl);
    }
    if ($installtype !== 'slave') {
        $mysql = array("mysql", "mysql-server");
        $list = array_merge($list, $mysql);
    }
    // When installing development version, don't loop yum (.git found)
    if (!file_exists('/usr/local/lxlabs/.git')) {
        while (true) {
            run_package_installer($list);
            if (file_exists("/usr/local/lxlabs/ext/php/php")) {
                break;
            } else {
                // This can be a endless loop, needs another check!
                print "Yum Gave Error... Trying Again...\n";
            }
        }
    } else {
        run_package_installer($list);
    }
    if ($installtype !== 'slave') {
        check_default_mysql($dbroot, $dbpass);
    }
    $xenfailed = false;
    //  why is that?
    //	exec("killall wget");
    system("mkdir -p /usr/local/lxlabs/hypervm");
    chdir("/usr/local/lxlabs/hypervm");
    system("mkdir -p /usr/local/lxlabs/hypervm/log");
    // Prevents deleting the development package
    if (!file_exists('/usr/local/lxlabs/.git')) {
        @unlink("hypervm-current.zip");
    }
    if (file_exists('/usr/local/lxlabs/.git')) {
        echo 'Development GIT version found. Skipping download from HyperVM-NG.';
    } else {
        system("wget http://download.hypervm-ng.org/download/hypervm-ng/production/hypervm-current.zip");
    }
    system("unzip -oq hypervm-current.zip", $return);
    if ($return) {
        print "\nUnzipping the core Failed.. Most likely it is corrupted. Please contact the support personnel\n";
        exit;
    }
    unlink("hypervm-current.zip");
    system("chown -R lxlabs:lxlabs /usr/local/lxlabs/");
    $dir_name = dirname(__FILE__);
    fix_network_forwarding();
    system("mkdir -p /usr/local/lxlabs/hypervm/etc/");
    @unlink("/usr/local/lxlabs/hypervm/etc/install_xen");
    @unlink("/usr/local/lxlabs/hypervm/etc/install_openvz");
    touch("/usr/local/lxlabs/hypervm/etc/install_{$virtualization}");
    chdir("/usr/local/lxlabs/hypervm/httpdocs/");
    system("/bin/cp /usr/local/lxlabs/hypervm/httpdocs/htmllib/filecore/php.ini /usr/local/lxlabs/ext/php/etc/php.ini");
    system("/usr/local/lxlabs/ext/php/php ../bin/install/create.php --install-type={$installtype} --db-rootuser={$dbroot} --db-rootpassword={$dbpass}");
    system("chmod 755 /etc/init.d/hypervm");
    system("/sbin/chkconfig hypervm on");
    system("/sbin/chkconfig iptables off");
    $skiparg = null;
    if ($skipostemplate) {
        $skiparg = "--skipostemplate=true";
    }
    if ($virtualization === "NONE") {
        print "No Virtualization has been chosen. It is assumed that it is an existing installation\n";
    } else {
        print "Virtualization is {$virtualization}. Installing {$virtualization} Components\n";
    }
    //
    // call script to install base OS templates and OpenVZ repo
    //
    passthru("/usr/local/lxlabs/ext/php/php ../bin/install/virt-install.php --install-type={$installtype} --virtualization-type={$virtualization} {$skiparg}");
    echo smart_wordwrap("\n\n\nCongratulations!.\nHyperVM has been installed successfully on your server as {$installtype} \n");
    if ($installtype === 'master') {
        echo smart_wordwrap("\nYou can browse to the administration interface at:\n");
        echo smart_wordwrap("Secure - https://<ip-address>:8887\n");
        echo smart_wordwrap("Normal -  http://<ip-address>:8888\n\n");
        echo smart_wordwrap("The login and password are 'admin' 'admin'. After Logging in, you will have to change your password to something more secure.\n");
        echo smart_wordwrap("Thanks for choosing HyperVM to manage your Server, and allowing us to be of service.\n");
    } else {
        echo smart_wordwrap("You should open the port 8889 on this server, since this is used for the communication between master and slave.\n");
        echo smart_wordwrap("To access this slave, go admin->slaves->add slave, give the ip/machine name of this server. The password is 'admin'. The slave will appear in the list of slaves, and you can access it just like you access localhost.\n");
    }
    if ($virtualization === 'openvz') {
        echo smart_wordwrap("\n***There is one more step you have to do to make this complete. Open /etc/grub.conf, and change the 'default=1' line to 'default=0', and reboot this machine. You will be rebooted into the OpenVZ kernel and will able to manage VPSes from the HyperVM interface.\n");
    } else {
        if ($virtualization === 'xen') {
            echo smart_wordwrap("\n**** You will have to reboot for the XEN kernel to take effect. Once rebooted, you will able to manage XEN virtual machines using the HyperVM interface.\n");
        }
    }
    echo smart_wordwrap("\n\nExtra note:\n");
    echo smart_wordwrap("To install extra XEN and/or OpenVZ OS templates please run:\n\n");
    echo smart_wordwrap("sh /script/install-extra-ostemplates\n");
    echo smart_wordwrap("\nThese templates are left out the install process to speed up the HyperVM installation. By default only CentOS 5 and HostInBox(Kloxo) OS templates are installed.\n\n");
    echo smart_wordwrap("\n#!# Reboot your system to boot into the right kernel #!#\n\n");
    if (file_exists('/usr/local/lxlabs/.git')) {
        echo smart_wordwrap("Remember, you installed a Development version. Do not use it on production servers!\n\n");
    }
}