stuart: devel/kolab kolabconf,1.2,1.3
cvs at intevation.de
cvs at intevation.de
Wed May 12 13:05:03 CEST 2004
Author: stuart
Update of /kolabrepository/devel/kolab
In directory doto:/tmp/cvs-serv11226
Modified Files:
kolabconf
Log Message:
Updated kolabconf to handle the new template mechanism. Also includes some nifty new features.
Index: kolabconf
===================================================================
RCS file: /kolabrepository/devel/kolab/kolabconf,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- kolabconf 12 May 2004 08:15:22 -0000 1.2
+++ kolabconf 12 May 2004 11:05:01 -0000 1.3
@@ -24,42 +24,90 @@
##########################################################################
use strict;
-use Getopt::Std;
-use Sys::Syslog;
+use Getopt::Long;
use IO::File;
use Kolab;
-use Kolab::Util;
-use Kolab::Conf;
-use Kolab::LDAP;
-use vars qw($opt_d);
+use Kolab::Templates;
-openlog('kolabconf', 'cons, pid', 'user');
+our $VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/);
-getopts('d');
-if ($opt_d) {
- foreach my $key (sort keys %Kolab::config) {
- print "$key : " . $Kolab::config{$key} . "\n";
- }
- exit 0;
-}
+our (@configs, $dump, $edit, $help, $nochange, $stdio, $version);
+GetOptions (
+ "config=s" => \@configs,
+ "dump" => \$dump,
+ "edit" => \$edit,
+ "help" => \$help,
+ "nochange" => \$nochange,
+ "stdio" => \$stdio,
+ "version" => \$version
+);
-print 'kolabconf - Kolab Configuration Generator
+Kolab::loadConfig(@configs);
- Copyright (c) 2003 Code Fusion cc
- Copyright (c) 2003 Tassilo Erlewein, Martin Konold, Achim Frank
+sub printVersion()
+{
+ print "kolabconf version $VERSION
+See the file CONTRIBUTORS that was distributed with this program for
+copyright information.
This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-';
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
+to the extent permitted by law.
+";
+}
-Kolab::log('KC', 'Rebuilding templates');
-Kolab::Conf::rebuildTemplates;
-Kolab::log('KC', 'Reloading kolab components');
-Kolab::reload;
-#if ($pid) {
-# Kolab::log('KC', "Refreshing the kolab daemon (w/ PID $pid)");
-# kill('HUP', $pid);
-#} else {
-# Kolab::log('KC', "Unable to determine the PID of the kolab daemon; skipping refresh", KOLAB_WARN);
-#}
-Kolab::log('KC', 'Finished');
+sub printHelp()
+{
+ print "Usage: $0 [OPTION]...
+
+ -c[cfgfile], --config[=cfgfile]
+ load configuration data from file cfgfile
+ -d, --dump
+ dump the loaded configuration data to stdout
+ -e, --edit
+ edit the current configuration using the editor specified
+ by the EDITOR environment variable and then automatically
+ regenerate the templates if a modification is detected
+ -n, --nochange
+ do not execute change commands
+ -s, --stdio
+ read a template from stdin, substitute any configuration
+ values encountered, and print the result to stdout
+ --help display this help and exit
+ --version output version information and exit
+";
+}
+
+if ($version) {
+ printVersion();
+} elsif ($help) {
+ printHelp();
+} elsif ($edit) {
+ my $editor = $ENV{"EDITOR"};
+ die "No suitable editor was found" unless $editor;
+
+ # TODO: copy kolab.conf to a temporary file, execute $EDITOR on the
+ # temporary file, check for changes when $EDITOR finishes & regenerate
+ # the templates if a change was detected
+ my $status = system($editor, "/kolab/etc/kolab/kolab.conf");
+ print "FINISHED $editor, return = $status\n";
+} elsif ($dump) {
+ foreach my $key (sort keys %Kolab::config) {
+ print "$key : $Kolab::config{$key}\n";
+ }
+} elsif ($stdio) {
+ while (<>) {
+ while (/\@{3}(\S+)\@{3}/) {
+ if ($Kolab::config{$1}) {
+ s/\@{3}(\S+)\@{3}/$Kolab::config{$1}/;
+ } else {
+ s/\@{3}(\S+)\@{3}//;
+ }
+ }
+ print $_;
+ }
+} else {
+ Kolab::initLog;
+
+ Kolab::Templates::build($nochange);
+}
More information about the commits
mailing list