From f2af9def6777d0192a83c8a86f1332569c742051 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 19 Jan 2011 15:22:12 +0100 Subject: [PATCH] Globale Variablen nach %::lx_office_conf verschoben Betroffen sind: $sendmail $openofficeorg_writer_bin $xvfb_bin $html2ps_bin $ghostscript_bin $latex_bin $pg_dump_exe $pg_restore_exe --- SL/DN.pm | 2 +- SL/Dispatcher.pm | 1 - SL/Mailer.pm | 4 ++-- SL/Template/HTML.pm | 4 ++-- SL/Template/LaTeX.pm | 2 +- SL/Template/OpenDocument.pm | 6 ++--- bin/mozilla/admin.pl | 16 ++++++------- bin/mozilla/am.pl | 5 ++-- bin/mozilla/io.pl | 4 ++-- config/lx-erp.conf | 38 ++++--------------------------- config/lx-erp.conf.default | 38 ++++--------------------------- config/lx_office.conf.default | 21 +++++++++++++++++ scripts/console | 4 ---- scripts/rose_auto_create_model.pl | 2 -- scripts/task_server.pl | 4 ---- 15 files changed, 53 insertions(+), 98 deletions(-) diff --git a/SL/DN.pm b/SL/DN.pm index e9a7e8133..cef36383d 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -667,7 +667,7 @@ sub melt_pdfs { $dunning_id =~ s|[^\d]||g; - my $in = IO::File->new("gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=- $inputfiles |"); + my $in = IO::File->new($::lx_office_conf{applications}->{ghostscript} . " -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=- $inputfiles |"); $form->error($main::locale->text('Could not spawn ghostscript.')) unless $in; if ($form->{media} eq 'printer') { diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index d7e645dcd..9ba2b70cf 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -89,7 +89,6 @@ sub pre_startup_setup { { no warnings 'once'; $::menufile = "menu.ini"; - $::sendmail = "| /usr/sbin/sendmail -t"; $::lxdebug = LXDebug->new; $::auth = SL::Auth->new; $::form = undef; diff --git a/SL/Mailer.pm b/SL/Mailer.pm index 17981331d..c4cea35f2 100644 --- a/SL/Mailer.pm +++ b/SL/Mailer.pm @@ -116,9 +116,9 @@ sub send { my %temp_form = ( %{ $form }, 'myconfig_email' => $email ); my $template = SL::Template::create(type => 'PlainText', form => \%temp_form); - my $sendmail = $template->parse_block($main::sendmail); + my $sendmail = $template->parse_block($::lx_office_conf{applications}->{sendmail}); - if (!open(OUT, $sendmail)) { + if (!open(OUT, "|$sendmail")) { $main::lxdebug->leave_sub(); return "$sendmail : $!"; } diff --git a/SL/Template/HTML.pm b/SL/Template/HTML.pm index abca75c07..0ff939fd8 100644 --- a/SL/Template/HTML.pm +++ b/SL/Template/HTML.pm @@ -70,7 +70,7 @@ sub convert_to_postscript { $psfile .= ".ps"; } - system("html2ps -f html2ps-config < $form->{tmpfile} > $psfile"); + system($::lx_office_conf{applications}->{html2ps} . " -f html2ps-config < $form->{tmpfile} > $psfile"); if ($?) { $self->{"error"} = $form->cleanup(); $self->cleanup(); @@ -103,7 +103,7 @@ sub convert_to_pdf { $pdffile .= ".pdf"; } - system("html2ps -f html2ps-config < $form->{tmpfile} | ps2pdf - $pdffile"); + system($::lx_office_conf{applications}->{html2ps} . " -f html2ps-config < $form->{tmpfile} | ps2pdf - $pdffile"); if ($?) { $self->{"error"} = $form->cleanup(); $self->cleanup(); diff --git a/SL/Template/LaTeX.pm b/SL/Template/LaTeX.pm index d1c208018..04c5f4b61 100644 --- a/SL/Template/LaTeX.pm +++ b/SL/Template/LaTeX.pm @@ -447,7 +447,7 @@ sub convert_to_pdf { } sub _get_latex_path { - return $main::latex_bin || 'pdflatex'; + return $::lx_office_conf{applications}->{latex} || 'pdflatex'; } sub get_mime_type() { diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index 2ed3c60fa..b1267c1c8 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -382,7 +382,7 @@ sub spawn_xvfb { my $pid = fork(); if (0 == $pid) { $main::lxdebug->message(LXDebug->DEBUG2(), " Child execing\n"); - exec($main::xvfb_bin, $display, "-screen", "0", "640x480x8", "-nolisten", "tcp"); + exec($::lx_office_conf{applications}->{xvfb}, $display, "-screen", "0", "640x480x8", "-nolisten", "tcp"); } sleep(3); $main::lxdebug->message(LXDebug->DEBUG2(), " parent dont sleeping\n"); @@ -457,7 +457,7 @@ sub spawn_openoffice { exit if ($new_pid); my $ssres = setsid(); $main::lxdebug->message(LXDebug->DEBUG2(), " Child execing\n"); - my @cmdline = ($main::openofficeorg_writer_bin, + my @cmdline = ($::lx_office_conf{applications}->{openofficeorg_writer}, "-minimized", "-norestore", "-nologo", "-nolockcheck", "-headless", "-accept=socket,host=localhost,port=" . @@ -509,7 +509,7 @@ sub convert_to_pdf { my @cmdline; if (!$main::openofficeorg_daemon) { - @cmdline = ($main::openofficeorg_writer_bin, + @cmdline = ($::lx_office_conf{applications}->{openofficeorg_writer}, "-minimized", "-norestore", "-nologo", "-nolockcheck", "-headless", "file:${filename}.odt", diff --git a/bin/mozilla/admin.pl b/bin/mozilla/admin.pl index acaae17e0..3d1185deb 100755 --- a/bin/mozilla/admin.pl +++ b/bin/mozilla/admin.pl @@ -845,7 +845,7 @@ sub backup_dataset { $form->{title} = "Lx-Office ERP " . $locale->text('Database Administration') . " / " . $locale->text('Backup Dataset'); - if ("$main::pg_dump_exe" eq "DISABLED") { + if ($::lx_office_conf{applications}->{pg_dump} eq "DISABLED") { $form->error($locale->text('Database backups and restorations are disabled in lx-erp.conf.')); } @@ -867,9 +867,9 @@ sub backup_dataset_start { $form->{title} = "Lx-Office ERP " . $locale->text('Database Administration') . " / " . $locale->text('Backup Dataset'); - $main::pg_dump_exe ||= "pg_dump"; + my $pg_dump_exe = $::lx_office_conf{applications}->{pg_dump} || "pg_dump"; - if ("$main::pg_dump_exe" eq "DISABLED") { + if ("$pg_dump_exe" eq "DISABLED") { $form->error($locale->text('Database backups and restorations are disabled in lx-erp.conf.')); } @@ -895,7 +895,7 @@ sub backup_dataset_start { push @args, ("-p", $form->{dbport}) if ($form->{dbport}); push @args, $form->{dbname}; - my $cmd = "$main::pg_dump_exe " . join(" ", map { s/\\/\\\\/g; s/\"/\\\"/g; $_ } @args); + my $cmd = "$pg_dump_exe " . join(" ", map { s/\\/\\\\/g; s/\"/\\\"/g; $_ } @args); my $name = "dataset_backup_$form->{dbname}_" . strftime("%Y%m%d", localtime()) . ".tar"; if ($form->{destination} ne "email") { @@ -954,7 +954,7 @@ sub restore_dataset { $form->{title} = "Lx-Office ERP " . $locale->text('Database Administration') . " / " . $locale->text('Restore Dataset'); - if ("$main::pg_restore_exe" eq "DISABLED") { + if ($::lx_office_conf{applications}->{pg_restore} eq "DISABLED") { $form->error($locale->text('Database backups and restorations are disabled in lx-erp.conf.')); } @@ -979,9 +979,9 @@ sub restore_dataset_start { $form->{title} = "Lx-Office ERP " . $locale->text('Database Administration') . " / " . $locale->text('Restore Dataset'); - $main::pg_restore_exe ||= "pg_restore"; + my $pg_restore_exe = $::lx_office_conf{applications}->{pg_restore} || "pg_restore"; - if ("$main::pg_restore_exe" eq "DISABLED") { + if ("$pg_restore_exe" eq "DISABLED") { $form->error($locale->text('Database backups and restorations are disabled in lx-erp.conf.')); } @@ -1068,7 +1068,7 @@ sub restore_dataset_start { push @args, ("-p", $form->{dbport}) if ($form->{dbport}); push @args, $tmp; - my $cmd = "$main::pg_restore_exe " . join(" ", map { s/\\/\\\\/g; s/\"/\\\"/g; $_ } @args); + my $cmd = "$pg_restore_exe " . join(" ", map { s/\\/\\\\/g; s/\"/\\\"/g; $_ } @args); my $in = IO::File->new("$cmd 2>&1 |"); diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 66874c736..7717adae3 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -2457,8 +2457,9 @@ sub config { _build_cfg_options('numberformat', ('1,000.00', '1000.00', '1.000,00', '1000,00')); my @formats = (); - if ($main::opendocument_templates && $main::openofficeorg_writer_bin && - $main::xvfb_bin && (-x $main::openofficeorg_writer_bin) && (-x $main::xvfb_bin)) { + if ($main::opendocument_templates + && $::lx_office_conf{applications}->{openofficeorg_writer} && (-x $::lx_office_conf{applications}->{openofficeorg_writer}) + && $::lx_office_conf{applications}->{xvfb} && (-x $::lx_office_conf{applications}->{xvfb})) { push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"), "value" => "opendocument_pdf" }); } diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 060efe84a..f7084c4df 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -1173,8 +1173,8 @@ sub print_options { if ($form->{media} ne 'email'); push @FORMAT, grep $_, - ($main::opendocument_templates && $main::openofficeorg_writer_bin && $main::xvfb_bin - && (-x $main::openofficeorg_writer_bin) && (-x $main::xvfb_bin) + ($main::opendocument_templates && $::lx_office_conf{applications}->{openofficeorg_writer} && $::lx_office_conf{applications}->{xvfb} + && (-x $::lx_office_conf{applications}->{openofficeorg_writer}) && (-x $::lx_office_conf{applications}->{xvfb}) && !$options{no_opendocument_pdf}) ? opthash("opendocument_pdf", $form->{DF}{"opendocument_pdf"}, $locale->text("PDF (OpenDocument/OASIS)")) : undef, ($main::latex_templates) ? diff --git a/config/lx-erp.conf b/config/lx-erp.conf index 16ad49287..86234f6eb 100644 --- a/config/lx-erp.conf +++ b/config/lx-erp.conf @@ -1,21 +1,17 @@ use Cwd; our ( - $dbcharset, $eur, $ghostscript_bin, $html2ps_bin, $language, $latex_bin, - $latex_templates, $lizenzen, $memberfile, $opendocument_templates, - $openofficeorg_daemon, $openofficeorg_daemon_port, $openofficeorg_writer_bin, - $parts_image_css, $parts_listing_images, $parts_show_image, $pg_dump_exe, - $pg_restore_exe, $sendmail, $show_best_before, $sid, $spool, $templates, - $userspath, $vertreter, $webdav, $xvfb_bin + $dbcharset, $eur, $language, + $latex_templates, $lizenzen, $opendocument_templates, + $openofficeorg_daemon, $openofficeorg_daemon_port, + $parts_image_css, $parts_listing_images, $parts_show_image, + $show_best_before, $vertreter, $webdav ); # Wenn Einnahmen-Überschussrechnung, dann auf 1 setzen # Wenn Bilanzierung (z.B. GmbH), dann auf 0 setzen $eur = 1; -# location of sendmail -$sendmail = '| /usr/sbin/sendmail -t<%if myconfig_email%> -f <%myconfig_email%><%end%>'; - # set language for login and admin # currently "de" (German), "de_DE" (new German) and "en" (English, not perfect) are available $language = "de"; @@ -46,9 +42,6 @@ $opendocument_templates = 1; # Die folgenden zwei Variablen legen Pfade zu Programmen fest, die benoetigt # werden, um OpenDocument-Vorlagen in PDFs umzuwandeln. -# Pfad zu OpenOffice.org writer -$openofficeorg_writer_bin = "/usr/bin/oowriter"; - # Soll OpenOffice dauerhaft gestartet bleiben? Die Konvertierung nachfolgender # Dokumente geht dann schneller. Allerdings wird auf dem System ein # installiertes Python mit den Python-UNO-Bindings benoetigt, die Bestandteil @@ -56,29 +49,8 @@ $openofficeorg_writer_bin = "/usr/bin/oowriter"; $openofficeorg_daemon = 1; $openofficeorg_daemon_port = 2002; -# Pfad zum "X virtual frame buffer", unter dem OpenOffice gestartet wird. -$xvfb_bin = "/usr/bin/Xvfb"; - # Das charset, in dem die Daten in der Datenbank abgelegt sind. $dbcharset = 'UTF-8'; # Für UNICODE UTF-8 # $dbcharset = "ISO-8859-15"; - -# Pfad zu 'html2ps' zum Export von Listenansichten als PDF -$html2ps_bin = "/usr/bin/html2ps"; -$ghostscript_bin = "/usr/bin/gs"; - -# Name von bzw. Pfad zu 'pdflatex' oder einer anderen kompatiblen Version -# wie z.B. 'xetex' -$latex_bin = 'pdflatex'; - -# Datenbankbackups werden mit dem externen Programm "pg_dump" erledigt. -# Wenn es nicht im aktuellen Pfad vorhanden ist, so muss hier der vollständige -# Pfad eingetragen werden. Wenn die Variable auf "DISABLED" gesetzt wird, -# so wird der Menüpunkt zum Backup von Datenbanken im Administrationsfrontend -# nicht angeboten. -# Das gleiche gilt analog für das Wiederherstellen mittels "pg_restore". -$pg_dump_exe = "pg_dump"; -$pg_restore_exe = "pg_restore"; - 1; diff --git a/config/lx-erp.conf.default b/config/lx-erp.conf.default index 16ad49287..86234f6eb 100644 --- a/config/lx-erp.conf.default +++ b/config/lx-erp.conf.default @@ -1,21 +1,17 @@ use Cwd; our ( - $dbcharset, $eur, $ghostscript_bin, $html2ps_bin, $language, $latex_bin, - $latex_templates, $lizenzen, $memberfile, $opendocument_templates, - $openofficeorg_daemon, $openofficeorg_daemon_port, $openofficeorg_writer_bin, - $parts_image_css, $parts_listing_images, $parts_show_image, $pg_dump_exe, - $pg_restore_exe, $sendmail, $show_best_before, $sid, $spool, $templates, - $userspath, $vertreter, $webdav, $xvfb_bin + $dbcharset, $eur, $language, + $latex_templates, $lizenzen, $opendocument_templates, + $openofficeorg_daemon, $openofficeorg_daemon_port, + $parts_image_css, $parts_listing_images, $parts_show_image, + $show_best_before, $vertreter, $webdav ); # Wenn Einnahmen-Überschussrechnung, dann auf 1 setzen # Wenn Bilanzierung (z.B. GmbH), dann auf 0 setzen $eur = 1; -# location of sendmail -$sendmail = '| /usr/sbin/sendmail -t<%if myconfig_email%> -f <%myconfig_email%><%end%>'; - # set language for login and admin # currently "de" (German), "de_DE" (new German) and "en" (English, not perfect) are available $language = "de"; @@ -46,9 +42,6 @@ $opendocument_templates = 1; # Die folgenden zwei Variablen legen Pfade zu Programmen fest, die benoetigt # werden, um OpenDocument-Vorlagen in PDFs umzuwandeln. -# Pfad zu OpenOffice.org writer -$openofficeorg_writer_bin = "/usr/bin/oowriter"; - # Soll OpenOffice dauerhaft gestartet bleiben? Die Konvertierung nachfolgender # Dokumente geht dann schneller. Allerdings wird auf dem System ein # installiertes Python mit den Python-UNO-Bindings benoetigt, die Bestandteil @@ -56,29 +49,8 @@ $openofficeorg_writer_bin = "/usr/bin/oowriter"; $openofficeorg_daemon = 1; $openofficeorg_daemon_port = 2002; -# Pfad zum "X virtual frame buffer", unter dem OpenOffice gestartet wird. -$xvfb_bin = "/usr/bin/Xvfb"; - # Das charset, in dem die Daten in der Datenbank abgelegt sind. $dbcharset = 'UTF-8'; # Für UNICODE UTF-8 # $dbcharset = "ISO-8859-15"; - -# Pfad zu 'html2ps' zum Export von Listenansichten als PDF -$html2ps_bin = "/usr/bin/html2ps"; -$ghostscript_bin = "/usr/bin/gs"; - -# Name von bzw. Pfad zu 'pdflatex' oder einer anderen kompatiblen Version -# wie z.B. 'xetex' -$latex_bin = 'pdflatex'; - -# Datenbankbackups werden mit dem externen Programm "pg_dump" erledigt. -# Wenn es nicht im aktuellen Pfad vorhanden ist, so muss hier der vollständige -# Pfad eingetragen werden. Wenn die Variable auf "DISABLED" gesetzt wird, -# so wird der Menüpunkt zum Backup von Datenbanken im Administrationsfrontend -# nicht angeboten. -# Das gleiche gilt analog für das Wiederherstellen mittels "pg_restore". -$pg_dump_exe = "pg_dump"; -$pg_restore_exe = "pg_restore"; - 1; diff --git a/config/lx_office.conf.default b/config/lx_office.conf.default index 4e6e83dd2..7d2cbecd6 100644 --- a/config/lx_office.conf.default +++ b/config/lx_office.conf.default @@ -8,6 +8,27 @@ templates = templates # Path to the old memberfile (ignored on new installations) memberfile = users/members +[applications] +# Location of sendmail +sendmail = /usr/sbin/sendmail -t<%if myconfig_email%> -f <%myconfig_email%><%end%> +# Location of OpenOffice.org writer +openofficeorg_writer = oowriter +# Location of the X virtual frame buffer used for OpenOffice +xvfb = Xvfb +# Location of the html2ps binary +html2ps = html2ps +# Location of the Ghostscript binary +ghostscript = gs +# Location of the pdflatex (or compatible, e.g. xetex) binary +latex = pdflatex +# Location of the two executables "pg_dump" and "pg_restore" used for +# database backup and restoration from the admin section. If +# "pg_dump" or "pg_restore" is set to "DISABLED" then the +# corresponding option (backup/restoration) will be hidden from the +# admin section. +pg_dump = pg_dump +pg_restore = pg_restore + [environment] # Add the following paths to the PATH environment variable. path = /usr/local/bin:/usr/X11R6/bin:/usr/X11/bin diff --git a/scripts/console b/scripts/console index 5e85b0264..2613c7237 100755 --- a/scripts/console +++ b/scripts/console @@ -59,10 +59,6 @@ sub lxinit { package main; - { no warnings 'once'; - $::sendmail = "| /usr/sbin/sendmail -t"; - } - eval { require "config/lx-erp.conf"; }; eval { require "config/lx-erp-local.conf"; } if -f "config/lx-erp-local.conf"; diff --git a/scripts/rose_auto_create_model.pl b/scripts/rose_auto_create_model.pl index 43d1af9eb..ba19a0c05 100755 --- a/scripts/rose_auto_create_model.pl +++ b/scripts/rose_auto_create_model.pl @@ -42,8 +42,6 @@ sub setup { my $login = shift @ARGV; - $::sendmail = "| /usr/sbin/sendmail -t"; - $::lxdebug = LXDebug->new(); require "config/lx-erp.conf"; diff --git a/scripts/task_server.pl b/scripts/task_server.pl index cbdc1bd12..843419fda 100755 --- a/scripts/task_server.pl +++ b/scripts/task_server.pl @@ -42,10 +42,6 @@ sub lxinit { package main; - { no warnings 'once'; - $::sendmail = "| /usr/sbin/sendmail -t"; - } - eval { require "config/lx-erp.conf"; 1; } or die $EVAL_ERROR; eval { require "config/lx-erp-local.conf"; 1; } or die $EVAL_ERROR if -f "config/lx-erp-local.conf"; -- 2.20.1