diff --git a/README.md b/README.md index 79e7c6a2e279c9672c049bea40b35c47f7045fc1..0e0ddd461e30bd9dafe90db257358d1eb5c07e95 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,16 @@ This module is compatible with ISPConfig version 3.1 ## Installation -This module have to be installed on master node in multiserver setup. +This module has to be installed on master node in multiserver setup. - Download this repo as archive, unpack it to `/usr/local/ispconfig/interface/web/` and rename forlder to `wizard` OR clone repo using git `git clone https://git.ispconfig.org/ispconfig/module-wizard.git /usr/local/ispconfig/interface/web/wizard` - Create DB table provided in db.sql file `mysql -u root -p < db.sql` - Enable module in user interface System -> CP Users -> Admin user -> Check "wizard" and save. - If it doesn't work, enable module manually by editing admin user in DB table `sys_user` column `modules` - + +On a slave server you only have to create the database table using the instructions above. + ## Planned features - Export results as PDF diff --git a/db.sql b/db.sql index dfeb121b37251d5595c822daf62a5eae482546e0..879ee9a71641bd52189aab2dfd4f7b7c4f7d8ab3 100644 --- a/db.sql +++ b/db.sql @@ -62,6 +62,7 @@ CREATE TABLE `wizard_template` ( `http_port` int(11) NOT NULL DEFAULT '80', `https_port` int(11) NOT NULL DEFAULT '443', `log_retention` int(11) NOT NULL DEFAULT '30', + `proxy_protocol` ENUM('n','y') NOT NULL DEFAULT 'n', `apache_directives` mediumtext, `nginx_directives` mediumtext, `php_fpm_use_socket` enum('n','y') NOT NULL DEFAULT 'n', @@ -74,6 +75,13 @@ CREATE TABLE `wizard_template` ( `pm_process_idle_timeout` int(11) unsigned NOT NULL DEFAULT '10', `pm_max_requests` int(11) unsigned NOT NULL DEFAULT '0', `custom_php_ini` mediumtext, + `backup_interval` varchar(255) NOT NULL DEFAULT 'none', + `backup_copies` int(11) NOT NULL DEFAULT 1, + `backup_format_web` varchar(255) NOT NULL DEFAULT 'default', + `backup_format_db` varchar(255) NOT NULL DEFAULT 'gzip', + `backup_encrypt` enum('n','y') NOT NULL DEFAULT 'n', + `backup_password` varchar(255) NOT NULL DEFAULT '', + `backup_excludes` mediumtext DEFAULT NULL, `database_charset` varchar(64) DEFAULT NULL, `database_remote_access` enum('n','y') NOT NULL DEFAULT 'n', `database_remote_ips` text, @@ -90,3 +98,16 @@ CREATE TABLE `wizard_template` ( `enablepop3` enum('n','y') NOT NULL DEFAULT 'y', PRIMARY KEY (`template_id`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +ALTER TABLE `wizard_template` + ADD COLUMN `proxy_protocol` ENUM('n','y') NOT NULL DEFAULT 'n' AFTER `log_retention`; + +ALTER TABLE `wizard_template` + ADD COLUMN `server_php_id` int(11) UNSIGNED NOT NULL DEFAULT 0; + +ALTER TABLE `wizard_template` ADD `jailkit_chroot_app_sections` mediumtext NULL DEFAULT NULL; +ALTER TABLE `wizard_template` ADD `jailkit_chroot_app_programs` mediumtext NULL DEFAULT NULL; +ALTER TABLE `wizard_template` ADD `delete_unused_jailkit` enum('n','y') NOT NULL DEFAULT 'n'; +ALTER TABLE `wizard_template` ADD `last_jailkit_update` date NULL DEFAULT NULL; +ALTER TABLE `wizard_template` ADD `last_jailkit_hash` varchar(255) DEFAULT NULL; + diff --git a/db_update_3.2.sql b/db_update_3.2.sql new file mode 100644 index 0000000000000000000000000000000000000000..027f9c649912185890ced983ed6f74ac4c7d8c4d --- /dev/null +++ b/db_update_3.2.sql @@ -0,0 +1,37 @@ + +ALTER TABLE `wizard_template` + ADD COLUMN `proxy_protocol` ENUM('n','y') NOT NULL DEFAULT 'n' AFTER `log_retention`; +ALTER TABLE `wizard_template` + ADD COLUMN `server_php_id` int(11) UNSIGNED NOT NULL DEFAULT 0; + + +ALTER TABLE `wizard_template` ADD `backup_interval` varchar(255) NOT NULL DEFAULT 'none' AFTER `custom_php_ini`; +ALTER TABLE `wizard_template` ADD `backup_copies` int(11) NOT NULL DEFAULT 1 AFTER `backup_interval`; + +-- backup format +ALTER TABLE `wizard_template` ADD `backup_format_web` VARCHAR( 255 ) NOT NULL default 'default' AFTER `backup_copies`; +ALTER TABLE `wizard_template` ADD `backup_format_db` VARCHAR( 255 ) NOT NULL default 'gzip' AFTER `backup_format_web`; +-- end of backup format + +-- backup encryption +ALTER TABLE `wizard_template` ADD `backup_encrypt` enum('n','y') NOT NULL DEFAULT 'n' AFTER `backup_format_db`; +ALTER TABLE `wizard_template` ADD `backup_password` VARCHAR( 255 ) NOT NULL DEFAULT '' AFTER `backup_encrypt`; +-- end of backup encryption + +ALTER TABLE `wizard_template` ADD `backup_excludes` mediumtext DEFAULT NULL AFTER `backup_password`; + +ALTER TABLE `wizard_template` ADD `jailkit_chroot_app_sections` mediumtext NULL DEFAULT NULL; +ALTER TABLE `wizard_template` ADD `jailkit_chroot_app_programs` mediumtext NULL DEFAULT NULL; +ALTER TABLE `wizard_template` ADD `delete_unused_jailkit` enum('n','y') NOT NULL DEFAULT 'n'; +ALTER TABLE `wizard_template` ADD `last_jailkit_update` date NULL DEFAULT NULL; +ALTER TABLE `wizard_template` ADD `last_jailkit_hash` varchar(255) DEFAULT NULL; + +-- Match incremental/upd_0091.sql +ALTER TABLE `wizard_template` ALTER pm SET DEFAULT 'ondemand'; +ALTER TABLE `wizard_template` DROP COLUMN `enable_spdy`; +ALTER TABLE `wizard_template` ADD `folder_directive_snippets` TEXT NULL AFTER `https_port`; +ALTER TABLE `wizard_template` CHANGE `apache_directives` `apache_directives` mediumtext NULL DEFAULT NULL; +ALTER TABLE `wizard_template` CHANGE `nginx_directives` `nginx_directives` mediumtext NULL DEFAULT NULL; + +-- Match incremental/upd_0092.sql +ALTER TABLE `wizard_template` DROP COLUMN `fastcgi_php_version`; diff --git a/form/new_service.tform.php b/form/new_service.tform.php index 21b961417040f0fd1c70c10bfd0025e727a8efa9..9d42a8b3aecb12993a45fc59abae3cdde8845b1f 100644 --- a/form/new_service.tform.php +++ b/form/new_service.tform.php @@ -79,6 +79,9 @@ $form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete +// Admin always right? +$wildcard_available = TRUE; + $form["tabs"]['client'] = array( 'title' => "New service", 'description' => 'Create domain, mail domain, site, database and ftp/ssh', @@ -161,6 +164,12 @@ $form["tabs"]['client'] = array( ), 'value' => '', ), + 'subdomain' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => 'template', + 'value' => ($wildcard_available ? array('template' => 'use_template_txt', 'none' => 'none_txt', 'www' => 'www.', '*' => '*.') : array('none' => 'none_txt', 'www' => 'www.')) + ), 'db' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', @@ -243,7 +252,7 @@ $form["tabs"]['client'] = array( 'dns' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', - 'default' => 'y', + 'default' => 'n', 'value' => array(0 => 'n', 1 => 'y') ), 'dns_template_id' => array( @@ -258,4 +267,4 @@ $form["tabs"]['client'] = array( 'value' => '', ), ) -); \ No newline at end of file +); diff --git a/lib/lang/cz_new_service.lng b/lib/lang/cz_new_service.lng index 0166b69e5b30dc772d2ec0504aed6d4a17dd763e..d96c56b1ec1c1946fa37a13e08db2fdc5a70c563 100644 --- a/lib/lang/cz_new_service.lng +++ b/lib/lang/cz_new_service.lng @@ -45,4 +45,7 @@ $wb['error_email_empty'] = 'Email prázdné.'; $wb['error_domain_regex'] = 'Doména obsahuje neplatné znaky.'; $wb['error_ns1_regex'] = 'NS1 obsahuje neplatné znaky.'; $wb['error_ns2_regex'] = 'NS2 obsahuje neplatné znaky.'; -$wb['error_email_regex'] = 'Email neosahuje platnou emailovou adresu.'; \ No newline at end of file +$wb['error_email_regex'] = 'Email neosahuje platnou emailovou adresu.'; +$wb['subdomain_txt'] = 'Auto-Subdomain'; +$wb['none_txt'] = 'None'; +$wb['use_template_txt'] = 'Use template value'; diff --git a/lib/lang/en_new_service.lng b/lib/lang/en_new_service.lng index c7013fd084672d01a08742a19dc9bebffa38e90a..7ef5238993eee5549446eed8c45564fac57ddddd 100644 --- a/lib/lang/en_new_service.lng +++ b/lib/lang/en_new_service.lng @@ -46,4 +46,7 @@ $wb['error_email_empty'] = 'Email empty.'; $wb['error_domain_regex'] = 'Domain contains invalid characters.'; $wb['error_ns1_regex'] = 'NS1 contains invalid characters.'; $wb['error_ns2_regex'] = 'NS2 contains invalid characters.'; -$wb['error_email_regex'] = 'Email does not contain a valid email address.'; \ No newline at end of file +$wb['error_email_regex'] = 'Email does not contain a valid email address.'; +$wb['subdomain_txt'] = 'Auto-Subdomain'; +$wb['none_txt'] = 'None'; +$wb['use_template_txt'] = 'Use template value'; diff --git a/lib/lang/es_new_service.lng b/lib/lang/es_new_service.lng index 53ae9eaae88e1e42199346e501905ca0a6d5c066..252d146d82e3a6bc09fd05ac77b3812a5b6c56dd 100644 --- a/lib/lang/es_new_service.lng +++ b/lib/lang/es_new_service.lng @@ -45,3 +45,6 @@ $wb['error_domain_regex'] = 'El dominio contiene caracteres erroneos.'; $wb['error_ns1_regex'] = 'NS1 contiene caracteres erroneos.'; $wb['error_ns2_regex'] = 'NS2 contiene caracteres erroneos.'; $wb['error_email_regex'] = 'El Email no contiene una direccion valida.'; +$wb['subdomain_txt'] = 'Auto-Subdomain'; +$wb['none_txt'] = 'None'; +$wb['use_template_txt'] = 'Use template value'; diff --git a/new_service.php b/new_service.php index 918d5a395a9f884798d08c80a888d34c251eae62..176c378f9a055069015a828c2b28099f3ce894c6 100644 --- a/new_service.php +++ b/new_service.php @@ -83,10 +83,21 @@ class page_action extends tform_actions { global $app, $conf; $fields = $app->tform->encode($this->dataRecord, $app->tform->getCurrentTab(), true); + $client_domain_exists = FALSE; // check for domain unique name - if($app->db->queryOneRecord('SELECT domain_id FROM domain WHERE domain = "'.$fields['domain'].'"')) { - $app->tform->errorMessage = $app->tform->wordbook['domain_error_unique']; + if($app->db->queryOneRecord('SELECT domain_id FROM domain WHERE domain = ?', $fields['domain'])) { + $client_domain_exists = TRUE; + // Check use as web domain. + if($app->db->queryOneRecord('SELECT domain_id FROM web_domain WHERE domain = ?', $fields['domain'])) { + $app->tform->errorMessage = $app->tform->wordbook['domain_error_unique'] . 'b'; + } + elseif($fields['mail'] && $app->db->queryOneRecord('SELECT domain_id FROM mail_domain WHERE domain = ?', $fields['domain'])) { + $app->tform->errorMessage = $app->tform->wordbook['domain_error_unique']. 'a'; + } + else { + // Exists as client domain, not with a website. + } } if($app->tform->errorMessage) @@ -114,7 +125,9 @@ class page_action extends tform_actions { $client_group_id = $res['groupid']; // add domain - $domain_id = $remote->insert_query('../client/form/domain.tform.php', $fields['client_id'], array('domain' => $fields['domain'])); + if (!$client_domain_exists) { + $domain_id = $remote->insert_query('../client/form/domain.tform.php', $fields['client_id'], array('domain' => $fields['domain'])); + } $min_password_length = 8; if(isset($server_config_array['misc']['min_password_length'])) $min_password_length = $server_config_array['misc']['min_password_length']; @@ -399,7 +412,7 @@ class page_action extends tform_actions { 'python' => $template['python'], 'perl' => $template['perl'], 'errordocs' => $template['errordocs'], - 'subdomain' => $template['subdomain'], + 'subdomain' => $fields['subdomain'] == 'template' ? $template['subdomain'] : $fields['subdomain'], 'php' => $template['php'], 'fastcgi_php_version' => $template['fastcgi_php_version'], 'seo_redirect' => $template['seo_redirect'], @@ -500,7 +513,7 @@ class page_action extends tform_actions { 'server_id' => $template['web_server_id'], 'parent_domain_id' => $site_id, 'username' => $client_ftp_prefix . $generated_username, - 'username_prefix' => $client_prefix, + 'username_prefix' => $client_ftp_prefix, 'password' => $app->auth->get_random_password($min_password_length, true), 'quota_size' => $template['hd_quota'], 'dir' => $site_data['document_root'], @@ -537,7 +550,7 @@ class page_action extends tform_actions { 'shell' => $template['shell'], 'active' => 'y', 'username' => $client_shell_prefix . $generated_username, - 'username_prefix' => $client_prefix, + 'username_prefix' => $client_shell_prefix, ); // username, password @@ -550,7 +563,8 @@ class page_action extends tform_actions { $remote->insert_query('../sites/form/shell_user.tform.php', $fields['client_id'], $ssh_params); } - $dbserver = $app->db->queryOneRecord("SELECT server_name FROM server WHERE web_server = 1 AND server_id = ?", $template['database_server_id']); + $dbserver = $app->db->queryOneRecord("SELECT server_name FROM server WHERE web_server = 1 AND server_id = ?", $template['database_server_id']); + $webserver = $app->db->queryOneRecord("SELECT server_name FROM server WHERE web_server = 1 AND server_id = ?", $template['web_server_id']); $global_config = $app->getconf->get_global_config('sites'); $phpmyadmin_url = $global_config['phpmyadmin_url']; @@ -580,7 +594,7 @@ class page_action extends tform_actions { '.$db_user_params['database_user'].' '.$db_user_params['database_password'].' - '.$phpmyadmin_url.' + '.$phpmyadmin_url.' '; } if(isset($ftp_params)) { @@ -601,12 +615,12 @@ class page_action extends tform_actions { SSH user SSH password - SSH Server + SSH Server '.$ssh_params['username'].' '.$ssh_params['password'].' - '.$webserver['server_name'].' + '.$webserver['server_name'].' '; } if(isset($mailbox_passwords) and (bool)count($mailbox_passwords)) @@ -630,6 +644,28 @@ class page_action extends tform_actions { '; + + // Loading the template + $app->uses('tpl'); + $app->tpl->newTemplate("templates/template_summary_plaintext.htm"); + + $app->tpl->setVar('sitedomain', $fields['domain']); + $app->tpl->setVar('database_username', $db_user_params['database_user']); + $app->tpl->setVar('database_password', $db_user_params['database_password']); + + if(isset($ftp_params)) { + $app->tpl->setVar('ftp_server_name', $webserver['server_name']); + $app->tpl->setVar('ftp_username', $ftp_params['username']); + $app->tpl->setVar('ftp_password', $ftp_params['password']); + } + + $app->tpl->setVar('ssh_server_name', $webserver['server_name']); + $app->tpl->setVar('ssh_username', $ssh_params['username']); + $app->tpl->setVar('ssh_password', $ssh_params['password']); + // TODO +// $app->tpl->setVar('mailbox_passwords', $mailbox_passwords); + + $app->tpl->pparse(); } private function clean_private_key($key) diff --git a/templates/new_service.htm b/templates/new_service.htm index 4c64065e3748ab35f3c57cf61a9e423a32a66424..31432411d5f32eb0ffd178e4938b4c54b7d09755 100644 --- a/templates/new_service.htm +++ b/templates/new_service.htm @@ -33,6 +33,14 @@ +
+ +
+
+ +
@@ -177,6 +185,7 @@