diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php index e42e3d63..a01d6017 100644 --- a/phpunit/bootstrap.php +++ b/phpunit/bootstrap.php @@ -26,8 +26,8 @@ require_once ALTERNC_PANEL."/class/functions.php"; // ********************* if(is_readable('local.sh')){ $configFile = file_get_contents('local.sh', 'r'); -} else if(is_readable('/etc/alternc/local.sh')){ - $configFile = file_get_contents('/etc/alternc/local.sh', 'r'); +} else if(is_readable('local.sh_generic')){ + $configFile = file_get_contents('local.sh_generic', 'r'); } else { throw new Exception("You must provide a local.sh file", 1 ); } @@ -40,7 +40,8 @@ $compat = array('DEFAULT_MX' => 'MX', ); foreach ($configFile as $line) { if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $matches)) { - $GLOBALS['L_'.$matches[1]] = $matches[2]; + //$GLOBALS['L_'.$matches[1]] = $matches[2]; + eval('$L_'.$matches[1].' = $matches[2];'); # Ugly, but work with phpunit... if (isset($compat[$matches[1]])) { $GLOBALS['L_'.$compat[$matches[1]]] = $matches[2]; } @@ -51,14 +52,10 @@ foreach ($configFile as $line) { // Constants and globals // ******************** -// Define constants from vars of /etc/alternc/local.sh -if( isset ($L_ALTERNC_MAIL) ) { - define('ALTERNC_MAIL', "$L_ALTERNC_MAIL"); -}if( isset ($ALTERNC_HTML) ) { - define('ALTERNC_HTML', "$ALTERNC_HTML"); -}if( isset ($ALTERNC_LOGS) ) { - define('ALTERNC_LOGS', "$ALTERNC_LOGS"); -} +// Define constants from vars of local.sh +define('ALTERNC_MAIL', "$L_ALTERNC_MAIL"); +define('ALTERNC_HTML', "$L_ALTERNC_HTML"); +define('ALTERNC_LOGS', "$L_ALTERNC_LOGS"); if(isset($L_ALTERNC_LOGS_ARCHIVE)){ define('ALTERNC_LOGS_ARCHIVE', "$L_ALTERNC_LOGS_ARCHIVE"); } @@ -71,6 +68,12 @@ define('ALTERNC_VHOST_FILE', ALTERNC_VHOST_DIR."vhosts_all.conf"); define('ALTERNC_VHOST_MANUALCONF', ALTERNC_VHOST_DIR."manual/"); $root = ALTERNC_PANEL."/"; +// Create test directory +foreach (array(ALTERNC_MAIL, ALTERNC_HTML, ALTERNC_LOGS) as $crdir ) { + if (! is_dir($crdir)) { + mkdir($crdir, 0777, true); + } +} // Database variables setup // *********************** @@ -81,6 +84,9 @@ $password = ""; // Local override if ( is_readable("my.cnf") ) { $mysqlConfigFile = file("my.cnf"); +} else if(is_readable('my.cnf_generic')){ + $mysqlConfigFile = file('my.cnf_generic'); + foreach ($mysqlConfigFile as $line) { if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $matches)) { switch ($matches[1]) { diff --git a/phpunit/local.sh_generic b/phpunit/local.sh_generic new file mode 100755 index 00000000..0a772c94 --- /dev/null +++ b/phpunit/local.sh_generic @@ -0,0 +1,60 @@ +#!/bin/sh +# +# AlternC - Web Hosting System - Configuration +# This file will be modified on package configuration +# (e.g. upgrade or dpkg-reconfigure alternc) + +# Hosting service name +HOSTING="AlternC" + +# Primary hostname for this box (will be used to access the management panel) +FQDN="phpunit-test.tld" + +# Public IP +PUBLIC_IP="128.66.0.42" + +# Internal IP +# (most of the time, should be equal to PUBLIC_IP, unless you are behind +# firewall doing address translation) +INTERNAL_IP="128.66.0.99" + +# Monitoring IP or network (will be allowed to access Apache status) +MONITOR_IP="" + +# Primary DNS hostname +NS1_HOSTNAME="phpunit-test.tld" + +# Secondary DNS hostname +NS2_HOSTNAME="phpunit-test.tld" + +# Mail server hostname +DEFAULT_MX="phpunit-test.tld" + +# Secondary mail server hostname +DEFAULT_SECONDARY_MX="" + +# Note: MySQL username/password configuration now stored in /etc/alternc/my.cnf + +# quels clients mysql sont permis (%, localhost, etc) +MYSQL_CLIENT="localhost" + +# the type of backup created by the sql backup script +# valid options are "rotate" (newsyslog-style) or "date" (suffix is the date) +SQLBACKUP_TYPE="rotate" + +# overwrite existing files when backing up +SQLBACKUP_OVERWRITE="no" + +# known slave servers, empty for none, localhost is special (no ssh) +ALTERNC_SLAVES="" + +# File to look at for forced launch of update_domain (use incron) +INOTIFY_UPDATE_DOMAIN="/var/run/alternc/inotify_update_domain.lock" + +INOTIFY_DO_ACTION="/var/run/alternc/inotify_do_action.lock" + +# Folder holding data (used for quota management) +ALTERNC_HTML="/tmp/var/www/alternc" +ALTERNC_MAIL="/tmp/var/mail/alternc" +ALTERNC_LOGS="/tmp/var/logs/alternc/sites" + diff --git a/phpunit/my.cnf_generic b/phpunit/my.cnf_generic new file mode 100644 index 00000000..3f536b8e --- /dev/null +++ b/phpunit/my.cnf_generic @@ -0,0 +1,11 @@ +# AlternC - Web Hosting System - MySQL Configuration +# Automatically generated by AlternC configuration, do not edit +# This file will be modified on package configuration +# (e.g. upgrade or dpkg-reconfigure alternc) +[mysql] +database="alternc_test" + +[client] +host="127.0.0.1" +user="root" +password=""