From 986edf8583a69376055802b5e99147354f17762a Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Mon, 24 Mar 2008 19:08:13 +0000 Subject: * split syslog::target into syslog::host and syslog::port * implemented stage3 backend for syslog-ng (syslogd still missing) * added another hook-script that: + stops busybox syslogd (in order to be superseded by native syslog daemon) + removes boot.klog if it exists (as it will hang, most probably since we have already emptied the kernel message log) With these changes, I have successfully tested remote syslog for a suse-10.2 vendor-OS. git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1684 95ad53e4-c205-0410-b2fa-d234c58c8868 --- .../plugins/syslog/OpenSLX/OSPlugin/syslog.pm | 179 ++++++++++++++++++++- os-plugins/plugins/syslog/XX_syslog.sh | 18 +++ .../syslog/init-hooks/15-have-ip-config/syslog.sh | 7 +- .../plugins/syslog/init-hooks/95-cleanup/syslog.sh | 10 ++ 4 files changed, 206 insertions(+), 8 deletions(-) create mode 100644 os-plugins/plugins/syslog/XX_syslog.sh create mode 100644 os-plugins/plugins/syslog/init-hooks/95-cleanup/syslog.sh (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm b/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm index 5ded36ee..9220d3ab 100644 --- a/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm +++ b/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm @@ -42,9 +42,9 @@ sub getInfo return { description => unshiftHereDoc(<<' End-of-Here'), - Sets up remote logging of boot process (via UPD). + Sets up system log service for SLX-clients. End-of-Here - mustRunAfter => [], + precedence => 50, }; } @@ -63,17 +63,186 @@ sub getAttrInfo content_descr => '1 means active - 0 means inactive', default => '1', }, - 'syslog::target' => { + 'syslog::kind' => { + applies_to_vendor_os => 1, + description => unshiftHereDoc(<<' End-of-Here'), + kind of syslog to use (syslogd or syslog-ng) + End-of-Here + content_regex => undef, + content_descr => 'allowed: syslogd, syslog-ng', + default => undef, + }, + 'syslog::host' => { applies_to_systems => 1, applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), - ip:port where syslog shall be sent to + name or IP-address of host where syslog shall be sent to End-of-Here content_regex => undef, - content_descr => 'allowed: gdm, kdm, xdm', + content_descr => 'a hostname or an IP address', default => undef, }, + 'syslog::port' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + port number (UDP) where syslog shall be sent to + End-of-Here + content_regex => undef, + content_descr => 'a port number', + default => 514, + }, }; } +sub installationPhase +{ + my $self = shift; + + $self->{pluginRepositoryPath} = shift; + $self->{pluginTempPath} = shift; + $self->{openslxPath} = shift; + $self->{attrs} = shift; + + # We are going to change some of the stage1 attributes during installation + # (basically we are filling the ones that are not defined). Since the result + # of these changes might change between invocations, we do not want to store + # the resulting values, but we want to store the original (undef). + # In order to do so, we copy all stage1 attributes directly into the + # object hash and change them there. + $self->{kind} = lc($self->{attrs}->{'syslog::kind'}); + + my $engine = $self->{'os-plugin-engine'}; + + if ($self->{kind} eq 'syslog-ng' && !qx{which syslog-ng}) { + $engine->installPackages('syslog-ng'); + } + if ($self->{kind} eq 'syslogd' && !qx{which syslogd}) { + $engine->installPackages('syslogd'); + } + + if (!$self->{kind}) { + if (qx{which syslog-ng}) { + $self->{kind} = 'syslog-ng'; + } + elsif (qx{which syslogd}) { + $self->{kind} = 'syslogd'; + } + else { + die _tr( + "no syslog daemon available, plugin 'syslog' wouldn't work!" + ); + } + print _tr("selecting %s as syslog kind\n", $self->{kind}); + } + + # start to actually do something - according to current stage1 attributes + if ($self->{kind} eq 'syslog-ng') { + $self->_setupSyslogNG(); + } + elsif ($self->{kind} eq 'syslogd') { +die 'sorry, support for kind "syslogd" is not implemented yet!'; + $self->_setupSyslogd(); + } + else { + die _tr( + 'unknown kind "%s" given, only "syslog-ng" and "syslogd" are supported!', + $self->{kind} + ); + } + + return; +} + +sub removalPhase +{ + my $self = shift; + my $pluginRepositoryPath = shift; + my $pluginTempPath = shift; + + return; +} + +sub _setupSyslogNG +{ + my $self = shift; + my $attrs = shift; + + my $repoPath = $self->{pluginRepositoryPath}; + + my $conf = unshiftHereDoc(<<' End-of-Here'); + #!/bin/ash + # written by OpenSLX-plugin 'syslog' + + cat >/mnt/etc/syslog-ng/syslog-ng.conf <>/mnt/etc/syslog-ng/syslog-ng.conf <>/mnt/etc/syslog-ng/syslog-ng.conf <{pluginRepositoryPath}; + + # TODO: implement! + + my $conf = unshiftHereDoc(<<' End-of-Here'); + #!/bin/ash + # written by OpenSLX-plugin 'syslog' + + + rllinker syslogd 1 15 + + End-of-Here + spitFile("$repoPath/syslog.sh", $conf); + + return; +} + 1; diff --git a/os-plugins/plugins/syslog/XX_syslog.sh b/os-plugins/plugins/syslog/XX_syslog.sh new file mode 100644 index 00000000..ccd27bbf --- /dev/null +++ b/os-plugins/plugins/syslog/XX_syslog.sh @@ -0,0 +1,18 @@ +#! /bin/ash +# +# stage3 part of 'syslog' plugin - the runlevel script +# +. /etc/functions +. /etc/distro-functions +. /etc/sysconfig/config +if [ -e /initramfs/plugin-conf/syslog.conf ]; then + . /initramfs/plugin-conf/syslog.conf + if [ $syslog_active -ne 0 ]; then + [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'syslog' os-plugin ..."; + + . /mnt/opt/openslx/plugin-repo/syslog/syslog.sh + + [ $DEBUGLEVEL -gt 0 ] && echo "done with 'syslog' os-plugin ..."; + + fi +fi diff --git a/os-plugins/plugins/syslog/init-hooks/15-have-ip-config/syslog.sh b/os-plugins/plugins/syslog/init-hooks/15-have-ip-config/syslog.sh index 8c6218cc..3ce3ca04 100644 --- a/os-plugins/plugins/syslog/init-hooks/15-have-ip-config/syslog.sh +++ b/os-plugins/plugins/syslog/init-hooks/15-have-ip-config/syslog.sh @@ -1,7 +1,8 @@ if [ -e /initramfs/plugin-conf/syslog.conf ]; then . /initramfs/plugin-conf/syslog.conf - if [ $syslog_active -ne 0 ]; then - echo "syslogd -R $syslog_target..." - syslogd -R $syslog_target & >/dev/null 2>&1 + if [ $syslog_active -ne 0 ] && [ -n "$syslog_host" ]; then + echo "syslogd -R ${syslog_host}:${syslog_port}..." + syslogd -R "${syslog_host}:${syslog_port}" & >/dev/null 2>&1 + klogd >/dev/null 2>&1 fi fi diff --git a/os-plugins/plugins/syslog/init-hooks/95-cleanup/syslog.sh b/os-plugins/plugins/syslog/init-hooks/95-cleanup/syslog.sh new file mode 100644 index 00000000..3e112ff7 --- /dev/null +++ b/os-plugins/plugins/syslog/init-hooks/95-cleanup/syslog.sh @@ -0,0 +1,10 @@ +if [ -e /initramfs/plugin-conf/syslog.conf ]; then + . /initramfs/plugin-conf/syslog.conf + if [ $syslog_active -ne 0 ] && [ -n "$syslog_host" ]; then + # kill syslogd, as it is going to be replaced by system's syslog soon + killall syslogd + # remove links to boot.klog, as that will hang (I suppose that is + # because we already emptied /dev/kmsg) + rm /mnt/etc/init.d/boot.d/*.klog + fi +fi -- cgit v1.2.3-55-g7522