Some patch for phpunit

This commit is contained in:
fufroma 2014-03-21 15:04:09 +01:00
parent 7e32c58d96
commit 926adef79c
3 changed files with 88 additions and 11 deletions

View File

@ -26,8 +26,8 @@ require_once ALTERNC_PANEL."/class/functions.php";
// ********************* // *********************
if(is_readable('local.sh')){ if(is_readable('local.sh')){
$configFile = file_get_contents('local.sh', 'r'); $configFile = file_get_contents('local.sh', 'r');
} else if(is_readable('/etc/alternc/local.sh')){ } else if(is_readable('local.sh_generic')){
$configFile = file_get_contents('/etc/alternc/local.sh', 'r'); $configFile = file_get_contents('local.sh_generic', 'r');
} else { } else {
throw new Exception("You must provide a local.sh file", 1 ); throw new Exception("You must provide a local.sh file", 1 );
} }
@ -40,7 +40,8 @@ $compat = array('DEFAULT_MX' => 'MX',
); );
foreach ($configFile as $line) { foreach ($configFile as $line) {
if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $matches)) { 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]])) { if (isset($compat[$matches[1]])) {
$GLOBALS['L_'.$compat[$matches[1]]] = $matches[2]; $GLOBALS['L_'.$compat[$matches[1]]] = $matches[2];
} }
@ -51,14 +52,10 @@ foreach ($configFile as $line) {
// Constants and globals // Constants and globals
// ******************** // ********************
// Define constants from vars of /etc/alternc/local.sh // Define constants from vars of local.sh
if( isset ($L_ALTERNC_MAIL) ) { define('ALTERNC_MAIL', "$L_ALTERNC_MAIL");
define('ALTERNC_MAIL', "$L_ALTERNC_MAIL"); define('ALTERNC_HTML', "$L_ALTERNC_HTML");
}if( isset ($ALTERNC_HTML) ) { define('ALTERNC_LOGS', "$L_ALTERNC_LOGS");
define('ALTERNC_HTML', "$ALTERNC_HTML");
}if( isset ($ALTERNC_LOGS) ) {
define('ALTERNC_LOGS', "$ALTERNC_LOGS");
}
if(isset($L_ALTERNC_LOGS_ARCHIVE)){ if(isset($L_ALTERNC_LOGS_ARCHIVE)){
define('ALTERNC_LOGS_ARCHIVE', "$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/"); define('ALTERNC_VHOST_MANUALCONF', ALTERNC_VHOST_DIR."manual/");
$root = ALTERNC_PANEL."/"; $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 // Database variables setup
// *********************** // ***********************
@ -81,6 +84,9 @@ $password = "";
// Local override // Local override
if ( is_readable("my.cnf") ) { if ( is_readable("my.cnf") ) {
$mysqlConfigFile = file("my.cnf"); $mysqlConfigFile = file("my.cnf");
} else if(is_readable('my.cnf_generic')){
$mysqlConfigFile = file('my.cnf_generic');
foreach ($mysqlConfigFile as $line) { foreach ($mysqlConfigFile as $line) {
if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $matches)) { if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $matches)) {
switch ($matches[1]) { switch ($matches[1]) {

60
phpunit/local.sh_generic Executable file
View File

@ -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"

11
phpunit/my.cnf_generic Normal file
View File

@ -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=""