From 16c087b605599810773f6d27cb45bfc4ba0f0efe Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 22 Jun 2006 03:40:18 +0000 Subject: [PATCH] - setup-cli can now set/change the default EMailAdmin profile - setup-cli --help has now subsections for header and config --- setup/lang/phpgw_de.lang | 7 +- setup/lang/phpgw_en.lang | 7 +- setup/setup-cli.php | 181 +++++++++++++++++++++++++++++---------- 3 files changed, 148 insertions(+), 47 deletions(-) diff --git a/setup/lang/phpgw_de.lang b/setup/lang/phpgw_de.lang index a6b0b73a9a..39789f784a 100644 --- a/setup/lang/phpgw_de.lang +++ b/setup/lang/phpgw_de.lang @@ -156,6 +156,7 @@ current system-charset setup de Aktueller Systemzeichensatz current system-charset is %1. setup de Aktueller Systemzeichensatz ist %1. current version setup de Gegenwärtige Version currently installed languages: %1
setup de Gegenwärtig installierte Sprachen: %1
+cyrus imap: admin user,password setup de Cyrus IMAP: Adminbenutzer,Passwort database setup de Datenbank database instance (egw domain) setup de Datenbankinstanz (eGW Domain) database is version %1 and up to date. setup de Datenbank ist Version %1 und aktuell. @@ -213,6 +214,7 @@ egroupware configuration file header.inc.php already exists, you need to use --e egroupware domain/instance %1(%2): setup de eGroupWare Domain/Instanz %1(%2): egroupware is already installed! setup de eGroupWare ist bereits installiert! egroupware sources in '%1' are not complete, file '%2' missing !!! setup de eGroupWare Quellen in '%1' sind nicht komplett, Datei '%2' fehlt !!! +emailadmin profile updated: setup de EMailAdmin Profil aktualisiert: enable for extra debug-messages setup de ankreuzen für zusätzliche Diagnosemeldungen enable mcrypt setup de MCrypt einschalten enter some random text for app session encryption setup de Zufallstext zur Verschlüsselung der Anwendungssitzung @@ -245,6 +247,7 @@ filesystem setup de Dateisystem force selectbox setup de Auswahl erzwingen found existing configuration file. loading settings from the file... setup de Existierende Konfigurationsdatei gefunden. Lade Einstellungen von der Datei ... give admin access to all installed apps setup de Admin Zugang zu allen installierten Anwendungen geben +gives further options setup de gibt zusätzliche Optionen go back setup de Zurück gehen go to setup de Gehen zu grant access setup de Zugriff gewähren @@ -316,7 +319,7 @@ ldap search filter for accounts, default: "(uid=%user)", %domain=egw-domain setu leave empty to keep current. setup de Leer lassen um das existierende Password zu behalten. limit access setup de Zugang beschränken limit access to setup to the following addresses, networks or hostnames (e.g. 127.0.0.1,10.1.1,myhost.dnydns.org) setup de Zugang zu Setup auf die folgenden IP Adressen, Netzwerke oder Hostnamen beschränken (z.B. 127.0.0.1,10.1.1,myhost.dnydns.org) -list availible values: setup de Listen der verfügbaren Werte: +list availible values setup de Listen der verfügbaren Werte list of availible translations setup de Liste der verfügbaren Sprachen login as user postgres, eg. by using su as root setup de Als Benutzer postgres einlogen, zB. durch benutzen von su als root login to mysql - setup de mysql aufrufen - @@ -408,6 +411,7 @@ pop/imap mail server hostname or ip address setup de POP/IMAP Mail Server Hostna possible reasons setup de Mögliche Gründe possible solutions setup de Mögliche Lösungen post-install dependency failure setup de Abhängigkeitsfehler nach der Installation +postfix with ldap: [yes(user edit forwarding)] setup de Postfix mit LDAP: [yes(Benutzer Weiterleitung ändern)] postgres: leave it empty to use the prefered unix domain sockets instead of a tcp/ip connection setup de Postgres: Leer lassen für die empfohlenen Unix Domain Sockets anstatt einer tcp/ip Verbindung potential problem setup de Potentielles Problem preferences setup de Einstellungen @@ -476,6 +480,7 @@ setup the database setup de Datenbank einzurichten setup/config admin login setup de Setup-/Konfigurationsadmin-Login should be the same as server root unless you know what you are doing. setup de Sollte das gleiche Verzeichnis wie die Server-Root sein, außer Sie wissen was Sie tun. show 'powered by' logo on setup de Zeige "powered by" Logo +sieve: host[,port(2000)] setup de Sieve: Rechner[,Port(2000)] size setup de Größe skip the installation tests (not recommended) setup de Installationstests überspringen (nicht empfohlen) smtp server hostname or ip address setup de SMTP Server Hostname oder IP Adresse diff --git a/setup/lang/phpgw_en.lang b/setup/lang/phpgw_en.lang index 721832f415..7785a5c8f5 100644 --- a/setup/lang/phpgw_en.lang +++ b/setup/lang/phpgw_en.lang @@ -156,6 +156,7 @@ current system-charset setup en Current system-charset current system-charset is %1. setup en Current system-charset is %1. current version setup en Current Version currently installed languages: %1
setup en Currently installed languages: %1
+cyrus imap: admin user,password setup en Cyrus IMAP: Admin user,Password database setup en Database database instance (egw domain) setup en Database instance (eGW domain) database is version %1 and up to date. setup en database is version %1 and up to date. @@ -213,6 +214,7 @@ egroupware configuration file header.inc.php already exists, you need to use --e egroupware domain/instance %1(%2): setup en eGroupWare domain/instance %1(%2): egroupware is already installed! setup en eGroupWare is already installed! egroupware sources in '%1' are not complete, file '%2' missing !!! setup en eGroupWare sources in '%1' are not complete, file '%2' missing !!! +emailadmin profile updated: setup en EMailAdmin profile updated: enable for extra debug-messages setup en enable for extra debug-messages enable mcrypt setup en Enable MCrypt enter some random text for app session encryption setup en Enter some random text for app session encryption @@ -243,6 +245,7 @@ filesystem setup en Filesystem force selectbox setup en Force Selectbox found existing configuration file. loading settings from the file... setup en Found existing configuration file. Loading settings from the file... give admin access to all installed apps setup en Give admin access to all installed apps +gives further options setup en gives further options go back setup en Go back go to setup en Go to grant access setup en Grant Access @@ -314,7 +317,7 @@ ldap search filter for accounts, default: "(uid=%user)", %domain=egw-domain setu leave empty to keep current. setup en Leave empty to keep current. limit access setup en Limit access limit access to setup to the following addresses, networks or hostnames (e.g. 127.0.0.1,10.1.1,myhost.dnydns.org) setup en Limit access to setup to the following addresses, networks or hostnames (e.g. 127.0.0.1,10.1.1,myhost.dnydns.org) -list availible values: setup en List availible values: +list availible values setup en List availible values list of availible translations setup en list of availible translations login as user postgres, eg. by using su as root setup en Login as user postgres, eg. by using su as root login to mysql - setup en Login to mysql - @@ -406,6 +409,7 @@ pop/imap mail server hostname or ip address setup en POP/IMAP mail server hostna possible reasons setup en Possible Reasons possible solutions setup en Possible Solutions post-install dependency failure setup en Post-install Dependency Failure +postfix with ldap: [yes(user edit forwarding)] setup en Postfix with LDAP: [yes(user edit forwarding)] postgres: leave it empty to use the prefered unix domain sockets instead of a tcp/ip connection setup en Postgres: Leave it empty to use the prefered unix domain sockets instead of a tcp/ip connection potential problem setup en Potential Problem preferences setup en Preferences @@ -474,6 +478,7 @@ setup the database setup en Setup the database setup/config admin login setup en Setup/Config Admin Login should be the same as server root unless you know what you are doing. setup en Should be the same as Server Root unless you know what you are doing. show 'powered by' logo on setup en Show 'powered by' logo on +sieve: host[,port(2000)] setup en Sieve: Host[,Port(2000)] size setup en size skip the installation tests (not recommended) setup en Skip the installation tests (not recommended) smtp server hostname or ip address setup en SMTP server hostname or IP address diff --git a/setup/setup-cli.php b/setup/setup-cli.php index 34f4537bd8..9de07690e6 100755 --- a/setup/setup-cli.php +++ b/setup/setup-cli.php @@ -95,7 +95,7 @@ switch($action) case '--help': case '--usage': - do_usage(); + do_usage($arguments[0]); break; default: @@ -129,8 +129,24 @@ function do_config($args) 'mail_suffix', array('name' => 'mail_login_type','allowed' => array('standard','vmailmgr')), ), + '--cyrus' => array( + 'imapAdminUsername', + 'imapAdminPW', + array('name' => 'imapType','default' => 3), + array('name' => 'imapEnableCyrusAdmin','default' => 'yes'), + ), + '--sieve' => array( + array('name' => 'imapSieveServer','default' => 'localhost'), + array('name' => 'imapSievePort','default' => 2000), + array('name' => 'imapEnableSieve','default' => 'yes'), // null or yes + ), + '--postfix' => array( + array('name' => 'editforwardingaddress','allowed' => array('yes',null)), + array('name' => 'smtpType','default' => 2), + ), '--smtpserver' => array( //smtp server,[smtp port],[smtp user],[smtp password] - 'smtp_server','smtp_port','smtp_auth_user','smtp_auth_passwd'), + 'smtp_server','smtp_port','smtp_auth_user','smtp_auth_passwd','' + ), '--account-auth' => array( array('name' => 'account_repository','allowed' => array('sql','ldap')), array('name' => 'auth_type','allowed' => array('sql','ldap','mail','ads','http','sqlssl','nis','pam')), @@ -142,22 +158,37 @@ function do_config($args) '--ldap-context' => 'ldap_context', '--ldap-group-context' => 'ldap_group_context', ); + $do_ea_profile = false; while (($arg = array_shift($args))) { if (!isset($config[$arg])) fail(90,lang("Unknown option '%1' !!!",$arg)); - foreach(is_array($config[$arg]) ? explode(',',array_shift($args)) : array(array_shift($args)) as $n => $value) + $options = array(); + if (substr($args[0],0,2) !== '--') { - if ($value === '' && is_array($config[$arg])) continue; + $options = is_array($config[$arg]) ? explode(',',array_shift($args)) : array(array_shift($args)); + } + $options[] = ''; $options[] = ''; + foreach($options as $n => $value) + { + if ($value === '' && is_array($config[$arg]) && !isset($config[$arg][$n]['default'])) continue; $name = is_array($config[$arg]) || $n ? $config[$arg][$n] : $config[$arg]; if (is_array($name)) { - if (!in_array($value,$name['allowed'])) fail(91,"'%1' is not allowed as %2. arguments of option %3 !!!",$value,1+$n,$arg); + if (isset($name['allowed']) && !in_array($value,$name['allowed'])) + { + fail(91,lang("'%1' is not allowed as %2. arguments of option %3 !!!",$value,1+$n,$arg)); + } + if (!$value && isset($name['default'])) $value = $name['default']; $name = $name['name']; } $values[$name] = $value; } + if (in_array($arg,array('--mailserver','--smtpserver','--cyrus','--postfix','--sieve'))) + { + $do_ea_profile = true; + } } foreach($values as $name => $value) { @@ -171,15 +202,44 @@ function do_config($args) if (count($values)) { echo lang('Configuration changed.')."\n"; + + if ($do_ea_profile) do_emailadmin($values); } - echo lang('Current configuration:')."\n"; + echo "\n".lang('Current configuration:')."\n"; $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',array( 'config_app' => 'phpgwapi', - "config_name LIKE '%\\_dir' OR (config_name LIKE 'mail%' AND config_name != 'mail_footer') OR config_name LIKE 'smtp%' OR config_name IN ('webserver_url','system_charset')", + "(config_name LIKE '%\\_dir' OR (config_name LIKE 'mail%' AND config_name != 'mail_footer') OR config_name LIKE 'smtp\\_%' OR config_name LIKE 'ldap%' OR config_name IN ('webserver_url','system_charset','auth_type','account_repository'))", ),__LINE__,__FILE__); while (($row = $GLOBALS['egw_setup']->db->row(true))) { - echo $row['config_name'].': '.$row['config_value']."\n"; + echo str_pad($row['config_name'].':',22).$row['config_value']."\n"; + } +} + +/** + * Updates the default EMailAdmin profile + * + * @param array $values + */ +function do_emailadmin() +{ + $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',array( + 'config_app' => 'phpgwapi', + "((config_name LIKE 'mail%' AND config_name != 'mail_footer') OR config_name LIKE 'smtp%' OR config_name LIKE 'imap%' OR config_name='editforwardingaddress')", + ),__LINE__,__FILE__); + while (($row = $GLOBALS['egw_setup']->db->row(true))) + { + $config[$row['config_name']] = $row['config_value']; + } + $config['smtpAuth'] = $config['smtp_auth_user'] ? 'yes' : null; + + $emailadmin =& CreateObject('emailadmin.bo',-1,false); // false=no session stuff + $emailadmin->setDefaultProfile($config); + + echo "\n".lang('EMailAdmin profile updated:')."\n"; + foreach($config as $name => $value) + { + echo str_pad($name.':',22).$value."\n"; } } @@ -798,45 +858,76 @@ function create_http_enviroment() /** * Echos usage message */ -function do_usage() +function do_usage($what='') { echo lang('Usage: %1 command [additional options]',basename($_SERVER['argv'][0]))."\n\n"; - echo '--check '.lang('checks eGroupWare\'s installed, it\'s versions and necessary upgrads (return values see --exit-codes)')."\n"; - echo '--install '.lang('domain(default),[config user(admin)],password,[backup to install],[charset(default depends on language)]')."\n"; - echo '--config '.lang('domain(default),[config user(admin)],password,[name=value,...] sets config values beside:')."\n"; - echo ' --files-dir, --backup-dir, --temp-dir '.lang('path to various directories: have to exist and be writeable by the webserver')."\n"; - echo ' --webserver-url '.lang('eg. /egroupware or http://domain.com/egroupware, default: %1',str_replace('/setup/setup-cli.php','',$_SERVER['PHP_SELF']))."\n"; - echo ' --mailserver '.lang('host,{imap | pop3 | imaps | pop3s},[domain],[{standard(default)|vmailmgr = add domain for mailserver login}]')."\n"; - echo ' --smtpserver '.lang('host,[smtp port],[smtp user],[smtp password]')."\n"; - echo ' --account-auth '.lang('account repository{sql(default) | ldap},[authentication{sql | ldap | mail | ads | http | ...}],[sql encrypttion{md5 | blowfish_crypt | md5_crypt | crypt}],[check save password{ (default)|True}],[allow cookie auth{ (default)|True}]')."\n"; - echo ' --ldap-host --ldap-root-dn --ldap-root-pw --ldap-context --ldap-group-context'."\n"; - echo '--admin '.lang('creates an admin user: domain(default),[config user(admin)],password,username,password,[first name],[last name],[email]')."\n"; - echo '--language '.lang('install or update translations: domain(all),[config user(admin)],password,[[+]lang1[,lang2,...]] + adds, no langs update existing ones')."\n"; - echo '--backup '.lang('domain(all),[config user(admin)],password,[file-name(default: backup-dir/db_backup-YYYYMMDDHHii)]')."\n"; - echo '--update '.lang('run a database schema update (if necessary): domain(all),[config user(admin)],password')."\n"; - echo lang('You can use the header user and password for every domain too. If the password is not set via the commandline, it is read from the enviroment variable EGW_CLI_PASSWORD or queried from the user.')."\n"; - - echo "\n".lang('Create or edit the eGroupWare configuration file: header.inc.php:')."\n"; - echo '--create-header '.lang('header-password[,header-user(admin)]')."\n"; - echo '--edit-header '.lang('[header-password],[header-user],[new-password],[new-user]')."\n"; - - echo "\n".lang('Additional options and there defaults (in brackets)')."\n"; - echo '--server-root '.lang('path of eGroupWare install directory (default auto-detected)')."\n"; - echo '--session-type '.lang('{db | php(default) | php-restore}')."\n"; - echo '--limit-access '.lang('comma separated ip-addresses or host-names, default access to setup from everywhere')."\n"; - echo '--mcrypt '.lang('use mcrypt to crypt session-data: {off(default) | on},[mcrypt-init-vector(default randomly generated)],[mcrypt-version]')."\n"; - echo '--db-persistent '.lang('use persistent db connections: {on(default) | off}')."\n"; - echo '--domain-selectbox '.lang('{off(default) | on}')."\n"; - - echo "\n".lang('Adding, editing or deleting an eGroupWare domain / database instance:')."\n"; - echo '--domain '.lang('add or edit a domain: [domain-name(default)],[db-name(egroupware)],[db-user(egroupware)],db-password,[db-type(mysql)],[db-host(localhost)],[db-port(db specific)],[config-user(as header)],[config-passwd(as header)]')."\n"; - echo '--delete-domain '.lang('domain-name')."\n"; - - echo "\n".lang('List availible values:')."\n"; - echo '--languages '.lang('list of availible translations')."\n"; - echo '--charsets '.lang('charsets used by the different languages')."\n"; - echo '--exit-codes '.lang('all exit codes of the command line interface')."\n"; + if (!$what) + { + echo '--check '.lang('checks eGroupWare\'s installed, it\'s versions and necessary upgrads (return values see --exit-codes)')."\n"; + echo '--install '.lang('domain(default),[config user(admin)],password,[backup to install],[charset(default depends on language)]')."\n"; + } + if (!$what || $what == 'config') + { + echo '--config '.lang('domain(default),[config user(admin)],password,[name=value,...] sets config values beside:')."\n"; + if (!$what) echo ' --help config '.lang('gives further options')."\n"; + } + if ($what == 'config') + { + echo ' --files-dir, --backup-dir, --temp-dir '.lang('path to various directories: have to exist and be writeable by the webserver')."\n"; + echo ' --webserver-url '.lang('eg. /egroupware or http://domain.com/egroupware, default: %1',str_replace('/setup/setup-cli.php','',$_SERVER['PHP_SELF']))."\n"; + echo ' --mailserver '.lang('host,{imap | pop3 | imaps | pop3s},[domain],[{standard(default)|vmailmgr = add domain for mailserver login}]')."\n"; + echo ' --smtpserver '.lang('host,[smtp port],[smtp user],[smtp password]')."\n"; + echo ' --postfix '.lang('Postfix with LDAP: [yes(user edit forwarding)]')."\n"; + echo ' --cyrus '.lang('Cyrus IMAP: Admin user,Password')."\n"; + echo ' --sieve '.lang('Sieve: Host[,Port(2000)]')."\n"; + echo ' --account-auth '.lang('account repository{sql(default) | ldap},[authentication{sql | ldap | mail | ads | http | ...}],[sql encrypttion{md5 | blowfish_crypt | md5_crypt | crypt}],[check save password{ (default)|True}],[allow cookie auth{ (default)|True}]')."\n"; + echo ' --ldap-host --ldap-root-dn --ldap-root-pw --ldap-context --ldap-group-context'."\n"; + } + if (!$what) + { + echo '--admin '.lang('creates an admin user: domain(default),[config user(admin)],password,username,password,[first name],[last name],[email]')."\n"; + echo '--language '.lang('install or update translations: domain(all),[config user(admin)],password,[[+]lang1[,lang2,...]] + adds, no langs update existing ones')."\n"; + echo '--backup '.lang('domain(all),[config user(admin)],password,[file-name(default: backup-dir/db_backup-YYYYMMDDHHii)]')."\n"; + echo '--update '.lang('run a database schema update (if necessary): domain(all),[config user(admin)],password')."\n"; + echo lang('You can use the header user and password for every domain too. If the password is not set via the commandline, it is read from the enviroment variable EGW_CLI_PASSWORD or queried from the user.')."\n"; + } + if (!$what || $what == 'header') + { + echo lang('Create or edit the eGroupWare configuration file: header.inc.php:')."\n"; + echo '--create-header '.lang('header-password[,header-user(admin)]')."\n"; + echo '--edit-header '.lang('[header-password],[header-user],[new-password],[new-user]')."\n"; + if (!$what) echo ' --help header '.lang('gives further options')."\n"; + } + if ($what == 'header') + { + echo "\n".lang('Additional options and there defaults (in brackets)')."\n"; + echo '--server-root '.lang('path of eGroupWare install directory (default auto-detected)')."\n"; + echo '--session-type '.lang('{db | php(default) | php-restore}')."\n"; + echo '--limit-access '.lang('comma separated ip-addresses or host-names, default access to setup from everywhere')."\n"; + echo '--mcrypt '.lang('use mcrypt to crypt session-data: {off(default) | on},[mcrypt-init-vector(default randomly generated)],[mcrypt-version]')."\n"; + echo '--db-persistent '.lang('use persistent db connections: {on(default) | off}')."\n"; + echo '--domain-selectbox '.lang('{off(default) | on}')."\n"; + + echo "\n".lang('Adding, editing or deleting an eGroupWare domain / database instance:')."\n"; + echo '--domain '.lang('add or edit a domain: [domain-name(default)],[db-name(egroupware)],[db-user(egroupware)],db-password,[db-type(mysql)],[db-host(localhost)],[db-port(db specific)],[config-user(as header)],[config-passwd(as header)]')."\n"; + echo '--delete-domain '.lang('domain-name')."\n"; + } + if (!$what) + { + echo '--help list '.lang('List availible values')."\n"; + } + if ($what == 'list') + { + echo lang('List availible values').":\n"; + echo '--languages '.lang('list of availible translations')."\n"; + echo '--charsets '.lang('charsets used by the different languages')."\n"; + echo '--exit-codes '.lang('all exit codes of the command line interface')."\n"; + } + if (!$what || !in_array($what,array('config','header','list'))) + { + echo '--help [config|header|list] '.lang('gives further options')."\n"; + } } function fail($exit_code,$message) @@ -861,7 +952,7 @@ function list_exit_codes() if (preg_match('/fail\(([0-9]+),(.*)\);/',$line,$matches)) { //echo "Line $n: $matches[1]: $matches[2]\n"; - eval('$codes['.$matches[1].'] = '.$matches[2].';'); + @eval('$codes['.$matches[1].'] = '.$matches[2].';'); } } ksort($codes,SORT_NUMERIC);