Merge branch 'develop' into optimization

This commit is contained in:
Marcos García de La Fuente 2014-07-22 04:39:31 +02:00
commit 203dc5518a
1026 changed files with 14411 additions and 11769 deletions

5
.gitignore vendored
View File

@ -17,7 +17,4 @@ doxygen_warnings.log
*.iml *.iml
Thumbs.db Thumbs.db
# Vagrant generated files # Vagrant generated files
.vagrant .vagrant
/index.html
/phpmyadmin
/xhprof

View File

@ -5,6 +5,9 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.7 compared to 3.6.* ***** ***** ChangeLog for 3.7 compared to 3.6.* *****
For users: For users:
- New: Enable feature developed for 3.6 we forgot to enabled: Adding prefix
on uploaded file names.
- New: No more dependency between contract and service module.
- New: [ task #867 ] Remove ESAEB external module code from core. - New: [ task #867 ] Remove ESAEB external module code from core.
- New: Can create proposal from an intervention. - New: Can create proposal from an intervention.
- New: Can filter events on a group of users. - New: Can filter events on a group of users.
@ -20,7 +23,10 @@ For users:
- New: Add country into table of thirdparties type. This will allow to provide - New: Add country into table of thirdparties type. This will allow to provide
a list of thirdparty types specific to a country (like argentina that a list of thirdparty types specific to a country (like argentina that
need type A or B). need type A or B).
- New: Can force a specific bank account onto an invoice/order... - New: Can force a specific bank account onto an invoice/order.
- New: First changes for accessibility.
- New: Home page of project area shows list of draft project (like other main page).
- New: Can search on project ref or string from project main page (like other main page).
- Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action - Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action
- Fix: [ bug #1470, #1472, #1473] User trigger problem - Fix: [ bug #1470, #1472, #1473] User trigger problem
- Fix: [ bug #1489, #1491 ] Intervention trigger problem - Fix: [ bug #1489, #1491 ] Intervention trigger problem
@ -212,6 +218,7 @@ Fix: [ bug #1484 ] BILL_SUPPLIER_PAYED trigger action does not intercept failure
Fix: [ bug #1482 ] Several supplier invoice triggers do not show trigger error messages Fix: [ bug #1482 ] Several supplier invoice triggers do not show trigger error messages
Fix: [ bug #1486 ] LINEBILL_SUPPLIER_CREATE and LINEBILL_SUPPLIER_UPDATE triggers do not intercept trigger action Fix: [ bug #1486 ] LINEBILL_SUPPLIER_CREATE and LINEBILL_SUPPLIER_UPDATE triggers do not intercept trigger action
Fix: [ bug #1522 ] Element list into associate object into project are no more filterd by project thirdparty Fix: [ bug #1522 ] Element list into associate object into project are no more filterd by project thirdparty
Fix: [ bug #1526 ] Thumbs of files uploaded with dots in their names do not load correctly
Fix: Import ProfId1 to siren and ProfId2 to siret Fix: Import ProfId1 to siren and ProfId2 to siret
***** ChangeLog for 3.5.3 compared to 3.5.2 ***** ***** ChangeLog for 3.5.3 compared to 3.5.2 *****

View File

@ -333,10 +333,10 @@ fi
# version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release
%changelog %changelog
* Wed Jun 20 2014 Laurent Destailleur 3.5.4-0.3 * Wed Jul 2 2014 Laurent Destailleur 3.6.0-0.2.b
- Upstream release - Upstream release
* Fri May 9 2014 Laurent Destailleur 3.6.0-0.2.b * Tue Jul 1 2014 Laurent Destailleur 3.5.4-0.3
- Upstream release - Upstream release
* Fri May 2 2014 Laurent Destailleur 3.5.3-0.3 * Fri May 2 2014 Laurent Destailleur 3.5.3-0.3

View File

@ -569,10 +569,10 @@ fi
# version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release
%changelog %changelog
* Wed Jun 20 2014 Laurent Destailleur 3.5.4-0.3 * Wed Jul 2 2014 Laurent Destailleur 3.6.0-0.2.b
- Upstream release - Upstream release
* Fri May 9 2014 Laurent Destailleur 3.6.0-0.2.b * Tue Jul 1 2014 Laurent Destailleur 3.5.4-0.3
- Upstream release - Upstream release
* Fri May 2 2014 Laurent Destailleur 3.5.3-0.3 * Fri May 2 2014 Laurent Destailleur 3.5.3-0.3

View File

@ -338,10 +338,10 @@ fi
# version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release
%changelog %changelog
* Wed Jun 20 2014 Laurent Destailleur 3.5.4-0.3 * Wed Jul 2 2014 Laurent Destailleur 3.6.0-0.2.b
- Upstream release - Upstream release
* Fri May 9 2014 Laurent Destailleur 3.6.0-0.2.b * Tue Jul 1 2014 Laurent Destailleur 3.5.4-0.3
- Upstream release - Upstream release
* Fri May 2 2014 Laurent Destailleur 3.5.3-0.3 * Fri May 2 2014 Laurent Destailleur 3.5.3-0.3

View File

@ -349,10 +349,10 @@ fi
# version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release
%changelog %changelog
* Wed Jun 20 2014 Laurent Destailleur 3.5.4-0.3 * Wed Jul 2 2014 Laurent Destailleur 3.6.0-0.2.b
- Upstream release - Upstream release
* Fri May 9 2014 Laurent Destailleur 3.6.0-0.2.b * Tue Jul 1 2014 Laurent Destailleur 3.5.4-0.3
- Upstream release - Upstream release
* Fri May 2 2014 Laurent Destailleur 3.5.3-0.3 * Fri May 2 2014 Laurent Destailleur 3.5.3-0.3

View File

@ -23,7 +23,7 @@ Usage
`cd` into the vagrant box directory and simply type `vagrant up`. `cd` into the vagrant box directory and simply type `vagrant up`.
That's all you need to do. It will build a brand new VirtalBox machine for you with everything you need to develop on Dolibarr. That's all you need to do. It will build a brand new VirtualBox machine for you with everything you need to develop on Dolibarr.
### Name resolution ### Name resolution
For easy access to the VM you need to setup name resolution to the machines IP. For easy access to the VM you need to setup name resolution to the machines IP.
@ -45,9 +45,16 @@ Somewhat bleeding edge vagrant box for develop branch related work.
- IP: 192.168.42.101 - IP: 192.168.42.101
- Vhost: dev.dolibarr.org - Vhost: dev.dolibarr.org
- OS: Debian Wheezy 7.5 - OS: Debian Wheezy 7.5 x64
- Webserver: Apache 2.2.22 - Webserver: Apache 2.2.22
- PHP: mod_php 5.5.13-1~dotdeb.1 - PHP: mod_php 5.5.14-1~dotdeb.1
Installed modules:
- cli
- curl
- gd
- imagick
- intl
- mcrypt
- Database: MySQL 5.5 - Database: MySQL 5.5
- Root user: root - Root user: root
- Root password: root - Root password: root
@ -55,7 +62,13 @@ Somewhat bleeding edge vagrant box for develop branch related work.
- Database user: user - Database user: user
- Database password: user - Database password: user
- Initial data: dev/initdata/mysqldump_dolibarr-3.5.0.sql - Initial data: dev/initdata/mysqldump_dolibarr-3.5.0.sql
- Database: PostgreSQL 9.3
- Adminer: lightweight database management. Access through http://192.168.42.101/adminer
- Debugger: XDebug - Debugger: XDebug
- Profiler: Xhprof - Profiler: Xhprof. Access through http://192.168.42.101/xhprof/xhprof_html
You can access MailCatcher to read all outgoing emails at http://192.168.42.101:1080 You can access MailCatcher to read all outgoing emails at http://192.168.42.101:1080
To access the machine you must use the following private keys:
- User root: located at puphpet/files/dot/ssh/root_rsa
- User vagrant: located at puphpet/files/dot/ssh/id_rsa

View File

@ -25,11 +25,19 @@ Vagrant.configure("2") do |config|
data['vm']['synced_folder'].each do |i, folder| data['vm']['synced_folder'].each do |i, folder|
if folder['source'] != '' && folder['target'] != '' if folder['source'] != '' && folder['target'] != ''
nfs = (folder['nfs'] == "true") ? "nfs" : nil if folder['sync_type'] == 'nfs'
if nfs == "nfs" config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}", type: "nfs"
config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}", type: nfs elsif folder['sync_type'] == 'smb'
config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}", type: "smb"
elsif folder['sync_type'] == 'rsync'
rsync_args = !folder['rsync']['args'].nil? ? folder['rsync']['args'] : ["--verbose", "--archive", "--delete", "-z"]
rsync_auto = !folder['rsync']['auto'].nil? ? folder['rsync']['auto'] : true
rsync_exclude = !folder['rsync']['exclude'].nil? ? folder['rsync']['exclude'] : [".vagrant/"]
config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}",
rsync__args: rsync_args, rsync__exclude: rsync_exclude, rsync__auto: rsync_auto, type: "rsync"
else else
config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}", type: nfs, config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}",
group: 'www-data', owner: 'www-data', mount_options: ["dmode=775", "fmode=764"] group: 'www-data', owner: 'www-data', mount_options: ["dmode=775", "fmode=764"]
end end
end end
@ -128,7 +136,14 @@ Vagrant.configure("2") do |config|
end end
end end
config.vm.provision :shell, :path => "puphpet/shell/execute-files.sh" config.vm.provision :shell do |s|
s.path = "puphpet/shell/execute-files.sh"
s.args = ["exec-once", "exec-always"]
end
config.vm.provision :shell, run: "always" do |s|
s.path = "puphpet/shell/execute-files.sh"
s.args = ["startup-once", "startup-always"]
end
config.vm.provision :shell, :path => "puphpet/shell/important-notices.sh" config.vm.provision :shell, :path => "puphpet/shell/important-notices.sh"
if File.file?("#{dir}/puphpet/files/dot/ssh/id_rsa") if File.file?("#{dir}/puphpet/files/dot/ssh/id_rsa")

View File

@ -29,10 +29,12 @@ vagrantfile-local:
- '--hiera_config /vagrant/puphpet/puppet/hiera.yaml' - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
- '--parser future' - '--parser future'
synced_folder: synced_folder:
PL1BkioqqvGY: jopH6005bn96:
source: ../../../ source: ../../../
target: /var/www target: /var/www/dolibarr
nfs: 'false' sync_type: default
rsync:
auto: 'false'
usable_port_range: 2200..2250 usable_port_range: 2200..2250
ssh: ssh:
host: null host: null
@ -71,7 +73,7 @@ apache:
settings: settings:
user: www-data user: www-data
group: www-data group: www-data
default_vhost: false default_vhost: true
manage_user: false manage_user: false
manage_group: false manage_group: false
sendfile: 0 sendfile: 0
@ -79,9 +81,9 @@ apache:
- php - php
- rewrite - rewrite
vhosts: vhosts:
CGyWQB0fx4x0: b2tOrs1TMtoF:
servername: dev.dolibarr.org servername: dev.dolibarr.org
docroot: /var/www/htdocs docroot: /var/www/dolibarr/htdocs
port: '80' port: '80'
setenv: setenv:
- 'APP_ENV dev' - 'APP_ENV dev'
@ -97,7 +99,7 @@ apache:
nginx: nginx:
install: 0 install: 0
vhosts: vhosts:
jeF1sybIJ3V2: 0dU5luf5AnIe:
server_name: awesome.dev server_name: awesome.dev
server_aliases: server_aliases:
- www.awesome.dev - www.awesome.dev
@ -152,7 +154,7 @@ mysql:
root_password: root root_password: root
adminer: 0 adminer: 0
databases: databases:
2OfuuapoIqsl: V6H3W2FVB7Yq:
grant: grant:
- ALTER - ALTER
- CREATE - CREATE
@ -166,16 +168,16 @@ mysql:
host: localhost host: localhost
user: user user: user
password: user password: user
sql_file: /var/www/dev/initdata/mysqldump_dolibarr_3.5.0.sql sql_file: /var/www/dolibarr/dev/initdata/mysqldump_dolibarr_3.5.0.sql
postgresql: postgresql:
install: 0 install: '1'
settings: settings:
root_password: '123' root_password: root
user_group: postgres user_group: postgres
encoding: UTF8 encoding: UTF8
version: '9.3' version: '9.3'
databases: { } databases: { }
adminer: 0 adminer: '1'
mariadb: mariadb:
install: 0 install: 0
root_password: '123' root_password: '123'

View File

@ -1,4 +1 @@
ssh/id_rsa ssh/*
ssh/id_rsa.pub
ssh/insecure_private_key
ssh/id_rsa.ppk

View File

@ -279,8 +279,14 @@ if hash_key_equals($mailcatcher_values, 'install', 1) {
} }
if ! defined(Class['supervisord']) { if ! defined(Class['supervisord']) {
class{ 'puphpet::python::pip': }
class { 'supervisord': class { 'supervisord':
install_pip => true, install_pip => false,
require => [
Class['my_fw::post'],
Class['Puphpet::Python::Pip'],
],
} }
} }
@ -467,15 +473,16 @@ if hash_key_equals($apache_values, 'install', 1) {
$apache_vhosts = merge($apache_values['vhosts'], { $apache_vhosts = merge($apache_values['vhosts'], {
'default_vhost_80' => { 'default_vhost_80' => {
'servername' => 'default', 'servername' => 'default',
'serveraliases' => ['*'],
'docroot' => '/var/www/default', 'docroot' => '/var/www/default',
'port' => 80, 'port' => 80,
'default_vhost' => true,
}, },
'default_vhost_443' => { 'default_vhost_443' => {
'servername' => 'default', 'servername' => 'default',
'serveraliases' => ['*'],
'docroot' => '/var/www/default', 'docroot' => '/var/www/default',
'port' => 443, 'port' => 443,
'default_vhost' => true,
'ssl' => 1,
}, },
}) })
} else { } else {
@ -515,11 +522,11 @@ if hash_key_equals($apache_values, 'install', 1) {
create_resources(apache::vhost, { "${key}" => merge($vhost, { create_resources(apache::vhost, { "${key}" => merge($vhost, {
'custom_fragment' => template('puphpet/apache/custom_fragment.erb'), 'custom_fragment' => template('puphpet/apache/custom_fragment.erb'),
'ssl' => 'ssl' in $vhost and str2bool($vhost['ssl']) ? { true => true, default => false }, 'ssl' => 'ssl' in $vhost and str2bool($vhost['ssl']) ? { true => true, default => false },
'ssl_cert' => 'ssl_cert' in $vhost and $vhost['ssl_cert'] ? { undef => undef, '' => undef, default => $vhost['ssl_cert'] }, 'ssl_cert' => hash_key_true($vhost, 'ssl_cert') ? { true => $vhost['ssl_cert'], default => undef },
'ssl_key' => 'ssl_key' in $vhost and $vhost['ssl_key'] ? { undef => undef, '' => undef, default => $vhost['ssl_key'] }, 'ssl_key' => hash_key_true($vhost, 'ssl_cert') ? { true => $vhost['ssl_key'], default => undef },
'ssl_chain' => 'ssl_chain' in $vhost and $vhost['ssl_chain'] ? { undef => undef, '' => undef, default => $vhost['ssl_chain'] }, 'ssl_chain' => hash_key_true($vhost, 'ssl_cert') ? { true => $vhost['ssl_chain'], default => undef },
'ssl_certs_dir' => 'ssl_certs_dir' in $vhost and $vhost['ssl_certs_dir'] ? { undef => undef, '' => undef, default => $vhost['ssl_certs_dir'] } 'ssl_certs_dir' => hash_key_true($vhost, 'ssl_cert') ? { true => $vhost['ssl_certs_dir'], default => undef }
}) })
}) })
@ -662,10 +669,6 @@ if hash_key_equals($nginx_values, 'install', 1) {
} }
} elsif hash_key_equals($hhvm_values, 'install', 1) { } elsif hash_key_equals($hhvm_values, 'install', 1) {
$fastcgi_pass = '127.0.0.1:9000' $fastcgi_pass = '127.0.0.1:9000'
set_php5_fpm_sock_group_and_user { 'hhvm':
require => Package['nginx'],
}
} else { } else {
$fastcgi_pass = '' $fastcgi_pass = ''
} }
@ -1096,7 +1099,7 @@ if hash_key_equals($xhprof_values, 'install', 1)
} }
if hash_key_equals($apache_values, 'install', 1) { if hash_key_equals($apache_values, 'install', 1) {
$xhprof_webroot_location = $puphpet::params::apache_webroot_location $xhprof_webroot_location = '/var/www/default'
$xhprof_webserver_service = 'httpd' $xhprof_webserver_service = 'httpd'
} elsif hash_key_equals($nginx_values, 'install', 1) { } elsif hash_key_equals($nginx_values, 'install', 1) {
$xhprof_webroot_location = $puphpet::params::nginx_webroot_location $xhprof_webroot_location = $puphpet::params::nginx_webroot_location
@ -1216,11 +1219,11 @@ if hash_key_equals($mysql_values, 'install', 1) {
if hash_key_equals($mysql_values, 'adminer', 1) and $mysql_php_installed { if hash_key_equals($mysql_values, 'adminer', 1) and $mysql_php_installed {
if hash_key_equals($apache_values, 'install', 1) { if hash_key_equals($apache_values, 'install', 1) {
$mysql_adminer_webroot_location = $puphpet::params::apache_webroot_location $mysql_adminer_webroot_location = '/var/www/default'
} elsif hash_key_equals($nginx_values, 'install', 1) { } elsif hash_key_equals($nginx_values, 'install', 1) {
$mysql_adminer_webroot_location = $puphpet::params::nginx_webroot_location $mysql_adminer_webroot_location = $puphpet::params::nginx_webroot_location
} else { } else {
$mysql_adminer_webroot_location = $puphpet::params::apache_webroot_location $mysql_adminer_webroot_location = '/var/www/default'
} }
class { 'puphpet::adminer': class { 'puphpet::adminer':
@ -1329,11 +1332,11 @@ if hash_key_equals($postgresql_values, 'install', 1) {
if hash_key_equals($postgresql_values, 'adminer', 1) and $postgresql_php_installed { if hash_key_equals($postgresql_values, 'adminer', 1) and $postgresql_php_installed {
if hash_key_equals($apache_values, 'install', 1) { if hash_key_equals($apache_values, 'install', 1) {
$postgresql_adminer_webroot_location = $puphpet::params::apache_webroot_location $postgresql_adminer_webroot_location = '/var/www/default'
} elsif hash_key_equals($nginx_values, 'install', 1) { } elsif hash_key_equals($nginx_values, 'install', 1) {
$postgresql_adminer_webroot_location = $puphpet::params::nginx_webroot_location $postgresql_adminer_webroot_location = $puphpet::params::nginx_webroot_location
} else { } else {
$postgresql_adminer_webroot_location = $puphpet::params::apache_webroot_location $postgresql_adminer_webroot_location = '/var/www/default'
} }
class { 'puphpet::adminer': class { 'puphpet::adminer':
@ -1364,7 +1367,7 @@ define postgresql_db (
$table = "${name}.*" $table = "${name}.*"
exec{ "${name}-import": exec{ "${name}-import":
command => "psql ${name} < ${sql_file}", command => "sudo -u postgres psql ${name} < ${sql_file}",
logoutput => true, logoutput => true,
refreshonly => $refresh, refreshonly => $refresh,
require => Postgresql::Server::Db[$name], require => Postgresql::Server::Db[$name],
@ -1491,11 +1494,11 @@ if hash_key_equals($mariadb_values, 'install', 1) {
if hash_key_equals($mariadb_values, 'adminer', 1) and $mariadb_php_installed { if hash_key_equals($mariadb_values, 'adminer', 1) and $mariadb_php_installed {
if hash_key_equals($apache_values, 'install', 1) { if hash_key_equals($apache_values, 'install', 1) {
$mariadb_adminer_webroot_location = $puphpet::params::apache_webroot_location $mariadb_adminer_webroot_location = '/var/www/default'
} elsif hash_key_equals($nginx_values, 'install', 1) { } elsif hash_key_equals($nginx_values, 'install', 1) {
$mariadb_adminer_webroot_location = $puphpet::params::nginx_webroot_location $mariadb_adminer_webroot_location = $puphpet::params::nginx_webroot_location
} else { } else {
$mariadb_adminer_webroot_location = $puphpet::params::apache_webroot_location $mariadb_adminer_webroot_location = '/var/www/default'
} }
class { 'puphpet::adminer': class { 'puphpet::adminer':
@ -1662,7 +1665,7 @@ if $beanstalkd_values == undef {
} }
if hash_key_equals($apache_values, 'install', 1) { if hash_key_equals($apache_values, 'install', 1) {
$beanstalk_console_webroot_location = "${puphpet::params::apache_webroot_location}/beanstalk_console" $beanstalk_console_webroot_location = '/var/www/default/beanstalk_console'
} elsif hash_key_equals($nginx_values, 'install', 1) { } elsif hash_key_equals($nginx_values, 'install', 1) {
$beanstalk_console_webroot_location = "${puphpet::params::nginx_webroot_location}/beanstalk_console" $beanstalk_console_webroot_location = "${puphpet::params::nginx_webroot_location}/beanstalk_console"
} else { } else {

View File

@ -0,0 +1,42 @@
#
# hash_key_true.rb
#
module Puppet::Parser::Functions
newfunction(:hash_key_true, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
Returns true if the key within hash is truthy
ENDHEREDOC
unless args.length == 2
raise Puppet::ParseError, ("hash_key_true(): wrong number of arguments (#{args.length}; must be 2)")
end
arr = args[0]
key = args[1]
unless arr.is_a?(Hash)
return false
end
unless arr.has_key?(key)
return false
end
if arr[key].nil?
return false
end
if arr[key].empty?
return false
end
if arr[key] == 'false'
return false
end
return true
end
end

View File

@ -69,17 +69,39 @@ class puphpet::hhvm(
} }
} }
'centos': { 'centos': {
$jemalloc_url = 'http://files.puphpet.com/centos6/jemalloc-3.6.0-1.el6.x86_64.rpm'
$jemalloc_download_location = '/.puphpet-stuff/jemalloc-3.6.0-1.el6.x86_64.rpm'
$require = defined(Class['my_fw::post']) ? {
true => Class['my_fw::post'],
default => [],
}
exec { "download jemalloc to ${download_location}":
creates => $download_location,
command => "wget --quiet --tries=5 --connect-timeout=10 -O '${jemalloc_download_location}' '${jemalloc_url}'",
timeout => 30,
path => '/usr/bin',
require => $require
}
package { 'jemalloc':
ensure => latest,
provider => yum,
source => $download_location,
require => Exec["download jemalloc to ${download_location}"],
}
yum::managed_yumrepo { 'hop5': yum::managed_yumrepo { 'hop5':
descr => 'hop5 repository', descr => 'hop5 repository',
baseurl => 'http://www.hop5.in/yum/el6/', baseurl => 'http://www.hop5.in/yum/el6/',
gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-HOP5', gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-HOP5',
enabled => 1, enabled => 1,
gpgcheck => 0, gpgcheck => 0,
priority => 1 priority => 1,
} }
} }
} }
if $real_webserver == 'apache2' { if $real_webserver == 'apache2' {
if ! defined(Class['apache::mod::mime']) { if ! defined(Class['apache::mod::mime']) {
class { 'apache::mod::mime': } class { 'apache::mod::mime': }

View File

@ -0,0 +1,22 @@
class puphpet::python::pip {
Exec { path => [ '/usr/bin/', '/usr/local/bin', '/bin', '/usr/local/sbin', '/usr/sbin', '/sbin' ] }
if ! defined(Package['python-setuptools']) {
package { 'python-setuptools': }
}
exec { 'easy_install pip':
unless => 'which pip',
require => Package['python-setuptools'],
}
if $::osfamily == 'RedHat' {
exec { 'rhel pip_provider_name_fix':
command => 'alternatives --install /usr/bin/pip-python pip-python /usr/bin/pip 1',
subscribe => Exec['easy_install pip'],
unless => 'which pip-python',
}
}
}

View File

@ -1,6 +1,10 @@
fixtures: fixtures:
repositories: repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib" 'stdlib':
concat: "git://github.com/puppetlabs/puppetlabs-concat" repo: 'git://github.com/puppetlabs/puppetlabs-stdlib'
ref: '4.1.0'
'concat':
repo: 'git://github.com/puppetlabs/puppetlabs-concat'
ref: '1.0.1'
symlinks: symlinks:
supervisord: "#{source_dir}" supervisord: "#{source_dir}"

View File

@ -1,21 +1,28 @@
language: ruby language: ruby
bundler_args: --without development bundler_args: --without development
script: "bundle exec rake spec lint" script: "bundle exec rake test"
rvm: rvm:
- 1.8.7 - 1.8.7
- 1.9.3 - 1.9.3
- 2.0.0 - 2.0.0
env: env:
matrix: - PUPPET_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 2.7.0" - PUPPET_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.3.0" - PUPPET_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION="~> 3.4.0" - PUPPET_VERSION="~> 3.3.0"
- PUPPET_VERSION="~> 3.4.0"
- PUPPET_VERSION="~> 3.5.0"
- PUPPET_VERSION="~> 3.6.0"
matrix: matrix:
exclude: exclude:
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.0.0 - rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0" env: PUPPET_VERSION="~> 2.7.0"
- rvm: 1.9.3
env: PUPPET_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_VERSION="~> 3.1.0"
- rvm: 1.8.7
env: PUPPET_VERSION="~> 3.2.0"
notifications: notifications:
email: false email: false

View File

@ -1,3 +1,66 @@
2014-06-20 - v0.4.0
Fixes:
- Removed root as group and replaced with uid 0 to enhance system
compatibility
Enhancements:
- Made package provider a user definable param see supervisord::package_provider and README for details of how to change this.
- All define types can now be automatically pulled in from hiera see example https://github.com/ajcrowe/puppet-supervisord#configure-a-program
- You can now override the default include path of $config_include/*.conf with your own array using $config_dirs. Bear in mind this would need to include whatever you set $config_include to be, with *.conf on the end.
Many thanks for the PRs from @jasperla, @mvantellingen for the bug report on the service name and @hasc for the enhancement ideas.
2014-06-06 - v0.3.3
Fixes:
- Fixed typo in stopwaitsec param, should have been stopwaitsecs, thanks to @rchrd2
2014-05-03 - v0.3.2
Changes:
- Added supervisord::executable_ctl variable for supervisorctl binary path, thanks to @bpgoldsb
2014-04-22 - v0.3.1
Fixes:
- Fixed typo in unix_socket_group param, thanks to @dig412
2014-03-11 - v0.3.0
Fixes:
- Fixed typo in fcgi config
- Fixed typo in supervisord config with minfds and minprocs, thanks to @peefourtee
- Typo in README fixed thanks to @hopkinsth
- Removed refreshonly from pip_install exec resource
- Number of syntax fixes thanks to `puppet lint`
Important Changes:
- Lots of input validation has been added **PLEASE** check your config works before upgrading!
- Changed init_extras naming to defaults and cleaned things up.
- Starting and stopping apps is now done with supervisorctl commands to avoid service restarts
Other Changes:
- CSV functions now order things consistently
- Included description for classes and functions
- Expanded spec testing built with Travis CI
- Added beaker acceptance tests
- Added greater validation of various parameters
- Added coverage reporting for resources
To-Do:
- Add support for additional OS families such as Solaris.
2013-10-31 - v0.2.3 2013-10-31 - v0.2.3
Fixes: Fixes:

View File

@ -1,14 +1,26 @@
source 'https://rubygems.org' source 'https://rubygems.org'
group :development, :test do group :test do
gem 'rake' gem 'rake'
gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint'
gem 'rspec-system-puppet', '~> 2.0' gem 'puppet-syntax'
gem 'puppet-lint', '~> 0.3.2' gem 'puppetlabs_spec_helper'
gem 'rspec-puppet', :git => 'https://github.com/rodjek/rspec-puppet.git' , :ref => 'c44381a240ec420d4ffda7bffc55ee4d9c08d682'
gem 'rspec', '2.14.1'
end end
if puppetversion = ENV['PUPPET_GEM_VERSION'] group :development do
gem 'puppet', puppetversion, :require => false gem 'travis'
else gem 'travis-lint'
gem 'puppet', :require => false gem 'beaker'
gem 'beaker-rspec'
gem 'pry'
gem 'guard-rake'
end
if puppetversion = ENV['PUPPET_VERSION']
gem 'puppet', puppetversion
else
gem 'puppet', '~> 3.4.0'
end end

View File

@ -1,5 +1,5 @@
name 'ajcrowe-supervisord' name 'ajcrowe-supervisord'
version '0.2.3' version '0.4.0'
source 'git@github.com/ajcrowe/puppet-supervisord.git' source 'git@github.com/ajcrowe/puppet-supervisord.git'
author 'Alex Crowe' author 'Alex Crowe'
license 'Apache License, Version 2.0' license 'Apache License, Version 2.0'

View File

@ -4,7 +4,7 @@
Puppet module to manage the [supervisord](http://supervisord.org/) process control system. Puppet module to manage the [supervisord](http://supervisord.org/) process control system.
Functions available to configure Functions available to configure
* [programs](http://supervisord.org/configuration.html#program-x-section-settings) * [programs](http://supervisord.org/configuration.html#program-x-section-settings)
* [groups](http://supervisord.org/configuration.html#group-x-section-settings) * [groups](http://supervisord.org/configuration.html#group-x-section-settings)
@ -31,10 +31,16 @@ class supervisord {
} }
``` ```
This will download [setuptool](https://bitbucket.org/pypa/setuptools) and install pip with easy_install. This will download [setuptool](https://bitbucket.org/pypa/setuptools) and install pip with easy_install.
You can pass a specific url with `$setuptools_url = 'url'` You can pass a specific url with `$setuptools_url = 'url'`
### Install without pip
If you want to use your system package manager you can specify that with `supervisord::package_provider`.
You'll also likely need to adjust the `supervisord::service_name` to match that installed by the system package. If you're using Debian or Redhat OS families you'll also want to disable the init scripts with `supervisord::install_init = false`.
Note: Only Debian and RedHat families have an init script currently. Note: Only Debian and RedHat families have an init script currently.
### Configure a program ### Configure a program
@ -61,23 +67,61 @@ supervisord::program { 'myprogram':
} }
``` ```
Or you can fully define your programs in hiera:
```yaml
supervisord::programs:
'myprogram':
command: 'command --args'
autostart: yes
autorestart: 'true'
environment:
HOME: '/home/myuser'
PATH: '/bin:/sbin:/usr/bin:/usr/sbin'
SECRET: 'mysecret'
```
### Configure a group ### Configure a group
```ruby ```ruby
supervisord::group { 'mygroup': supervisord::group { 'mygroup':
priority => 100, priority => 100,
program => ['program1', 'program2', 'program3'] programs => ['program1', 'program2', 'program3']
} }
``` ```
### Configure an eventlistener
```ruby
supervisord::eventlistener { 'mylistener':
command => 'command --args',
events => ['PROCESS_STATE', 'PROCESS_STATE_START']
priority => '100',
env_var => 'my_common_envs'
}
```
### Run supervisorctl Commands
Should you need to run a sequence of command with `supervisorctl` you can use the define type `supervisord::supervisorctl`
```ruby
supervisord::supervisorctl { 'restart_myapp':
command => 'restart',
process => 'myapp'
}
```
You can also issue a command without specifying a process.
### Development ### Development
If you have suggestions or improvements please file an issue or pull request, i'll try and sort them as quickly as possble. If you have suggestions or improvements please file an issue or pull request, i'll try and sort them as quickly as possble.
If you submit a pull please try and include tests for the new functionality. The module is tested with [Travis-CI](https://travis-ci.org/ajcrowe/puppet-supervisord). If you submit a pull please try and include tests for the new functionality/fix. The module is tested with [Travis-CI](https://travis-ci.org/ajcrowe/puppet-supervisord).
### Credits ### Credits
* Debian init script sourced from the system package. * Debian init script sourced from the system package.
* RedHat/Centos init script sourced from https://github.com/Supervisor/initscripts * RedHat/Centos init script sourced from https://github.com/Supervisor/initscripts

View File

@ -1,7 +1,28 @@
require 'puppetlabs_spec_helper/rake_tasks' require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint' require 'puppet-lint/tasks/puppet-lint'
require 'rspec-system/rake_task' require 'puppet-syntax/tasks/puppet-syntax'
PuppetLint.configuration.send('disable_80chars') PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class') PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_quoted_booleans')
PuppetLint.configuration.send('disable_autoloader_layout')
exclude_paths = [
"pkg/**/*",
"vendor/**/*",
"spec/**/*",
]
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths
desc "Acceptance Tests"
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end
desc "Test Suite"
task :test => [
:lint,
:syntax,
:spec
]

View File

@ -1,14 +1,12 @@
# #
# Converts the array to a csv string # Converts the array to a csv string
# #
#
# $array = [ 'string1', 'string2', 'string3' ] # $array = [ 'string1', 'string2', 'string3' ]
# #
# becomes: # becomes:
# #
# $string = "string1,string2,string3" # $string = "string1,string2,string3"
# #
module Puppet::Parser::Functions module Puppet::Parser::Functions
newfunction(:array2csv, :type => :rvalue, :doc => <<-'EOS' newfunction(:array2csv, :type => :rvalue, :doc => <<-'EOS'
Returns a sorted csv formatted string from an array in the form Returns a sorted csv formatted string from an array in the form

View File

@ -1,7 +1,6 @@
# #
# Converts the hash to a csv string # Converts the hash to a csv string
# #
#
# $hash = { # $hash = {
# HOME => '/home/user', # HOME => '/home/user',
# ENV1 => 'env1', # ENV1 => 'env1',
@ -12,7 +11,6 @@
# #
# $string = "HOME='/home/user',ENV1='env1',SECRET='secret'" # $string = "HOME='/home/user',ENV1='env1',SECRET='secret'"
# #
module Puppet::Parser::Functions module Puppet::Parser::Functions
newfunction(:hash2csv, :type => :rvalue, :doc => <<-'EOS' newfunction(:hash2csv, :type => :rvalue, :doc => <<-'EOS'
Returns a csv formatted string from an hash in the form Returns a csv formatted string from an hash in the form

View File

@ -1,6 +1,16 @@
# Class: supervisord::config
#
# Configuration class for supervisor init and conf directories
#
class supervisord::config inherits supervisord { class supervisord::config inherits supervisord {
file { [ "${supervisord::config_include}", "${supervisord::log_path}"]: file { $supervisord::config_include:
ensure => directory,
owner => 'root',
mode => '0755'
}
file { $supervisord::log_path:
ensure => directory, ensure => directory,
owner => 'root', owner => 'root',
mode => '0755' mode => '0755'
@ -15,30 +25,26 @@ class supervisord::config inherits supervisord {
} }
if $supervisord::install_init { if $supervisord::install_init {
$osname = downcase($::osfamily)
file { '/etc/init.d/supervisord': file { '/etc/init.d/supervisord':
ensure => present, ensure => present,
owner => 'root', owner => 'root',
mode => '0755', mode => '0755',
content => template("supervisord/init/${osname}_init.erb") content => template("supervisord/init/${::osfamily}/init.erb")
} }
if $supervisord::init_extras { if $supervisord::init_defaults {
file { $supervisord::init_extras: file { $supervisord::init_defaults:
ensure => present, ensure => present,
owner => 'root', owner => 'root',
mode => '0755', mode => '0755',
content => template("supervisord/init/${osname}_extra.erb") content => template("supervisord/init/${::osfamily}/defaults.erb")
} }
} }
} }
concat { $supervisord::config_file: concat { $supervisord::config_file:
owner => 'root', owner => 'root',
group => 'root', group => '0',
mode => '0755' mode => '0755'
} }

View File

@ -1,8 +1,16 @@
# Define: supervisord::eventlistener
#
# This define creates an eventlistener configuration file
#
# Documentation on parameters available at:
# http://supervisord.org/configuration.html#eventlistener-x-section-settings
#
define supervisord::eventlistener( define supervisord::eventlistener(
$command, $command,
$ensure = present, $ensure = present,
$ensure_process = 'running',
$buffer_size = 10,
$events = undef, $events = undef,
$buffer_size = undef,
$result_handler = undef, $result_handler = undef,
$env_var = undef, $env_var = undef,
$process_name = undef, $process_name = undef,
@ -15,16 +23,16 @@ define supervisord::eventlistener(
$startretries = undef, $startretries = undef,
$exitcodes = undef, $exitcodes = undef,
$stopsignal = undef, $stopsignal = undef,
$stopwaitsec = undef, $stopwaitsecs = undef,
$stopasgroup = undef, $stopasgroup = undef,
$killasgroup = undef, $killasgroup = undef,
$user = undef, $user = undef,
$redirect_stderr = undef, $redirect_stderr = undef,
$stdout_logfile = "${supervisord::log_path}/eventlistener_${name}.log", $stdout_logfile = "eventlistener_${name}.log",
$stdout_logfile_maxbytes = undef, $stdout_logfile_maxbytes = undef,
$stdout_logfile_backups = undef, $stdout_logfile_backups = undef,
$stdout_events_enabled = undef, $stdout_events_enabled = undef,
$stderr_logfile = "${supervisord::log_path}/eventlistener_${name}.error", $stderr_logfile = "eventlistener_${name}.error",
$stderr_logfile_maxbytes = undef, $stderr_logfile_maxbytes = undef,
$stderr_logfile_backups = undef, $stderr_logfile_backups = undef,
$stderr_events_enabled = undef, $stderr_events_enabled = undef,
@ -36,11 +44,45 @@ define supervisord::eventlistener(
include supervisord include supervisord
# parameter validation
validate_string($command)
validate_re($ensure_process, ['running', 'stopped', 'removed'])
validate_re($buffer_size, '^\d+')
if $events { validate_array($events) }
if $result_handler { validate_string($result_handler) }
if $numprocs { validate_re($numprocs, '^\d+')}
if $numprocs_start { validate_re($numprocs_start, '^\d+')}
if $priority { validate_re($priority, '^\d+') }
if $autostart { validate_bool($autostart) }
if $autorestart { validate_re($autorestart, ['true', 'false', 'unexpected']) }
if $startsecs { validate_re($startsecs, '^\d+')}
if $startretries { validate_re($startretries, '^\d+')}
if $exitcodes { validate_string($exitcodes)}
if $stopsignal { validate_re($stopsignal, ['TERM', 'HUP', 'INT', 'QUIT', 'KILL', 'USR1', 'USR2']) }
if $stopwaitsecs { validate_re($stopwaitsecs, '^\d+')}
if $stopasgroup { validate_bool($stopasgroup) }
if $killasgroup { validate_bool($killasgroup) }
if $user { validate_string($user) }
if $redirect_stderr { validate_bool($redirect_stderr) }
validate_string($stdout_logfile)
if $stdout_logfile_maxbytes { validate_string($stdout_logfile_maxbytes) }
if $stdout_logfile_backups { validate_re($stdout_logfile_backups, '^\d+')}
if $stdout_events_enabled { validate_bool($stdout_events_enabled) }
validate_string($stderr_logfile)
if $stderr_logfile_maxbytes { validate_string($stderr_logfile_maxbytes) }
if $stderr_logfile_backups { validate_re($stderr_logfile_backups, '^\d+')}
if $stderr_events_enabled { validate_bool($stderr_events_enabled) }
if $directory { validate_absolute_path($directory) }
if $umask { validate_re($umask, '^[0-7][0-7][0-7]$') }
# convert environment data into a csv
if $env_var { if $env_var {
$env_hash = hiera($env_var) $env_hash = hiera_hash($env_var)
validate_hash($env_hash)
$env_string = hash2csv($env_hash) $env_string = hash2csv($env_hash)
} }
elsif $environment { elsif $environment {
validate_hash($environment)
$env_string = hash2csv($environment) $env_string = hash2csv($environment)
} }
@ -55,6 +97,22 @@ define supervisord::eventlistener(
owner => 'root', owner => 'root',
mode => '0755', mode => '0755',
content => template('supervisord/conf/eventlistener.erb'), content => template('supervisord/conf/eventlistener.erb'),
notify => Class['supervisord::service'] notify => Class['supervisord::reload']
}
case $ensure_process {
'stopped': {
supervisord::supervisorctl { "stop_${name}":
command => 'stop',
process => $name
}
}
'removed': {
supervisord::supervisorctl { "remove_${name}":
command => 'remove',
process => $name
}
}
default: { }
} }
} }

View File

@ -1,7 +1,15 @@
# Define: supervisord::fcgi_program
#
# This define creates an eventlistener configuration file
#
# Documentation on parameters available at:
# http://supervisord.org/configuration.html#fcgi-program-x-section-settings
#
define supervisord::fcgi_program( define supervisord::fcgi_program(
$command, $command,
$socket, $socket,
$ensure = present, $ensure = present,
$ensure_process = 'running',
$socket_owner = undef, $socket_owner = undef,
$socket_mode = undef, $socket_mode = undef,
$env_var = undef, $env_var = undef,
@ -15,17 +23,17 @@ define supervisord::fcgi_program(
$startretries = undef, $startretries = undef,
$exitcodes = undef, $exitcodes = undef,
$stopsignal = undef, $stopsignal = undef,
$stopwaitsec = undef, $stopwaitsecs = undef,
$stopasgroup = undef, $stopasgroup = undef,
$killasgroup = undef, $killasgroup = undef,
$user = undef, $user = undef,
$redirect_stderr = undef, $redirect_stderr = undef,
$stdout_logfile = "${supervisord::log_path}/fcgi-program_${name}.log", $stdout_logfile = "fcgi-program_${name}.log",
$stdout_logfile_maxbytes = undef, $stdout_logfile_maxbytes = undef,
$stdout_logfile_backups = undef, $stdout_logfile_backups = undef,
$stdout_capture_maxbytes = undef, $stdout_capture_maxbytes = undef,
$stdout_events_enabled = undef, $stdout_events_enabled = undef,
$stderr_logfile = "${supervisord::log_path}/fcgi-program_${name}.error", $stderr_logfile = "fcgi-program_${name}.error",
$stderr_logfile_maxbytes = undef, $stderr_logfile_maxbytes = undef,
$stderr_logfile_backups = undef, $stderr_logfile_backups = undef,
$stderr_capture_maxbytes = undef, $stderr_capture_maxbytes = undef,
@ -38,11 +46,46 @@ define supervisord::fcgi_program(
include supervisord include supervisord
# parameter validation
validate_string($command)
validate_re($ensure_process, ['running', 'stopped', 'removed'])
validate_re($socket, ['^tcp:\/\/.*:\d+$', '^unix:\/\/\/'])
if $process_name { validate_string($process_name) }
if $numprocs { validate_re($numprocs, '^\d+')}
if $numprocs_start { validate_re($numprocs_start, '^\d+')}
if $priority { validate_re($priority, '^\d+') }
if $autostart { validate_bool($autostart) }
if $autorestart { validate_re($autorestart, ['true', 'false', 'unexpected']) }
if $startsecs { validate_re($startsecs, '^\d+')}
if $startretries { validate_re($startretries, '^\d+')}
if $exitcodes { validate_string($exitcodes)}
if $stopsignal { validate_re($stopsignal, ['TERM', 'HUP', 'INT', 'QUIT', 'KILL', 'USR1', 'USR2']) }
if $stopwaitsecs { validate_re($stopwaitsecs, '^\d+')}
if $stopasgroup { validate_bool($stopasgroup) }
if $killasgroup { validate_bool($killasgroup) }
if $user { validate_string($user) }
if $redirect_stderr { validate_bool($redirect_stderr) }
validate_string($stdout_logfile)
if $stdout_logfile_maxbytes { validate_string($stdout_logfile_maxbytes) }
if $stdout_logfile_backups { validate_re($stdout_logfile_backups, '^\d+')}
if $stdout_capture_maxbytes { validate_string($stdout_capture_maxbytes) }
if $stdout_events_enabled { validate_bool($stdout_events_enabled) }
validate_string($stderr_logfile)
if $stderr_logfile_maxbytes { validate_string($stderr_logfile_maxbytes) }
if $stderr_logfile_backups { validate_re($stderr_logfile_backups, '^\d+')}
if $stderr_capture_maxbytes { validate_string($stderr_capture_maxbytes) }
if $stderr_events_enabled { validate_bool($stderr_events_enabled) }
if $directory { validate_absolute_path($directory) }
if $umask { validate_re($umask, '^[0-7][0-7][0-7]$') }
# convert environment data into a csv
if $env_var { if $env_var {
$env_hash = hiera($env_var) $env_hash = hiera_hash($env_var)
validate_hash($env_hash)
$env_string = hash2csv($env_hash) $env_string = hash2csv($env_hash)
} }
elsif $environment { elsif $environment {
validate_hash($environment)
$env_string = hash2csv($environment) $env_string = hash2csv($environment)
} }
@ -53,6 +96,22 @@ define supervisord::fcgi_program(
owner => 'root', owner => 'root',
mode => '0755', mode => '0755',
content => template('supervisord/conf/fcgi_program.erb'), content => template('supervisord/conf/fcgi_program.erb'),
notify => Class['supervisord::service'] notify => Class['supervisord::reload']
}
case $ensure_process {
'stopped': {
supervisord::supervisorctl { "stop_${name}":
command => 'stop',
process => $name
}
}
'removed': {
supervisord::supervisorctl { "remove_${name}":
command => 'remove',
process => $name
}
}
default: { }
} }
} }

View File

@ -1,3 +1,10 @@
# Define: supervisord::group
#
# This define creates an group configuration file
#
# Documentation on parameters available at:
# http://supervisord.org/configuration.html#group-x-section-settings
#
define supervisord::group ( define supervisord::group (
$programs, $programs,
$ensure = present, $ensure = present,
@ -6,6 +13,10 @@ define supervisord::group (
include supervisord include supervisord
# parameter validation
validate_array($programs)
if $priority { validate_re($priority, '^\d+', "invalid priority value of: ${priority}") }
$progstring = array2csv($programs) $progstring = array2csv($programs)
$conf = "${supervisord::config_include}/group_${name}.conf" $conf = "${supervisord::config_include}/group_${name}.conf"
@ -13,6 +24,7 @@ define supervisord::group (
ensure => $ensure, ensure => $ensure,
owner => 'root', owner => 'root',
mode => '0755', mode => '0755',
content => template('supervisord/conf/group.erb') content => template('supervisord/conf/group.erb'),
notify => Class['supervisord::reload']
} }
} }

View File

@ -1,12 +1,18 @@
# This class installs supervisord and configured it to run on boot # Class: supervisord
#
# This class installs supervisord via pip
#
class supervisord( class supervisord(
$package_ensure = $supervisord::params::package_ensure, $package_ensure = $supervisord::params::package_ensure,
$package_provider = $supervisord::params::package_provider,
$service_ensure = $supervisord::params::service_ensure, $service_ensure = $supervisord::params::service_ensure,
$service_name = $supervisord::params::service_name,
$install_init = $supervisord::params::install_init, $install_init = $supervisord::params::install_init,
$install_pip = false, $install_pip = false,
$init_extras = $supervisord::params::init_extras, $init_defaults = $supervisord::params::init_defaults,
$setuptools_url = $supervisord::params::setuptools_url, $setuptools_url = $supervisord::params::setuptools_url,
$executable = $supervisord::params::executable, $executable = $supervisord::params::executable,
$executable_ctl = $supervisord::params::executable_ctl,
$log_path = $supervisord::params::log_path, $log_path = $supervisord::params::log_path,
$log_file = $supervisord::params::log_file, $log_file = $supervisord::params::log_file,
@ -19,20 +25,20 @@ class supervisord(
$nodaemon = $supervisord::params::nodaemon, $nodaemon = $supervisord::params::nodaemon,
$minfds = $supervisord::params::minfds, $minfds = $supervisord::params::minfds,
$minprocs = $supervisord::params::minprocs, $minprocs = $supervisord::params::minprocs,
$config_path = $supervisord::params::config_path,
$config_include = $supervisord::params::config_include, $config_include = $supervisord::params::config_include,
$config_file = $supervisord::params::config_file, $config_file = $supervisord::params::config_file,
$config_dirs = undef,
$umask = $supervisord::params::umask, $umask = $supervisord::params::umask,
$unix_socket = $supervisord::params::unix_socket, $unix_socket = $supervisord::params::unix_socket,
$unix_socket_file = $supervisord::params::unix_socket_file, $unix_socket_file = $supervisord::params::unix_socket_file,
$unix_socket_mode = $supervisord::params::unix_socket_mode, $unix_socket_mode = $supervisord::params::unix_socket_mode,
$unix_socket_owner = $supervisord::params::unix_socket_owner, $unix_socket_owner = $supervisord::params::unix_socket_owner,
$unix_scoket_group = $supervisord::params::unix_socket_group, $unix_socket_group = $supervisord::params::unix_socket_group,
$inet_server = $supervisord::params::inet_server, $inet_server = $supervisord::params::inet_server,
$inet_server_hostname = $supervisord::params::inet_hostname, $inet_server_hostname = $supervisord::params::inet_server_hostname,
$inet_server_port = $supervisord::params::inet_port, $inet_server_port = $supervisord::params::inet_server_port,
$unix_auth = false, $unix_auth = false,
$unix_username = undef, $unix_username = undef,
@ -47,26 +53,76 @@ class supervisord(
$childlogdir = undef, $childlogdir = undef,
$environment = undef, $environment = undef,
$env_var = undef, $env_var = undef,
$directory = undef,
$strip_ansi = false, $strip_ansi = false,
$nocleanup = false $nocleanup = false,
$eventlisteners = {},
$fcgi_programs = {},
$groups = {},
$programs = {}
) inherits supervisord::params { ) inherits supervisord::params {
validate_bool($install_pip)
validate_bool($install_init)
validate_bool($nodaemon)
validate_bool($unix_auth)
validate_bool($inet_auth)
validate_bool($strip_ansi)
validate_bool($nocleanup)
validate_hash($eventlisteners)
validate_hash($fcgi_programs)
validate_hash($groups)
validate_hash($programs)
validate_absolute_path($config_include)
validate_absolute_path($log_path)
validate_absolute_path($run_path)
if $childlogdir { validate_absolute_path($childlogdir) }
if $directory { validate_absolute_path($directory) }
$log_levels = ['^critical$', '^error$', '^warn$', '^info$', '^debug$', '^trace$', '^blather$']
validate_re($log_level, $log_levels, "invalid log_level: ${log_level}")
validate_re($umask, '^0[0-7][0-7]$', "invalid umask: ${umask}.")
validate_re($unix_socket_mode, '^[0-7][0-7][0-7][0-7]$', "invalid unix_socket_mode: ${unix_socket_mode}")
if ! is_integer($logfile_backups) { fail("invalid logfile_backups: ${logfile_backups}.")}
if ! is_integer($minfds) { fail("invalid minfds: ${minfds}.")}
if ! is_integer($minprocs) { fail("invalid minprocs: ${minprocs}.")}
if ! is_integer($inet_server_port) { fail("invalid inet_server_port: ${inet_server_port}.")}
if $env_var { if $env_var {
validate_hash($env_var)
$env_hash = hiera($env_var) $env_hash = hiera($env_var)
$env_string = hash2csv($env_hash) $env_string = hash2csv($env_hash)
} }
elsif $environment { elsif $environment {
validate_hash($environment)
$env_string = hash2csv($environment) $env_string = hash2csv($environment)
} }
if $config_dirs {
validate_array($config_dirs)
$config_include_string = join($config_dirs, " ")
}
else {
$config_include_string = "${config_include}/*.conf"
}
create_resources('supervisord::eventlistener', $eventlisteners)
create_resources('supervisord::fcgi_program', $fcgi_programs)
create_resources('supervisord::group', $groups)
create_resources('supervisord::program', $programs)
if $install_pip { if $install_pip {
include supervisord::pip include supervisord::pip
Class['supervisord::pip'] -> Class['supervisord::install'] Class['supervisord::pip'] -> Class['supervisord::install']
} }
include supervisord::install, supervisord::config, supervisord::service include supervisord::install, supervisord::config, supervisord::service, supervisord::reload
Class['supervisord::install'] -> Class['supervisord::config'] ~> Class['supervisord::service'] Class['supervisord::install'] -> Class['supervisord::config'] ~> Class['supervisord::service']
Class['supervisord::reload'] -> Supervisord::Supervisorctl <| |>
} }

View File

@ -1,6 +1,10 @@
# Class supervisord::install
#
# Installs supervisor package (defaults to using pip)
#
class supervisord::install inherits supervisord { class supervisord::install inherits supervisord {
package { 'supervisor': package { 'supervisor':
ensure => $supervisord::package_ensure, ensure => $supervisord::package_ensure,
provider => 'pip' provider => $supervisord::package_provider
} }
} }

View File

@ -1,13 +1,21 @@
# Class: supervisord::params
#
# Default parameters for supervisord
#
class supervisord::params { class supervisord::params {
# default supervisord params
$package_ensure = 'installed' $package_ensure = 'installed'
$package_provider = 'pip'
$service_ensure = 'running' $service_ensure = 'running'
$service_name = 'supervisord'
$package_name = 'supervisor' $package_name = 'supervisor'
$executable = '/usr/local/bin/supervisord' $executable = 'supervisord'
$executable_ctl = 'supervisorctl'
$run_path = '/var/run' $run_path = '/var/run'
$pid_file = "${run_path}/supervisord.pid" $pid_file = 'supervisord.pid'
$log_path = '/var/log/supervisor' $log_path = '/var/log/supervisor'
$log_file = "${log_path}/supervisord.log" $log_file = 'supervisord.log'
$logfile_maxbytes = '50MB' $logfile_maxbytes = '50MB'
$logfile_backups = '10' $logfile_backups = '10'
$log_level = 'info' $log_level = 'info'
@ -20,7 +28,7 @@ class supervisord::params {
$setuptools_url = 'https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py' $setuptools_url = 'https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py'
$unix_socket = true $unix_socket = true
$unix_socket_file = "${run_path}/supervisor.sock" $unix_socket_file = 'supervisor.sock'
$unix_socket_mode = '0700' $unix_socket_mode = '0700'
$unix_socket_owner = 'nobody' $unix_socket_owner = 'nobody'
@ -31,17 +39,17 @@ class supervisord::params {
case $::osfamily { case $::osfamily {
'RedHat': { 'RedHat': {
$init_extras = '/etc/sysconfig/supervisord' $init_defaults = '/etc/sysconfig/supervisord'
$unix_socket_group = 'nobody' $unix_socket_group = 'nobody'
$install_init = true $install_init = true
} }
'Debian': { 'Debian': {
$init_extras = '/etc/default/supervisor' $init_defaults = '/etc/default/supervisor'
$unix_socket_group = 'nogroup' $unix_socket_group = 'nogroup'
$install_init = true $install_init = true
} }
default: { default: {
$init_extras = false $init_defaults = false
$unix_socket_group = 'nogroup' $unix_socket_group = 'nogroup'
$install_init = false $install_init = false
} }

View File

@ -1,8 +1,10 @@
# Class: supervisord::pip
#
# Optional class to install setuptool and pip
#
class supervisord::pip inherits supervisord { class supervisord::pip inherits supervisord {
Exec { Exec { path => [ '/usr/bin/', '/usr/local/bin', '/bin', '/usr/local/sbin', '/usr/sbin', '/sbin' ] }
path => '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin'
}
exec { 'install_setuptools': exec { 'install_setuptools':
command => "curl ${supervisord::setuptools_url} | python", command => "curl ${supervisord::setuptools_url} | python",

View File

@ -1,6 +1,14 @@
# Define: supervisord::program
#
# This define creates an program configuration file
#
# Documentation on parameters available at:
# http://supervisord.org/configuration.html#program-x-section-settings
#
define supervisord::program( define supervisord::program(
$command, $command,
$ensure = present, $ensure = present,
$ensure_process = 'running',
$env_var = undef, $env_var = undef,
$process_name = undef, $process_name = undef,
$numprocs = undef, $numprocs = undef,
@ -12,17 +20,17 @@ define supervisord::program(
$startretries = undef, $startretries = undef,
$exitcodes = undef, $exitcodes = undef,
$stopsignal = undef, $stopsignal = undef,
$stopwaitsec = undef, $stopwaitsecs = undef,
$stopasgroup = undef, $stopasgroup = undef,
$killasgroup = undef, $killasgroup = undef,
$user = undef, $user = undef,
$redirect_stderr = undef, $redirect_stderr = undef,
$stdout_logfile = "${supervisord::log_path}/program_${name}.log", $stdout_logfile = "program_${name}.log",
$stdout_logfile_maxbytes = undef, $stdout_logfile_maxbytes = undef,
$stdout_logfile_backups = undef, $stdout_logfile_backups = undef,
$stdout_capture_maxbytes = undef, $stdout_capture_maxbytes = undef,
$stdout_events_enabled = undef, $stdout_events_enabled = undef,
$stderr_logfile = "${supervisord::log_path}/program_${name}.error", $stderr_logfile = "program_${name}.error",
$stderr_logfile_maxbytes = undef, $stderr_logfile_maxbytes = undef,
$stderr_logfile_backups = undef, $stderr_logfile_backups = undef,
$stderr_capture_maxbytes = undef, $stderr_capture_maxbytes = undef,
@ -35,11 +43,45 @@ define supervisord::program(
include supervisord include supervisord
# parameter validation
validate_string($command)
validate_re($ensure_process, ['running', 'stopped', 'removed'])
if $process_name { validate_string($process_name) }
if $numprocs { validate_re($numprocs, '^\d+')}
if $numprocs_start { validate_re($numprocs_start, '^\d+')}
if $priority { validate_re($priority, '^\d+') }
if $autostart { validate_bool($autostart) }
if $autorestart { validate_re($autorestart, ['true', 'false', 'unexpected']) }
if $startsecs { validate_re($startsecs, '^\d+')}
if $startretries { validate_re($startretries, '^\d+')}
if $exitcodes { validate_string($exitcodes)}
if $stopsignal { validate_re($stopsignal, ['TERM', 'HUP', 'INT', 'QUIT', 'KILL', 'USR1', 'USR2']) }
if $stopwaitsecs { validate_re($stopwaitsecs, '^\d+')}
if $stopasgroup { validate_bool($stopasgroup) }
if $killasgroup { validate_bool($killasgroup) }
if $user { validate_string($user) }
if $redirect_stderr { validate_bool($redirect_stderr) }
validate_string($stdout_logfile)
if $stdout_logfile_maxbytes { validate_string($stdout_logfile_maxbytes) }
if $stdout_logfile_backups { validate_re($stdout_logfile_backups, '^\d+')}
if $stdout_capture_maxbytes { validate_string($stdout_capture_maxbytes) }
if $stdout_events_enabled { validate_bool($stdout_events_enabled) }
validate_string($stderr_logfile)
if $stderr_logfile_maxbytes { validate_string($stderr_logfile_maxbytes) }
if $stderr_logfile_backups { validate_re($stderr_logfile_backups, '^\d+')}
if $stderr_capture_maxbytes { validate_string($stderr_capture_maxbytes) }
if $stderr_events_enabled { validate_bool($stderr_events_enabled) }
if $directory { validate_absolute_path($directory) }
if $umask { validate_re($umask, '^[0-7][0-7][0-7]$') }
# convert environment data into a csv
if $env_var { if $env_var {
$env_hash = hiera($env_var) $env_hash = hiera_hash($env_var)
validate_hash($env_hash)
$env_string = hash2csv($env_hash) $env_string = hash2csv($env_hash)
} }
elsif $environment { elsif $environment {
validate_hash($environment)
$env_string = hash2csv($environment) $env_string = hash2csv($environment)
} }
@ -50,6 +92,22 @@ define supervisord::program(
owner => 'root', owner => 'root',
mode => '0755', mode => '0755',
content => template('supervisord/conf/program.erb'), content => template('supervisord/conf/program.erb'),
notify => Class['supervisord::service'] notify => Class['supervisord::reload']
}
case $ensure_process {
'stopped': {
supervisord::supervisorctl { "stop_${name}":
command => 'stop',
process => $name
}
}
'removed': {
supervisord::supervisorctl { "remove_${name}":
command => 'remove',
process => $name
}
}
default: { }
} }
} }

View File

@ -0,0 +1,21 @@
# Class: supervisord::reload
#
# Class to reread and update supervisord with supervisorctl
#
class supervisord::reload {
Exec { path => [ '/usr/bin/', '/usr/local/bin' ] }
$supervisorctl = $::supervisord::executable_ctl
exec { 'supervisorctl_reread':
command => "${supervisorctl} reread",
refreshonly => true,
returns => [0, 2],
}
exec { 'supervisorctl_update':
command => "${supervisorctl} update",
refreshonly => true,
returns => [0, 2],
}
}

View File

@ -1,5 +1,9 @@
# Class: supervisord::service
#
# Class for the supervisord service
#
class supervisord::service inherits supervisord { class supervisord::service inherits supervisord {
service { 'supervisord': service { $supervisord::service_name:
ensure => $supervisord::service_ensure, ensure => $supervisord::service_ensure,
enable => true, enable => true,
hasrestart => true, hasrestart => true,

View File

@ -0,0 +1,29 @@
# Define: supervisord:supervisorctl
#
# This define executes command with the supervisorctl tool
#
define supervisord::supervisorctl(
$command,
$process = undef,
$refreshonly = false
) {
Exec { path => [ '/usr/bin/', '/usr/local/bin' ] }
validate_string($command)
validate_string($process)
$supervisorctl = $::supervisord::executable_ctl
if $process {
$cmd = join([$supervisorctl, $command, $process], ' ')
}
else {
$cmd = join([$supervisorctl, $command])
}
exec { "supervisorctl_command_${name}":
command => $cmd,
refreshonly => $refreshonly
}
}

View File

@ -0,0 +1,10 @@
HOSTS:
centos-65-i386:
roles:
- master
platform: el-6-i386
box : centos-65-i386-virtualbox-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-i386-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View File

@ -0,0 +1,10 @@
HOSTS:
centos-65-x64:
roles:
- master
platform: el-6-x86_64
box : centos-65-x64-virtualbox-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View File

@ -0,0 +1,10 @@
HOSTS:
debian-73-i386:
roles:
- master
platform: debian-7-i386
box : debian-73-i386-virtualbox-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-i386-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View File

@ -0,0 +1,10 @@
HOSTS:
debian-73-x64:
roles:
- master
platform: debian-7-amd64
box : debian-73-x64-virtualbox-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View File

@ -0,0 +1,10 @@
HOSTS:
debian-73-x64:
roles:
- master
platform: debian-7-amd64
box : debian-73-x64-virtualbox-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box
hypervisor : vagrant
CONFIG:
type: foss

View File

@ -0,0 +1,114 @@
require 'spec_helper_acceptance'
describe 'supervisord install' do
context 'default parameters with pip and init install' do
it 'should work with no errors' do
pp = <<-EOS
class { 'supervisord': install_pip => true, install_init => true}
EOS
expect(apply_manifest(pp).exit_code).to_not eq(1)
expect(apply_manifest(pp).exit_code).to eq(0)
end
describe service('supervisord') do
it { should be_enabled }
it { should be_running }
it 'should restart successfully' do
cmd="service supervisord restart"
expect(shell(cmd).exit_code).to_not eq(1)
end
end
end
end
describe 'supervisord::program' do
context 'create a program config' do
it 'should install a program file' do
pp = <<-EOS
include supervisord
supervisord::program { 'test':
command => 'echo',
priority => '100',
environment => {
'HOME' => '/root',
'PATH' => '/bin',
}
}
EOS
expect(apply_manifest(pp).exit_code).to_not eq(1)
expect(apply_manifest(pp).exit_code).to eq(0)
end
it 'should contain the correct values' do
cmd='grep command=echo /etc/supervisor.d/program_test.conf'
expect(shell(cmd).exit_code).to eq(0)
cmd='grep priority=100 /etc/supervisor.d/program_test.conf'
expect(shell(cmd).exit_code).to eq(0)
cmd='grep "environment=" /etc/supervisor.d/program_test.conf'
expect(shell(cmd).exit_code).to eq(0)
end
end
end
describe 'supervisord::fcgi-program' do
context 'create fcgi-program config' do
it 'should install a fcgi-program file' do
pp = <<-EOS
include supervisord
supervisord::fcgi_program { 'test':
socket => 'tcp://localhost:1000',
command => 'echo',
priority => '100',
environment => {
'HOME' => '/root',
'PATH' => '/bin',
}
}
EOS
expect(apply_manifest(pp).exit_code).to_not eq(1)
expect(apply_manifest(pp).exit_code).to eq(0)
end
it 'should contain the correct values' do
cmd='grep socket=tcp://localhost:1000 /etc/supervisor.d/fcgi-program_test.conf'
expect(shell(cmd).exit_code).to eq(0)
cmd="grep command=echo /etc/supervisor.d/fcgi-program_test.conf"
expect(shell(cmd).exit_code).to eq(0)
cmd="grep priority=100 /etc/supervisor.d/fcgi-program_test.conf"
expect(shell(cmd).exit_code).to eq(0)
cmd='grep "environment=" /etc/supervisor.d/fcgi-program_test.conf'
expect(shell(cmd).exit_code).to eq(0)
end
end
end
describe 'supervisord::group' do
context 'create group config' do
it 'should install a group config' do
pp = <<-EOS
include supervisord
supervisord::group { 'test':
programs => ['test'],
priority => '100',
}
EOS
expect(apply_manifest(pp).exit_code).to_not eq(1)
expect(apply_manifest(pp).exit_code).to eq(0)
end
it 'should contain the correct values' do
cmd='grep "programs=test" /etc/supervisor.d/group_test.conf'
expect(shell(cmd).exit_code).to eq(0)
cmd="grep priority=100 /etc/supervisor.d/group_test.conf"
expect(shell(cmd).exit_code).to eq(0)
end
end
end

View File

@ -3,14 +3,26 @@ require 'spec_helper'
describe 'supervisord' do describe 'supervisord' do
concatdir = '/var/lib/puppet/concat' concatdir = '/var/lib/puppet/concat'
configfile = '/etc/supervisord.conf'
let(:facts) {{ :concat_basedir => concatdir }} let(:facts) {{ :concat_basedir => concatdir }}
it { should contain_class('supervisord') } it { should contain_class('supervisord') }
it { should contain_class('supervisord::install') } it { should contain_class('supervisord::install') }
it { should contain_class('supervisord::config') } it { should contain_class('supervisord::config') }
it { should contain_class('supervisord::service') } it { should contain_class('supervisord::service') }
it { should contain_concat__fragment('supervisord_main').with_content(/logfile/) } it { should contain_class('supervisord::params') }
it { should contain_class('supervisord::reload') }
it { should contain_package('supervisor') }
describe '#service_name' do
context 'default' do
it { should contain_service('supervisord') }
end
context 'specified' do
let(:params) {{ :service_name => 'myservicename' }}
it { should contain_service('myservicename') }
end
end
describe '#install_pip' do describe '#install_pip' do
context 'default' do context 'default' do
@ -18,8 +30,16 @@ describe 'supervisord' do
end end
context 'true' do context 'true' do
let (:params) {{ :install_pip => true }} let(:params) {{ :install_pip => true }}
it { should contain_class('supervisord::pip') } it { should contain_class('supervisord::pip') }
it { should contain_exec('install_setuptools') }
it { should contain_exec('install_pip') }
end
context 'true and RedHat' do
let(:params) {{ :install_pip => true }}
let(:facts) {{ :osfamily => 'RedHat', :concat_basedir => concatdir }}
it { should contain_exec('pip_provider_name_fix') }
end end
end end
@ -28,11 +48,6 @@ describe 'supervisord' do
it { should contain_class('supervisord').without_env_hash } it { should contain_class('supervisord').without_env_hash }
it { should contain_class('supervisord').without_env_string } it { should contain_class('supervisord').without_env_string }
end end
#context 'is specified' do
# let(:params) {{ :env_var => 'foovars' }}
# let(:hiera_data) {{ :foovars => { 'key1' => 'value1', 'key2' => 'value2' } }}
# it { should contain_concat__fragment('supervisord_main').with_content(/environment=key1='value1',key2='value2'/) }
#end
end end
describe '#environment' do describe '#environment' do
@ -41,7 +56,8 @@ describe 'supervisord' do
end end
context 'is specified' do context 'is specified' do
let(:params) {{ :environment => { 'key1' => 'value1', 'key2' => 'value2' } }} let(:params) {{ :environment => { 'key1' => 'value1', 'key2' => 'value2' } }}
it { should contain_concat__fragment('supervisord_main').with_content(/environment=key1='value1',key2='value2'/) } it { should contain_concat__fragment('supervisord_main')\
.with_content(/environment=key1='value1',key2='value2'/) }
end end
end end
@ -54,17 +70,20 @@ describe 'supervisord' do
it { should_not contain_file('/etc/init.d/supervisord') } it { should_not contain_file('/etc/init.d/supervisord') }
end end
describe 'on supported OS' describe 'on supported OS' do
context 'with Debian' do context 'with Debian' do
let(:facts) {{ :osfamily => 'Debian', :concat_basedir => concatdir }} let(:facts) {{ :osfamily => 'Debian', :concat_basedir => concatdir }}
it { should contain_file('/etc/init.d/supervisord') } it { should contain_file('/etc/init.d/supervisord') }
it { should contain_file('/etc/default/supervisor') }
end end
context 'with RedHat' do context 'with RedHat' do
let(:facts) {{ :osfamily => 'RedHat', :concat_basedir => concatdir }} let(:facts) {{ :osfamily => 'RedHat', :concat_basedir => concatdir }}
it { should contain_file('/etc/init.d/supervisord') } it { should contain_file('/etc/init.d/supervisord') }
it { should contain_file('/etc/sysconfig/supervisord') }
end end
end end
end
describe '#unix_socket' do describe '#unix_socket' do
context 'default' do context 'default' do
@ -89,10 +108,192 @@ describe 'supervisord' do
describe '#run_path' do describe '#run_path' do
context 'default' do context 'default' do
it { should_not contain_file('/var/run') } it { should_not contain_file('/var/run') }
it { should contain_concat__fragment('supervisord_main') \
.with_content(/pidfile=\/var\/run\/supervisord.pid$/) }
end end
context 'custom setting' do context 'is specified' do
let(:params) {{ :run_path => '/var/run/supervisord'}} let(:params) {{ :run_path => '/opt/supervisord/run' }}
it { should contain_file('/var/run/supervisord') } it { should contain_file('/opt/supervisord/run') }
it { should contain_concat__fragment('supervisord_main') \
.with_content(/pidfile=\/opt\/supervisord\/run\/supervisord.pid$/) }
end
end
describe '#log_path' do
context 'default' do
it { should contain_file('/var/log/supervisor') }
it { should contain_concat__fragment('supervisord_main') \
.with_content(/logfile=\/var\/log\/supervisor\/supervisord.log$/) }
end
context 'is specified' do
let(:params) {{ :log_path => '/opt/supervisord/logs' }}
it { should contain_file('/opt/supervisord/logs')}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/logfile=\/opt\/supervisord\/logs\/supervisord.log$/) }
end
end
describe '#config_include' do
context 'default' do
it { should contain_file('/etc/supervisor.d') }
it { should contain_concat__fragment('supervisord_main') \
.with_content(/files=\/etc\/supervisor.d\/\*.conf$/) }
end
context 'is specified' do
let(:params) {{ :config_include => '/opt/supervisord/conf.d' }}
it { should contain_file('/opt/supervisord/conf.d') }
it { should contain_concat__fragment('supervisord_main') \
.with_content(/files=\/opt\/supervisord\/conf.d\/\*.conf$/) }
end
end
describe '#config_dirs' do
context 'is specified' do
let(:params) {{ :config_dirs => ['/etc/supervisor.d/*.conf', '/opt/supervisor.d/*', '/usr/share/supervisor.d/*.config'] }}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/files=\/etc\/supervisor.d\/\*.conf \/opt\/supervisor.d\/\* \/usr\/share\/supervisor.d\/\*.config$/) }
end
end
describe '#config_file' do
context 'default' do
it { should contain_file('/etc/supervisord.conf') }
end
context 'is specified' do
let(:params) {{ :config_file => '/opt/supervisord/supervisor.conf' }}
it { should contain_file('/opt/supervisord/supervisor.conf') }
end
end
describe '#nodaemon' do
context 'default' do
it { should contain_concat__fragment('supervisord_main') \
.with_content(/nodaemon=false$/) }
end
context 'true' do
let(:params) {{ :nodaemon => true }}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/nodaemon=true$/) }
end
context 'invalid' do
let(:params) {{ :nodaemon => 'invalid' }}
it { expect { raise_error(Puppet::Error, /is not a boolean/) }}
end
end
describe '#minfds' do
context 'default' do
it { should contain_concat__fragment('supervisord_main') \
.with_content(/minfds=1024$/) }
end
context 'specified' do
let(:params) {{ :minfds => 2048 }}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/minfds=2048$/) }
end
context 'invalid' do
let(:params) {{ :minfds => 'string' }}
it { expect { raise_error(Puppet::Error, /invalid minfds/) }}
end
end
describe '#minprocs' do
context 'default' do
it { should contain_concat__fragment('supervisord_main') \
.with_content(/minprocs=200$/) }
end
context 'specified' do
let(:params) {{ :minprocs => 300 }}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/minprocs=300$/) }
end
context 'invalid' do
let(:params) {{ :minfds => 'string' }}
it { expect { raise_error(Puppet::Error, /invalid minprocs/) }}
end
end
describe '#strip_ansi' do
context 'default' do
it { should_not contain_concat__fragment('supervisord_main') \
.with_content(/strip_ansi$/) }
end
context 'true' do
let(:params) {{ :strip_ansi => true }}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/strip_ansi=true$/) }
end
context 'invalid' do
let(:params) {{ :strip_ansi => 'string' }}
it { expect { raise_error(Puppet::Error, /is not a boolean/) }}
end
end
describe '#user' do
context 'default' do
it { should_not contain_concat__fragment('supervisord_main') \
.with_content(/user$/) }
end
context 'specified' do
let(:params) {{ :user => 'myuser' }}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/user=myuser$/) }
end
end
describe '#identifier' do
context 'default' do
it { should_not contain_concat__fragment('supervisord_main') \
.with_content(/identifier$/) }
end
context 'specified' do
let(:params) {{ :identifier => 'myidentifier' }}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/identifier=myidentifier$/) }
end
end
describe '#directory' do
context 'default' do
it { should_not contain_concat__fragment('supervisord_main') \
.with_content(/directory$/) }
end
context 'specified' do
let(:params) {{ :directory => '/opt/supervisord' }}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/directory=\/opt\/supervisord$/) }
end
end
describe '#nocleanup' do
context 'default' do
it { should_not contain_concat__fragment('supervisord_main') \
.with_content(/nocleanup$/) }
end
context 'true' do
let(:params) {{ :nocleanup => true }}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/nocleanup=true$/) }
end
context 'invalid' do
let(:params) {{ :nocleanup => 'string' }}
it { expect { raise_error(Puppet::Error, /is not a boolean/) }}
end
end
describe '#childlogdir' do
context 'default' do
it { should_not contain_concat__fragment('supervisord_main') \
.with_content(/childlogdir$/) }
end
context 'specified' do
let(:params) {{ :childlogdir => '/opt/supervisord/logdir' }}
it { should contain_concat__fragment('supervisord_main') \
.with_content(/childlogdir=\/opt\/supervisord\/logdir$/) }
end
context 'invalid' do
let(:params) {{ :childlogdir => 'not_a_path' }}
it { expect { raise_error(Puppet::Error, /is not an absolute path/) }}
end end
end end
end end

View File

@ -2,14 +2,85 @@ require 'spec_helper'
describe 'supervisord::eventlistener', :type => :define do describe 'supervisord::eventlistener', :type => :define do
let(:title) {'foo'} let(:title) {'foo'}
let(:default_params) {{ :command => 'bar',
:stdout_logfile => '/var/log/supervisor/eventlistener_foo.log',
:stderr_logfile => '/var/log/supervisor/eventlistener_foo.error',
}}
let(:params) { default_params }
let(:facts) {{ :concat_basedir => '/var/lib/puppet/concat' }} let(:facts) {{ :concat_basedir => '/var/lib/puppet/concat' }}
let(:default_params) do
{
:command => 'bar',
:process_name => '%(process_num)s',
:events => ['PROCESS_STATE', 'PROCESS_STATE_STARTING'],
:buffer_size => 10,
:numprocs => '1',
:numprocs_start => '0',
:priority => '999',
:autostart => true,
:autorestart => 'unexpected',
:startsecs => '1',
:startretries => '3',
:exitcodes => '0,2',
:stopsignal => 'TERM',
:stopwaitsecs => '10',
:stopasgroup => true,
:killasgroup => true,
:user => 'baz',
:redirect_stderr => true,
:stdout_logfile => 'eventlistener_foo.log',
:stdout_logfile_maxbytes => '50MB',
:stdout_logfile_backups => '10',
:stdout_events_enabled => true,
:stderr_logfile => 'eventlistener_foo.error',
:stderr_logfile_maxbytes => '50MB',
:stderr_logfile_backups => '10',
:stderr_events_enabled => true,
:environment => { 'env1' => 'value1', 'env2' => 'value2' },
:directory => '/opt/supervisord/chroot',
:umask => '022',
:serverurl => 'AUTO'
}
end
it { should contain_supervisord__eventlistener('foo') } context 'default' do
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/command=bar/) } let(:params) { default_params }
it { should contain_supervisord__eventlistener('foo') }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/\[eventlistener:foo\]/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/command=bar/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/process_name=\%\(process_num\)s/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/events=PROCESS_STATE,PROCESS_STATE_STARTING/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/buffer_size=10/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/numprocs=1/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/numprocs_start=0/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/priority=999/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/autostart=true/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/startsecs=1/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/startretries=3/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/exitcodes=0,2/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stopsignal=TERM/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stopwaitsecs=10/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stopasgroup=true/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/killasgroup=true/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/user=baz/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/redirect_stderr=true/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stdout_logfile=\/var\/log\/supervisor\/eventlistener_foo.log/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stdout_logfile_maxbytes=50MB/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stdout_logfile_backups=10/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stdout_events_enabled=true/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stderr_logfile=\/var\/log\/supervisor\/eventlistener_foo.error/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stderr_logfile_maxbytes=50MB/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stderr_logfile_backups=10/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/stderr_events_enabled=true/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/environment=env1='value1',env2='value2'/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/directory=\/opt\/supervisord\/chroot/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/umask=022/) }
it { should contain_file('/etc/supervisor.d/eventlistener_foo.conf').with_content(/serverurl=AUTO/) }
end
context 'ensure_process_stopped' do
let(:params) { default_params.merge({ :ensure_process => 'stopped' }) }
it { should contain_supervisord__supervisorctl('stop_foo') }
end
context 'ensure_process_removed' do
let(:params) { default_params.merge({ :ensure_process => 'removed' }) }
it { should contain_supervisord__supervisorctl('remove_foo') }
end
end end

View File

@ -2,21 +2,87 @@ require 'spec_helper'
describe 'supervisord::fcgi_program', :type => :define do describe 'supervisord::fcgi_program', :type => :define do
let(:title) {'foo'} let(:title) {'foo'}
let(:default_params) {{ :command => 'bar',
:socket => 'tcp://localhost:1000',
:stdout_logfile => '/var/log/supervisor/fcgi-program_foo.log',
:stderr_logfile => '/var/log/supervisor/fcgi-program_foo.error',
:user => 'baz'
}}
let(:params) { default_params }
let(:facts) {{ :concat_basedir => '/var/lib/puppet/concat' }} let(:facts) {{ :concat_basedir => '/var/lib/puppet/concat' }}
let(:default_params) do
{
:command => 'bar',
:socket => 'tcp://localhost:1000',
:process_name => '%(process_num)s',
:numprocs => '1',
:numprocs_start => '0',
:priority => '999',
:autostart => true,
:autorestart => 'unexpected',
:startsecs => '1',
:startretries => '3',
:exitcodes => '0,2',
:stopsignal => 'TERM',
:stopwaitsecs => '10',
:stopasgroup => true,
:killasgroup => true,
:user => 'baz',
:redirect_stderr => true,
:stdout_logfile => 'fcgi-program_foo.log',
:stdout_logfile_maxbytes => '50MB',
:stdout_logfile_backups => '10',
:stdout_capture_maxbytes => '0',
:stdout_events_enabled => true,
:stderr_logfile => 'fcgi-program_foo.error',
:stderr_logfile_maxbytes => '50MB',
:stderr_logfile_backups => '10',
:stderr_capture_maxbytes => '0',
:stderr_events_enabled => true,
:environment => { 'env1' => 'value1', 'env2' => 'value2' },
:directory => '/opt/supervisord/chroot',
:umask => '022',
:serverurl => 'AUTO'
}
end
it { should contain_supervisord__fcgi_program('foo') } context 'default' do
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/\[fcgi-program:foo\]/) } let(:params) { default_params }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/socket=tcp:\/\/localhost:1000/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/command=bar/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/user=baz/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stdout_logfile=\/var\/log\/supervisor\/fcgi-program_foo.log/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stderr_logfile=\/var\/log\/supervisor\/fcgi-program_foo.error/) }
it { should contain_supervisord__fcgi_program('foo') }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/\[fcgi-program:foo\]/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/socket=tcp:\/\/localhost:1000/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/command=bar/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/process_name=\%\(process_num\)s/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/numprocs=1/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/numprocs_start=0/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/priority=999/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/autostart=true/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/startsecs=1/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/startretries=3/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/exitcodes=0,2/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stopsignal=TERM/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stopwaitsecs=10/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stopasgroup=true/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/killasgroup=true/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/user=baz/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/redirect_stderr=true/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stdout_logfile=\/var\/log\/supervisor\/fcgi-program_foo.log/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stdout_logfile_maxbytes=50MB/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stdout_logfile_backups=10/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stdout_capture_maxbytes=0/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stdout_events_enabled=true/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stderr_logfile=\/var\/log\/supervisor\/fcgi-program_foo.error/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stderr_logfile_maxbytes=50MB/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stderr_logfile_backups=10/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stderr_capture_maxbytes=0/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/stderr_events_enabled=true/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/environment=env1='value1',env2='value2'/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/directory=\/opt\/supervisord\/chroot/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/umask=022/) }
it { should contain_file('/etc/supervisor.d/fcgi-program_foo.conf').with_content(/serverurl=AUTO/) }
end
context 'ensure_process_stopped' do
let(:params) { default_params.merge({ :ensure_process => 'stopped' }) }
it { should contain_supervisord__supervisorctl('stop_foo') }
end
context 'ensure_process_removed' do
let(:params) { default_params.merge({ :ensure_process => 'removed' }) }
it { should contain_supervisord__supervisorctl('remove_foo') }
end
end end

