Skip to content

Commit 796661c

Browse files
author
Marius Cramer
committed
Merge branch 'master' into 'master'
FS#2403 - Disable apps vhost in server config See merge request !235
2 parents 6495dda + abee909 commit 796661c

File tree

84 files changed

+312
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+312
-9
lines changed

install/sql/incremental/upd_dev_collection.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,9 @@ CREATE TABLE `server_ip_map` (
168168
ALTER TABLE `web_domain` ADD COLUMN `rewrite_to_https` ENUM('y','n') NOT NULL DEFAULT 'n' AFTER `seo_redirect`;
169169

170170
ALTER TABLE openvz_ip ADD COLUMN `additional` VARCHAR(255) NOT NULL DEFAULT 'n';
171+
172+
ALTER TABLE openvz_template ADD COLUMN `custom` text;
173+
174+
ALTER TABLE openvz_vm
175+
ADD COLUMN `bootorder` INT(11) NOT NULL DEFAULT '1' AFTER `start_boot`,
176+
ADD COLUMN `custom` text;

install/sql/ispconfig3.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,14 +1093,15 @@ CREATE TABLE IF NOT EXISTS `openvz_template` (
10931093
`capability` varchar(255) DEFAULT NULL,
10941094
`features` varchar(255) DEFAULT NULL,
10951095
`iptables` varchar(255) DEFAULT NULL,
1096+
`custom` text,
10961097
PRIMARY KEY (`template_id`)
10971098
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
10981099

10991100
--
11001101
-- Dumping data for table `openvz_template`
11011102
--
11021103

1103-
INSERT INTO `openvz_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `diskspace`, `traffic`, `bandwidth`, `ram`, `ram_burst`, `cpu_units`, `cpu_num`, `cpu_limit`, `io_priority`, `active`, `description`, `numproc`, `numtcpsock`, `numothersock`, `vmguarpages`, `kmemsize`, `tcpsndbuf`, `tcprcvbuf`, `othersockbuf`, `dgramrcvbuf`, `oomguarpages`, `privvmpages`, `lockedpages`, `shmpages`, `physpages`, `numfile`, `avnumproc`, `numflock`, `numpty`, `numsiginfo`, `dcachesize`, `numiptent`, `swappages`, `hostname`, `nameserver`, `create_dns`, `capability`, `features`, `iptables`) VALUES(1, 1, 1, 'riud', 'riud', '', 'small', 10, -1, -1, 256, 512, 1000, 4, 400, 4, 'y', '', '999999:999999', '7999992:7999992', '7999992:7999992', '65536:65536', '2147483646:2147483646', '214748160:396774400', '214748160:396774400', '214748160:396774400', '214748160:396774400', '65536:65536', '131072:131072', '999999:999999', '65536:65536', '0:2147483647', '23999976:23999976', '180:180', '999999:999999', '500000:500000', '999999:999999', '2147483646:2147483646', '999999:999999', '256000:256000', 'v{VEID}.test.tld', '8.8.8.8 8.8.4.4', 'n', '', '', '');
1104+
INSERT INTO `openvz_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `diskspace`, `traffic`, `bandwidth`, `ram`, `ram_burst`, `cpu_units`, `cpu_num`, `cpu_limit`, `io_priority`, `active`, `description`, `numproc`, `numtcpsock`, `numothersock`, `vmguarpages`, `kmemsize`, `tcpsndbuf`, `tcprcvbuf`, `othersockbuf`, `dgramrcvbuf`, `oomguarpages`, `privvmpages`, `lockedpages`, `shmpages`, `physpages`, `numfile`, `avnumproc`, `numflock`, `numpty`, `numsiginfo`, `dcachesize`, `numiptent`, `swappages`, `hostname`, `nameserver`, `create_dns`, `capability`, `features`, `iptables`, `custom`) VALUES(1, 1, 1, 'riud', 'riud', '', 'small', 10, -1, -1, 256, 512, 1000, 4, 400, 4, 'y', '', '999999:999999', '7999992:7999992', '7999992:7999992', '65536:65536', '2147483646:2147483646', '214748160:396774400', '214748160:396774400', '214748160:396774400', '214748160:396774400', '65536:65536', '131072:131072', '999999:999999', '65536:65536', '0:2147483647', '23999976:23999976', '180:180', '999999:999999', '500000:500000', '999999:999999', '2147483646:2147483646', '999999:999999', '256000:256000', 'v{VEID}.test.tld', '8.8.8.8 8.8.4.4', 'n', '', '', '', '');
11041105

11051106
-- --------------------------------------------------------
11061107

@@ -1141,6 +1142,7 @@ CREATE TABLE IF NOT EXISTS `openvz_vm` (
11411142
`hostname` varchar(255) DEFAULT NULL,
11421143
`vm_password` varchar(255) DEFAULT NULL,
11431144
`start_boot` varchar(255) NOT NULL DEFAULT 'y',
1145+
`bootorder` int(11) NOT NULL DEFAULT '1',
11441146
`active` varchar(255) NOT NULL DEFAULT 'y',
11451147
`active_until_date` date NOT NULL DEFAULT '0000-00-00',
11461148
`description` text,
@@ -1159,6 +1161,7 @@ CREATE TABLE IF NOT EXISTS `openvz_vm` (
11591161
`features` text,
11601162
`iptabless` text,
11611163
`config` mediumtext,
1164+
`custom` text,
11621165
PRIMARY KEY (`vm_id`)
11631166
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
11641167

install/tpl/server.ini.master

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ user=www-data
7272
group=www-data
7373
nginx_user=www-data
7474
nginx_group=www-data
75+
apps_vhost_enabled=y
7576
apps_vhost_port=8081
7677
apps_vhost_ip=_default_
7778
apps_vhost_servername=
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
/**
4+
Copyright (c) 2015, Florian Schaal, schaal @it
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
@author Florian Schaal, info@schaal-24.de
31+
@copyrighth Florian Schaal, info@schaal-24.de
32+
*/
33+
34+
class validate_openvz {
35+
36+
function get_error($errmsg, $additional='') {
37+
global $app;
38+
if(isset($app->tform->wordbook[$errmsg])) {
39+
return $app->tform->wordbook[$errmsg].$additional."<br>\r\n";
40+
} else {
41+
return $errmsg."<br>".$additional."<br>\r\n";
42+
}
43+
}
44+
45+
function check_custom($field_name, $field_value, $validator) {
46+
$template = file('../vm/templates/openvz.conf.tpl', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
47+
$custom_array = explode("\n", $field_value);
48+
$used_parameters = array();
49+
foreach ($template as $line) {
50+
$line = trim ($line);
51+
if (preg_match('/^[^#].*=\".*\"/', $line)) {
52+
$line = explode('=', $line, 2);
53+
$used_parameters[] = $line[0];
54+
}
55+
}
56+
foreach ($custom_array as $check) {
57+
$check = trim(strtoupper($check));
58+
$check = explode('=', trim($check), 2);
59+
$check = trim($check[0]);
60+
if (in_array($check, $used_parameters)) {
61+
return $this->get_error($validator['errmsg'], $check);
62+
}
63+
}
64+
}
65+
66+
}

interface/lib/plugins/vm_openvz_plugin.inc.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ function openvz_vm_delete($event_name, $page_form) {
130130
global $app, $conf;
131131

132132
//* Free the IP address
133-
$tmp = $app->db->queryOneRecord("SELECT ip_address_id FROM openvz_ip WHERE vm_id = ?", $page_form->id);
134-
$app->db->datalogUpdate('openvz_ip', array('vm_id' => 0), 'ip_address_id', $tmp['ip_address_id']);
135-
unset($tmp);
136-
133+
$tmp_rec = $app->db->queryAllRecords("SELECT ip_address_id FROM openvz_ip WHERE vm_id = ?", $page_form->id);
134+
foreach ($tmp_rec as $tmp) {
135+
$app->db->datalogUpdate('openvz_ip', array('vm_id' => 0), 'ip_address_id', $tmp['ip_address_id']);
136+
}
137137
}
138138

139139
private function applyTemplate() {
@@ -154,8 +154,9 @@ private function applyTemplate() {
154154
$sql .= "capability = ?, ";
155155
$sql .= "features = ?, ";
156156
$sql .= "iptables = ? ";
157+
$sql .= "custom = ? ";
157158
$sql .= "WHERE vm_id = ?";
158-
$app->db->query($sql, $tpl['diskspace'], $tpl['ram'], $tpl['ram_burst'], $tpl['cpu_units'], $tpl['cpu_num'], $tpl['cpu_limit'], $tpl['io_priority'], $tpl['nameserver'], $tpl['create_dns'], $tpl['capability'], $tpl['features'], $tpl['iptables'], $this->id);
159+
$app->db->query($sql, $tpl['diskspace'], $tpl['ram'], $tpl['ram_burst'], $tpl['cpu_units'], $tpl['cpu_num'], $tpl['cpu_limit'], $tpl['io_priority'], $tpl['nameserver'], $tpl['create_dns'], $tpl['capability'], $tpl['features'], $tpl['iptables'], $tpl['custom'], $this->id);
159160

160161
}
161162

@@ -174,6 +175,7 @@ private function makeOpenVZConfig() {
174175
$onboot = ($vm['start_boot'] == 'y')?'yes':'no';
175176
$tpl->setVar('onboot', $onboot);
176177

178+
$tpl->setVar('bootorder', $vm['bootorder']);
177179
$tpl->setVar('kmemsize', $vm_template['kmemsize']);
178180
$tpl->setVar('lockedpages', $vm_template['lockedpages']);
179181
$tpl->setVar('privvmpages', $burst_ram.':'.$burst_ram);
@@ -228,6 +230,8 @@ private function makeOpenVZConfig() {
228230
$tpl->setVar('features', $vm['features']);
229231
$tpl->setVar('iptables', $vm['iptables']);
230232

233+
$tpl->setVar('custom', $vm['custom']);
234+
231235
$tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ?", $app->functions->intval($vm['ostemplate_id']));
232236
$tpl->setVar('ostemplate', $tmp['template_file']);
233237
unset($tmp);

interface/web/admin/form/server_config.tform.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,12 @@
10381038
1 => 'y'
10391039
)
10401040
),
1041+
'apps_vhost_enabled' => array (
1042+
'datatype' => 'VARCHAR',
1043+
'formtype' => 'CHECKBOX',
1044+
'default' => 'y',
1045+
'value' => array (0 => 'n', 1 => 'y')
1046+
),
10411047
'apps_vhost_port' => array(
10421048
'datatype' => 'VARCHAR',
10431049
'formtype' => 'TEXT',

interface/web/admin/lib/lang/ar_server_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,5 @@ $wb['crontab_dir_error_regex'] = 'Invalid crontab directory.';
255255
$wb['cron_wget_error_regex'] = 'Invalid cron wget path.';
256256
$wb['network_filesystem_txt'] = 'Network Filesystem';
257257
$wb["disable_bind_log_txt"] = "Disable bind9 messages for Loglevel WARN";
258+
$wb["apps_vhost_enabled_txt"] = "Apps-vhost enabled";
258259
?>

interface/web/admin/lib/lang/bg_server_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,5 @@ $wb['crontab_dir_error_regex'] = 'Invalid crontab directory.';
255255
$wb['cron_wget_error_regex'] = 'Invalid cron wget path.';
256256
$wb['network_filesystem_txt'] = 'Network Filesystem';
257257
$wb["disable_bind_log_txt"] = "Disable bind9 messages for Loglevel WARN";
258+
$wb["apps_vhost_enabled_txt"] = "Apps-vhost enabled";
258259
?>

interface/web/admin/lib/lang/br_server_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,5 @@ $wb['crontab_dir_error_regex'] = 'Invalid crontab directory.';
255255
$wb['cron_wget_error_regex'] = 'Invalid cron wget path.';
256256
$wb['network_filesystem_txt'] = 'Network Filesystem';
257257
$wb["disable_bind_log_txt"] = "Disable bind9 messages for Loglevel WARN";
258+
$wb["apps_vhost_enabled_txt"] = "Apps-vhost enabled";
258259
?>

interface/web/admin/lib/lang/cz_server_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,5 +253,6 @@ $wb['crontab_dir_error_regex'] = 'Invalid crontab directory.';
253253
$wb['cron_wget_error_regex'] = 'Invalid cron wget path.';
254254
$wb['network_filesystem_txt'] = 'Network Filesystem';
255255
$wb["disable_bind_log_txt"] = "Disable bind9 messages for Loglevel WARN";
256+
$wb["apps_vhost_enabled_txt"] = "Apps-vhost enabled";
256257
?>
257258

0 commit comments

Comments
 (0)