From ed30c60150ffda0301eb1f8d30c93cac94de41df Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 25 Jul 2011 10:38:22 -0400
Subject: [PATCH] Fixed some warnings in the installer.
---
install/lib/installer_base.lib.php | 247 +++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 215 insertions(+), 32 deletions(-)
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index f9c4ba3..c7ec0ca 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -52,6 +52,10 @@
die('ERROR: '.$msg."\n");
}
+ public function warning($msg) {
+ echo('WARNING: '.$msg."\n");
+ }
+
public function simple_query($query, $answers, $default) {
$finished = false;
do {
@@ -113,11 +117,12 @@
if(is_installed('mysql') || is_installed('mysqld')) $conf['mysql']['installed'] = true;
if(is_installed('postfix')) $conf['postfix']['installed'] = true;
+ if(is_installed('mailman')) $conf['mailman']['installed'] = true;
if(is_installed('apache') || is_installed('apache2') || is_installed('httpd')) $conf['apache']['installed'] = true;
if(is_installed('getmail')) $conf['getmail']['installed'] = true;
if(is_installed('courierlogger')) $conf['courier']['installed'] = true;
if(is_installed('dovecot')) $conf['dovecot']['installed'] = true;
- if(is_installed('saslsauthd')) $conf['saslauthd']['installed'] = true;
+ if(is_installed('saslauthd')) $conf['saslauthd']['installed'] = true;
if(is_installed('amavisd-new')) $conf['amavis']['installed'] = true;
if(is_installed('clamdscan')) $conf['clamav']['installed'] = true;
if(is_installed('pure-ftpd') || is_installed('pure-ftpd-wrapper')) $conf['pureftpd']['installed'] = true;
@@ -125,7 +130,13 @@
if(is_installed('jk_chrootsh')) $conf['jailkit']['installed'] = true;
if(is_installed('pdns_server') || is_installed('pdns_control')) $conf['powerdns']['installed'] = true;
if(is_installed('named') || is_installed('bind') || is_installed('bind9')) $conf['bind']['installed'] = true;
-
+ if(is_installed('squid')) $conf['squid']['installed'] = true;
+ if(is_installed('nginx')) $conf['nginx']['installed'] = true;
+ if(is_installed('iptables') && is_installed('ufw')) $conf['ufw']['installed'] = true;
+ if(is_installed('fail2ban-server')) $conf['fail2ban']['installed'] = true;
+ if(is_dir("/etc/Bastille")) $conf['bastille']['installed'] = true;
+
+ if ($conf['services']['web'] && $conf['apache']['installed'] && is_file($conf['apache']["vhost_conf_enabled_dir"]."/000-ispconfig.vhost")) $this->ispconfig_interface_installed = true;
}
/** Create the database for ISPConfig */
@@ -222,6 +233,11 @@
$tpl_ini_array['dns']['named_conf_path'] = $conf['bind']['named_conf_path'];
$tpl_ini_array['dns']['named_conf_local_path'] = $conf['bind']['named_conf_local_path'];
+ if ($conf['nginx']['installed'] == true) {
+ $tpl_ini_array['nginx']['vhost_conf_dir'] = $conf['nginx']['vhost_conf_dir'];
+ $tpl_ini_array['nginx']['vhost_conf_enabled_dir'] = $conf['nginx']['vhost_conf_enabled_dir'];
+ }
+
if (array_key_exists('awstats', $conf)) {
foreach ($conf['awstats'] as $aw_sett => $aw_value) {
$tpl_ini_array['web']['awstats_'.$aw_sett] = $aw_value;
@@ -237,6 +253,8 @@
$file_server_enabled = ($conf['services']['file'])?1:0;
$db_server_enabled = ($conf['services']['db'])?1:0;
$vserver_server_enabled = ($conf['services']['vserver'])?1:0;
+ $proxy_server_enabled = ($conf['services']['proxy'])?1:0;
+ $firewall_server_enabled = ($conf['services']['firewall'])?1:0;
//** Get the database version number based on the patchfiles
$found = true;
@@ -256,13 +274,13 @@
if($conf['mysql']['master_slave_setup'] == 'y') {
//* Insert the server record in master DB
- $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
+ $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`,`firewall_server`,`proxy_server`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version, $proxy_server_enabled, $firewall_server_enabled);";
$this->dbmaster->query($sql);
$conf['server_id'] = $this->dbmaster->insertID();
$conf['server_id'] = $conf['server_id'];
//* Insert the same record in the local DB
- $sql = "INSERT INTO `server` (`server_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`) VALUES ('".$conf['server_id']."',1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
+ $sql = "INSERT INTO `server` (`server_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`,`firewall_server`,`proxy_server`) VALUES ('".$conf['server_id']."',1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version, $proxy_server_enabled, $firewall_server_enabled);";
$this->db->query($sql);
//* username for the ispconfig user
@@ -272,7 +290,7 @@
} else {
//* Insert the server, if its not a mster / slave setup
- $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
+ $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`,`firewall_server`,`proxy_server`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version, $proxy_server_enabled, $firewall_server_enabled);";
$this->db->query($sql);
$conf['server_id'] = $this->db->insertID();
$conf['server_id'] = $conf['server_id'];
@@ -281,7 +299,7 @@
}
- public function grant_master_database_rights() {
+ public function grant_master_database_rights($verbose = false) {
global $conf;
/*
@@ -336,6 +354,9 @@
*/
if ($value['pwd'] != ''){
$query = "CREATE USER '".$value['user']."'@'".$host."' IDENTIFIED BY '" . $value['pwd'] . "'";
+ if ($verbose){
+ echo "\n\n" . $query ."\n";
+ }
$this->dbmaster->query($query); // ignore the error
}
@@ -344,62 +365,98 @@
* In Case that it will not exist, do nothing (ignore the error!)
*/
$query = "REVOKE ALL PRIVILEGES, GRANT OPTION FROM '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo "\n\n" . $query ."\n";
+ }
$this->dbmaster->query($query); // ignore the error
//* Create the ISPConfig database user in the remote database
$query = "GRANT SELECT ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, INSERT ON ".$value['db'].".`sys_log` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`sys_datalog` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`software_update_inst` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, UPDATE(`updated`) ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, UPDATE (`ssl_request`, `ssl_cert`, `ssl_action`) ON ".$value['db'].".`web_domain` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT ON ".$value['db'].".`sys_group` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, UPDATE (`action_state`, `response`) ON ".$value['db'].".`sys_remoteaction` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, INSERT , DELETE ON ".$value['db'].".`monitor_data` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, INSERT, UPDATE ON ".$value['db'].".`mail_traffic` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, INSERT, UPDATE ON ".$value['db'].".`web_traffic` TO '".$value['user']."'@'".$host."' ";
+ if ($verbose){
+ echo $query ."\n";
+ }
if(!$this->dbmaster->query($query)) {
- $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
+ $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
}
@@ -446,6 +503,62 @@
copy('tpl/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh);
}
+ }
+
+ public function configure_mailman($status = 'insert') {
+ global $conf;
+
+ $config_dir = $conf['mailman']['config_dir'].'/';
+ $full_file_name = $config_dir.'mm_cfg.py';
+ //* Backup exiting file
+ if(is_file($full_file_name)) {
+ copy($full_file_name, $config_dir.'mm_cfg.py~');
+ }
+
+ // load files
+ $content = rf('tpl/mm_cfg.py.master');
+ $old_file = rf($full_file_name);
+
+ $old_options = array();
+ $lines = explode("\n", $old_file);
+ foreach ($lines as $line)
+ {
+ if (trim($line) != '' && substr($line, 0, 1) != '#')
+ {
+ @list($key, $value) = @explode("=", $line);
+ if (!empty($value))
+ {
+ $key = rtrim($key);
+ $old_options[$key] = trim($value);
+ }
+ }
+ }
+
+ $virtual_domains = '';
+ if($status == 'update')
+ {
+ // create virtual_domains list
+ $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain");
+
+ if(is_array($domainAll)) {
+ foreach($domainAll as $domain)
+ {
+ if ($domainAll[0]['domain'] == $domain['domain'])
+ $virtual_domains .= "'".$domain['domain']."'";
+ else
+ $virtual_domains .= ", '".$domain['domain']."'";
+ }
+ }
+ }
+ else
+ $virtual_domains = "' '";
+
+ $content = str_replace('{hostname}', $conf['hostname'], $content);
+ if(!isset($old_options['DEFAULT_SERVER_LANGUAGE'])) $old_options['DEFAULT_SERVER_LANGUAGE'] = ''
+ $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content);
+ $content = str_replace('{virtual_domains}', $virtual_domains, $content);
+
+ wf($full_file_name, $content);
}
public function configure_postfix($options = '') {
@@ -504,8 +617,10 @@
'myhostname = '.$conf['hostname'],
'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain',
'mynetworks = 127.0.0.0/8 [::1]/128',
+ 'alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases',
+ 'alias_database = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases',
'virtual_alias_domains =',
- 'virtual_alias_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_forwardings.cf, mysql:'.$config_dir.'/mysql-virtual_email2email.cf',
+ 'virtual_alias_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_forwardings.cf, proxy:mysql:'.$config_dir.'/mysql-virtual_email2email.cf, hash:/var/lib/mailman/data/virtual-mailman',
'virtual_mailbox_domains = proxy:mysql:'.$config_dir.'/mysql-virtual_domains.cf',
'virtual_mailbox_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailboxes.cf',
'virtual_mailbox_base = '.$cf['vmail_mailbox_base'],
@@ -522,12 +637,6 @@
'transport_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_transports.cf',
'relay_domains = mysql:'.$config_dir.'/mysql-virtual_relaydomains.cf',
'relay_recipient_maps = mysql:'.$config_dir.'/mysql-virtual_relayrecipientmaps.cf',
- 'virtual_create_maildirsize = yes',
- 'virtual_maildir_extended = yes',
- 'virtual_mailbox_limit_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailbox_limit_maps.cf',
- 'virtual_mailbox_limit_override = yes',
- 'virtual_maildir_limit_message = "The user you are trying to reach is over quota."',
- 'virtual_overquota_bounce = yes',
'proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps',
'smtpd_sender_restrictions = check_sender_access mysql:'.$config_dir.'/mysql-virtual_sender.cf',
'smtpd_client_restrictions = check_client_access mysql:'.$config_dir.'/mysql-virtual_client.cf',
@@ -537,7 +646,8 @@
'header_checks = regexp:'.$config_dir.'/header_checks',
'mime_header_checks = regexp:'.$config_dir.'/mime_header_checks',
'nested_header_checks = regexp:'.$config_dir.'/nested_header_checks',
- 'body_checks = regexp:'.$config_dir.'/body_checks'
+ 'body_checks = regexp:'.$config_dir.'/body_checks',
+ 'owner_request_special = no'
);
//* Create the header and body check files
@@ -545,7 +655,13 @@
touch($config_dir.'/mime_header_checks');
touch($config_dir.'/nested_header_checks');
touch($config_dir.'/body_checks');
-
+
+ //* Create the mailman files
+ exec('mkdir -p /var/lib/mailman/data');
+ touch('/var/lib/mailman/data/aliases');
+ exec('postmap /var/lib/mailman/data/aliases');
+ touch('/var/lib/mailman/data/virtual-mailman');
+ exec('postmap /var/lib/mailman/data/virtual-mailman');
//* Make a backup copy of the main.cf file
copy($config_dir.'/main.cf', $config_dir.'/main.cf~');
@@ -559,7 +675,7 @@
if(!stristr($options,'dont-create-certs')) {
//* Create the SSL certificate
$command = 'cd '.$config_dir.'; '
- .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509';
+ .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 3650 -x509';
exec($command);
$command = 'chmod o= '.$config_dir.'/smtpd.key';
@@ -1010,7 +1126,7 @@
// copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
$content = rf('tpl/apache_ispconfig.conf.master');
- $records = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'");
+ $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
if(is_array($records) && count($records) > 0) {
foreach($records as $rec) {
$content .= 'NameVirtualHost '.$rec['ip_address'].":80\n";
@@ -1036,11 +1152,77 @@
replaceLine('/etc/webalizer/webalizer.conf','#Incremental','Incremental yes',0,0);
replaceLine('/etc/webalizer/webalizer.conf','#HistoryName','HistoryName webalizer.hist',0,0);
}
-
+
+ // Check the awsatst script
+ if(!is_dir('/usr/share/awstats/tools')) exec('mkdir -p /usr/share/awstats/tools');
+ if(!file_exists('/usr/share/awstats/tools/awstats_buildstaticpages.pl') && file_exists('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl')) symlink('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl','/usr/share/awstats/tools/awstats_buildstaticpages.pl');
+ if(file_exists('/etc/awstats/awstats.conf.local')) replaceLine('/etc/awstats/awstats.conf.local','LogFormat=4','LogFormat=1',0,1);
+
//* add a sshusers group
$command = 'groupadd sshusers';
if(!is_group('sshusers')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+ }
+
+ public function configure_nginx()
+ {
+ global $conf;
+ $row = $this->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ".$conf["server_id"]."");
+ $ip_address = gethostbyname($row["server_name"]);
+ $server_name = $row["server_name"];
+
+ //setup proxy.conf
+ $configfile = 'proxy.conf';
+ if(is_file($conf["nginx"]["config_dir"].'/'.$configfile)) copy($conf["nginx"]["config_dir"].'/'.$configfile,$conf["nginx"]["config_dir"].'/'.$configfile.'~');
+ if(is_file($conf["nginx"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["nginx"]["config_dir"].'/'.$configfile.'~');
+ $content = rf("tpl/nginx_".$configfile.".master");
+ wf($conf["nginx"]["config_dir"].'/'.$configfile,$content);
+ exec('chmod 600 '.$conf["nginx"]["config_dir"].'/'.$configfile);
+ exec('chown root:root '.$conf["nginx"]["config_dir"].'/'.$configfile);
+
+ //setup conf.d/cache.conf
+ $configfile = 'cache.conf';
+ if(is_file($conf["nginx"]["config_dir"].'/conf.d/'.$configfile)) copy($conf["nginx"]["config_dir"].'/conf.d/'.$configfile,$conf["nginx"]["config_dir"].'/conf.d/'.$configfile.'~');
+ if(is_file($conf["nginx"]["config_dir"].'/conf.d/'.$configfile.'~')) exec('chmod 400 '.$conf["nginx"]["config_dir"].'/conf.d/'.$configfile.'~');
+ $content = rf("tpl/nginx_".$configfile.".master");
+ wf($conf["nginx"]["config_dir"].'/conf.d/'.$configfile,$content);
+ exec('chmod 600 '.$conf["nginx"]["config_dir"].'/conf.d/'.$configfile);
+ exec('chown root:root '.$conf["nginx"]["config_dir"].'/conf.d/'.$configfile);
+
+ //setup cache directories
+ mkdir('/var/cache/nginx/cache');
+ exec('chown www-data:www-data /var/cache/nginx/cache');
+ mkdir('/var/cache/nginx/temp');
+ exec('chown www-data:www-data /var/cache/nginx/temp');
+ }
+
+ public function configure_squid()
+ {
+ global $conf;
+ $row = $this->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ".$conf["server_id"]."");
+ $ip_address = gethostbyname($row["server_name"]);
+ $server_name = $row["server_name"];
+
+ $configfile = 'squid.conf';
+ if(is_file($conf["squid"]["config_dir"].'/'.$configfile)) copy($conf["squid"]["config_dir"].'/'.$configfile,$conf["squid"]["config_dir"].'/'.$configfile.'~');
+ if(is_file($conf["squid"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["squid"]["config_dir"].'/'.$configfile.'~');
+ $content = rf("tpl/".$configfile.".master");
+ $content = str_replace('{server_name}',$server_name,$content);
+ $content = str_replace('{ip_address}',$ip_address, $content);
+ $content = str_replace('{config_dir}',$conf['squid']['config_dir'], $content);
+ wf($conf["squid"]["config_dir"].'/'.$configfile,$content);
+ exec('chmod 600 '.$conf["squid"]["config_dir"].'/'.$configfile);
+ exec('chown root:root '.$conf["squid"]["config_dir"].'/'.$configfile);
+ }
+
+ public function configure_ufw_firewall()
+ {
+ $configfile = 'ufw.conf';
+ if(is_file('/etc/ufw/ufw.conf')) copy('/etc/ufw/ufw.conf','/etc/ufw/ufw.conf~');
+ $content = rf("tpl/".$configfile.".master");
+ wf('/etc/ufw/ufw.conf',$content);
+ exec('chmod 600 /etc/ufw/ufw.conf');
+ exec('chown root:root /etc/ufw/ufw.conf');
}
public function configure_firewall() {
@@ -1360,13 +1542,14 @@
$file_server_enabled = ($conf['services']['file'])?1:0;
$db_server_enabled = ($conf['services']['db'])?1:0;
$vserver_server_enabled = ($conf['services']['vserver'])?1:0;
+ $proxy_server_enabled = ($conf['services']['proxy'])?1:0;
+ $firewall_server_enabled = ($conf['services']['firewall'])?1:0;
-
- $sql = "UPDATE `server` SET mail_server = '$mail_server_enabled', web_server = '$web_server_enabled', dns_server = '$dns_server_enabled', file_server = '$file_server_enabled', db_server = '$db_server_enabled', vserver_server = '$vserver_server_enabled' WHERE server_id = ".intval($conf['server_id']);
+ $sql = "UPDATE `server` SET mail_server = '$mail_server_enabled', web_server = '$web_server_enabled', dns_server = '$dns_server_enabled', file_server = '$file_server_enabled', db_server = '$db_server_enabled', vserver_server = '$vserver_server_enabled', proxy_server = '$proxy_server_enabled', firewall_server = '$firewall_server_enabled' WHERE server_id = ".intval($conf['server_id']);
if($conf['mysql']['master_slave_setup'] == 'y') {
$this->dbmaster->query($sql);
@@ -1719,4 +1902,4 @@
}
}
-?>
+?>
\ No newline at end of file
--
Gitblit v1.9.1