View File

@ -2,19 +2,85 @@ require 'spec_helper'
describe 'supervisord::program', :type => :define do describe 'supervisord::program', :type => :define do
let(:title) {'foo'} let(:title) {'foo'}
let(:default_params) {{ :command => 'bar',
:stdout_logfile => '/var/log/supervisor/program_foo.log',
:stderr_logfile => '/var/log/supervisor/program_foo.error',
:user => 'baz'
}}
let(:params) { default_params }
let(:facts) {{ :concat_basedir => '/var/lib/puppet/concat' }} let(:facts) {{ :concat_basedir => '/var/lib/puppet/concat' }}
let(:default_params) do
{
:command => 'bar',
:process_name => '%(process_num)s',
:numprocs => '1',
:numprocs_start => '0',
:priority => '999',
:autostart => true,
:autorestart => 'unexpected',
:startsecs => '1',
:startretries => '3',
:exitcodes => '0,2',
:stopsignal => 'TERM',
:stopwaitsecs => '10',
:stopasgroup => true,
:killasgroup => true,
:user => 'baz',
:redirect_stderr => true,
:stdout_logfile => 'program_foo.log',
:stdout_logfile_maxbytes => '50MB',
:stdout_logfile_backups => '10',
:stdout_capture_maxbytes => '0',
:stdout_events_enabled => true,
:stderr_logfile => 'program_foo.error',
:stderr_logfile_maxbytes => '50MB',
:stderr_logfile_backups => '10',
:stderr_capture_maxbytes => '0',
:stderr_events_enabled => true,
:environment => { 'env1' => 'value1', 'env2' => 'value2' },
:directory => '/opt/supervisord/chroot',
:umask => '022',
:serverurl => 'AUTO'
}
end
it { should contain_supervisord__program('foo') } context 'default' do
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/\[program:foo\]/) } let(:params) { default_params }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/command=bar/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/user=baz/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stdout_logfile=\/var\/log\/supervisor\/program_foo.log/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stderr_logfile=\/var\/log\/supervisor\/program_foo.error/) }
it { should contain_supervisord__program('foo') }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/\[program:foo\]/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/command=bar/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/process_name=\%\(process_num\)s/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/numprocs=1/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/numprocs_start=0/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/priority=999/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/autostart=true/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/startsecs=1/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/startretries=3/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/exitcodes=0,2/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stopsignal=TERM/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stopwaitsecs=10/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stopasgroup=true/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/killasgroup=true/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/user=baz/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/redirect_stderr=true/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stdout_logfile=\/var\/log\/supervisor\/program_foo.log/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stdout_logfile_maxbytes=50MB/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stdout_logfile_backups=10/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stdout_capture_maxbytes=0/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stdout_events_enabled=true/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stderr_logfile=\/var\/log\/supervisor\/program_foo.error/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stderr_logfile_maxbytes=50MB/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stderr_logfile_backups=10/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stderr_capture_maxbytes=0/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/stderr_events_enabled=true/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/environment=env1='value1',env2='value2'/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/directory=\/opt\/supervisord\/chroot/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/umask=022/) }
it { should contain_file('/etc/supervisor.d/program_foo.conf').with_content(/serverurl=AUTO/) }
end
context 'ensure_process_stopped' do
let(:params) { default_params.merge({ :ensure_process => 'stopped' }) }
it { should contain_supervisord__supervisorctl('stop_foo') }
end
context 'ensure_process_removed' do
let(:params) { default_params.merge({ :ensure_process => 'removed' }) }
it { should contain_supervisord__supervisorctl('remove_foo') }
end
end end

