diff options
author | Oliver Tappe | 2008-04-06 15:40:09 +0200 |
---|---|---|
committer | Oliver Tappe | 2008-04-06 15:40:09 +0200 |
commit | 5a8c8a1638eea2ff6897046fcbc94bb42ccbe94d (patch) | |
tree | 036281d5a9b6d847c4bfc92f3c52f96a6ada2df0 /os-plugins/plugins/syslog/OpenSLX | |
parent | * Instead of passing all known attributes of the current system into each plu... (diff) | |
download | core-5a8c8a1638eea2ff6897046fcbc94bb42ccbe94d.tar.gz core-5a8c8a1638eea2ff6897046fcbc94bb42ccbe94d.tar.xz core-5a8c8a1638eea2ff6897046fcbc94bb42ccbe94d.zip |
* made names of distro module consistent across OpenSLX - now the always start with
a capital letter followed by all lowercase (Debian, Fedora, Gentoo, Suse, Ubuntu)
* refactored loading of distro modules into a separate function (loadDistroModule()
in Basics.pm)
* finished support to logging to a file in syslog plugin
* worked at desktop plugin (still not working, though)
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1721 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/plugins/syslog/OpenSLX')
-rw-r--r-- | os-plugins/plugins/syslog/OpenSLX/Distro/Base.pm | 63 | ||||
-rw-r--r-- | os-plugins/plugins/syslog/OpenSLX/Distro/Suse.pm | 41 | ||||
-rw-r--r-- | os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm | 30 |
3 files changed, 126 insertions, 8 deletions
diff --git a/os-plugins/plugins/syslog/OpenSLX/Distro/Base.pm b/os-plugins/plugins/syslog/OpenSLX/Distro/Base.pm new file mode 100644 index 00000000..dd599404 --- /dev/null +++ b/os-plugins/plugins/syslog/OpenSLX/Distro/Base.pm @@ -0,0 +1,63 @@ +# Copyright (c) 2008 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# syslog/OpenSLX/Distro/Base.pm +# - provides base implementation of the Distro API for the syslog plugin. +# ----------------------------------------------------------------------------- +package syslog::OpenSLX::Distro::Base; + +use strict; +use warnings; + +our $VERSION = 1.01; # API-version . implementation-version + +use OpenSLX::Basics; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + $self->{engine} = shift; + + return 1; +} + +sub runlevelInfo +{ + my $self = shift; + my $attrs = shift; + + # most distros (well: Debian & Ubuntu) use a different initscript depending + # on which version of syslog is installed ('syslogd' or 'syslog-ng') + my $kind = lc($attrs->{'syslog::kind'}); + my %nameMap = ( + 'syslogd' => 'sysklogd', + 'syslog-ng' => 'syslog-ng', + ); + my $rlInfo = { + scriptName => $nameMap{$kind}, + startAt => 2, + stopAt => 15, + }; + + return $rlInfo; +} + +1; diff --git a/os-plugins/plugins/syslog/OpenSLX/Distro/Suse.pm b/os-plugins/plugins/syslog/OpenSLX/Distro/Suse.pm new file mode 100644 index 00000000..7255d6f5 --- /dev/null +++ b/os-plugins/plugins/syslog/OpenSLX/Distro/Suse.pm @@ -0,0 +1,41 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# syslog/OpenSLX/Distro/Suse.pm +# - provides SUSE-specific overrides of the Distro API for the syslog plugin. +# ----------------------------------------------------------------------------- +package syslog::OpenSLX::Distro::Suse; + +use strict; +use warnings; + +use base qw(syslog::OpenSLX::Distro::Base); + +use OpenSLX::Basics; + +################################################################################ +### interface methods +################################################################################ + +sub runlevelInfo +{ + my $self = shift; + my $attrs = shift; + + my $rlInfo = $self->SUPER::runlevelInfo($attrs); + + # SUSE uses a script named 'syslog', no matter if syslogd or syslog-ng + # is installed + $rlInfo->{scriptName} = 'syslog'; + + return $rlInfo; +} + +1; diff --git a/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm b/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm index 9220d3ab..e5e63c29 100644 --- a/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm +++ b/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm @@ -92,6 +92,16 @@ sub getAttrInfo content_descr => 'a port number', default => 514, }, + 'syslog::file' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + name of file where all log messages shall be written + End-of-Here + content_regex => undef, + content_descr => 'a complete file path', + default => undef, + }, }; } @@ -170,7 +180,9 @@ sub _setupSyslogNG my $repoPath = $self->{pluginRepositoryPath}; - my $conf = unshiftHereDoc(<<' End-of-Here'); + my $rlInfo = $self->{distro}->runlevelInfo($attrs); + + my $conf = unshiftHereDoc(<<" End-of-Here"); #!/bin/ash # written by OpenSLX-plugin 'syslog' @@ -190,11 +202,11 @@ sub _setupSyslogNG }; END - if [ -n "${syslog_host}" ]; then - [ -z ${syslog_port} ] && syslog_port=514 + if [ -n "\${syslog_host}" ]; then + [ -z \${syslog_port} ] && syslog_port=514 cat >>/mnt/etc/syslog-ng/syslog-ng.conf <<END destination loghost { - udp( "${syslog_host}" port(${syslog_port}) ); + udp( "\${syslog_host}" port(\${syslog_port}) ); }; log { source(all); @@ -203,10 +215,10 @@ sub _setupSyslogNG END fi - if [ -n "${syslog_file}" ]; then + if [ -n "\${syslog_file}" ]; then cat >>/mnt/etc/syslog-ng/syslog-ng.conf <<END destination allmessages { - file("/var/log/allmessages"); + file("\${syslog_file}"); }; log { source(all); @@ -215,7 +227,7 @@ sub _setupSyslogNG END fi - rllinker syslog-ng 1 15 + rllinker $rlInfo->{scriptName} $rlInfo->{startAt} $rlInfo->{stopAt} End-of-Here spitFile("$repoPath/syslog.sh", $conf); @@ -230,6 +242,8 @@ sub _setupSyslogd my $repoPath = $self->{pluginRepositoryPath}; + my $rlInfo = $self->{distro}->runlevelInfo($attrs); + # TODO: implement! my $conf = unshiftHereDoc(<<' End-of-Here'); @@ -237,7 +251,7 @@ sub _setupSyslogd # written by OpenSLX-plugin 'syslog' - rllinker syslogd 1 15 + rllinker $rlInfo->{scriptName} $rlInfo->{startAt} $rlInfo->{stopAt} End-of-Here spitFile("$repoPath/syslog.sh", $conf); |