From f1eb5420a7b67f1b55734e87b939609eb3a722a8 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Mon, 2 Jun 2014 12:35:45 +0200 Subject: [PATCH] add option to enable/disable generation of bind-configs for the system-hostname Signed-off-by: Michael Kaufmann (d00p) --- actions/admin/settings/160.nameserver.php | 8 +++++++ install/froxlor.sql | 3 ++- .../updates/froxlor/0.9/update_0.9.inc.php | 10 ++++++++ .../preconfig/0.9/preconfig_0.9.inc.php | 11 +++++++++ lib/cron_init.php | 2 +- lib/tables.inc.php | 2 +- lng/english.lng.php | 1 + lng/german.lng.php | 1 + scripts/jobs/cron_tasks.inc.dns.10.bind.php | 24 ++++++++++--------- 9 files changed, 48 insertions(+), 14 deletions(-) diff --git a/actions/admin/settings/160.nameserver.php b/actions/admin/settings/160.nameserver.php index 8c9341f7..095677b6 100644 --- a/actions/admin/settings/160.nameserver.php +++ b/actions/admin/settings/160.nameserver.php @@ -78,6 +78,14 @@ return array( 'default' => '', 'save_method' => 'storeSettingField', ), + 'system_dns_createhostnameentry' => array( + 'label' => $lng['serversettings']['dns_createhostnameentry'], + 'settinggroup' => 'system', + 'varname' => 'dns_createhostnameentry', + 'type' => 'bool', + 'default' => false, + 'save_method' => 'storeSettingField' + ), 'system_dns_createmailentry' => array( 'label' => $lng['serversettings']['mail_also_with_mxservers'], 'settinggroup' => 'system', diff --git a/install/froxlor.sql b/install/froxlor.sql index b2e64de8..1c060388 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -504,6 +504,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'crondreload', '/etc/init.d/cron reload'), ('system', 'croncmdline', '/usr/bin/nice -n 5 /usr/bin/php5 -q'), ('system', 'cron_allowautoupdate', '0'), + ('system', 'dns_createhostnameentry', '0'), ('panel', 'decimal_places', '4'), ('panel', 'adminmail', 'admin@SERVERNAME'), ('panel', 'phpmyadmin_url', ''), @@ -531,7 +532,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('panel', 'phpconfigs_hidestdsubdomain', '0'), ('panel', 'allow_theme_change_admin', '1'), ('panel', 'allow_theme_change_customer', '1'), - ('panel', 'version', '0.9.32'); + ('panel', 'version', '0.9.33-dev2'); DROP TABLE IF EXISTS `panel_tasks`; diff --git a/install/updates/froxlor/0.9/update_0.9.inc.php b/install/updates/froxlor/0.9/update_0.9.inc.php index 7b0ed368..679ac4a9 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -2781,3 +2781,13 @@ if (isFroxlorVersion('0.9.32')) { updateToVersion('0.9.33-dev1'); } + +if (isFroxlorVersion('0.9.33-dev1')) { + showUpdateStep("Updating from 0.9.33-dev1 to 0.9.33-dev2", false); + + showUpdateStep("Adding settings for hostname-dns-entry"); + Settings::AddNew("system.dns_createhostnameentry", isset($_POST['dns_createhostnameentry']) ? (int)$_POST['dns_createhostnameentry'] : '0'); + lastStepStatus(0); + + updateToVersion('0.9.33-dev2'); +} diff --git a/install/updates/preconfig/0.9/preconfig_0.9.inc.php b/install/updates/preconfig/0.9/preconfig_0.9.inc.php index a408b41c..206d871b 100644 --- a/install/updates/preconfig/0.9/preconfig_0.9.inc.php +++ b/install/updates/preconfig/0.9/preconfig_0.9.inc.php @@ -668,4 +668,15 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) { eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); } + if (versionInUpdate($current_version, '0.9.33-dev2')) { + // only if bind is used - if not the default will be set, which is '0' (off) + if (Settings::get('system.bind_enable') == 1) { + $has_preconfig = true; + $description = 'You can enable/disable the generation of the bind-zone / config for the system hostname.

'; + $question = 'Do you want to generate a bind-zone for the system-hostname? (default: no): '; + $question.= makeyesno('dns_createhostnameentry', '1', '0', '0').'
'; + eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); + } + } + } diff --git a/lib/cron_init.php b/lib/cron_init.php index 28c4acfb..bd49828c 100644 --- a/lib/cron_init.php +++ b/lib/cron_init.php @@ -143,7 +143,7 @@ fwrite($debugHandler, 'Database-connection established' . "\n"); * if using fcgid or fpm for froxlor-vhost itself, we have to check * whether the permission of the files are still correct */ -fwrite($debugHandler, 'Checking froxlor file permissions'); +fwrite($debugHandler, 'Checking froxlor file permissions'."\n"); $_mypath = makeCorrectDir(FROXLOR_INSTALL_DIR); if (((int)Settings::Get('system.mod_fcgid') == 1 && (int)Settings::Get('system.mod_fcgid_ownvhost') == 1) diff --git a/lib/tables.inc.php b/lib/tables.inc.php index 8f493600..0669d55d 100644 --- a/lib/tables.inc.php +++ b/lib/tables.inc.php @@ -51,6 +51,6 @@ define('TABLE_PANEL_DOMAIN_SSL_SETTINGS', 'domain_ssl_settings'); define('TABLE_DOMAINTOIP', 'panel_domaintoip'); // VERSION INFO -$version = '0.9.33-dev1'; +$version = '0.9.33-dev2'; $dbversion = '2'; $branding = ''; diff --git a/lng/english.lng.php b/lng/english.lng.php index 7043d8b9..073d0379 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1822,3 +1822,4 @@ $lng['error']['passwordshouldnotbeusername'] = 'The password should not be the s // Added in Froxlor 0.9.33 $lng['admin']['customer_show_news_feed'] = "Show custom newsfeed on customer-dashboard"; $lng['admin']['customer_news_feed_url'] = "RSS-Feed for the custom newsfeed"; +$lng['serversettings']['dns_createhostnameentry'] = "Create bind-zone/config for system hostname"; diff --git a/lng/german.lng.php b/lng/german.lng.php index e5c3fdfd..1eba97b7 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1546,3 +1546,4 @@ $lng['error']['passwordshouldnotbeusername'] = 'Das Passwort sollte nicht mit de // Added in Froxlor 0.9.33 $lng['admin']['customer_show_news_feed'] = "Zeige benutzerdefinierten Newsfeed im Kunden-Dashboard"; $lng['admin']['customer_news_feed_url'] = "RSS-Feed für den benutzerdefinierten Newsfeed"; +$lng['serversettings']['dns_createhostnameentry'] = "Erstelle bind-Zone/Konfiguration für den System-Hostnamen"; diff --git a/scripts/jobs/cron_tasks.inc.dns.10.bind.php b/scripts/jobs/cron_tasks.inc.dns.10.bind.php index 43eec84d..b722a10b 100644 --- a/scripts/jobs/cron_tasks.inc.dns.10.bind.php +++ b/scripts/jobs/cron_tasks.inc.dns.10.bind.php @@ -89,17 +89,19 @@ class bind { } // frolxor-hostname (#1090) - $hostname_arr = array( - 'id' => 'none', - 'domain' => Settings::Get('system.hostname'), - 'customerid' => 'none', - 'loginname' => 'froxlor.panel', - 'bindserial' => date('Ymd').'00', - 'dkim' => '0', - 'iswildcarddomain' => '1', - 'zonefile' => '' - ); - $bindconf_file .= $this->_generateDomainConfig($hostname_arr, true); + if (Settings::get('system.dns_createhostnameentry') == 1) { + $hostname_arr = array( + 'id' => 'none', + 'domain' => Settings::Get('system.hostname'), + 'customerid' => 'none', + 'loginname' => 'froxlor.panel', + 'bindserial' => date('Ymd').'00', + 'dkim' => '0', + 'iswildcarddomain' => '1', + 'zonefile' => '' + ); + $bindconf_file .= $this->_generateDomainConfig($hostname_arr, true); + } $bindconf_file_handler = fopen(makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w'); fwrite($bindconf_file_handler, $bindconf_file);