View File

@ -0,0 +1,13 @@
require 'spec_helper'
describe 'supervisord::supervisorctl', :type => :define do
let(:title) {'command_foo'}
let(:default_params) {{
:command => 'command',
:process => 'foo'
}}
let(:params) { default_params }
let(:facts) {{ :concat_basedir => '/var/lib/puppet/concat' }}
it { should contain_supervisord__supervisorctl('command_foo') }
end

View File

@ -7,3 +7,4 @@ RSpec.configure do |c|
c.manifest_dir = File.join(fixture_path, 'manifests') c.manifest_dir = File.join(fixture_path, 'manifests')
end end
at_exit { RSpec::Puppet::Coverage.report! }

View File

@ -0,0 +1,24 @@
require 'beaker-rspec'
hosts.each do |host|
# Install Puppet
install_puppet
end
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Readable test descriptions
c.formatter = :documentation
# Configure all nodes in nodeset
c.before :suite do
# Install module
puppet_module_install(:source => proj_root, :module_name => 'supervisord')
hosts.each do |host|
on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module','install','puppetlabs-concat'), { :acceptable_exit_codes => [0,1] }
end
end
end

View File

@ -1,25 +0,0 @@
require 'rspec-system/spec_helper'
require 'rspec-system-puppet/helpers'
include RSpecSystemPuppet::Helpers
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Enable colour
c.tty = true
# This is where we 'setup' the nodes before running our tests
c.before :suite do
# Install puppet
puppet_install
puppet_master_install
# Replace mymodule with your module name
puppet_module_install(:source => proj_root, :module_name => 'supervisord')
shell('puppet module install puppetlabs/stdlib')
shell('puppet module install puppetlabs/concat')
end
end

