Merge branch 'master' of alternc.org:alternc into feature-ssl
This commit is contained in:
commit
c7b32fc62d
|
@ -126,11 +126,11 @@ foreach ($domains as $key => $domain) {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
# 2.1 keep a copy of where it was, in an SQL request
|
# 2.1 keep a copy of where it was, in an SQL request
|
||||||
$backup .= "UPDATE `sub_domaines` SET `type`='$type', valeur='$dest',web_action='UPDATE' WHERE `domaine`='$domain' AND sub='$sub';\n";
|
$backup .= "UPDATE `sub_domaines` SET `type`='$type', valeur='$dest',web_action='UPDATE' WHERE id=" . $r['sub'][$k]['id'] . ";\n";
|
||||||
|
|
||||||
# 2.2 change the subdomain to redirect to http://spam.koumbit.org/
|
# 2.2 change the subdomain to redirect to http://spam.koumbit.org/
|
||||||
$dom->lock();
|
$dom->lock();
|
||||||
if (!$dom->set_sub_domain($domain, $sub, $dom->type_url, $redirect)) {
|
if (! $db->query("UPDATE `sub_domaines` SET `type`='" . $dom->type_url . "', valeur='$redirect',web_action='UPDATE' WHERE id=" . $r['sub'][$k]['id'] . ";\n") ) {
|
||||||
print "-- error in $sub.$domain: " . $err->errstr() . "\n";
|
print "-- error in $sub.$domain: " . $err->errstr() . "\n";
|
||||||
}
|
}
|
||||||
$dom->unlock();
|
$dom->unlock();
|
||||||
|
@ -141,6 +141,36 @@ foreach ($domains as $key => $domain) {
|
||||||
if (!$confirmed) print '</ul>';
|
if (!$confirmed) print '</ul>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$mail_dom = $mail->enum_domains();
|
||||||
|
|
||||||
|
if ($confirmed) {
|
||||||
|
print "<pre>";
|
||||||
|
printf(_("-- disabling all the mail passwords\n"));
|
||||||
|
}
|
||||||
|
if (!$confirmed) print "\n<li>mailboxes<ul>\n";
|
||||||
|
reset($mail_dom);
|
||||||
|
# 1.3 foreach mail domain, we list the email hashes
|
||||||
|
foreach ($mail_dom as $key => $domain) {
|
||||||
|
if (!$confirmed) print '' . $domain['domaine'] . '</h4><ul>';
|
||||||
|
$mails = $mail->enum_domain_mails($domain['id']);
|
||||||
|
foreach ($mails as $key => $add) {
|
||||||
|
if ($add['islocal']) {
|
||||||
|
if (!$confirmed) print '<li>' . $add['address'] . '@' . $domain['domaine'];
|
||||||
|
$pass = $add['password'];
|
||||||
|
$id = $add['id'];
|
||||||
|
$backup .= $b = "update address set password='$pass' where id=$id;\n";
|
||||||
|
if (!$confirmed) print "<!-- $b --></li>\n";
|
||||||
|
if ($confirmed) {
|
||||||
|
$db->query("update `address` set password='!$pass' where id=$id;\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$confirmed) print "</ul>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!$confirmed) print "</ul></li></ul>\n";
|
||||||
|
|
||||||
# 3. wrap up (?)
|
# 3. wrap up (?)
|
||||||
if ($confirmed) {
|
if ($confirmed) {
|
||||||
print "-- The following is a serie of SQL request you can run, as root, to revert the user's domains to their previous state.\n";
|
print "-- The following is a serie of SQL request you can run, as root, to revert the user's domains to their previous state.\n";
|
||||||
|
|
|
@ -32,6 +32,10 @@ if (!$mem->del_session()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$H=getenv("HTTP_HOST");
|
$H=getenv("HTTP_HOST");
|
||||||
|
if (variable_get('https_redirect', false, 'switch users to HTTPS') && !isset($_SERVER['HTTPS'])) {
|
||||||
|
header("Location: https://$H/");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($restrictip)) {
|
if (!isset($restrictip)) {
|
||||||
$restrictip=1;
|
$restrictip=1;
|
||||||
|
@ -74,7 +78,7 @@ if ( empty($logo) || ! $logo ) {
|
||||||
<br/>
|
<br/>
|
||||||
<?php
|
<?php
|
||||||
if (isset($_GET['authip_token'])) $authip_token=$_GET['authip_token'];
|
if (isset($_GET['authip_token'])) $authip_token=$_GET['authip_token'];
|
||||||
if (variable_get('https_warning', true, 'warn users to switch to HTTPS') && !isset($_SERVER['HTTPS'])) {
|
if (!isset($_SERVER['HTTPS'])) {
|
||||||
echo '<h4>' . sprintf(_('WARNING: you are trying to access the control panel insecurely, click <a href="https://%s">here</a> to go to secure mode'), $_SERVER["HTTP_HOST"]) . '</h4>';
|
echo '<h4>' . sprintf(_('WARNING: you are trying to access the control panel insecurely, click <a href="https://%s">here</a> to go to secure mode'), $_SERVER["HTTP_HOST"]) . '</h4>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -32,13 +32,18 @@ require_once("../class/config.php");
|
||||||
if (!$r=$mysql->php_myadmin_connect()) {
|
if (!$r=$mysql->php_myadmin_connect()) {
|
||||||
$error=$err->errstr();
|
$error=$err->errstr();
|
||||||
} else {
|
} else {
|
||||||
|
session_write_close();
|
||||||
// SSO of PhpMyAdmin
|
// SSO of PhpMyAdmin
|
||||||
|
session_set_cookie_params(0, '/', '', 0);
|
||||||
|
session_name('AlternC_Panel');
|
||||||
|
session_start();
|
||||||
$_SESSION['PMA_single_signon_user'] = $r["login"];
|
$_SESSION['PMA_single_signon_user'] = $r["login"];
|
||||||
$_SESSION['PMA_single_signon_password'] = $r["pass"];
|
$_SESSION['PMA_single_signon_password'] = $r["pass"];
|
||||||
$_SESSION['PMA_single_signon_host'] = $r["host"]; // pma >= 2.11
|
$_SESSION['PMA_single_signon_host'] = $r["host"]; // pma >= 2.11
|
||||||
|
|
||||||
|
session_write_close();
|
||||||
// finally redirect to phpMyAdmin :
|
// finally redirect to phpMyAdmin :
|
||||||
header("Location: /alternc-sql/");
|
header("Location: /alternc-sql/index.php?server=1");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,9 +91,9 @@ class DB_Sql {
|
||||||
/* establish connection, select database */
|
/* establish connection, select database */
|
||||||
if ( 0 == $this->Link_ID ) {
|
if ( 0 == $this->Link_ID ) {
|
||||||
|
|
||||||
$this->Link_ID=mysql_pconnect($Host, $User, $Password);
|
$this->Link_ID=mysql_connect($Host, $User, $Password);
|
||||||
if (!$this->Link_ID) {
|
if (!$this->Link_ID) {
|
||||||
$this->halt("pconnect($Host, $User, \$Password) failed.");
|
$this->halt("connect($Host, $User, \$Password) failed.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,11 @@ class m_bro {
|
||||||
$root_alternc=$root ;
|
$root_alternc=$root ;
|
||||||
// Passage du root en chemin rel (diffrent avec un lien)
|
// Passage du root en chemin rel (diffrent avec un lien)
|
||||||
$root=realpath($root) ;
|
$root=realpath($root) ;
|
||||||
|
if (! $root=realpath($root)) {
|
||||||
|
// Guillaume: it needed to work.. if file doesn't exist it need to crash
|
||||||
|
// gently
|
||||||
|
$root=$root_alternc;
|
||||||
|
}
|
||||||
// separer le chemin entre le repertoire et le fichier
|
// separer le chemin entre le repertoire et le fichier
|
||||||
$file=basename($dir);
|
$file=basename($dir);
|
||||||
$dir=dirname($dir);
|
$dir=dirname($dir);
|
||||||
|
@ -556,7 +561,7 @@ class m_bro {
|
||||||
* @return boolean TRUE Si les fichiers ont t renomms, FALSE si une erreur s'est produite.
|
* @return boolean TRUE Si les fichiers ont t renomms, FALSE si une erreur s'est produite.
|
||||||
*/
|
*/
|
||||||
function ChangePermissions($R,$d,$perm,$verbose=false) {
|
function ChangePermissions($R,$d,$perm,$verbose=false) {
|
||||||
global $err;
|
global $err, $action;
|
||||||
$absolute=$this->convertabsolute($R,false);
|
$absolute=$this->convertabsolute($R,false);
|
||||||
if (!$absolute) {
|
if (!$absolute) {
|
||||||
$err->raise("bro",_("File or folder name is incorrect"));
|
$err->raise("bro",_("File or folder name is incorrect"));
|
||||||
|
@ -1025,6 +1030,9 @@ class m_bro {
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
$d=escapeshellarg(".".$this->convertabsolute($dir,true));
|
$d=escapeshellarg(".".$this->convertabsolute($dir,true));
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
// relacher le lock global sinon ce download va geler alternc pour
|
||||||
|
// tout le monde
|
||||||
|
alternc_shutdown();
|
||||||
passthru("/bin/tar -cZ -C ".getuserpath()."/".$mem->user["login"]."/ $d");
|
passthru("/bin/tar -cZ -C ".getuserpath()."/".$mem->user["login"]."/ $d");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,6 +1051,9 @@ class m_bro {
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
$d=escapeshellarg(".".$this->convertabsolute($dir,true));
|
$d=escapeshellarg(".".$this->convertabsolute($dir,true));
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
// relacher le lock global sinon ce download va geler alternc pour
|
||||||
|
// tout le monde
|
||||||
|
alternc_shutdown();
|
||||||
passthru("/bin/tar -cz -C ".getuserpath()."/ $d");
|
passthru("/bin/tar -cz -C ".getuserpath()."/ $d");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1061,6 +1072,9 @@ class m_bro {
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
$d=escapeshellarg(".".$this->convertabsolute($dir,true));
|
$d=escapeshellarg(".".$this->convertabsolute($dir,true));
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
// relacher le lock global sinon ce download va geler alternc pour
|
||||||
|
// tout le monde
|
||||||
|
alternc_shutdown();
|
||||||
passthru("/bin/tar -cj -C ".getuserpath()."/ $d");
|
passthru("/bin/tar -cj -C ".getuserpath()."/ $d");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1172,6 +1186,9 @@ class m_bro {
|
||||||
}
|
}
|
||||||
$timestamp=date("H:i:s");
|
$timestamp=date("H:i:s");
|
||||||
|
|
||||||
|
// relacher le lock global sinon ce download va geler alternc pour
|
||||||
|
// tout le monde
|
||||||
|
alternc_shutdown();
|
||||||
if(exec("/bin/tar cvf - ".getuserpath()."/ | gzip -9c > ".$dir."/".$mem->user['login']."_html_".$timestamp.".tar.gz")){
|
if(exec("/bin/tar cvf - ".getuserpath()."/ | gzip -9c > ".$dir."/".$mem->user['login']."_html_".$timestamp.".tar.gz")){
|
||||||
$err->log("bro","export_data_succes");
|
$err->log("bro","export_data_succes");
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -734,7 +734,7 @@ class m_dom {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($dns && $v == -3) {
|
if ($dns && $v == -3) {
|
||||||
$err->raise("dom", _("The domain cannot be found in the whois database"));
|
$err->raise("dom", _("The name servers referenced by this domain do not match those referenced by this AlternC instance"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -996,7 +996,7 @@ class m_dom {
|
||||||
$ligne = preg_replace("/^ *([^ ]*) \(.*\)$/", "\\1", trim($ligne));
|
$ligne = preg_replace("/^ *([^ ]*) \(.*\)$/", "\\1", trim($ligne));
|
||||||
if ($found)
|
if ($found)
|
||||||
$tmp = trim($ligne);
|
$tmp = trim($ligne);
|
||||||
if ($tmp)
|
if (isset($tmp) && $tmp)
|
||||||
$serveurList[] = $tmp;
|
$serveurList[] = $tmp;
|
||||||
if ($ligne == "Nameservers:") {
|
if ($ligne == "Nameservers:") {
|
||||||
$state = 1;
|
$state = 1;
|
||||||
|
|
|
@ -112,6 +112,10 @@ class m_piwik {
|
||||||
$user_creation_date = $user->date_registered;
|
$user_creation_date = $user->date_registered;
|
||||||
return $db->query("INSERT INTO piwik_users (uid, login, created_date) VALUES ('$cuid', '$user_login', '$user_creation_date')");
|
return $db->query("INSERT INTO piwik_users (uid, login, created_date) VALUES ('$cuid', '$user_login', '$user_creation_date')");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$err->raise('piwik', $api_data->message);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
} else { // api_data = false -> error is already filled
|
} else { // api_data = false -> error is already filled
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ class m_quota {
|
||||||
}
|
}
|
||||||
reset($this->disk);
|
reset($this->disk);
|
||||||
|
|
||||||
if (!empty ($this->disk)) { // Check if there are some disk quota to check
|
if ($this->disk_quota_enable && !empty ($this->disk)) { // Check if there are some disk quota to check
|
||||||
// Look if there are some cached value
|
// Look if there are some cached value
|
||||||
$disk_cached = $mem->session_tempo_params_get('quota_cache_disk');
|
$disk_cached = $mem->session_tempo_params_get('quota_cache_disk');
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,13 @@ case "$1" in
|
||||||
|
|
||||||
dpkg-statoverride --list /etc/roundcube/debian-db.php >/dev/null &&
|
dpkg-statoverride --list /etc/roundcube/debian-db.php >/dev/null &&
|
||||||
dpkg-statoverride --remove /etc/roundcube/debian-db.php
|
dpkg-statoverride --remove /etc/roundcube/debian-db.php
|
||||||
chown -R www-data:root /etc/roundcube/debian-db.php
|
chown root:www-data /etc/roundcube/debian-db.php
|
||||||
chmod -R 460 /etc/roundcube/debian-db.php
|
chmod 640 /etc/roundcube/debian-db.php
|
||||||
|
|
||||||
dpkg-statoverride --list /etc/roundcube/main.inc.php >/dev/null &&
|
dpkg-statoverride --list /etc/roundcube/main.inc.php >/dev/null &&
|
||||||
dpkg-statoverride --remove /etc/roundcube/main.inc.php
|
dpkg-statoverride --remove /etc/roundcube/main.inc.php
|
||||||
chown -R www-data:root /etc/roundcube/main.inc.php
|
chown root:www-data /etc/roundcube/main.inc.php
|
||||||
chmod -R 460 /etc/roundcube/main.inc.php
|
chmod 640 /etc/roundcube/main.inc.php
|
||||||
|
|
||||||
dpkg-statoverride --list /var/log/roundcube >/dev/null &&
|
dpkg-statoverride --list /var/log/roundcube >/dev/null &&
|
||||||
dpkg-statoverride --remove /var/log/roundcube
|
dpkg-statoverride --remove /var/log/roundcube
|
||||||
|
|
|
@ -192,7 +192,20 @@ protocol imap {
|
||||||
}
|
}
|
||||||
|
|
||||||
service imap {
|
service imap {
|
||||||
executable = /usr/lib/alternc/popimap-log-login.sh /usr/lib/dovecot/imap
|
# tell imap to do post-login lookup using a socket called "imap-postlogin"
|
||||||
|
executable = imap postlogin
|
||||||
|
}
|
||||||
|
|
||||||
|
# The service name below doesn't actually matter.
|
||||||
|
service postlogin {
|
||||||
|
# all post-login scripts are executed via script-login binary
|
||||||
|
executable = script-login /usr/lib/alternc/popimap-log-login.sh
|
||||||
|
|
||||||
|
# the script process runs as the user specified here (v2.0.14+):
|
||||||
|
#user = $default_internal_user
|
||||||
|
# this UNIX socket listener must use the same name as given to imap executable
|
||||||
|
unix_listener postlogin {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,7 +260,8 @@ protocol pop3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
service pop3 {
|
service pop3 {
|
||||||
executable = /usr/lib/alternc/popimap-log-login.sh /usr/lib/dovecot/pop3
|
# tell imap to do post-login lookup using a socket called "imap-postlogin"
|
||||||
|
executable = pop3 postlogin
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
|
@ -114,5 +114,7 @@ mailman unix - n n - - pipe
|
||||||
#dovecot LDA, as explained here: http://wiki.dovecot.org/LDA/Postfix
|
#dovecot LDA, as explained here: http://wiki.dovecot.org/LDA/Postfix
|
||||||
dovecot unix - n n - 0 pipe
|
dovecot unix - n n - 0 pipe
|
||||||
flags=DRhu user=vmail:vmail argv=/usr/bin/sudo /usr/lib/dovecot/deliver -f ${sender} -a ${recipient} -d ${user}@${nexthop}
|
flags=DRhu user=vmail:vmail argv=/usr/bin/sudo /usr/lib/dovecot/deliver -f ${sender} -a ${recipient} -d ${user}@${nexthop}
|
||||||
|
#smtp inet n - n - 1 postscreen
|
||||||
|
#smtpd pass - - n - - smtpd
|
||||||
|
#dnsblog unix - - n - 0 dnsblog
|
||||||
|
#tlsproxy unix - - n - 0 tlsproxy
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
# Purpose of file: Main install script, launch it anytime ;)
|
# Purpose of file: Main install script, launch it anytime ;)
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
# Somes check before start operations
|
# Somes check before start operations
|
||||||
if [ `id -u` -ne 0 ]; then
|
if [ `id -u` -ne 0 ]; then
|
||||||
echo "must be launched as root"
|
echo "must be launched as root"
|
||||||
|
@ -528,7 +530,7 @@ tar -zcf "$INSTALLED_CONFIG_TAR" -C / $CONFIG_FILES
|
||||||
# Last touches
|
# Last touches
|
||||||
#
|
#
|
||||||
|
|
||||||
find $ALTERNC_HTML -maxdepth 1 -type d -exec setfacl -b -k -m d:g:alterncpanel:rw- -m d:u:alterncpanel:rw- -m u:alterncpanel:rw- -m g:alterncpanel:rw- {} \;
|
find $ALTERNC_HTML -maxdepth 1 -type d -exec setfacl -b -k -m d:g:alterncpanel:rwx -m d:u:alterncpanel:rwx -m u:alterncpanel:rwx -m g:alterncpanel:rwx {} \;
|
||||||
|
|
||||||
#creating log file
|
#creating log file
|
||||||
if [ ! -e "/var/log/alternc/bureau.log" ]; then
|
if [ ! -e "/var/log/alternc/bureau.log" ]; then
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE `actions` CHANGE `type` `type` ENUM('CREATE_FILE','FIX_USER','CREATE_DIR','DELETE','MOVE','FIX_DIR','FIX_FILE','CHMOD') DEFAULT NULL ;
|
||||||
|
|
|
@ -25,6 +25,45 @@ class Alternc_Diagnostic_Data {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// recursive rebuild
|
||||||
|
function buildFromArray( $content ){
|
||||||
|
|
||||||
|
if( ! $this->isValidArrayData( $content ) ) {
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
$type = $content["type"];
|
||||||
|
$newInstance = new Alternc_Diagnostic_Data( $type );
|
||||||
|
$newInstance->index = $content["index"];
|
||||||
|
$newInstance->metadata = $content["metadata"];
|
||||||
|
$data = $content["data"];
|
||||||
|
// The content is raw
|
||||||
|
if( $type === self::TYPE_SECTION){
|
||||||
|
$newInstance->data = $data;
|
||||||
|
}
|
||||||
|
// The content is made of services or sections
|
||||||
|
else foreach( $content["data"] as $section_name => $sectionData ){
|
||||||
|
$sectionContent = $this->buildFromArray( $sectionData );
|
||||||
|
$newInstance->addData( $section_name, $sectionContent );
|
||||||
|
}
|
||||||
|
return $newInstance;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure we have a valid format result
|
||||||
|
function isValidArrayData( $content ){
|
||||||
|
if(
|
||||||
|
!is_array($content)
|
||||||
|
|| !array_key_exists( "type", $content )
|
||||||
|
|| !array_key_exists("metadata",$content)
|
||||||
|
|| !array_key_exists("index",$content)
|
||||||
|
|| !array_key_exists("data",$content)
|
||||||
|
|| ! in_array( $content["type"], array(self::TYPE_ROOT,self::TYPE_DOMAIN,self::TYPE_SECTION) ) ){
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets
|
* Sets
|
||||||
|
|
|
@ -1,28 +1,83 @@
|
||||||
<?php
|
<?php
|
||||||
|
error_reporting( E_ERROR );
|
||||||
|
|
||||||
|
|
||||||
class Alternc_Diagnostic_Diff{
|
class Alternc_Diagnostic_Diff{
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param type $file_reference_1
|
|
||||||
* Either a number or a string refering to the file
|
|
||||||
* Default = Last file
|
|
||||||
* @param type $file_reference_2
|
|
||||||
* Either a number or a string refering to the file
|
|
||||||
* Default = pre-last file
|
|
||||||
*/
|
|
||||||
function compare($file_reference_1, $file_reference_2){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a file by reference or name
|
|
||||||
*
|
*
|
||||||
* @param string $file_reference
|
|
||||||
* @return Alternc_Diagnostic_Data Resulting data
|
|
||||||
*/
|
*/
|
||||||
function resolve( $file_reference){
|
function compare(Alternc_Diagnostic_Data $source, Alternc_Diagnostic_Data $target ){
|
||||||
|
|
||||||
|
$sourceIndex = $source->getIndex();
|
||||||
|
$targetIndex = $target->getIndex();
|
||||||
|
// Check diagnostics are same level
|
||||||
|
$source_type = $source->getType();
|
||||||
|
$target_type = $target->getType();
|
||||||
|
if( $source_type != $target_type){
|
||||||
|
throw new \Exception("Invalid type comparison requested: $source_type vs $target_type");
|
||||||
|
}
|
||||||
|
$diffInstance = new Alternc_Diagnostic_Data( $source_type );
|
||||||
|
|
||||||
|
#echo "type $source_type\n";
|
||||||
|
// Compare general data
|
||||||
|
if( $source->getMetadata() != $target->getMetadata() ){
|
||||||
|
$diffInstance->setMetadata( array_diff( $source->getMetadata(), $target->getMetadata() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $source->getIndex() != $target->getIndex() ){
|
||||||
|
$diffInstance->setIndex( array_diff( $source->getIndex(), $target->getIndex() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// If section content ie. no subsections
|
||||||
|
if( $source_type == Alternc_Diagnostic_Data::TYPE_SECTION ){
|
||||||
|
#echo "Real section\n";
|
||||||
|
if( is_array( $source->getData() ) && is_array( $target->getData() ) ){
|
||||||
|
|
||||||
|
$diff = array_diff( $source->getData(), $target->getData() ) ;
|
||||||
|
if( $diff ){
|
||||||
|
$diffInstance->setData( array_diff( $source->getData(), $target->getData()) );
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if( $source->getData() != $target->getData() ){
|
||||||
|
$diffInstance->setData( array("source" => $source->getData(),"target" => $target->getData() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$sourceData = $source->getData();
|
||||||
|
$targetData = $target->getData();
|
||||||
|
$seenSections = array();
|
||||||
|
foreach( $sourceData as $section_name => $sectionData ){
|
||||||
|
|
||||||
|
#echo "section_name $section_name\n";
|
||||||
|
$section_data_type = $sectionData->getType();
|
||||||
|
if( ! isset( $targetData[$section_name] ) ) {
|
||||||
|
#echo "section_name not in target\n";
|
||||||
|
$tempDataInstance = new Alternc_Diagnostic_Data($section_data_type);
|
||||||
|
$tempDataInstance->setMetadata( array("Not in target") );
|
||||||
|
}else{
|
||||||
|
#echo "section_name for diff\n";
|
||||||
|
$tempDataInstance = $this->compare($sectionData, $targetData[$section_name] );
|
||||||
|
}
|
||||||
|
if( ! is_null( $tempDataInstance ) ){
|
||||||
|
$diffInstance->addData( $section_name, $tempDataInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if( count( $diffInstance->getData() )
|
||||||
|
|| count( $diffInstance->getIndex() )
|
||||||
|
|| count( $diffInstance->getMetadata() )
|
||||||
|
){
|
||||||
|
return $diffInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,17 @@ class Alternc_Diagnostic_Directory {
|
||||||
function getList( $max = null){
|
function getList( $max = null){
|
||||||
|
|
||||||
$dir = new DirectoryIterator($this->file_path);
|
$dir = new DirectoryIterator($this->file_path);
|
||||||
|
$fileList = array();
|
||||||
|
while($dir->valid()) {
|
||||||
|
if( $dir->isDot() ){
|
||||||
|
$dir->next();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$file_name = $dir->getFilename();
|
||||||
|
$fileList[] = $file_name;
|
||||||
|
$dir->next();
|
||||||
|
}
|
||||||
|
return $fileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +46,35 @@ class Alternc_Diagnostic_Directory {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @todo Confirm usefulness
|
||||||
|
public function getFileContent( $id ) {
|
||||||
|
$fileList = $this->getList();
|
||||||
|
if( array_key_exists( $id, $fileList ) ){
|
||||||
|
return file_get_contents( $this->file_path."/".$fileList[$id]);
|
||||||
|
}
|
||||||
|
if( in_array($id, $fileList)){
|
||||||
|
$key = array_search( $id, $fileList );
|
||||||
|
return file_get_contents( $this->file_path."/".$fileList[$key]);
|
||||||
|
}
|
||||||
|
throw new \Exception("Could not find diagnostic for id : $id");
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFileInfo($id){
|
||||||
|
|
||||||
|
$fileList = $this->getList();
|
||||||
|
|
||||||
|
if( array_key_exists( $id, $fileList ) ){
|
||||||
|
$file_path = $this->file_path."/".$fileList[$id];
|
||||||
|
}
|
||||||
|
if( in_array($id, $fileList)){
|
||||||
|
$key = array_search( $id, $fileList );
|
||||||
|
$file_path = $this->file_path."/".$fileList[$key];
|
||||||
|
}
|
||||||
|
$fileInfos = pathinfo( $file_path );
|
||||||
|
return ($fileInfos);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -84,5 +84,39 @@ class Alternc_Diagnostic_Format_Abstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a Data object to file
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function write( Alternc_Diagnostic_Data $data = null ){
|
||||||
|
|
||||||
|
if( null == $data ){
|
||||||
|
if( ! $this->data ){
|
||||||
|
throw new \Exception( "A format cannot be written without a Data");
|
||||||
|
}
|
||||||
|
$data = $this->data;
|
||||||
|
}
|
||||||
|
$content = $this->dataToContent( $data );
|
||||||
|
$filename = $this->getFilename();
|
||||||
|
if( ! file_put_contents($filename, $content) ){
|
||||||
|
throw new \Exception("Failed to write in json format to file $filename" );
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string file_name
|
||||||
|
* @return Alternc_Diagnostic_Data A diagnostic structure
|
||||||
|
*/
|
||||||
|
function read( $file_name ){
|
||||||
|
|
||||||
|
$content = $this->directory->getFileContent( $file_name );
|
||||||
|
return $this->contentToData( $content );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,20 +2,9 @@
|
||||||
|
|
||||||
interface Alternc_Diagnostic_Format_Interface{
|
interface Alternc_Diagnostic_Format_Interface{
|
||||||
|
|
||||||
/**
|
function contentToData( $content );
|
||||||
*
|
|
||||||
* @param mixed $file_reference
|
|
||||||
* Either a number or a string refering to the file
|
|
||||||
* @return Alternc_Diagnostic_Data A diagnostic file
|
|
||||||
*/
|
|
||||||
function read( $file_reference );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
function dataToContent();
|
||||||
* Writes a Data object to file
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
function write();
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,7 +19,12 @@ class Alternc_Diagnostic_Format_Json
|
||||||
/**
|
/**
|
||||||
* @inherit
|
* @inherit
|
||||||
*/
|
*/
|
||||||
function read( $file_reference ){
|
function contentToData( $content ){
|
||||||
|
|
||||||
|
$arrayData = json_decode( $content , true);
|
||||||
|
$dataInstance = new Alternc_Diagnostic_Data(Alternc_Diagnostic_Data::TYPE_ROOT);
|
||||||
|
$this->data = $dataInstance->buildFromArray( $arrayData );
|
||||||
|
return $this->data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,20 +32,17 @@ class Alternc_Diagnostic_Format_Json
|
||||||
/**
|
/**
|
||||||
* @inherit
|
* @inherit
|
||||||
*/
|
*/
|
||||||
function write(Alternc_Diagnostic_Data $data = null ){
|
function dataToContent(Alternc_Diagnostic_Data $data = null ){
|
||||||
|
|
||||||
if( $data ){
|
if( $data ){
|
||||||
$this->setData($data);
|
$this->setData($data);
|
||||||
}
|
}
|
||||||
$file_content = json_encode($this->getData());
|
$content = json_encode($this->getData());
|
||||||
$filename = $this->getFilename();
|
$filename = $this->getFilename();
|
||||||
if(json_last_error()){
|
if(json_last_error()){
|
||||||
throw new \Exception("Json conversion failed with error #".json_last_error()."for data".serialize($this->getData()));
|
throw new \Exception("Json conversion failed with error #".json_last_error()."for data".serialize($this->getData()));
|
||||||
}
|
}
|
||||||
if( ! file_put_contents($filename, $file_content) ){
|
return $content;
|
||||||
throw new \Exception("Failed to write in json format to file $filename for data".serialize($this->getData()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON implementation of the format interface : writes, reads, compares
|
||||||
|
*/
|
||||||
|
class Alternc_Diagnostic_Format_Txt
|
||||||
|
extends Alternc_Diagnostic_Format_Abstract
|
||||||
|
implements Alternc_Diagnostic_Format_Interface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inherit
|
||||||
|
*/
|
||||||
|
public function __construct(Alternc_Diagnostic_Directory $directory) {
|
||||||
|
parent::__construct($directory);
|
||||||
|
$this->setExtension("txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inherit
|
||||||
|
*/
|
||||||
|
function contentToData( $content ){
|
||||||
|
|
||||||
|
// @todo or skip ? Quite a fragile storage
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inherit
|
||||||
|
*/
|
||||||
|
function dataToContent(Alternc_Diagnostic_Data $data = null, $depth = 0 ){
|
||||||
|
$d = $this->space_depth($depth);
|
||||||
|
echo $d."Type: ".$data->type."\n";
|
||||||
|
$d .= " ";
|
||||||
|
if( $data->type == Alternc_Diagnostic_Data::TYPE_SECTION ){
|
||||||
|
foreach( $data->data as $key => $value ){
|
||||||
|
if( is_int( $key) ){
|
||||||
|
echo $d.json_encode( $value, true )."\n";
|
||||||
|
}else{
|
||||||
|
echo $d.$key." => ".json_encode( $value, true )."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach( $data->data as $section_name => $sectionData ){
|
||||||
|
echo $d."Section: $section_name\n";
|
||||||
|
$this->dataToContent( $sectionData, $depth+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function space_depth( $depth){
|
||||||
|
$buf = "";
|
||||||
|
for( $i=0; $i < $depth; $i++){
|
||||||
|
$buf .= " ";
|
||||||
|
}
|
||||||
|
return $buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -55,32 +55,101 @@ class Alternc_Diagnostic_Manager{
|
||||||
* @param Console_CommandLine_Result $options
|
* @param Console_CommandLine_Result $options
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
function create(Console_CommandLine_Result $options){
|
function c_create(Console_CommandLine_Result $options){
|
||||||
|
|
||||||
$args = $options->args;
|
$args = $options->args;
|
||||||
$options = $options->options;
|
$options = $options->options;
|
||||||
$diagnosticData = new Alternc_Diagnostic_Data(Alternc_Diagnostic_Data::TYPE_ROOT);
|
$diagnosticdata = new Alternc_Diagnostic_Data(Alternc_Diagnostic_Data::TYPE_ROOT);
|
||||||
|
|
||||||
$serviceList = explode(',',$options["services"]);
|
$servicelist = explode(',',$options["services"]);
|
||||||
foreach ($serviceList as $service) {
|
foreach ($servicelist as $service) {
|
||||||
$class_name = "Alternc_Diagnostic_Service_".trim(ucfirst($service));
|
$class_name = "Alternc_Diagnostic_Service_".trim(ucfirst($service));
|
||||||
if(!class_exists($class_name)){
|
if(!class_exists($class_name)){
|
||||||
throw new \Exception("Invalid service $service");
|
throw new \exception("invalid service $service");
|
||||||
}
|
}
|
||||||
/** @var Alternc_Diagnostic_Service_Interface */
|
/** @var alternc_diagnostic_service_interface */
|
||||||
$serviceAgent = new $class_name( array("service" => $this) );
|
$serviceagent = new $class_name( array("service" => $this) );
|
||||||
|
|
||||||
// Runs the service agent and store the results
|
// runs the service agent and store the results
|
||||||
$diagnosticData->addData($serviceAgent->name, $serviceAgent->run());
|
$diagnosticdata->addData($serviceagent->name, $serviceagent->run());
|
||||||
}
|
}
|
||||||
$this->formatInstance->setData($diagnosticData)->write();
|
$this->formatInstance->setData($diagnosticdata)->write();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function compare( $options ){}
|
function c_diff( $options ){
|
||||||
function index( $options ){}
|
|
||||||
function show( $options ){}
|
|
||||||
function delete( $options ){}
|
$args = $options->args;
|
||||||
|
$options = $options->options;
|
||||||
|
$source = $options["source"];
|
||||||
|
$target = $options["target"];
|
||||||
|
$format = $options['format'];
|
||||||
|
$sourceDiagnostic = $this->getDiagnosticFromId($source);
|
||||||
|
$targetDiagnostic = $this->getDiagnosticFromId($target);
|
||||||
|
$diff = new Alternc_Diagnostic_Diff();
|
||||||
|
$diffData = $diff->compare($sourceDiagnostic,$targetDiagnostic);
|
||||||
|
$formatInstance = $this->getFormatInstance( $format );
|
||||||
|
echo $formatInstance->dataToContent( $diffData);
|
||||||
|
}
|
||||||
|
|
||||||
|
function c_list( $options ){
|
||||||
|
|
||||||
|
$args = $options->args;
|
||||||
|
$options = $options->options;
|
||||||
|
$fileList = $this->directoryInstance->getList();
|
||||||
|
foreach( $fileList as $number => $file ){
|
||||||
|
echo "$number\t$file\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
function c_show( $options ){
|
||||||
|
|
||||||
|
|
||||||
|
$args = $options->args;
|
||||||
|
$options = $options->options;
|
||||||
|
$id = $options['id'];
|
||||||
|
$format = $options['format'];
|
||||||
|
$data = $this->getDiagnosticFromId( $id);
|
||||||
|
$formatInstance = $this->getFormatInstance( $format );
|
||||||
|
echo $formatInstance->dataToContent( $data );
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
function c_delete( $options ){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a file by reference or name
|
||||||
|
*
|
||||||
|
* @param string $file_reference
|
||||||
|
* @return Alternc_Diagnostic_Data Resulting data
|
||||||
|
* @todo add the ability to resolve by filename
|
||||||
|
*/
|
||||||
|
protected function getDiagnosticFromId ( $id ) {
|
||||||
|
|
||||||
|
$fileInfo = $this->directoryInstance->getFileInfo( $id ) ;
|
||||||
|
$extension = $fileInfo["extension"];
|
||||||
|
$formatInstance = $this->getFormatInstance( $extension);
|
||||||
|
$formatInstance->read( $fileInfo["basename"] );
|
||||||
|
$data = $formatInstance->getData();
|
||||||
|
return $data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getFormatInstance ( $format ){
|
||||||
|
switch( $format ){
|
||||||
|
case "json":
|
||||||
|
$instance = new Alternc_Diagnostic_Format_Json( $this->directoryInstance );
|
||||||
|
break;
|
||||||
|
case "txt":
|
||||||
|
$instance = new Alternc_Diagnostic_Format_Txt( $this->directoryInstance );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \Exception("Invalid format : $format");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,8 +23,6 @@ for CONFIG_FILE in \
|
||||||
. "$CONFIG_FILE"
|
. "$CONFIG_FILE"
|
||||||
done
|
done
|
||||||
|
|
||||||
from="noreply@$FQDN"
|
|
||||||
|
|
||||||
if [ "x$url" == "x" ] ; then
|
if [ "x$url" == "x" ] ; then
|
||||||
echo Missing arguments
|
echo Missing arguments
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -62,7 +60,7 @@ echo -e "\n---------- END ----------"
|
||||||
# If there is an email specified, mail it
|
# If there is an email specified, mail it
|
||||||
if [ ! "x$email" == "x" -a ! "$email" == "null" ] ; then
|
if [ ! "x$email" == "x" -a ! "$email" == "null" ] ; then
|
||||||
date=$(date +%x\ %X)
|
date=$(date +%x\ %X)
|
||||||
cat "$tmpfile" | mailx -s "AlternC Cron #$id - Report $date" -r "$from" "$(urldecode $email)"
|
mailx -s "AlternC Cron #$id - Report $date" -a "From: noreply@$FQDN" "$(urldecode $email)" < "$tmpfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "$tmpfile"
|
rm -f "$tmpfile"
|
||||||
|
|
|
@ -126,7 +126,7 @@ if(is_file("/usr/share/alternc/panel/class/config_nochk.php")){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$directoryInstance = new Alternc_Diagnostic_Directory("/tmp/diagnostic");
|
$directoryInstance = new Alternc_Diagnostic_Directory("/var/log/alternc/diagnostic");
|
||||||
|
|
||||||
|
|
||||||
// instanciation of the diagnosticManager service
|
// instanciation of the diagnosticManager service
|
||||||
|
@ -168,9 +168,49 @@ $createCommmand->addOption('format', array(
|
||||||
'help_name' => 'format'
|
'help_name' => 'format'
|
||||||
));
|
));
|
||||||
|
|
||||||
$indexCommmand = $consoleParser->addCommand('index', array('multiple'=>false,"alias"=>"i","description" => "Shows all available diagnostics"));
|
$listCommmand = $consoleParser->addCommand('list', array('multiple'=>false,"alias"=>"i","description" => "Shows all available diagnostics"));
|
||||||
$compareCommmand = $consoleParser->addCommand('compare', array('multiple'=>false,"alias"=>"x","description" => "Removes one or more diagnotics"));
|
$diffCommmand = $consoleParser->addCommand('diff', array('multiple'=>false,"alias"=>"x","description" => "Removes one or more diagnotics"));
|
||||||
$compareCommmand = $consoleParser->addCommand('show', array('multiple'=>false,"alias"=>"s","description" => "Prints a diagnotic content"));
|
$diffCommmand->addOption('source', array(
|
||||||
|
'short_name' => '-s',
|
||||||
|
'long_name' => '--source',
|
||||||
|
'action' => 'StoreString',
|
||||||
|
'default' => '0',
|
||||||
|
'description' => 'First file to diff, id or basename. Default: 0',
|
||||||
|
'help_name' => 'source'
|
||||||
|
));
|
||||||
|
$diffCommmand->addOption('target', array(
|
||||||
|
'short_name' => '-t',
|
||||||
|
'long_name' => '--target',
|
||||||
|
'action' => 'StoreString',
|
||||||
|
'default' => '1',
|
||||||
|
'description' => 'First file to diff, id or basename. Default: 1',
|
||||||
|
'help_name' => 'target'
|
||||||
|
));
|
||||||
|
$diffCommmand->addOption('format', array(
|
||||||
|
'short_name' => '-f',
|
||||||
|
'long_name' => '--format',
|
||||||
|
'action' => 'StoreString',
|
||||||
|
'default' => 'txt',
|
||||||
|
'description' => 'Sets the format of the diagnostic diff. default: txt',
|
||||||
|
'help_name' => 'format'
|
||||||
|
));
|
||||||
|
$showCommand = $consoleParser->addCommand('show', array('multiple'=>false,"alias"=>"s","description" => "Prints a diagnotic content"));
|
||||||
|
$showCommand->addOption('id', array(
|
||||||
|
'short_name' => '-i',
|
||||||
|
'long_name' => '--id',
|
||||||
|
'action' => 'StoreString',
|
||||||
|
'default' => '0',
|
||||||
|
'description' => 'Provides the id or name of a diagnostic to show. Default: 0',
|
||||||
|
'help_name' => 'id'
|
||||||
|
));
|
||||||
|
$showCommand->addOption('format', array(
|
||||||
|
'short_name' => '-f',
|
||||||
|
'long_name' => '--format',
|
||||||
|
'action' => 'StoreString',
|
||||||
|
'default' => 'txt',
|
||||||
|
'description' => 'Sets the format of the output. Default: txt. Other choices : array',
|
||||||
|
'help_name' => 'format'
|
||||||
|
));
|
||||||
$deleteCommmand = $consoleParser->addCommand('delete', array('multiple'=>false,"alias"=>"d","description" => "Deletes diagnostic files"));
|
$deleteCommmand = $consoleParser->addCommand('delete', array('multiple'=>false,"alias"=>"d","description" => "Deletes diagnostic files"));
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,15 +219,15 @@ $deleteCommmand = $consoleParser->addCommand('delete', a
|
||||||
try {
|
try {
|
||||||
$result = $consoleParser->parse();
|
$result = $consoleParser->parse();
|
||||||
if ($result->command_name){
|
if ($result->command_name){
|
||||||
$command_name = $result->command_name;
|
$command_name = "c_".$result->command_name;
|
||||||
$command = $result->command;
|
$command = $result->command;
|
||||||
}else{
|
}else{
|
||||||
throw new \Exception("Command missing, use -h to learn about available commands.");
|
throw new \Exception("Welcome to AlternC Diagnostics! Use -h to learn about available commands.");
|
||||||
}
|
}
|
||||||
if( !method_exists($diagnosticManager, $command_name)){
|
if( !method_exists($diagnosticManager, $command_name)){
|
||||||
throw new \Exception("Invalid command : $command");
|
throw new \Exception("Invalid command : $command");
|
||||||
}
|
}
|
||||||
$diagnosticManager->$command_name($command);
|
$result = $diagnosticManager->$command_name($command);
|
||||||
} catch (\Exception $exc) {
|
} catch (\Exception $exc) {
|
||||||
$consoleParser->displayError($exc->getMessage());
|
$consoleParser->displayError($exc->getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,12 +85,8 @@ function d($mess){
|
||||||
*/
|
*/
|
||||||
function mail_it(){
|
function mail_it(){
|
||||||
global $errorsList,$L_FQDN;
|
global $errorsList,$L_FQDN;
|
||||||
// Forces array
|
|
||||||
if( !is_array($errorsList)){
|
|
||||||
$errorsList = array($errorsList);
|
|
||||||
}
|
|
||||||
// Builds message from array
|
// Builds message from array
|
||||||
$msg = implode("\n", $errorsList);
|
$msg = var_export($errorsList, TRUE);
|
||||||
// Attempts to send email
|
// Attempts to send email
|
||||||
// @todo log if fails
|
// @todo log if fails
|
||||||
mail("alterncpanel@$L_FQDN",'Script do_actions.php issues',"\n Errors reporting mail:\n\n$msg");
|
mail("alterncpanel@$L_FQDN",'Script do_actions.php issues',"\n Errors reporting mail:\n\n$msg");
|
||||||
|
@ -264,14 +260,9 @@ while ($rr=$action->get_action()){
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
$output=array("Fail: Sorry dude, i do not know this type of action");
|
$errorsList[]=array("Fail: Sorry, i do not know this type of action: ". $r['type']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Get the error (if exists).
|
|
||||||
if(isset($output[0])){
|
|
||||||
$return=$output[0];
|
|
||||||
$errorsList[]="\nAction n°".$r["id"]." '".$r["type"]."' failed! With user: ".$r["user"]."\nHere is the complete output:\n".print_r($output);
|
|
||||||
}
|
|
||||||
// We finished the action, notify the DB.
|
// We finished the action, notify the DB.
|
||||||
d("Finishing... return value is : $return\n");
|
d("Finishing... return value is : $return\n");
|
||||||
if(!$action->finish($r["id"],addslashes($return))){
|
if(!$action->finish($r["id"],addslashes($return))){
|
||||||
|
|
|
@ -126,15 +126,15 @@ doone() {
|
||||||
# Set the file readable only for the AlternC User
|
# Set the file readable only for the AlternC User
|
||||||
mkdir -p "$REP"
|
mkdir -p "$REP"
|
||||||
chown -R $GID:$GID "$REP"
|
chown -R $GID:$GID "$REP"
|
||||||
chmod 2770 -R "$REP"
|
chmod 2750 -R "$REP"
|
||||||
|
|
||||||
# # Delete existings ACL
|
# # Delete existings ACL
|
||||||
# # Set the defaults acl on all the files
|
# # Set the defaults acl on all the files
|
||||||
# setfacl -b -k -n -R -m d:g:alterncpanel:rwx -m d:u::rwx -m d:g::rwx -m d:u:$GID:rwx -m d:g:$GID:rwx -m d:o::--- -m d:mask:rwx\
|
# setfacl -b -k -n -R -m d:g:alterncpanel:rwx -m d:u::rwx -m d:g::rwx -m d:u:$GID:rwx -m d:g:$GID:rwx -m d:o::--- -m d:mask:rwx\
|
||||||
# -Rm g:alterncpanel:rwx -m u:$GID:rwx -m g:$GID:rwx -m mask:rwx\
|
# -Rm g:alterncpanel:rwx -m u:$GID:rwx -m g:$GID:rwx -m mask:rwx\
|
||||||
# "$REP"
|
# "$REP"
|
||||||
setfacl -bknR -m d:u:alterncpanel:rwx -m d:g:alterncpanel:rwx -m u:alterncpanel:rwx -m g:alterncpanel:rwx -m d:o::--- -m o::---\
|
setfacl -bknR -m d:u:alterncpanel:rwx -m d:g:alterncpanel:r-x -m u:alterncpanel:rwx -m g:alterncpanel:r-x -m d:o::--- -m o::---\
|
||||||
-m d:u:$GID:rwx -m d:g:$GID:rwx -m u:$GID:rwx -m g:$GID:rwx -m d:mask:rwx -m mask:rwx "$REP"
|
-m d:u:$GID:rwx -m d:g:$GID:r-x -m u:$GID:rwx -m g:$GID:r-x -m d:mask:rwx -m mask:rwx "$REP"
|
||||||
|
|
||||||
fixtmp $GID
|
fixtmp $GID
|
||||||
read GID LOGIN || true
|
read GID LOGIN || true
|
||||||
|
|
|
@ -6,7 +6,7 @@ TEMPLATE_DIR="/etc/alternc/templates/apache2"
|
||||||
HOSTING_DIR="/etc/alternc/functions_hosting"
|
HOSTING_DIR="/etc/alternc/functions_hosting"
|
||||||
|
|
||||||
HTML_HOME="$ALTERNC_HTML"
|
HTML_HOME="$ALTERNC_HTML"
|
||||||
VHOST_DIR="/var/lib/alternc/apache-vhost"
|
VHOST_DIR="/var/lib/alternc/apache-vhost/"
|
||||||
|
|
||||||
launch_hooks() {
|
launch_hooks() {
|
||||||
local ACTION=$1
|
local ACTION=$1
|
||||||
|
|
|
@ -19,7 +19,7 @@ global $cuid;
|
||||||
// those will be tried in order, the first one to return more than 7
|
// those will be tried in order, the first one to return more than 7
|
||||||
// chars will win
|
// chars will win
|
||||||
$generators = array('pwqgen', 'pwgen');
|
$generators = array('pwqgen', 'pwgen');
|
||||||
$dryrun = false;
|
$dryrun = true;
|
||||||
// 1GB default quota
|
// 1GB default quota
|
||||||
$default_quotas = 1024; // in MB because using bytes would be too
|
$default_quotas = 1024; // in MB because using bytes would be too
|
||||||
// precise (try to guess AlternC, just you try)
|
// precise (try to guess AlternC, just you try)
|
||||||
|
|
|
@ -15,7 +15,10 @@ if [ ! -r "$ALTERNC_CONFIG_FILE" ]; then
|
||||||
fi
|
fi
|
||||||
. "$ALTERNC_CONFIG_FILE"
|
. "$ALTERNC_CONFIG_FILE"
|
||||||
|
|
||||||
mysql_query "update address a, domaines d, mailbox m set m.lastlogin=now() where a.domain_id=d.id and m.address_id=a.id and concat_ws('@',a.address,d.domaine) = '$USER';"
|
addr=$(echo $USER | sed 's/@.*//')
|
||||||
|
dom=$(echo $USER | sed 's/^.*@//')
|
||||||
|
|
||||||
|
mysql_query "update address a, domaines d, mailbox m set m.lastlogin=now() where a.domain_id=d.id and m.address_id=a.id and a.address='$addr' and d.domaine='$dom';"
|
||||||
|
|
||||||
# Now launch the expected binary server
|
# Now launch the expected binary server
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
@ -114,7 +114,7 @@ do
|
||||||
mysql_query "delete from sub_domaines where domaine='$dom'; delete from domaines where domaine='$dom';"
|
mysql_query "delete from sub_domaines where domaine='$dom'; delete from domaines where domaine='$dom';"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then
|
if [ ! -z "$(cat "$RELOAD_WEB")" ] || [ "$1" = "force" ]; then
|
||||||
|
|
||||||
# Just to encourage user to use THIS directory and not another one
|
# Just to encourage user to use THIS directory and not another one
|
||||||
test -d "$VHOST_MANUALCONF" || mkdir -p "$VHOST_MANUALCONF"
|
test -d "$VHOST_MANUALCONF" || mkdir -p "$VHOST_MANUALCONF"
|
||||||
|
@ -132,7 +132,7 @@ if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then
|
||||||
else
|
else
|
||||||
echo "Include \"$LOGFORMAT_FILE\""
|
echo "Include \"$LOGFORMAT_FILE\""
|
||||||
fi
|
fi
|
||||||
find "$VHOST_DIR" -mindepth 2 -type f -iname "*.conf" -print0 | xargs -0 cat
|
find "$VHOST_DIR/" -mindepth 2 -type f -iname "*.conf" -print0 | xargs -0 cat
|
||||||
echo "###END OF ALTERNC AUTO-GENERATED FILE - DO NOT EDIT MANUALLY###"
|
echo "###END OF ALTERNC AUTO-GENERATED FILE - DO NOT EDIT MANUALLY###"
|
||||||
) > "$tempo"
|
) > "$tempo"
|
||||||
|
|
||||||
|
|
|
@ -195,16 +195,20 @@ protocol imap {
|
||||||
}
|
}
|
||||||
|
|
||||||
service imap {
|
service imap {
|
||||||
executable = imap imap-postlogin
|
# tell imap to do post-login lookup using a socket called "postlogin"
|
||||||
|
executable = imap postlogin
|
||||||
vsz_limit = 512M
|
vsz_limit = 512M
|
||||||
}
|
}
|
||||||
|
|
||||||
service imap-postlogin {
|
# The service name below doesn't actually matter.
|
||||||
|
service postlogin {
|
||||||
|
# all post-login scripts are executed via script-login binary
|
||||||
executable = script-login /usr/lib/alternc/popimap-log-login.sh
|
executable = script-login /usr/lib/alternc/popimap-log-login.sh
|
||||||
|
|
||||||
# the script process runs as the user specified here (v2.0.14+):
|
# the script process runs as the user specified here (v2.0.14+):
|
||||||
#user = $default_internal_user
|
#user = $default_internal_user
|
||||||
# this UNIX socket listener must use the same name as given to imap executable
|
# this UNIX socket listener must use the same name as given to imap executable
|
||||||
unix_listener imap-postlogin {
|
unix_listener postlogin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +263,8 @@ protocol pop3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
service pop3 {
|
service pop3 {
|
||||||
executable = /usr/lib/alternc/popimap-log-login.sh /usr/lib/dovecot/pop3
|
# tell imap to do post-login lookup using a socket called "postlogin"
|
||||||
|
executable = pop3 postlogin
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue