From 6f4e97bbae4266568b190f9d405700663cce7399 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 20 Mar 2012 13:28:11 +0100 Subject: [PATCH] Import GIT --- createlinks | 12 +++++ .../e-smith/db/accounts/defaults/vtigercrm/type | 1 + .../db/configuration/defaults/vtigercrm/Alias | 1 + .../db/configuration/defaults/vtigercrm/DbName | 1 + .../db/configuration/defaults/vtigercrm/DbUser | 1 + .../configuration/defaults/vtigercrm/InstallMode | 1 + .../db/configuration/defaults/vtigercrm/access | 1 + .../db/configuration/defaults/vtigercrm/status | 1 + .../db/configuration/defaults/vtigercrm/type | 1 + .../db/configuration/migrate/vtigercrm-database | 33 ++++++++++++ root/etc/e-smith/templates/etc/crontab/vtigercrm | 22 ++++++++ .../etc/e-smith/sql/init/80vtigercrm_mysql.sql | 59 +++++++++++++++++++++ .../etc/httpd/conf/httpd.conf/98vtigercrm | 53 +++++++++++++++++++ .../httpd.conf/VirtualHosts/61VtigerForceHTTPS | 17 ++++++ .../templates/usr/share/vtigercrm/config.php/ALL | 36 +++++++++++++ smeserver-vtigercrm.spec | 61 ++++++++++++++++++++++ 16 files changed, 301 insertions(+) create mode 100644 createlinks create mode 100644 root/etc/e-smith/db/accounts/defaults/vtigercrm/type create mode 100644 root/etc/e-smith/db/configuration/defaults/vtigercrm/Alias create mode 100644 root/etc/e-smith/db/configuration/defaults/vtigercrm/DbName create mode 100644 root/etc/e-smith/db/configuration/defaults/vtigercrm/DbUser create mode 100644 root/etc/e-smith/db/configuration/defaults/vtigercrm/InstallMode create mode 100644 root/etc/e-smith/db/configuration/defaults/vtigercrm/access create mode 100644 root/etc/e-smith/db/configuration/defaults/vtigercrm/status create mode 100644 root/etc/e-smith/db/configuration/defaults/vtigercrm/type create mode 100644 root/etc/e-smith/db/configuration/migrate/vtigercrm-database create mode 100644 root/etc/e-smith/templates/etc/crontab/vtigercrm create mode 100644 root/etc/e-smith/templates/etc/e-smith/sql/init/80vtigercrm_mysql.sql create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98vtigercrm create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61VtigerForceHTTPS create mode 100644 root/etc/e-smith/templates/usr/share/vtigercrm/config.php/ALL create mode 100644 smeserver-vtigercrm.spec diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..f808d60 --- /dev/null +++ b/createlinks @@ -0,0 +1,12 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + + +my $event = 'webapps-update'; +templates2events("/usr/share/vtigercrm/config.php", qw(webapps-update bootstrap-console-save)); +templates2events("/etc/e-smith/sql/init/80vtigercrm_mysql.sql", $event); + +safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/usr/share/vtigercrm/config.php/template-begin"); +safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/usr/share/vtigercrm/config.php/template-end"); + diff --git a/root/etc/e-smith/db/accounts/defaults/vtigercrm/type b/root/etc/e-smith/db/accounts/defaults/vtigercrm/type new file mode 100644 index 0000000..96cdd3b --- /dev/null +++ b/root/etc/e-smith/db/accounts/defaults/vtigercrm/type @@ -0,0 +1 @@ +url diff --git a/root/etc/e-smith/db/configuration/defaults/vtigercrm/Alias b/root/etc/e-smith/db/configuration/defaults/vtigercrm/Alias new file mode 100644 index 0000000..8ff4a58 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/vtigercrm/Alias @@ -0,0 +1 @@ +vtiger,crm diff --git a/root/etc/e-smith/db/configuration/defaults/vtigercrm/DbName b/root/etc/e-smith/db/configuration/defaults/vtigercrm/DbName new file mode 100644 index 0000000..841d4c1 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/vtigercrm/DbName @@ -0,0 +1 @@ +vtigercrmdb diff --git a/root/etc/e-smith/db/configuration/defaults/vtigercrm/DbUser b/root/etc/e-smith/db/configuration/defaults/vtigercrm/DbUser new file mode 100644 index 0000000..c237133 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/vtigercrm/DbUser @@ -0,0 +1 @@ +vtigercrmuser diff --git a/root/etc/e-smith/db/configuration/defaults/vtigercrm/InstallMode b/root/etc/e-smith/db/configuration/defaults/vtigercrm/InstallMode new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/vtigercrm/InstallMode @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/vtigercrm/access b/root/etc/e-smith/db/configuration/defaults/vtigercrm/access new file mode 100644 index 0000000..3e18ebf --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/vtigercrm/access @@ -0,0 +1 @@ +private diff --git a/root/etc/e-smith/db/configuration/defaults/vtigercrm/status b/root/etc/e-smith/db/configuration/defaults/vtigercrm/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/vtigercrm/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/vtigercrm/type b/root/etc/e-smith/db/configuration/defaults/vtigercrm/type new file mode 100644 index 0000000..24e1098 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/vtigercrm/type @@ -0,0 +1 @@ +service diff --git a/root/etc/e-smith/db/configuration/migrate/vtigercrm-database b/root/etc/e-smith/db/configuration/migrate/vtigercrm-database new file mode 100644 index 0000000..cd227e5 --- /dev/null +++ b/root/etc/e-smith/db/configuration/migrate/vtigercrm-database @@ -0,0 +1,33 @@ +{ + my $rec = $DB->get('vtigercrm') + || $DB->new_record('vtigercrm', {type => 'service'}); + my $pw = $rec->prop('DbPassword'); + if (not $pw or length($pw) < 57) + { + use MIME::Base64 qw(encode_base64); + + $pw = "not set due to error"; + if ( open( RANDOM, "/dev/urandom" ) ) + { + my $buf; + # 57 bytes is a full line of Base64 coding, and contains + # 456 bits of randomness - given a perfectly random /dev/random + if ( read( RANDOM, $buf, 57 ) != 57 ) + { + warn("Short read from /dev/random: $!"); + } + else + { + $pw = encode_base64($buf); + chomp $pw; + } + close RANDOM; + } + else + { + warn "Could not open /dev/urandom: $!"; + } + $rec->set_prop('DbPassword', $pw); + } +} + diff --git a/root/etc/e-smith/templates/etc/crontab/vtigercrm b/root/etc/e-smith/templates/etc/crontab/vtigercrm new file mode 100644 index 0000000..a80f0a1 --- /dev/null +++ b/root/etc/e-smith/templates/etc/crontab/vtigercrm @@ -0,0 +1,22 @@ +{ +if (($vtigercrm{'CronJobs'} || 'disabled') eq 'enabled'){ +$OUT .=<<"HERE"; + +# Vtiger Cron Jobs +*/5 * * * * www wget --no-check-certificate https://localhost/vtigercrm/cron/intimateTaskStatus.php -O /dev/null 2> /dev/null +*/5 * * * * www wget --no-check-certificate https://localhost/vtigercrm/vtigercron.php?service=MailScanner -O /dev/null 2> /dev/null +*/5 * * * * www wget --no-check-certificate https://localhost/vtigercrm/vtigercron.php?service=RecurringInvoice -O /dev/null 2> /dev/null +*/5 * * * * www wget --no-check-certificate https://localhost/vtigercrm/vtigercron.php?service=com_vtiger_workflow -O /dev/null 2> /dev/null +*/5 * * * * www wget --no-check-certificate https://localhost/vtigercrm/SendReminder.php -O /dev/null 2> /dev/null +*/5 * * * * www wget --no-check-certificate https://localhost/vtigercrm/SendSupportNotification.php -O /dev/null + +HERE + +} +else{ + $OUT .= "\n\n# VtigerCRM Cron Jobs are disabled\n" . + "# To enable them:\n" . + "# db configuration setprop vtigercrm CronJobs enabled\n" . + "# signal-event webapps-update"; +} +} diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/80vtigercrm_mysql.sql b/root/etc/e-smith/templates/etc/e-smith/sql/init/80vtigercrm_mysql.sql new file mode 100644 index 0000000..5274b11 --- /dev/null +++ b/root/etc/e-smith/templates/etc/e-smith/sql/init/80vtigercrm_mysql.sql @@ -0,0 +1,59 @@ +# Vtiger CRM MySQL init template +# +# This files creates/updates Vtiger CRM MySQL database infos + + +USE mysql; + +CREATE DATABASE IF NOT EXISTS { $vtigercrm{DbName} } DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; + +REPLACE INTO user ( + host, + user, + password) + VALUES ( + 'localhost', + '{ $vtigercrm{DbUser} }', + PASSWORD ('{ $vtigercrm{DbPassword} }')); + +REPLACE INTO user ( + host, + user, + password) + VALUES ( + '%', + '{ $vtigercrm{DbUser} }', + PASSWORD ('{ $vtigercrm{DbPassword} }')); + +REPLACE INTO db ( + host, + db, + user, + select_priv, insert_priv, update_priv, delete_priv, + create_priv, alter_priv, index_priv, drop_priv, create_tmp_table_priv, + grant_priv, lock_tables_priv, references_priv) + VALUES ( + 'localhost', + '{ $vtigercrm{DbName} }', + '{ $vtigercrm{DbUser} }', + 'Y', 'Y', 'Y', 'Y', + 'Y', 'Y', 'Y', 'Y', 'Y', + 'N', 'Y', 'Y'); + +REPLACE INTO db ( + host, + db, + user, + select_priv, insert_priv, update_priv, delete_priv, + create_priv, alter_priv, index_priv, drop_priv, create_tmp_table_priv, + grant_priv, lock_tables_priv, references_priv) + VALUES ( + '%', + '{ $vtigercrm{DbName} }', + '{ $vtigercrm{DbUser} }', + 'Y', 'Y', 'Y', 'Y', + 'Y', 'Y', 'Y', 'Y', 'Y', + 'N', 'Y', 'Y'); + +FLUSH PRIVILEGES; + diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98vtigercrm b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98vtigercrm new file mode 100644 index 0000000..2096dc2 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98vtigercrm @@ -0,0 +1,53 @@ +Alias /vtigercrm /usr/share/vtigercrm +{ + +foreach my $alias (split (/[,;]/, ($vtigercrm{'Alias'} || '') )){ + $OUT .= "Alias /$alias /usr/share/vtigercrm\n"; +} +} + + + Options None + AllowOverride None + + AddType application/x-httpd-php .php .php3 + php_admin_value memory_limit 64M + php_admin_value max_execution_time 600 + php_admin_flag allow_call_time_reference on + php_admin_flag register_globals off + php_admin_value error_reporting "E_WARNING & ~E_NOTICE" +{ +if ((${'vtigercrm'}{'InstallMode'} || 'disabled') eq 'enabled'){ + $OUT .= " php_admin_flag display_errors On\n". + " php_admin_flag log_errors Off"; +} +} + + Order Deny,Allow +{ +my $access = (${'vtigercrm'}{'access'} || 'private') eq 'public' ? + 'all':"$localAccess $externalSSLAccess"; +$OUT .= " Allow from $access\n"; +} + + Order allow,deny + { + $OUT .= (${'vtigercrm'}{'InstallMode'} || 'disabled') eq 'enabled' ? + "Allow from $localAccess $externalSSLAccess\n":"Deny from all\n"; + } + + + + + + # 15" should be enough for migration in most case + php_value max_execution_time 900 + php_value memory_limit 128M + Order Allow,Deny +{ +$OUT .= (${'vtigercrm'}{'InstallMode'} || 'disabled') eq 'enabled' ? + " Allow from $localAccess $externalSSLAccess\n":" Deny from all\n"; +} + + + diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61VtigerForceHTTPS b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61VtigerForceHTTPS new file mode 100644 index 0000000..054db68 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61VtigerForceHTTPS @@ -0,0 +1,17 @@ +{ + +my $p = $modSSL{'TCPPort'} || '443'; + +if ($port ne $p){ + + ## Redirect Web Address to Secure Address + my @urls = split (/[,;]/, ($vtigercrm{'Alias'} || '')); + push (@urls, 'vtigercrm'); + $OUT .= "\tRewriteEngine on\n"; + foreach my $url (@urls){ + $OUT .= "\tRewriteRule ^/$url(/.*|\$) https://%{HTTP_HOST}/$url\$1 \[L,R\]\n"; + } + +} +} + diff --git a/root/etc/e-smith/templates/usr/share/vtigercrm/config.php/ALL b/root/etc/e-smith/templates/usr/share/vtigercrm/config.php/ALL new file mode 100644 index 0000000..bca2c4e --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/vtigercrm/config.php/ALL @@ -0,0 +1,36 @@ + +/********************************************************************************* +* The contents of this file are subject to the SugarCRM Public License Version 1.1.2 +* ("License"); You may not use this file except in compliance with the +* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for +* the specific language governing rights and limitations under the License. +* The Original Code is: SugarCRM Open Source +* The Initial Developer of the Original Code is SugarCRM, Inc. +* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.; +* All Rights Reserved. +* Contributor(s): ______________________________________. +********************************************************************************/ + +/** + * The configuration file for FHS system + * is located at /etc/vtigercrm directory. + */ + + +include('config.inc.php'); + +$dbconfig['db_server'] = 'localhost'; +$dbconfig['db_port'] = ':3306'; +$dbconfig['db_username'] = '{$vtigercrm{'DbUser'};}'; +$dbconfig['db_password'] = '{$vtigercrm{'DbPassword'};}'; +$dbconfig['db_name'] = '{$vtigercrm{'DbName'};}'; +$dbconfig['db_type'] = 'mysql'; +$dbconfig['db_status'] = 'true'; + +// TODO: test if port is empty +// TODO: set db_hostname dependending on db_type +$dbconfig['db_hostname'] = $dbconfig['db_server'].$dbconfig['db_port']; + + diff --git a/smeserver-vtigercrm.spec b/smeserver-vtigercrm.spec new file mode 100644 index 0000000..678a48d --- /dev/null +++ b/smeserver-vtigercrm.spec @@ -0,0 +1,61 @@ +# $Id: smeserver-vtigercrm.spec,v 1.0 2009/09/30 16:20:28 slords Exp $ +# Authority: VIP-ire +# Name: Daniel B. + +Summary: Vtiger CRM for SME Server +%define name smeserver-vtigercrm +Name: %{name} +%define version 0.1 +%define release 0 +Version: %{version} +Release: %{release}%{?dist} +License: GPL +Group: Mitel/addon +Source: %{name}-%{version}.tar.gz + +#Patch0: smeserver-vtigercrm-0.1-foo.patch + + +URL: http://www.vtiger.com/ +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot +BuildArchitectures: noarch +Requires: e-smith-base +Requires: vtigercrm >= 5.1.0 +Requires: smeserver-webapps-common +BuildRequires: e-smith-devtools >= 1.13.1-03 + +%description +Integration package of Vtiger CRM for SME Server + +%changelog +* Wed Sep 30 2009 Daniel B. 0.1-0 +- Initial rpm + +%prep + +%setup +#%patch0 -p1 + +%build +perl createlinks + +%install +/bin/rm -rf $RPM_BUILD_ROOT +(cd root ; /usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT) +/bin/rm -f %{name}-%{version}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT > %{name}-%{version}-filelist + +%files -f %{name}-%{version}-filelist +%defattr(-,root,root) + +%clean +rm -rf $RPM_BUILD_ROOT + +%post +/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf +sv t /service/httpd-e-smith + +%postun +/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf +sv t /service/httpd-e-smith +