View File

@ -1,120 +0,0 @@
require 'spec_helper_system'
describe 'basic install' do
it 'class should work with no errors' do
pp = <<-EOS
class { 'supervisord': install_pip => true, install_init => true}
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
r.refresh
r.exit_code.should be_zero
end
shell("pgrep supervisord") do |r|
r.exit_code.should be_zero
end
end
end
describe 'add a program config' do
it 'supervisord::program should install a program config' do
pp = <<-EOS
include supervisord
supervisord::program { 'test':
command => 'echo',
priority => '100',
environment => {
'HOME' => '/root',
'PATH' => '/bin',
}
}
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
r.refresh
r.exit_code.should be_zero
end
shell("grep command=echo /etc/supervisor.d/program_test.conf") do |r|
r.exit_code.should be_zero
end
shell("grep priority=100 /etc/supervisor.d/program_test.conf") do |r|
r.exit_code.should be_zero
end
shell('grep "environment=" /etc/supervisor.d/program_test.conf') do |r|
r.exit_code.should be_zero
end
end
end
describe 'add a fcgi-program config' do
it 'supervisord::fcgi_program should install a program config' do
pp = <<-EOS
include supervisord
supervisord::fcgi_program { 'test':
socket => 'tcp://localhost:1000',
command => 'echo',
priority => '100',
environment => {
'HOME' => '/root',
'PATH' => '/bin',
}
}
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
r.refresh
r.exit_code.should be_zero
end
shell("grep socket=tcp://localhost:1000 /etc/supervisor.d/fcgi-program_test.conf") do |r|
r.exit_code.should be_zero
end
shell("grep command=echo /etc/supervisor.d/fcgi-program_test.conf") do |r|
r.exit_code.should be_zero
end
shell("grep priority=100 /etc/supervisor.d/fcgi-program_test.conf") do |r|
r.exit_code.should be_zero
end
shell('grep "environment=" /etc/supervisor.d/fcgi-program_test.conf') do |r|
r.exit_code.should be_zero
end
end
end
describe 'add a group config' do
it 'supervisord::group should install a program config' do
pp = <<-EOS
include supervisord
supervisord::group { 'test':
programs => ['program1', 'program2'],
priority => '100',
}
EOS
puppet_apply(pp) do |r|
r.exit_code.should_not == 1
r.refresh
r.exit_code.should be_zero
end
shell('grep "programs=program1,program2" /etc/supervisor.d/group_test.conf') do |r|
r.exit_code.should be_zero
end
shell("grep priority=100 /etc/supervisor.d/fcgi-program_test.conf") do |r|
r.exit_code.should be_zero
end
end
end

