Ejemplo n.º 1
0
 function backup_databases2($dbs, $mysqlusers, $file)
 {
     # set empty file then fill with dump of each mysql database, in ehcp, (before vers 0.27: all databases were dumped, that caused: malfunction because of restore of mysql db itself... now, mysql db is not restored... so, passwords of new mysql server are kept after restore... )
     print_r($dbs);
     if (count($dbs) > 0) {
         foreach ($dbs as $db) {
             $sql = "create database if not exists " . $db['dbname'] . ";\n";
             $sql .= "use " . $db['dbname'] . ";\n";
             writeoutput2($file, $sql, "a");
             $cmd = escapeshellcmd("mysqldump " . $db['dbname'] . " -u root --password="******" >> " . escapeshellcmd($file);
             passthru3($cmd, __FUNCTION__);
         }
     }
     if (count($mysqlusers) > 0) {
         foreach ($mysqlusers as $user) {
             #print_r($user);
             $dbname = $user['dbname'];
             $dbusername = $user['dbusername'];
             $dbuserpass = $user['password'];
             $sql = "grant all privileges on {$dbname}.* to '{$dbusername}'@'localhost' identified by '{$dbuserpass}' ;";
             writeoutput2($file, $sql, "a");
         }
     }
     // Flush privileges to activate the new user accounts and passwords
     $fixAccounts = "\nFLUSH PRIVILEGES ;";
     writeoutput2($file, $fixAccounts, "a");
 }
Ejemplo n.º 2
0
function rebuild_apache2_config2()
{
    global $app, $ehcpinstalldir;
    echo "* installpath set as: {$ehcpinstalldir} \n";
    $tarih = date("YmdHis");
    passthru2("cp -rf /etc/apache2 /etc/apache2.backupbyehcp.{$tarih}");
    addifnotexists("Include {$ehcpinstalldir}/apachehcp_subdomains.conf ", "/etc/apache2/apache2.conf");
    addifnotexists("Include {$ehcpinstalldir}/apachehcp_auth.conf ", "/etc/apache2/apache2.conf");
    addifnotexists("Include {$ehcpinstalldir}/apachehcp_passivedomains.conf ", "/etc/apache2/apache2.conf");
    addifnotexists("Include {$ehcpinstalldir}/apachehcp.conf", "/etc/apache2/apache2.conf");
    #replacelineinfile('NameVirtualHost','NameVirtualHost *','/etc/apache2/ports.conf');
    #editlineinfile("Options Indexes","Options -Indexes","/etc/apache2/sites-enabled/000-default");
    addifnotexists("ServerName myserver", "/etc/apache2/apache2.conf");
    if (file_exists("/etc/apache2/envvars")) {
        replacelineinfile("export APACHE_RUN_USER="******"export APACHE_RUN_USER="******"/etc/apache2/envvars");
        replacelineinfile("export APACHE_RUN_GROUP=", "export APACHE_RUN_GROUP=" . $app->wwwgroup, "/etc/apache2/envvars");
        addifnotexists("umask 111", "/etc/apache2/envvars");
        # newly added files wil have rw-rw-rw- permission, allowing all to read-write them. this will enable vsftpd to delete webserver-generated files.. before this, those files could not be deleted...
    } else {
        replacelineinfile("User ", "User " . $app->wwwuser, "/etc/apache2/apache2.conf");
        replacelineinfile("User ", "Group " . $app->wwwgroup, "/etc/apache2/apache2.conf");
    }
    #replacelineinfile('DocumentRoot /','DocumentRoot /var/www','/etc/apache2/sites-available/default');
    passthru2("cp -vf /etc/apache2/sites-available/default /etc/apache2/sites-available/default.original.{$tarih}");
    # backup original apache default conf
    passthru2("cp -vf {$ehcpinstalldir}/etc/apache2/default /etc/apache2/sites-available/default");
    # write new conf with new settings that has -Indexes and so on... may be disabled, may be incompatible with future versions of apache2
    copy("/etc/apache2/sites-available/default", "/etc/apache2/sites-available/default.backupbyehcp." . date("YmdHis"));
    # backup old config..
    passthru2("cp -vf {$ehcpinstalldir}/etc/apache2/default /etc/apache2/sites-available/000-default");
    passthru2("cp -vf {$ehcpinstalldir}/etc/apache2/apachetemplate_ipbased {$ehcpinstalldir}/");
    passthru2("cp -vf {$ehcpinstalldir}/etc/apache2/apachetemplate {$ehcpinstalldir}/");
    passthru2("cp -vf {$ehcpinstalldir}/etc/apache2/apachetemplate_passivedomains {$ehcpinstalldir}/");
    passthru2("cp -vf {$ehcpinstalldir}/etc/apache2/apache_subdomain_template {$ehcpinstalldir}/");
    passthru2("cp -vf {$ehcpinstalldir}/etc/apache2/ports.conf /etc/apache2/");
    passthru3("rm -rvf /etc/apache2/sites-enabled/*");
    passthru2("cp -vf {$ehcpinstalldir}/etc/apache2/default /etc/apache2/sites-enabled/");
    #passthru2("ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load");
    passthru2("a2enmod rewrite");
    passthru2("a2enmod php5");
    passthru2("a2enmod expires");
    passthru2("a2enmod headers");
    passthru2("cp -vf /etc/apache2/mods-available/php5.* /etc/apache2/mods-enabled/");
    passthru("cp ./wwwindex.html /var/www/apache2-default/index.html");
    passthru("cp -rvf ./images_default_index /var/www/apache2-default/");
    # default apache setting
    passthru("cp ./wwwindex.html /var/www/index.html");
    passthru("cp -rvf ./images_default_index /var/www/");
    # new ehcp setting since ver 0.29.15 - added at 13.11.2010
    passthru2("mkdir -p /var/www/new");
    passthru("cp ./wwwindex.html /var/www/new/index.html");
    passthru("cp -rvf ./images_default_index /var/www/new/");
    passthru("cp ./ehcp /etc/init.d/");
    passthru("cp ./ehcp_daemon.py /etc/init.d/");
    passthru("chmod a+r /var/www/apache2-default/index.html");
    passthru("chmod a+r /var/www/index.html");
    bosluk2();
}