View File

@ -39,8 +39,8 @@ exitcodes=<%= @exitcodes %>
<% if @stopsignal -%> <% if @stopsignal -%>
stopsignal=<%= @stopsignal %> stopsignal=<%= @stopsignal %>
<% end -%> <% end -%>
<% if @stopwaitsec -%> <% if @stopwaitsecs -%>
stopwaitsec=<%= @stopwaitsec %> stopwaitsecs=<%= @stopwaitsecs %>
<% end -%> <% end -%>
<% if @stopasgroup -%> <% if @stopasgroup -%>
stopasgroup=<%= @stopasgroup %> stopasgroup=<%= @stopasgroup %>
@ -54,7 +54,7 @@ user=<%= @user %>
<% if @redirect_stderr -%> <% if @redirect_stderr -%>
redirect_stderr=<%= @redirect_stderr %> redirect_stderr=<%= @redirect_stderr %>
<% end -%> <% end -%>
stdout_logfile=<%= @stdout_logfile %> stdout_logfile=<%= scope.lookupvar('supervisord::log_path') %>/<%= @stdout_logfile %>
<% if @stdout_logfile_maxbytes -%> <% if @stdout_logfile_maxbytes -%>
stdout_logfile_maxbytes=<%= @stdout_logfile_maxbytes %> stdout_logfile_maxbytes=<%= @stdout_logfile_maxbytes %>
<% end -%> <% end -%>
@ -64,7 +64,7 @@ stdout_logfile_backups=<%= @stdout_logfile_backups %>
<% if @stdout_events_enabled -%> <% if @stdout_events_enabled -%>
stdout_events_enabled=<%= @stdout_events_enabled %> stdout_events_enabled=<%= @stdout_events_enabled %>
<% end -%> <% end -%>
stderr_logfile=<%= @stderr_logfile %> stderr_logfile=<%= scope.lookupvar('supervisord::log_path') %>/<%= @stderr_logfile %>
<% if @stderr_logfile_maxbytes -%> <% if @stderr_logfile_maxbytes -%>
stderr_logfile_maxbytes=<%= @stderr_logfile_maxbytes %> stderr_logfile_maxbytes=<%= @stderr_logfile_maxbytes %>
<% end -%> <% end -%>

View File

@ -37,8 +37,8 @@ exitcodes=<%= @exitcodes %>
<% if @stopsignal -%> <% if @stopsignal -%>
stopsignal=<%= @stopsignal %> stopsignal=<%= @stopsignal %>
<% end -%> <% end -%>
<% if @stopwaitsec -%> <% if @stopwaitsecs -%>
stopwaitsec=<%= @stopwaitsec %> stopwaitsecs=<%= @stopwaitsecs %>
<% end -%> <% end -%>
<% if @stopasgroup -%> <% if @stopasgroup -%>
stopasgroup=<%= @stopasgroup %> stopasgroup=<%= @stopasgroup %>
@ -53,7 +53,7 @@ user=<%= @user %>
redirect_stderr=<%= @redirect_stderr %> redirect_stderr=<%= @redirect_stderr %>
<% end -%> <% end -%>
<% if @stdout_logfile -%> <% if @stdout_logfile -%>
stdout_logfile=<%= @stdout_logfile %> stdout_logfile=<%= scope.lookupvar('supervisord::log_path') %>/<%= @stdout_logfile %>
<% end -%> <% end -%>
<% if @stdout_logfile_maxbytes -%> <% if @stdout_logfile_maxbytes -%>
stdout_logfile_maxbytes=<%= @stdout_logfile_maxbytes %> stdout_logfile_maxbytes=<%= @stdout_logfile_maxbytes %>
@ -68,7 +68,7 @@ stdout_capture_maxbytes=<%= @stdout_capture_maxbytes %>
stdout_events_enabled=<%= @stdout_events_enabled %> stdout_events_enabled=<%= @stdout_events_enabled %>
<% end -%> <% end -%>
<% if @stderr_logfile -%> <% if @stderr_logfile -%>
stderr_logfile=<%= @stderr_logfile %> stderr_logfile=<%= scope.lookupvar('supervisord::log_path') %>/<%= @stderr_logfile %>
<% end -%> <% end -%>
<% if @stderr_logfile_maxbytes -%> <% if @stderr_logfile_maxbytes -%>
stderr_logfile_maxbytes=<%= @stderr_logfile_maxbytes %> stderr_logfile_maxbytes=<%= @stderr_logfile_maxbytes %>

View File

@ -30,8 +30,8 @@ exitcodes=<%= @exitcodes %>
<% if @stopsignal -%> <% if @stopsignal -%>
stopsignal=<%= @stopsignal %> stopsignal=<%= @stopsignal %>
<% end -%> <% end -%>
<% if @stopwaitsec -%> <% if @stopwaitsecs -%>
stopwaitsec=<%= @stopwaitsec %> stopwaitsecs=<%= @stopwaitsecs %>
<% end -%> <% end -%>
<% if @stopasgroup -%> <% if @stopasgroup -%>
stopasgroup=<%= @stopasgroup %> stopasgroup=<%= @stopasgroup %>
@ -46,7 +46,7 @@ user=<%= @user %>
redirect_stderr=<%= @redirect_stderr %> redirect_stderr=<%= @redirect_stderr %>
<% end -%> <% end -%>
<% if @stdout_logfile -%> <% if @stdout_logfile -%>
stdout_logfile=<%= @stdout_logfile %> stdout_logfile=<%= scope.lookupvar('supervisord::log_path') %>/<%= @stdout_logfile %>
<% end -%> <% end -%>
<% if @stdout_logfile_maxbytes -%> <% if @stdout_logfile_maxbytes -%>
stdout_logfile_maxbytes=<%= @stdout_logfile_maxbytes %> stdout_logfile_maxbytes=<%= @stdout_logfile_maxbytes %>
@ -61,7 +61,7 @@ stdout_capture_maxbytes=<%= @stdout_capture_maxbytes %>
stdout_events_enabled=<%= @stdout_events_enabled %> stdout_events_enabled=<%= @stdout_events_enabled %>
<% end -%> <% end -%>
<% if @stderr_logfile -%> <% if @stderr_logfile -%>
stderr_logfile=<%= @stderr_logfile %> stderr_logfile=<%= scope.lookupvar('supervisord::log_path') %>/<%= @stderr_logfile %>
<% end -%> <% end -%>
<% if @stderr_logfile_maxbytes -%> <% if @stderr_logfile_maxbytes -%>
stderr_logfile_maxbytes=<%= @stderr_logfile_maxbytes %> stderr_logfile_maxbytes=<%= @stderr_logfile_maxbytes %>

View File

@ -19,15 +19,15 @@ DESC=supervisor
test -x $DAEMON || exit 0 test -x $DAEMON || exit 0
LOGDIR=<%= @log_path %> LOGDIR=<%= @log_path %>
PIDFILE=<%= @pid_file %> PIDFILE=<%= @run_path %>/<%= @pid_file %>
DODTIME=5 # Time to wait for the server to die, in seconds DODTIME=5 # Time to wait for the server to die, in seconds
# If this value is set too low you might not # If this value is set too low you might not
# let some servers to die gracefully and # let some servers to die gracefully and
# 'restart' will not work # 'restart' will not work
# Include supervisor defaults if available # Include supervisor defaults if available
if [ -f /etc/default/supervisor ] ; then if [ -f <%= @init_defaults %> ] ; then
. /etc/default/supervisor . <%= @init_defaults %>
fi fi
set -e set -e

View File

@ -5,4 +5,4 @@ set -a
# should probably put both of these options as runtime arguments # should probably put both of these options as runtime arguments
OPTIONS="-c <%= @config_file %>" OPTIONS="-c <%= @config_file %>"
PIDFILE=<%= @pid_file %> PIDFILE=<%= @run_path %><%= @pid_file %>

View File

@ -13,18 +13,19 @@
# xmlrpc interface as well as a few other nifty features. # xmlrpc interface as well as a few other nifty features.
# processname: supervisord # processname: supervisord
# config: <%= @config_file %> # config: <%= @config_file %>
# pidfile: <%= @pid_file %> # pidfile: <%= @run_path %>/<%= @pid_file %>
# #
# source function library # source function library
. /etc/rc.d/init.d/functions . /etc/rc.d/init.d/functions
# source system settings # source system settings
[ -e <%= @init_extras %> ] && . <%= @init_extras %> [ -e <%= @init_defaults %> ] && . <%= @init_defaults %>
RETVAL=0 RETVAL=0
DAEMON=/usr/bin/supervisord DAEMON=/usr/bin/supervisord
DESC=supervisord DESC=supervisord
PIDFILE=<%= @run_path %>/<%= @pid_file %>
running_pid() running_pid()
{ {

View File

@ -1,9 +1,9 @@
[supervisord] [supervisord]
logfile=<%= @log_file %> logfile=<%= @log_path %>/<%= @log_file %>
pidfile=<%= @pid_file %> pidfile=<%= @run_path %>/<%= @pid_file %>
nodaemon=<%= @nodaemon %> nodaemon=<%= @nodaemon %>
minfds=<%= @minfds %> minfds=<%= @minfds %>
minfds=<%= @minprocs %> minprocs=<%= @minprocs %>
umask=<%= @umask %> umask=<%= @umask %>
<% if @strip_ansi -%> <% if @strip_ansi -%>
strip_ansi=<%= @strip_ansi %> strip_ansi=<%= @strip_ansi %>
@ -12,7 +12,7 @@ strip_ansi=<%= @strip_ansi %>
user=<%= @user %> user=<%= @user %>
<% end -%> <% end -%>
<% if @identifier -%> <% if @identifier -%>
indentifier=<%= @identifier %> identifier=<%= @identifier %>
<% end -%> <% end -%>
<% if @directory -%> <% if @directory -%>
directory=<%= @directory %> directory=<%= @directory %>
@ -31,4 +31,4 @@ environment=<%= @env_string %>
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[include] [include]
files=<%= @config_include %>/*.conf files=<%= @config_include_string %>

View File

@ -1,5 +1,5 @@
[unix_http_server] [unix_http_server]
file=<%= @unix_socket_file %> file=<%= @run_path %>/<%= @unix_socket_file %>
chmod=<%= @unix_socket_mode %> chmod=<%= @unix_socket_mode %>
chown=<%= @unix_socket_owner %>:<%= @unix_socket_group %> chown=<%= @unix_socket_owner %>:<%= @unix_socket_group %>
<% if @unix_auth -%> <% if @unix_auth -%>
@ -8,7 +8,7 @@ password=<%= @unix_socket_password %>
<% end -%> <% end -%>
[supervisorctl] [supervisorctl]
serverurl=unix://<%= @unix_socket_file %> serverurl=unix://<%= @run_path %>/<%= @unix_socket_file %>
<% if @unix_auth -%> <% if @unix_auth -%>
username=<%= @unix_username %> username=<%= @unix_username %>
password=<%= @unix_password %> password=<%= @unix_password %>

View File

@ -1,9 +1,35 @@
supervisord::program { 'myprogram': supervisord::program { 'myprogram':
command => 'command --args', command => 'command --args',
priority => '100', process_name => '%(process_num)s',
environment => { numprocs => '1',
numprocs_start => '0',
priority => '999',
autostart => true,
autorestart => 'unexpected',
startsecs => '1',
startretries => '3',
exitcodes => '0,2',
stopsignal => 'TERM',
stopwaitsecs => '10',
stopasgroup => false,
killasgroup => false,
redirect_stderr => false,
stdout_logfile => 'program_foo.log',
stdout_logfile_maxbytes => '50MB',
stdout_logfile_backups => '10',
stdout_capture_maxbytes => '0',
stdout_events_enabled => false,
stderr_logfile => 'program_foo.error',
stderr_logfile_maxbytes => '50MB',
stderr_logfile_backups => '10',
stderr_capture_maxbytes => '0',
stderr_events_enabled => false,
environment => {
'HOME' => '/home/myuser', 'HOME' => '/home/myuser',
'PATH' => '/bin:/sbin:/usr/bin:/usr/sbin', 'PATH' => '/bin:/sbin:/usr/bin:/usr/sbin',
'SECRET' => 'mysecret' 'SECRET' => 'mysecret'
} },
directory => undef,
umask => '022',
serverurl => 'AUTO'
} }

View File

@ -4,17 +4,26 @@ export DEBIAN_FRONTEND=noninteractive
VAGRANT_CORE_FOLDER=$(cat '/.puphpet-stuff/vagrant-core-folder.txt') VAGRANT_CORE_FOLDER=$(cat '/.puphpet-stuff/vagrant-core-folder.txt')
shopt -s nullglob EXEC_ONCE_DIR="$1"
files=("${VAGRANT_CORE_FOLDER}"/files/exec-once/*) EXEC_ALWAYS_DIR="$2"
if [[ ! -f '/.puphpet-stuff/exec-once-ran' && (${#files[@]} -gt 0) ]]; then shopt -s nullglob
echo 'Running files in files/exec-once' files=("${VAGRANT_CORE_FOLDER}"/files/"${EXEC_ONCE_DIR}"/*)
find "${VAGRANT_CORE_FOLDER}/files/exec-once" -maxdepth 1 -not -path '*/\.*' -type f \( ! -iname "empty" \) -exec chmod +x '{}' \; -exec {} \;
echo 'Finished running files in files/exec-once' if [[ (${#files[@]} -gt 0) ]]; then
echo 'To run again, delete file /.puphpet-stuff/exec-once-ran' echo "Running files in files/${EXEC_ONCE_DIR}"
touch /.puphpet-stuff/exec-once-ran
if [ ! -d "/.puphpet-stuff/${EXEC_ONCE_DIR}-ran" ]; then
mkdir "/.puphpet-stuff/${EXEC_ONCE_DIR}-ran"
echo "Created directory /.puphpet-stuff/${EXEC_ONCE_DIR}-ran"
fi
find "${VAGRANT_CORE_FOLDER}/files/${EXEC_ONCE_DIR}" -maxdepth 1 -not -path '*/\.*' -type f \( ! -iname "empty" \) -exec cp -n '{}' "/.puphpet-stuff/${EXEC_ONCE_DIR}-ran" \;
find "/.puphpet-stuff/${EXEC_ONCE_DIR}-ran" -maxdepth 1 -type f -exec chmod +x '{}' \; -exec {} \; -exec sh -c '>{}' \;
echo "Finished running files in files/${EXEC_ONCE_DIR}"
echo "To run again, delete file(s) you want rerun in /.puphpet-stuff/${EXEC_ONCE_DIR}-ran or the whole folder to rerun all"
fi fi
echo 'Running files in files/exec-always' echo "Running files in files/${EXEC_ALWAYS_DIR}"
find "${VAGRANT_CORE_FOLDER}/files/exec-always" -maxdepth 1 -not -path '*/\.*' -type f \( ! -iname "empty" \) -exec chmod +x '{}' \; -exec {} \; find "${VAGRANT_CORE_FOLDER}/files/${EXEC_ALWAYS_DIR}" -maxdepth 1 -not -path '*/\.*' -type f \( ! -iname "empty" \) -exec chmod +x '{}' \; -exec {} \;
echo 'Finished running files in files/exec-always' echo "Finished running files in files/${EXEC_ALWAYS_DIR}"

View File

@ -5,37 +5,76 @@ VAGRANT_CORE_FOLDER=$(cat '/.puphpet-stuff/vagrant-core-folder.txt')
OS=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" ID) OS=$(/bin/bash "${VAGRANT_CORE_FOLDER}/shell/os-detect.sh" ID)
VAGRANT_SSH_USERNAME=$(echo "$1") VAGRANT_SSH_USERNAME=$(echo "$1")
if [[ ! -f "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa" ]]; then function create_key()
ssh-keygen -f "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa" -P "" {
BASE_KEY_NAME=$(echo "$1")
if [[ ! -f "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa.ppk" ]]; then if [[ ! -f "${VAGRANT_CORE_FOLDER}/files/dot/ssh/${BASE_KEY_NAME}" ]]; then
if [ "${OS}" == 'debian' ] || [ "${OS}" == 'ubuntu' ]; then ssh-keygen -f "${VAGRANT_CORE_FOLDER}/files/dot/ssh/${BASE_KEY_NAME}" -P ""
apt-get install -y putty-tools >/dev/null
elif [ "${OS}" == 'centos' ]; then if [[ ! -f "${VAGRANT_CORE_FOLDER}/files/dot/ssh/${BASE_KEY_NAME}.ppk" ]]; then
yum -y install putty >/dev/null if [ "${OS}" == 'debian' ] || [ "${OS}" == 'ubuntu' ]; then
apt-get install -y putty-tools >/dev/null
elif [ "${OS}" == 'centos' ]; then
yum -y install putty >/dev/null
fi
puttygen "${VAGRANT_CORE_FOLDER}/files/dot/ssh/${BASE_KEY_NAME}" -O private -o "${VAGRANT_CORE_FOLDER}/files/dot/ssh/${BASE_KEY_NAME}.ppk"
fi fi
puttygen "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa" -O private -o "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa.ppk" echo "Your private key for SSH-based authentication has been saved to 'puphpet/files/dot/ssh/${BASE_KEY_NAME}'!"
else
echo "Pre-existing private key found at 'puphpet/files/dot/ssh/${BASE_KEY_NAME}'"
fi fi
}
echo 'Your private key for SSH-based authentication have been saved to "puphpet/files/dot/ssh/"!' create_key 'root_id_rsa'
else create_key 'id_rsa'
echo 'Using pre-existing private key at "puphpet/files/dot/ssh/id_rsa"'
PUBLIC_SSH_KEY=$(cat "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa.pub")
echo 'Adding generated key to /root/.ssh/id_rsa'
echo 'Adding generated key to /root/.ssh/id_rsa.pub'
echo 'Adding generated key to /root/.ssh/authorized_keys'
mkdir -p /root/.ssh
cp "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa" '/root/.ssh/'
cp "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa.pub" '/root/.ssh/'
if [[ ! -f '/root/.ssh/authorized_keys' ]] || ! grep -q "${PUBLIC_SSH_KEY}" '/root/.ssh/authorized_keys'; then
cat "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa.pub" >> '/root/.ssh/authorized_keys'
fi fi
echo 'Adding generated key to /root/.ssh/authorized_keys' chown -R root '/root/.ssh'
mkdir -p /root/.ssh chgrp -R root '/root/.ssh'
cat "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa.pub" > '/root/.ssh/authorized_keys' chmod 700 '/root/.ssh'
chmod 644 '/root/.ssh/id_rsa.pub'
chmod 600 '/root/.ssh/id_rsa'
chmod 600 '/root/.ssh/authorized_keys' chmod 600 '/root/.ssh/authorized_keys'
if [ "${VAGRANT_SSH_USERNAME}" != 'root' ]; then if [ "${VAGRANT_SSH_USERNAME}" != 'root' ]; then
VAGRANT_SSH_FOLDER="/home/${VAGRANT_SSH_USERNAME}/.ssh"; VAGRANT_SSH_FOLDER="/home/${VAGRANT_SSH_USERNAME}/.ssh";
echo "Adding generated key to ${VAGRANT_SSH_FOLDER}/authorized_keys" mkdir -p "${VAGRANT_SSH_FOLDER}"
cat "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa.pub" > "${VAGRANT_SSH_FOLDER}/authorized_keys"
chown "${VAGRANT_SSH_USERNAME}" "${VAGRANT_SSH_FOLDER}/authorized_keys"
chgrp "${VAGRANT_SSH_USERNAME}" "${VAGRANT_SSH_FOLDER}/authorized_keys"
chmod 600 "${VAGRANT_SSH_FOLDER}/authorized_keys"
fi
passwd -d vagrant >/dev/null echo "Adding generated key to ${VAGRANT_SSH_FOLDER}/id_rsa"
echo "Adding generated key to ${VAGRANT_SSH_FOLDER}/id_rsa.pub"
echo "Adding generated key to ${VAGRANT_SSH_FOLDER}/authorized_keys"
cp "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa" "${VAGRANT_SSH_FOLDER}/id_rsa"
cp "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa.pub" "${VAGRANT_SSH_FOLDER}/id_rsa.pub"
if [[ ! -f "${VAGRANT_SSH_FOLDER}/authorized_keys" ]] || ! grep -q "${PUBLIC_SSH_KEY}" "${VAGRANT_SSH_FOLDER}/authorized_keys"; then
cat "${VAGRANT_CORE_FOLDER}/files/dot/ssh/id_rsa.pub" >> "${VAGRANT_SSH_FOLDER}/authorized_keys"
fi
chown -R "${VAGRANT_SSH_USERNAME}" "${VAGRANT_SSH_FOLDER}"
chgrp -R "${VAGRANT_SSH_USERNAME}" "${VAGRANT_SSH_FOLDER}"
chmod 700 "${VAGRANT_SSH_FOLDER}"
chmod 644 "${VAGRANT_SSH_FOLDER}/id_rsa.pub"
chmod 600 "${VAGRANT_SSH_FOLDER}/id_rsa"
chmod 600 "${VAGRANT_SSH_FOLDER}/authorized_keys"
passwd -d "${VAGRANT_SSH_USERNAME}" >/dev/null
fi

View File

View File

View File

@ -1 +0,0 @@
Url not available

View File

@ -68,11 +68,11 @@ if ($action == 'update' || $action == 'add')
if (! $error) if (! $error)
{ {
$mesg = '<div class="ok">'.$langs->trans("SetupSaved").'</div>'; setEventMessage($langs->trans("SetupSaved"));
} }
else else
{ {
$mesg = '<div class="error">'.$langs->trans("Error").'</div>'; setEventMessage($langs->trans("Error"), 'errors');
} }
} }
@ -117,10 +117,6 @@ $head = member_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("Members"), 0, 'user'); dol_fiche_head($head, 'general', $langs->trans("Members"), 0, 'user');
dol_htmloutput_mesg($mesg);
print_fiche_titre($langs->trans("MemberMainOptions"),'',''); print_fiche_titre($langs->trans("MemberMainOptions"),'','');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -60,11 +60,11 @@ if ($action == 'update')
if (! $error) if (! $error)
{ {
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>"; setEventMessage($langs->trans("SetupSaved"));
} }
else else
{ {
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>"; setEventMessage($langs->trans("Error"), 'errors');
} }
} }
@ -86,8 +86,6 @@ $head = member_admin_prepare_head();
dol_fiche_head($head, 'public', $langs->trans("Members"), 0, 'user'); dol_fiche_head($head, 'public', $langs->trans("Members"), 0, 'user');
dol_htmloutput_mesg($mesg);
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';

View File

@ -1 +0,0 @@
Url not available

View File

@ -1 +0,0 @@
Url not available

View File

View File

@ -1 +0,0 @@
Url not available

View File

@ -52,7 +52,6 @@ $object = new Adherent($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$adht = new AdherentType($db); $adht = new AdherentType($db);
$errmsg=''; $errmsg='';
$errmsgs=array();
$defaultdelay=1; $defaultdelay=1;
$defaultdelayunit='y'; $defaultdelayunit='y';
@ -108,7 +107,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights
{ {
$langs->load("errors"); $langs->load("errors");
$errmsg=$langs->trans($company->error); $errmsg=$langs->trans($company->error);
$errmsgs=$company->errors; setEventMessage($company->errors, 'errors');
} }
else else
{ {
@ -129,7 +128,7 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights
if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id)
{ {
$error++; $error++;
$mesg='<div class="error">'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'</div>'; setEventMessage($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), 'errors');
} }
} }
@ -165,7 +164,7 @@ if ($action == 'setsocid')
$thirdparty=new Societe($db); $thirdparty=new Societe($db);
$thirdparty->fetch(GETPOST('socid','int')); $thirdparty->fetch(GETPOST('socid','int'));
$error++; $error++;
$mesg='<div class="error">'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name).'</div>'; setEventMessage($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), 'errors');
} }
} }
@ -282,7 +281,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $
{ {
$error++; $error++;
$errmsg=$object->error; $errmsg=$object->error;
$errmsgs=$object->errors; setEventMessage($object->errors, 'errors');
} }
if (! $error) if (! $error)
@ -444,7 +443,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $
if (! ($bank_line_id > 0)) if (! ($bank_line_id > 0))
{ {
$errmsg=$paiement->error; $errmsg=$paiement->error;
$errmsgs=$paiement->errors; setEventMessage($paiement->errors, 'errors');
$error++; $error++;
} }
} }
@ -689,7 +688,7 @@ if ($rowid)
dol_fiche_end(); dol_fiche_end();
dol_htmloutput_errors($errmsg,$errmsgs); dol_htmloutput_errors($errmsg);
/* /*

View File

View File

@ -1 +0,0 @@
Url not available

View File

View File

@ -81,8 +81,6 @@ if (! empty($canvas))
// Security check // Security check
$result=restrictedArea($user,'adherent',$rowid,'','','fk_soc', 'rowid', $objcanvas); $result=restrictedArea($user,'adherent',$rowid,'','','fk_soc', 'rowid', $objcanvas);
$errmsg=''; $errmsgs=array();
if ($rowid > 0) if ($rowid > 0)
{ {
// Load member // Load member
@ -128,7 +126,7 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights
if ($userid != $user->id && $userid != $object->user_id) if ($userid != $user->id && $userid != $object->user_id)
{ {
$error++; $error++;
$mesg='<div class="error">'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'</div>'; setEventMessage($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), 'errors');
} }
} }
@ -164,7 +162,7 @@ if ($action == 'setsocid')
$thirdparty=new Societe($db); $thirdparty=new Societe($db);
$thirdparty->fetch($socid); $thirdparty->fetch($socid);
$error++; $error++;
$errmsg='<div class="error">'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name).'</div>'; setEventMessage($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name), 'errors');
} }
} }
@ -190,12 +188,12 @@ if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user
if ($result < 0) if ($result < 0)
{ {
$langs->load("errors"); $langs->load("errors");
$errmsg=$langs->trans($nuser->error); setEventMessage($langs->trans($nuser->error), 'errors');
} }
} }
else else
{ {
$errmsg=$object->error; setEventMessage($object->error, 'errors');
} }
} }
@ -211,13 +209,13 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights
if ($result < 0) if ($result < 0)
{ {
$langs->load("errors"); $langs->load("errors");
$errmsg=$langs->trans($company->error); setEventMessage($langs->trans($company->error), 'errors');
$errmsgs=$company->errors; setEventMessage($company->errors, 'errors');
} }
} }
else else
{ {
$errmsg=$object->error; setEventMessage($object->error, 'errors');
} }
} }
@ -231,7 +229,7 @@ if ($action == 'confirm_sendinfo' && $confirm == 'yes')
$result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent")); $result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent"));
$langs->load("mails"); $langs->load("mails");
$mesg=$langs->trans("MailSuccessfulySent", $from, $object->email); setEventMessage($langs->trans("MailSuccessfulySent", $from, $object->email));
} }
} }
@ -252,12 +250,12 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
if ($morphy != 'mor' && empty($lastname)) { if ($morphy != 'mor' && empty($lastname)) {
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."<br>\n"; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname")), 'errors');
} }
if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) {
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."<br>\n"; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname")), 'errors');
} }
// Create new object // Create new object
@ -343,7 +341,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0) if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0)
{ {
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>'; setEventMessage($langs->trans("ErrorFailedToSaveFile"), 'errors');
} }
else else
{ {
@ -359,7 +357,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
} }
else else
{ {
$errmsgs[] = "ErrorBadImageFormat"; setEventMessage("ErrorBadImageFormat", 'errors');
} }
} }
else else
@ -387,8 +385,11 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
} }
else else
{ {
if ($object->error) $errmsg=$object->error; if ($object->error) {
else $errmsgs=$object->errors; setEventMessage($object->error, 'errors');
} else {
setEventMessage($object->errors, 'errors');
}
$action=''; $action='';
} }
} }
@ -472,14 +473,14 @@ if ($action == 'add' && $user->rights->adherent->creer)
// Check parameters // Check parameters
if (empty($morphy) || $morphy == "-1") { if (empty($morphy) || $morphy == "-1") {
$error++; $error++;
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature"))."<br>\n"; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature")), 'errors');
} }
// Test si le login existe deja // Test si le login existe deja
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{ {
if (empty($login)) { if (empty($login)) {
$error++; $error++;
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->trans("Login"))."<br>\n"; setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Login")), 'errors');
} }
else { else {
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'"; $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'";
@ -490,32 +491,32 @@ if ($action == 'add' && $user->rights->adherent->creer)
if ($num) { if ($num) {
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
$errmsg .= $langs->trans("ErrorLoginAlreadyExists",$login)."<br>\n"; setEventMessage($langs->trans("ErrorLoginAlreadyExists",$login), 'errors');
} }
} }
if (empty($pass)) { if (empty($pass)) {
$error++; $error++;
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Password"))."<br>\n"; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Password")), 'errors');
} }
} }
if ($morphy != 'mor' && empty($lastname)) { if ($morphy != 'mor' && empty($lastname)) {
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."<br>\n"; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname")), 'errors');
} }
if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) { if ($morphy != 'mor' && (!isset($firstname) || $firstname=='')) {
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."<br>\n"; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname")), 'errors');
} }
if (! ($typeid > 0)) { // Keep () before ! if (! ($typeid > 0)) { // Keep () before !
$error++; $error++;
$errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"))."<br>\n"; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors');
} }
if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) { if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) {
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
$errmsg .= $langs->trans("ErrorBadEMail",$email)."<br>\n"; setEventMessage($langs->trans("ErrorBadEMail",$email), 'errors');
} }
$public=0; $public=0;
if (isset($public)) $public=1; if (isset($public)) $public=1;
@ -536,8 +537,11 @@ if ($action == 'add' && $user->rights->adherent->creer)
{ {
$db->rollback(); $db->rollback();
if ($object->error) $errmsg=$object->error; if ($object->error) {
else $errmsgs=$object->errors; setEventMessage($object->error, 'errors');
} else {
setEventMessage($object->errors, 'errors');
}
$action = 'create'; $action = 'create';
} }
@ -589,15 +593,18 @@ if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm ==
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
$errmsg.=$object->error; setEventMessage($object->error, 'errors');
} }
} }
} }
else else
{ {
$error++; $error++;
if ($object->error) $errmsg=$object->error; if ($object->error) {
else $errmsgs=$object->errors; setEventMessage($object->error, 'errors');
} else {
setEventMessage($object->errors, 'errors');
}
} }
if (! $error) if (! $error)
@ -613,6 +620,8 @@ if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm ==
if ($user->rights->adherent->supprimer && $action == 'confirm_resign') if ($user->rights->adherent->supprimer && $action == 'confirm_resign')
{ {
$error = 0;
if ($confirm == 'yes') if ($confirm == 'yes')
{ {
$adht = new AdherentType($db); $adht = new AdherentType($db);
@ -628,17 +637,23 @@ if ($user->rights->adherent->supprimer && $action == 'confirm_resign')
} }
if ($result < 0) if ($result < 0)
{ {
$errmsg.=$object->error; $error++;
setEventMessage($object->error, 'errors');
} }
} }
else else
{ {
if ($object->error) $errmsg=$object->error; $error++;
else $errmsgs=$object->errors;
if ($object->error) {
setEventMessage($object->error, 'errors');
} else {
setEventMessage($object->errors, 'errors');
}
$action=''; $action='';
} }
} }
if (! empty($backtopage) && ! $errmsg) if (! empty($backtopage) && ! $error)
{ {
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
@ -652,7 +667,7 @@ if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $conf
{ {
if (!$mailmanspip->del_to_spip($object)) if (!$mailmanspip->del_to_spip($object))
{ {
$errmsg.= $langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error."<BR>\n"; setEventMessage($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, 'errors');
} }
} }
} }
@ -663,7 +678,7 @@ if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm
{ {
if (!$mailmanspip->add_to_spip($object)) if (!$mailmanspip->add_to_spip($object))
{ {
$errmsg.= $langs->trans('AddIntoSpipError').': '.$mailmanspip->error."<BR>\n"; setEventMessage($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, 'errors');
} }
} }
} }
@ -725,9 +740,6 @@ else
print_fiche_titre($langs->trans("NewMember")); print_fiche_titre($langs->trans("NewMember"));
dol_htmloutput_mesg($errmsg,$errmsgs,'error');
dol_htmloutput_mesg($mesg,$mesgs);
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';
@ -952,9 +964,6 @@ else
dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
dol_htmloutput_errors($errmsg,$errmsgs);
dol_htmloutput_mesg($mesg);
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';
@ -1168,8 +1177,6 @@ else
if ($rowid && $action != 'edit') if ($rowid && $action != 'edit')
{ {
dol_htmloutput_mesg($mesg);
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Mode affichage */ /* Mode affichage */
@ -1199,8 +1206,6 @@ else
dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user'); dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
dol_htmloutput_errors($errmsg,$errmsgs);
// Confirm create user // Confirm create user
if ($action == 'create_user') if ($action == 'create_user')
{ {

View File

@ -282,8 +282,6 @@ if ($rowid && $action != 'edit')
dol_fiche_head($head, 'general', $langs->trans("Subscription"), '', 'payment'); dol_fiche_head($head, 'general', $langs->trans("Subscription"), '', 'payment');
if ($msg) print '<div class="error">'.$msg.'</div>';
// Confirmation to delete subscription // Confirmation to delete subscription
if ($action == 'delete') if ($action == 'delete')
{ {

View File

@ -60,8 +60,6 @@ if (! $result)
if ($action == 'dolibarr2ldap') if ($action == 'dolibarr2ldap')
{ {
$message="";
$db->begin(); $db->begin();
$ldap=new Ldap(); $ldap=new Ldap();
@ -75,12 +73,12 @@ if ($action == 'dolibarr2ldap')
if ($result >= 0) if ($result >= 0)
{ {
$message.='<div class="ok">'.$langs->trans("MemberSynchronized").'</div>'; setEventMessage($langs->trans("MemberSynchronized"));
$db->commit(); $db->commit();
} }
else else
{ {
$message.='<div class="error">'.$ldap->error.'</div>'; setEventMessage($ldap->error, 'errors');
$db->rollback(); $db->rollback();
} }
} }
@ -157,10 +155,6 @@ print '</table>';
print '</div>'; print '</div>';
dol_htmloutput_mesg($message);
/* /*
* Barre d'actions * Barre d'actions
*/ */

View File

@ -95,21 +95,22 @@ $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d";
if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ
$sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t";
$sql.= " WHERE d.fk_adherent_type = t.rowid "; $sql.= " WHERE d.fk_adherent_type = t.rowid ";
if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$catid; if ($catid > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($catid);
if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL"; if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$search_categ; if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ);
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL"; if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
$sql.= " AND d.entity = ".$conf->entity; $sql.= " AND d.entity = ".$conf->entity;
if ($sall) if ($sall)
{ {
// For natural search // For natural search
$scrit = explode(' ', $sall); $scrit = explode(' ', $sall);
foreach ($scrit as $crit) { foreach ($scrit as $crit)
{
$sql.=" AND ("; $sql.=" AND (";
if (is_numeric($sall)) $sql.= "d.rowid = ".$sall." OR "; if (is_numeric($sall)) $sql.= "d.rowid = ".$sall." OR ";
$sql.=" d.firstname LIKE '%".$sall."%' OR d.lastname LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'"; $sql.=" d.firstname LIKE '%".$db->escape($sall)."%' OR d.lastname LIKE '%".$db->escape($sall)."%' OR d.societe LIKE '%".$db->escape($sall)."%'";
$sql.=" OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.address LIKE '%".$sall."%'"; $sql.=" OR d.email LIKE '%".$db->escape($sall)."%' OR d.login LIKE '%".$db->escape($sall)."%' OR d.address LIKE '%".$db->escape($sall)."%'";
$sql.=" OR d.town LIKE '%".$sall."%' OR d.note LIKE '%".$sall."%')"; $sql.=" OR d.town LIKE '%".$db->escape($sall)."%' OR d.note LIKE '%".$db->escape($sall)."%')";
} }
} }
if ($type > 0) if ($type > 0)
@ -118,24 +119,24 @@ if ($type > 0)
} }
if (isset($_GET["statut"]) || isset($_POST["statut"])) if (isset($_GET["statut"]) || isset($_POST["statut"]))
{ {
$sql.=" AND d.statut in (".$statut.")"; // Peut valoir un nombre ou liste de nombre separes par virgules $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
} }
if ($search_ref) if ($search_ref)
{ {
if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$search_ref.")"; if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$db->escape($search_ref).")";
else $sql.=" AND 1 = 2"; // Always wrong else $sql.=" AND 1 = 2"; // Always wrong
} }
if ($search_lastname) if ($search_lastname)
{ {
$sql.= " AND (d.firstname LIKE '%".$search_lastname."%' OR d.lastname LIKE '%".$search_lastname."%')"; $sql.= " AND (d.firstname LIKE '%".$db->escape($search_lastname)."%' OR d.lastname LIKE '%".$db->escape($search_lastname)."%' OR d.societe LIKE '%".$db->escape($search_lastname)."%')";
} }
if ($search_login) if ($search_login)
{ {
$sql.= " AND d.login LIKE '%".$search_login."%'"; $sql.= " AND d.login LIKE '%".$db->escape($search_login)."%'";
} }
if ($search_email) if ($search_email)
{ {
$sql.= " AND (d.email LIKE '%".$search_email."%')"; $sql.= " AND (d.email LIKE '%".$db->escape($search_email)."%')";
} }
if ($filter == 'uptodate') if ($filter == 'uptodate')
{ {

View File

@ -237,8 +237,6 @@ if ($action == 'create')
print_fiche_titre($langs->trans("NewMemberType")); print_fiche_titre($langs->trans("NewMemberType"));
if ($mesg) print '<div class="error">'.$mesg.'</div>';
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -34,7 +34,6 @@ if (! $user->admin) accessforbidden();
$rowid = GETPOST('rowid','int'); $rowid = GETPOST('rowid','int');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$errmesg='';
// Define possible position of boxes // Define possible position of boxes
$pos_name = getStaticMember('InfoBox','listOfPages'); $pos_name = getStaticMember('InfoBox','listOfPages');
@ -80,7 +79,7 @@ if ($action == 'add')
} }
else else
{ {
$errmesg=$db->lasterror(); setEventMessage($db->lasterror(), 'errors');
$error++; $error++;
} }
} }
@ -116,7 +115,7 @@ if ($action == 'add')
$resql = $db->query($sql); $resql = $db->query($sql);
if (! $resql) if (! $resql)
{ {
$errmesg=$db->lasterror(); setEventMessage($db->lasterror(), 'errors');
$error++; $error++;
} }
} }
@ -217,9 +216,6 @@ print_fiche_titre($langs->trans("Boxes"),'','setup');
print $langs->trans("BoxesDesc")." ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n"; print $langs->trans("BoxesDesc")." ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
dol_htmloutput_errors($errmesg);
/* /*
* Recherche des boites actives par defaut pour chaque position possible * Recherche des boites actives par defaut pour chaque position possible
* On stocke les boites actives par defaut dans $boxes[position][id_boite]=1 * On stocke les boites actives par defaut dans $boxes[position][id_boite]=1

View File

@ -300,74 +300,74 @@ if ($action == 'edit' || $action == 'updateedit')
print '<tr class="liste_titre"><th width="35%">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n"; print '<tr class="liste_titre"><th width="35%">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired">'.$langs->trans("CompanyName").'</td><td>'; print '<tr '.$bc[$var].'><td class="fieldrequired"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
print '<input name="nom" size="30" value="'. ($conf->global->MAIN_INFO_SOCIETE_NOM?$conf->global->MAIN_INFO_SOCIETE_NOM:$_POST["nom"]) . '"></td></tr>'."\n"; print '<input name="nom" id="name" size="30" value="'. ($conf->global->MAIN_INFO_SOCIETE_NOM?$conf->global->MAIN_INFO_SOCIETE_NOM:$_POST["nom"]) . '" autofocus="autofocus"></td></tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyAddress").'</td><td>'; print '<tr '.$bc[$var].'><td><label for="address">'.$langs->trans("CompanyAddress").'</label></td><td>';
print '<textarea name="address" cols="80" rows="'.ROWS_3.'">'. ($conf->global->MAIN_INFO_SOCIETE_ADDRESS?$conf->global->MAIN_INFO_SOCIETE_ADDRESS:$_POST["address"]) . '</textarea></td></tr>'."\n"; print '<textarea name="address" id="address" cols="80" rows="'.ROWS_3.'">'. ($conf->global->MAIN_INFO_SOCIETE_ADDRESS?$conf->global->MAIN_INFO_SOCIETE_ADDRESS:$_POST["address"]) . '</textarea></td></tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyZip").'</td><td>'; print '<tr '.$bc[$var].'><td><label for="zipcode">'.$langs->trans("CompanyZip").'</label></td><td>';
print '<input name="zipcode" value="'. ($conf->global->MAIN_INFO_SOCIETE_ZIP?$conf->global->MAIN_INFO_SOCIETE_ZIP:$_POST["zipcode"]) . '" size="10"></td></tr>'."\n"; print '<input name="zipcode" id="zipcode" value="'. ($conf->global->MAIN_INFO_SOCIETE_ZIP?$conf->global->MAIN_INFO_SOCIETE_ZIP:$_POST["zipcode"]) . '" size="10"></td></tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyTown").'</td><td>'; print '<tr '.$bc[$var].'><td><label for="town">'.$langs->trans("CompanyTown").'</label></td><td>';
print '<input name="town" size="30" value="'. ($conf->global->MAIN_INFO_SOCIETE_TOWN?$conf->global->MAIN_INFO_SOCIETE_TOWN:$_POST["town"]) . '"></td></tr>'."\n"; print '<input name="town" id="town" size="30" value="'. ($conf->global->MAIN_INFO_SOCIETE_TOWN?$conf->global->MAIN_INFO_SOCIETE_TOWN:$_POST["town"]) . '"></td></tr>'."\n";
// Country // Country
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired">'.$langs->trans("Country").'</td><td class="maxwidthonsmartphone">'; print '<tr '.$bc[$var].'><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
//if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation //if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation
print $form->select_country($mysoc->country_id,'country_id'); print $form->select_country($mysoc->country_id,'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td></tr>'."\n"; print '</td></tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("State").'</td><td class="maxwidthonsmartphone">'; print '<tr '.$bc[$var].'><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
$formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_STATE,$mysoc->country_code,'state_id'); $formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_STATE,$mysoc->country_code,'state_id');
print '</td></tr>'."\n"; print '</td></tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCurrency").'</td><td>'; print '<tr '.$bc[$var].'><td><label for="currency">'.$langs->trans("CompanyCurrency").'</label></td><td>';
print $form->selectCurrency($conf->currency,"currency"); print $form->selectCurrency($conf->currency,"currency");
print '</td></tr>'."\n"; print '</td></tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("Phone").'</td><td>'; print '<tr '.$bc[$var].'><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
print '<input name="tel" value="'. $conf->global->MAIN_INFO_SOCIETE_TEL . '"></td></tr>'; print '<input name="tel" id="phone" value="'. $conf->global->MAIN_INFO_SOCIETE_TEL . '"></td></tr>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("Fax").'</td><td>'; print '<tr '.$bc[$var].'><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
print '<input name="fax" value="'. $conf->global->MAIN_INFO_SOCIETE_FAX . '"></td></tr>'; print '<input name="fax" id="fax" value="'. $conf->global->MAIN_INFO_SOCIETE_FAX . '"></td></tr>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("EMail").'</td><td>'; print '<tr '.$bc[$var].'><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
print '<input name="mail" size="60" value="'. $conf->global->MAIN_INFO_SOCIETE_MAIL . '"></td></tr>'; print '<input name="mail" id="email" size="60" value="'. $conf->global->MAIN_INFO_SOCIETE_MAIL . '"></td></tr>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
// Web // Web
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("Web").'</td><td>'; print '<tr '.$bc[$var].'><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
print '<input name="web" size="60" value="'. $conf->global->MAIN_INFO_SOCIETE_WEB . '"></td></tr>'; print '<input name="web" id="web" size="60" value="'. $conf->global->MAIN_INFO_SOCIETE_WEB . '"></td></tr>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
// Barcode // Barcode
if (! empty($conf->barcode->enabled)) if (! empty($conf->barcode->enabled))
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("Gencod").'</td><td>'; print '<tr '.$bc[$var].'><td><label for="barcode">'.$langs->trans("Gencod").'</label></td><td>';
print '<input name="barcode" size="40" value="'. $conf->global->MAIN_INFO_SOCIETE_GENCOD . '"></td></tr>'; print '<input name="barcode" id="barcode" size="40" value="'. $conf->global->MAIN_INFO_SOCIETE_GENCOD . '"></td></tr>';
print '</td></tr>'; print '</td></tr>';
} }
// Logo // Logo
$var=!$var; $var=!$var;
print '<tr'.dol_bc($var,'hideonsmartphone').'><td>'.$langs->trans("Logo").' (png,jpg)</td><td>'; print '<tr'.dol_bc($var,'hideonsmartphone').'><td><label for="logo">'.$langs->trans("Logo").' (png,jpg)</label></td><td>';
print '<table width="100%" class="nocellnopadd"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">'; print '<table width="100%" class="nocellnopadd"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
print '<input type="file" class="flat" name="logo" size="50">'; print '<input type="file" class="flat" name="logo" id="logo" size="50">';
print '</td><td valign="middle" align="right">'; print '</td><td valign="middle" align="right">';
if (! empty($mysoc->logo_mini)) if (! empty($mysoc->logo_mini))
{ {
@ -387,8 +387,8 @@ if ($action == 'edit' || $action == 'updateedit')
// Note // Note
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td valign="top">'.$langs->trans("Note").'</td><td>'; print '<tr '.$bc[$var].'><td valign="top"><label for="note">'.$langs->trans("Note").'</label></td><td>';
print '<textarea class="flat" name="note" cols="80" rows="'.ROWS_5.'">'.(! empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? $conf->global->MAIN_INFO_SOCIETE_NOTE : '').'</textarea></td></tr>'; print '<textarea class="flat" name="note" id="note" cols="80" rows="'.ROWS_5.'">'.(! empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? $conf->global->MAIN_INFO_SOCIETE_NOTE : '').'</textarea></td></tr>';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -404,17 +404,17 @@ if ($action == 'edit' || $action == 'updateedit')
// Managing Director(s) // Managing Director(s)
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ManagingDirectors").'</td><td>'; print '<tr '.$bc[$var].'><td width="35%"><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
print '<input name="MAIN_INFO_SOCIETE_MANAGERS" size="80" value="' . $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '"></td></tr>'; print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" size="80" value="' . $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '"></td></tr>';
// Capital // Capital
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Capital").'</td><td>'; print '<tr '.$bc[$var].'><td width="35%"><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
print '<input name="capital" size="20" value="' . $conf->global->MAIN_INFO_CAPITAL . '"></td></tr>'; print '<input name="capital" id="capital" size="20" value="' . $conf->global->MAIN_INFO_CAPITAL . '"></td></tr>';
// Forme juridique // Forme juridique
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("JuridicalStatus").'</td><td>'; print '<tr '.$bc[$var].'><td><label for="legal_form">'.$langs->trans("JuridicalStatus").'</label></td><td>';
if ($mysoc->country_code) if ($mysoc->country_code)
{ {
print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$mysoc->country_code); print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$mysoc->country_code);
@ -429,10 +429,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId1",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId1",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId1",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td width="35%"><label for="profid1">'.$langs->transcountry("ProfId1",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="siren" size="20" value="' . (! empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '') . '">'; print '<input name="siren" id="profid1" size="20" value="' . (! empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '') . '">';
} }
else else
{ {
@ -445,10 +445,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId2",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId2",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId2",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td width="35%"><label for="profid2">'.$langs->transcountry("ProfId2",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="siret" size="20" value="' . (! empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '' ) . '">'; print '<input name="siret" id="profid2" size="20" value="' . (! empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '' ) . '">';
} }
else else
{ {
@ -461,10 +461,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId3",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId3",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId3",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td width="35%"><label for="profid3">'.$langs->transcountry("ProfId3",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="ape" size="20" value="' . (! empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '') . '">'; print '<input name="ape" id="profid3" size="20" value="' . (! empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '') . '">';
} }
else else
{ {
@ -477,10 +477,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId4",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId4",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId4",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td width="35%"><label for="profid4">'.$langs->transcountry("ProfId4",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="rcs" size="20" value="' . (! empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '') . '">'; print '<input name="rcs" id="profid4" size="20" value="' . (! empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '') . '">';
} }
else else
{ {
@ -493,10 +493,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId5",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId5",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId5",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td width="35%"><label for="profid5">'.$langs->transcountry("ProfId5",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="MAIN_INFO_PROFID5" size="20" value="' . (! empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '') . '">'; print '<input name="MAIN_INFO_PROFID5" id="profid5" size="20" value="' . (! empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '') . '">';
} }
else else
{ {
@ -509,10 +509,10 @@ if ($action == 'edit' || $action == 'updateedit')
if ($langs->transcountry("ProfId6",$mysoc->country_code) != '-') if ($langs->transcountry("ProfId6",$mysoc->country_code) != '-')
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId6",$mysoc->country_code).'</td><td>'; print '<tr '.$bc[$var].'><td width="35%"><label for="profid6">'.$langs->transcountry("ProfId6",$mysoc->country_code).'</label></td><td>';
if (! empty($mysoc->country_code)) if (! empty($mysoc->country_code))
{ {
print '<input name="MAIN_INFO_PROFID6" size="20" value="' . (! empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '') . '">'; print '<input name="MAIN_INFO_PROFID6" id="profid6" size="20" value="' . (! empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '') . '">';
} }
else else
{ {
@ -523,8 +523,8 @@ if ($action == 'edit' || $action == 'updateedit')
// TVA Intra // TVA Intra
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("VATIntra").'</td><td>'; print '<tr '.$bc[$var].'><td width="35%"><label for="intra_vat">'.$langs->trans("VATIntra").'</label></td><td>';
print '<input name="tva" size="20" value="' . (! empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '') . '">'; print '<input name="tva" id="intra_vat" size="20" value="' . (! empty($conf->global->MAIN_INFO_TVAINTRA) ? $conf->global->MAIN_INFO_TVAINTRA : '') . '">';
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -539,7 +539,7 @@ if ($action == 'edit' || $action == 'updateedit')
$var=true; $var=true;
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FiscalMonthStart").'</td><td>'; print '<tr '.$bc[$var].'><td width="35%"><label for="fiscalmonthstart">'.$langs->trans("FiscalMonthStart").'</label></td><td>';
print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . '</td></tr>'; print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . '</td></tr>';
print "</table>"; print "</table>";
@ -555,19 +555,19 @@ if ($action == 'edit' || $action == 'updateedit')
$var=true; $var=true;
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" value=\"1\"".(empty($conf->global->FACTURE_TVAOPTION)?"":" checked")."> ".$langs->trans("VATIsUsed")."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"use_vat\" value=\"1\"".(empty($conf->global->FACTURE_TVAOPTION)?"":" checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->trans("VATIsUsedDesc")."</td></tr>"; print "<tr><td><label for=\"use_vat\">".$langs->trans("VATIsUsedDesc")."</label></td></tr>";
print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i></td></tr>\n"; print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i></td></tr>\n";
print "</table>"; print "</table>";
print "</td></tr>\n"; print "</td></tr>\n";
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" value=\"0\"".(empty($conf->global->FACTURE_TVAOPTION)?" checked":"")."> ".$langs->trans("VATIsNotUsed")."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" id=\"no_vat\" value=\"0\"".(empty($conf->global->FACTURE_TVAOPTION)?" checked":"")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->trans("VATIsNotUsedDesc")."</td></tr>"; print "<tr><td><label for=\"no_vat\">".$langs->trans("VATIsNotUsedDesc")."</label></td></tr>";
print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i></td></tr>\n"; print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i></td></tr>\n";
print "</table>"; print "</table>";
print "</td></tr>\n"; print "</td></tr>\n";
@ -589,20 +589,20 @@ if ($action == 'edit' || $action == 'updateedit')
$var=true; $var=true;
$var=!$var; $var=!$var;
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax1\" value=\"localtax1on\"".(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code)."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax1\" id=\"lt1\" value=\"localtax1on\"".(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->transcountry("LocalTax1IsUsedDesc",$mysoc->country_code)."</td></tr>"; print "<tr><td><label for=\"lt1\">".$langs->transcountry("LocalTax1IsUsedDesc",$mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code); $example=$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code);
print ($example!="LocalTax1IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":""); print ($example!="LocalTax1IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
if(! isOnlyOneLocalTax(1)) if(! isOnlyOneLocalTax(1))
{ {
print '<tr><td align="left">'.$langs->trans("LTRate").': '; print '<tr><td align="left"><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
$formcompany->select_localtax(1,$conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1"); $formcompany->select_localtax(1,$conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
} }
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="left">'.$langs->trans("CalcLocaltax").': '; print '<tr><td align="left"></label for="clt1">'.$langs->trans("CalcLocaltax").'</label>: ';
$opcions=array($langs->transcountry("CalcLocaltax1",$mysoc->country_code),$langs->transcountry("CalcLocaltax2",$mysoc->country_code),$langs->transcountry("CalcLocaltax3",$mysoc->country_code)); $opcions=array($langs->transcountry("CalcLocaltax1",$mysoc->country_code),$langs->transcountry("CalcLocaltax2",$mysoc->country_code),$langs->transcountry("CalcLocaltax3",$mysoc->country_code));
print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1); print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1);
print '</td></tr>'; print '</td></tr>';
@ -610,10 +610,10 @@ if ($action == 'edit' || $action == 'updateedit')
print "</td></tr>\n"; print "</td></tr>\n";
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax1\" value=\"localtax1off\"".($conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off"?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$mysoc->country_code)."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax1\" id=\"nolt1\" value=\"localtax1off\"".($conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off"?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->transcountry("LocalTax1IsNotUsedDesc",$mysoc->country_code)."</td></tr>"; print "<tr><td><label for=\"nolt1\">".$langs->transcountry("LocalTax1IsNotUsedDesc",$mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code); $example=$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code);
print ($example!="LocalTax1IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code)."</i></td></tr>\n":""); print ($example!="LocalTax1IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
print "</table>"; print "</table>";
@ -633,19 +633,19 @@ if ($action == 'edit' || $action == 'updateedit')
$var=!$var; $var=!$var;
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax2\" value=\"localtax2on\"".(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code)."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"lt2\" value=\"localtax2on\"".(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->transcountry("LocalTax2IsUsedDesc",$mysoc->country_code)."</td></tr>"; print "<tr><td><label for=\"lt2\">".$langs->transcountry("LocalTax2IsUsedDesc",$mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code); $example=$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code);
print ($example!="LocalTax2IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":""); print ($example!="LocalTax2IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
print '<tr><td align="left">'.$langs->transcountry("LTRate").': '; print '<tr><td align="left"><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
if(! isOnlyOneLocalTax(2)) if(! isOnlyOneLocalTax(2))
{ {
$formcompany->select_localtax(2,$conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); $formcompany->select_localtax(2,$conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
print '</td></tr>'; print '</td></tr>';
} }
print '<tr><td align="left">'.$langs->trans("CalcLocaltax").': '; print '<tr><td align="left"><label for="clt2">'.$langs->trans("CalcLocaltax").'</label>: ';
$opcions=array($langs->transcountry("CalcLocaltax1",$mysoc->country_code),$langs->transcountry("CalcLocaltax2",$mysoc->country_code),$langs->transcountry("CalcLocaltax3",$mysoc->country_code)); $opcions=array($langs->transcountry("CalcLocaltax1",$mysoc->country_code),$langs->transcountry("CalcLocaltax2",$mysoc->country_code),$langs->transcountry("CalcLocaltax3",$mysoc->country_code));
print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2); print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2);
print '</td></tr>'; print '</td></tr>';
@ -653,10 +653,10 @@ if ($action == 'edit' || $action == 'updateedit')
print "</td></tr>\n"; print "</td></tr>\n";
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax2\" value=\"localtax2off\"".($conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off"?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$mysoc->country_code)."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><input type=\"radio\" name=\"optionlocaltax2\" id=\"nolt2\" value=\"localtax2off\"".($conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off"?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->transcountry("LocalTax2IsNotUsedDesc",$mysoc->country_code)."</td></tr>"; print "<tr><td><label for=\"nolt2\">".$langs->transcountry("LocalTax2IsNotUsedDesc",$mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code); $example=$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code);
print ($example!="LocalTax2IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code)."</i></td></tr>\n":""); print ($example!="LocalTax2IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
print "</table>"; print "</table>";
@ -959,19 +959,19 @@ else
$var=true; $var=true;
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optiontva\" disabled value=\"1\"".(empty($conf->global->FACTURE_TVAOPTION)?"":" checked")."> ".$langs->trans("VATIsUsed")."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><input ".$bc[$var]." type=\"radio\" name=\"optiontva\" id=\"use_vat\" disabled value=\"1\"".(empty($conf->global->FACTURE_TVAOPTION)?"":" checked")."> ".$langs->trans("VATIsUsed")."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->trans("VATIsUsedDesc")."</td></tr>"; print "<tr><td><label for=\"use_vat\">".$langs->trans("VATIsUsedDesc")."</label></td></tr>";
print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i></td></tr>\n"; print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i></td></tr>\n";
print "</table>"; print "</table>";
print "</td></tr>\n"; print "</td></tr>\n";
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optiontva\" disabled value=\"0\"".(empty($conf->global->FACTURE_TVAOPTION)?" checked":"")."> ".$langs->trans("VATIsNotUsed")."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><input ".$bc[$var]." type=\"radio\" name=\"optiontva\" id=\"no_vat\" disabled value=\"0\"".(empty($conf->global->FACTURE_TVAOPTION)?" checked":"")."> ".$langs->trans("VATIsNotUsed")."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->trans("VATIsNotUsedDesc")."</td></tr>"; print "<tr><td><label=\"no_vat\">".$langs->trans("VATIsNotUsedDesc")."</label></td></tr>";
print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i></td></tr>\n"; print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i></td></tr>\n";
print "</table>"; print "</table>";
print "</td></tr>\n"; print "</td></tr>\n";
@ -994,10 +994,10 @@ else
$var=true; $var=true;
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax1\" disabled value=\"localtax1on\"".(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code)."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax1\" id=\"lt1\" disabled value=\"localtax1on\"".(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->transcountry("LocalTax1IsUsedDesc",$mysoc->country_code)."</td></tr>"; print "<tr><td></label for=\"lt1\">".$langs->transcountry("LocalTax1IsUsedDesc",$mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code); $example=$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code);
print ($example!="LocalTax1IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":""); print ($example!="LocalTax1IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
if($conf->global->MAIN_INFO_VALUE_LOCALTAX1!=0) if($conf->global->MAIN_INFO_VALUE_LOCALTAX1!=0)
@ -1022,10 +1022,10 @@ else
print "</td></tr>\n"; print "</td></tr>\n";
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax1\" disabled value=\"localtax1off\"".($conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off"?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$mysoc->country_code)."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax1\" id=\"nolt1\" disabled value=\"localtax1off\"".($conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off"?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->transcountry("LocalTax1IsNotUsedDesc",$mysoc->country_code)."</td></tr>"; print "<tr><td><label for=\"no_lt1\">".$langs->transcountry("LocalTax1IsNotUsedDesc",$mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code); $example=$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code);
print ($example!="LocalTax1IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code)."</i></td></tr>\n":""); print ($example!="LocalTax1IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
print "</table>"; print "</table>";
@ -1045,10 +1045,10 @@ else
$var=true; $var=true;
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax2\" disabled value=\"localtax2on\"".(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code)."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax2\" id=\"lt2\" disabled value=\"localtax2on\"".(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->transcountry("LocalTax2IsUsedDesc",$mysoc->country_code)."</td></tr>"; print "<tr><td><label for=\"lt2\">".$langs->transcountry("LocalTax2IsUsedDesc",$mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code); $example=$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code);
print ($example!="LocalTax2IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":""); print ($example!="LocalTax2IsUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
if($conf->global->MAIN_INFO_VALUE_LOCALTAX2!=0) if($conf->global->MAIN_INFO_VALUE_LOCALTAX2!=0)
@ -1074,10 +1074,10 @@ else
print "</td></tr>\n"; print "</td></tr>\n";
$var=!$var; $var=!$var;
print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax2\" disabled value=\"localtax2off\"".($conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off"?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$mysoc->country_code)."</label></td>"; print "<tr ".$bc[$var]."><td width=\"140\"><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax2\" id=\"nolt2\" disabled value=\"localtax2off\"".($conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off"?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print "<table>"; print "<table>";
print "<tr><td>".$langs->transcountry("LocalTax2IsNotUsedDesc",$mysoc->country_code)."</td></tr>"; print "<tr><td><label for=\"nolt2\">".$langs->transcountry("LocalTax2IsNotUsedDesc",$mysoc->country_code)."</label></td></tr>";
$example=$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code); $example=$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code);
print ($example!="LocalTax2IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code)."</i></td></tr>\n":""); print ($example!="LocalTax2IsNotUsedExample"?"<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code)."</i></td></tr>\n":"");
print "</table>"; print "</table>";

View File

@ -105,7 +105,6 @@ if ($action == 'add' || GETPOST("modify"))
if ($result1 && $result2) if ($result1 && $result2)
{ {
$db->commit(); $db->commit();
//$mesg='<div class="ok">'.$langs->trans("Success").'</div>';
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
@ -171,7 +170,6 @@ if ($_POST["delete"])
if ($result1 && $result2) if ($result1 && $result2)
{ {
$db->commit(); $db->commit();
//$mesg='<div class="ok">'.$langs->trans("Success").'</div>';
header("Location: external_rss.php"); header("Location: external_rss.php");
exit; exit;
} }

View File

@ -120,7 +120,10 @@ $var=true;
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax))
{ {
dol_htmloutput_errors('',array($langs->trans("NotAvailable"),$langs->trans("JavascriptDisabled")),1); setEventMessage(array(
$langs->trans("NotAvailable"),
$langs->trans("JavascriptDisabled")
), 'errors');
} }
else else
{ {

View File

@ -43,7 +43,6 @@ static $tmpstatut2label=array(
$statut2label=array(''); $statut2label=array('');
foreach ($tmpstatut2label as $key => $val) $statut2label[$key]=$langs->trans($val); foreach ($tmpstatut2label as $key => $val) $statut2label[$key]=$langs->trans($val);
$mesg='';
$errors=array(); $errors=array();
$object = new Fiscalyear($db); $object = new Fiscalyear($db);
@ -64,8 +63,6 @@ $title = $langs->trans('FiscalYears');
print_fiche_titre($langs->trans('FiscalYears')); print_fiche_titre($langs->trans('FiscalYears'));
dol_htmloutput_errors($mesg);
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity"; $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
$sql.= " WHERE f.entity = ".$conf->entity; $sql.= " WHERE f.entity = ".$conf->entity;

View File

@ -46,8 +46,6 @@ static $tmpstatut2label=array(
$statut2label=array(''); $statut2label=array('');
foreach ($tmpstatut2label as $key => $val) $statut2label[$key]=$langs->trans($val); foreach ($tmpstatut2label as $key => $val) $statut2label[$key]=$langs->trans($val);
$mesg = '';
$object = new Fiscalyear($db); $object = new Fiscalyear($db);
$date_start=dol_mktime(0,0,0,GETPOST('fiscalyearmonth','int'),GETPOST('fiscalyearday','int'),GETPOST('fiscalyearyear','int')); $date_start=dol_mktime(0,0,0,GETPOST('fiscalyearmonth','int'),GETPOST('fiscalyearday','int'),GETPOST('fiscalyearyear','int'));
@ -67,7 +65,7 @@ if ($action == 'confirm_delete' && $confirm == "yes")
} }
else else
{ {
$mesg=$object->error; setEventMessage($object->error, 'errors');
} }
} }
@ -87,12 +85,12 @@ else if ($action == 'add')
if (empty($object->date_start) && empty($object->date_end)) if (empty($object->date_start) && empty($object->date_end))
{ {
$mesg.=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors');
$error++; $error++;
} }
if (empty($object->label)) if (empty($object->label))
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Label")).'</div>'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Label")), 'errors');
$error++; $error++;
} }
@ -107,7 +105,7 @@ else if ($action == 'add')
} }
else else
{ {
$mesg=$object->error; setEventMessage($object->error, 'errors');
$action='create'; $action='create';
} }
} }
@ -144,7 +142,7 @@ else if ($action == 'update')
} }
else else
{ {
$mesg=$object->error; setEventMessage($object->error, 'errors');
} }
} }
else else
@ -169,8 +167,6 @@ if ($action == 'create')
{ {
print_fiche_titre($langs->trans("NewFiscalYear")); print_fiche_titre($langs->trans("NewFiscalYear"));
dol_htmloutput_errors($mesg);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
@ -209,8 +205,6 @@ else if ($id)
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0) if ($result > 0)
{ {
dol_htmloutput_mesg($mesg);
$head = fiscalyear_prepare_head($object); $head = fiscalyear_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron'); dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron');

View File

@ -427,7 +427,7 @@ if (function_exists("ldap_connect"))
} }
else else
{ {
$mesg='<div class="error">'.$ldap->error.'</div>'; setEventMessage($ldap->error, 'errors');
} }
print "<br>\n"; print "<br>\n";

View File

@ -43,7 +43,7 @@ if ($action == 'update')
|| $_POST["MAIN_MAX_DECIMALS_SHOWN"] > $MAXDEC) || $_POST["MAIN_MAX_DECIMALS_SHOWN"] > $MAXDEC)
{ {
$error++; $error++;
$mesg='<div class="error">'.$langs->trans("ErrorDecimalLargerThanAreForbidden",$MAXDEC).'</div>'; setEventMessage($langs->trans("ErrorDecimalLargerThanAreForbidden",$MAXDEC), 'errors');
} }
if ($_POST["MAIN_MAX_DECIMALS_UNIT"] < 0 if ($_POST["MAIN_MAX_DECIMALS_UNIT"] < 0
@ -52,7 +52,7 @@ if ($action == 'update')
{ {
$langs->load("errors"); $langs->load("errors");
$error++; $error++;
$mesg='<div class="error">'.$langs->trans("ErrorNegativeValueNotAllowed").'</div>'; setEventMessage($langs->trans("ErrorNegativeValueNotAllowed"), 'errors');
} }
if ($_POST["MAIN_ROUNDING_RULE_TOT"]) if ($_POST["MAIN_ROUNDING_RULE_TOT"])
@ -61,7 +61,7 @@ if ($action == 'update')
{ {
$langs->load("errors"); $langs->load("errors");
$error++; $error++;
$mesg='<div class="error">'.$langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT").'</div>'; setEventMessage($langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT"), 'errors');
} }
} }
@ -94,8 +94,6 @@ print_fiche_titre($langs->trans("LimitsSetup"),'','setup');
print $langs->trans("LimitsDesc")."<br>\n"; print $langs->trans("LimitsDesc")."<br>\n";
print "<br>\n"; print "<br>\n";
if ($mesg) print $mesg.'<br>';
if ($action == 'edit') if ($action == 'edit')
{ {
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';

View File

@ -653,9 +653,13 @@ else
if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort",$server,$port).'</div>'; if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort",$server,$port).'</div>';
else else
{ {
print '<div class="error">'.$langs->trans("ServerNotAvailableOnIPOrPort",$server,$port); $errormsg = $langs->trans("ServerNotAvailableOnIPOrPort",$server,$port);
if ($mail->error) print ' - '.$mail->error;
print '</div>'; if ($mail->error) {
$errormsg .= ' - '.$mail->error;
}
setEventMessage($errormsg, 'errors');
} }
print '<br>'; print '<br>';
} }

View File

@ -49,8 +49,6 @@ foreach($dirmenus as $dirmenu)
} }
$error=0; $error=0;
$errmsgs=array();
// Cette page peut etre longue. On augmente le delai autorise. // Cette page peut etre longue. On augmente le delai autorise.
// Ne fonctionne que si on est pas en safe_mode. // Ne fonctionne que si on est pas en safe_mode.
@ -105,7 +103,8 @@ if ($action == 'update' && empty($_POST["cancel"]))
else else
{ {
$error++; $error++;
$errmsgs[]='Failed to initialize menu '.$key.'.'; //TODO: Translate
setEventMessage('Failed to initialize menu '.$key.'.', 'errors');
$db->rollback(); $db->rollback();
} }
} }
@ -268,10 +267,6 @@ else
print '</div>'; print '</div>';
dol_htmloutput_errors('',$errmsgs);
if ($action != 'edit') if ($action != 'edit')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';

View File

@ -39,7 +39,6 @@ $dirsmartphone = "/core/menus/smartphone";
$dirmenu = array($dirstandard,$dirsmartphone); $dirmenu = array($dirstandard,$dirsmartphone);
$action=GETPOST('action'); $action=GETPOST('action');
$mesg=GETPOST('mesg');
$menu_handler_top=$conf->global->MAIN_MENU_STANDARD; $menu_handler_top=$conf->global->MAIN_MENU_STANDARD;
$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE; $menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE;
@ -79,16 +78,16 @@ if ($action == 'update')
$result=$menu->update($user); $result=$menu->update($user);
if ($result > 0) if ($result > 0)
{ {
$mesg='<div class="ok">'.$langs->trans("RecordModifiedSuccessfully").'</div>'; setEventMessage($langs->trans("RecordModifiedSuccessfully"));
} }
else else
{ {
$mesg='<div class="error">'.$menu->error.'</div>'; setEventMessage($menu->error, 'errors');
} }
} }
else else
{ {
$mesg='<div class="error">'.$menu->error.'</div>'; setEventMessage($menu->error, 'errors');
} }
$_GET["menuId"] = $_POST['menuId']; $_GET["menuId"] = $_POST['menuId'];
$action = "edit"; $action = "edit";
@ -136,37 +135,37 @@ if ($action == 'add')
$error=0; $error=0;
if (! $error && ! $_POST['menu_handler']) if (! $error && ! $_POST['menu_handler'])
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("MenuHandler")).'</div>'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("MenuHandler")), 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (! $error && ! $_POST['type']) if (! $error && ! $_POST['type'])
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Type")).'</div>'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Type")), 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (! $error && ! $_POST['url']) if (! $error && ! $_POST['url'])
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Url")).'</div>'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Url")), 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (! $error && ! $_POST['titre']) if (! $error && ! $_POST['titre'])
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Title")).'</div>'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Title")), 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (! $error && $_POST['menuId'] && $_POST['type'] == 'top') if (! $error && $_POST['menuId'] && $_POST['type'] == 'top')
{ {
$mesg='<div class="error">'.$langs->trans("ErrorTopMenuMustHaveAParentWithId0").'</div>'; setEventMessage($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (! $error && empty($_POST['menuId']) && $_POST['type'] == 'left') if (! $error && empty($_POST['menuId']) && $_POST['type'] == 'left')
{ {
$mesg='<div class="error">'.$langs->trans("ErrorLeftMenuMustHaveAParentId").'</div>'; setEventMessage($langs->trans("ErrorLeftMenuMustHaveAParentId"), 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
@ -205,7 +204,7 @@ if ($action == 'add')
else else
{ {
$action = 'create'; $action = 'create';
$mesg='<div class="error">'.$menu->error.'</div>'; setEventMessage($menu->error, 'errors');
} }
} }
} }
@ -223,7 +222,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
$this->db->commit(); $this->db->commit();
llxHeader(); llxHeader();
print '<div class="ok">'.$langs->trans("MenuDeleted").'</div>'; setEventMessage($langs->trans("MenuDeleted"));
llxFooter(); llxFooter();
exit ; exit ;
} }
@ -375,8 +374,6 @@ if ($action == 'create')
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
print '</form>'; print '</form>';
dol_htmloutput_mesg($mesg);
} }
elseif ($action == 'edit') elseif ($action == 'edit')
{ {
@ -463,8 +460,6 @@ elseif ($action == 'edit')
print '</form>'; print '</form>';
print '<br>'; print '<br>';
dol_htmloutput_mesg($mesg);
} }

View File

@ -43,7 +43,6 @@ foreach($dirmenus as $dirmenu)
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha'); $confirm=GETPOST('confirm','alpha');
$mesg=GETPOST('mesg');
$menu_handler_top=$conf->global->MAIN_MENU_STANDARD; $menu_handler_top=$conf->global->MAIN_MENU_STANDARD;
$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE; $menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE;
@ -187,7 +186,9 @@ elseif ($action == 'confirm_delete' && $confirm == 'yes')
{ {
$db->commit(); $db->commit();
header("Location: ".DOL_URL_ROOT.'/admin/menus/index.php?menu_handler='.$menu_handler.'&mesg='.urlencode($langs->trans("MenuDeleted"))); setEventMessage($langs->trans("MenuDeleted"));
header("Location: ".DOL_URL_ROOT.'/admin/menus/index.php?menu_handler='.$menu_handler);
exit ; exit ;
} }
else else
@ -216,9 +217,6 @@ llxHeader('',$langs->trans("Menus"),'','',0,0,$arrayofjs,$arrayofcss);
print_fiche_titre($langs->trans("Menus"),'','setup'); print_fiche_titre($langs->trans("Menus"),'','setup');
dol_htmloutput_mesg($mesg);
$h = 0; $h = 0;
$head[$h][0] = DOL_URL_ROOT."/admin/menus.php"; $head[$h][0] = DOL_URL_ROOT."/admin/menus.php";
@ -360,7 +358,7 @@ if ($conf->use_javascript_ajax)
else else
{ {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans("ErrorFeatureNeedJavascript").'</div>'; setEventMessage($langs->trans("ErrorFeatureNeedJavascript"), 'errors');
} }
print '<br>'; print '<br>';

View File

@ -95,11 +95,10 @@ if ($db->type == 'pgsql')
{ {
// Check option standard_conforming_strings is on // Check option standard_conforming_strings is on
$paramarray=$db->getServerParametersValues('standard_conforming_strings'); $paramarray=$db->getServerParametersValues('standard_conforming_strings');
if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1) // if ($paramarray['standard_conforming_strings'] != 'on' && $paramarray['standard_conforming_strings'] != 1)
{ // {
$langs->load("errors"); // $langs->load("errors");
//print '<div class="error">'.$langs->trans("ErrorDatabaseParameterWrong",'standard_conforming_strings','on').'</div>'; // }
}
} }
print '<br>'; print '<br>';

View File

@ -30,7 +30,9 @@ $langs->load("other");
if (! $user->admin) accessforbidden(); if (! $user->admin) accessforbidden();
if (GETPOST('msg','alpha')) $message='<div class="error">'.GETPOST('msg','alpha').'</div>'; if (GETPOST('msg','alpha')) {
setEventMessage(GETPOST('msg','alpha'), 'errors');
}
$urldolibarr='http://www.dolibarr.org/downloads/'; $urldolibarr='http://www.dolibarr.org/downloads/';
@ -54,7 +56,7 @@ if (GETPOST('action','alpha')=='install')
if (! $original_file) if (! $original_file)
{ {
$langs->load("Error"); $langs->load("Error");
$mesg = '<div class="warning">'.$langs->trans("ErrorFileRequired").'</div>'; setEventMessage($langs->trans("ErrorFileRequired"), 'warnings');
$error++; $error++;
} }
else else
@ -62,7 +64,7 @@ if (GETPOST('action','alpha')=='install')
if (! preg_match('/\.zip/i',$original_file)) if (! preg_match('/\.zip/i',$original_file))
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFileMustBeADolibarrPackage",$original_file).'</div>'; setEventMessage($langs->trans("ErrorFileMustBeADolibarrPackage",$original_file), 'errors');
$error++; $error++;
} }
} }
@ -80,12 +82,11 @@ if (GETPOST('action','alpha')=='install')
if (! empty($result['error'])) if (! empty($result['error']))
{ {
$langs->load("errors"); $langs->load("errors");
$mesg = '<div class="error">'.$langs->trans($result['error'],$original_file).'</div>'; setEventMessage($langs->trans($result['error'],$original_file), 'errors');
} }
else else
{ {
$mesg = '<div class="ok">'.$langs->trans("SetupIsReadyForUse").'</div>'; setEventMessage($langs->trans("SetupIsReadyForUse"));
} }
} }
} }
@ -107,9 +108,6 @@ print $langs->trans("CurrentVersion").' : <b>'.DOL_VERSION.'</b><br>';
print $langs->trans("LastStableVersion").' : <b>'.$langs->trans("FeatureNotYetAvailable").'</b><br>'; print $langs->trans("LastStableVersion").' : <b>'.$langs->trans("FeatureNotYetAvailable").'</b><br>';
print '<br>'; print '<br>';
//dol_htmloutput_errors($mesg);
dol_htmloutput_mesg($mesg);
print $langs->trans("Upgrade").'<br>'; print $langs->trans("Upgrade").'<br>';
print '<hr>'; print '<hr>';
print $langs->trans("ThisIsProcessToFollow").'<br>'; print $langs->trans("ThisIsProcessToFollow").'<br>';
@ -152,7 +150,7 @@ if (! empty($conf->global->MAIN_ONLINE_INSTALL_MODULE))
else else
{ {
$message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); $message=info_admin($langs->trans("NotExistsDirect",$dirins).$langs->trans("InfDirAlt").$langs->trans("InfDirExample"));
print '<div class="warning">'.$message.'</div>'; setEventMessage($message, 'warnings');
} }
} }
else else

View File

@ -57,8 +57,6 @@ print_fiche_titre($langs->trans("TranslationSetup"),'','setup');
print $langs->trans("TranslationDesc")."<br>\n"; print $langs->trans("TranslationDesc")."<br>\n";
print "<br>\n"; print "<br>\n";
dol_htmloutput_mesg($message);
print $langs->trans("CurrentUserLanguage").': <strong>'.$langs->defaultlang.'</strong><br>'; print $langs->trans("CurrentUserLanguage").': <strong>'.$langs->defaultlang.'</strong><br>';
print img_warning().' '.$langs->trans("SomeTranslationAreUncomplete").'<br>'; print img_warning().' '.$langs->trans("SomeTranslationAreUncomplete").'<br>';

View File

View File

@ -1 +0,0 @@
Url not available

Some files were not shown because too many files have changed in this diff Show More