diff --git a/cyphesis.spec b/cyphesis.spec index 5453980..12d57ff 100644 --- a/cyphesis.spec +++ b/cyphesis.spec @@ -1,9 +1,15 @@ %define selinux_variants mls strict targeted %define selinux_policyver %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp) +#%define logwatch_root %{_sysconfdir}/logwatch +#%define logwatch_conf %{logwatch_root}/conf +%define logwatch_root %{_datadir}/logwatch +%define logwatch_conf %{logwatch_root}/dist.conf +%define logwatch_scripts %{logwatch_root}/scripts + Name: cyphesis Version: 0.5.11 -Release: 1%{?dist} +Release: 1%{?dist}.2 Summary: WorldForge game server Group: System Environment/Libraries License: GPL @@ -12,6 +18,10 @@ Source0: http://dl.sourceforge.net/worldforge/%{name}-%{version}.tar.gz Source1: cyphesis.te Source2: cyphesis.if Source3: cyphesis.fc +Source4: logwatch.logconf.cyphesis +Source5: logwatch.script.cyphesis +Source6: logwatch.serviceconf.cyphesis +Source7: logwatch.shared.applycyphesisdate Patch0: cyphesis-0.5.8-init.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: python-devel libgcrypt-devel pkgconfig atlascpp-devel @@ -19,9 +29,6 @@ BuildRequires: varconf-devel libsigc++20-devel mercator-devel skstream-devel BuildRequires: postgresql-devel readline-devel avahi-devel BuildRequires: checkpolicy selinux-policy-devel hardlink -%if "%{selinux_policyver}" != "" -Requires: selinux-policy >= %{selinux_policyver} -%endif Requires: postgresql-server Requires(post): /sbin/chkconfig Requires(post): /sbin/service @@ -41,12 +48,22 @@ It is the server used in most current WorldForge games. Summary: SELinux policy files for the WorldForge game server Group: Amusements/Games Requires: %{name} = %{version}-%{release} +%if "%{selinux_policyver}" != "" +Requires: selinux-policy >= %{selinux_policyver} +%endif Requires(post): /usr/sbin/semodule /usr/sbin/semanage /sbin/fixfiles Requires(preun): /sbin/service /usr/sbin/semodule /usr/sbin/semanage /sbin/fixfiles /usr/sbin/setsebool Requires(postun): /usr/sbin/semodule %description selinux SELinux policy files for the WorldForge game server +%package logwatch +Summary: logwatch scripts for the WorldForge game server +Group: Amusements/Games +Requires: %{name} = %{version}-%{release} logwatch +%description logwatch +logwatch scripts for the WorldForge game server + %prep %setup -q @@ -88,6 +105,13 @@ install -m 755 %{name}.init %{buildroot}%{_sysconfdir}/init.d/%{name} install -d %{buildroot}%{_sysconfdir}/sysconfig install -m 644 %{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name} +# Install logwatch files +install -pD -m 0644 %{SOURCE4} %{buildroot}%{logwatch_conf}/logfiles/%{name}.conf +install -pD -m 0755 %{SOURCE5} %{buildroot}%{logwatch_scripts}/services/%{name} +install -pD -m 0644 %{SOURCE6} %{buildroot}%{logwatch_conf}/services/%{name}.conf +install -pD -m 0755 %{SOURCE7} %{buildroot}%{logwatch_scripts}/shared/applycyphesisdate + + # Install selinux policies pushd SELinux for variant in %{selinux_variants} @@ -178,6 +202,13 @@ rm -rf %{buildroot} %config(noreplace) %{_sysconfdir}/sysconfig/%{name} %{_datadir}/%{name} +%files logwatch +%defattr(-,root,root,-) +%{logwatch_conf}/logfiles/%{name}.conf +%{logwatch_conf}/services/%{name}.conf +%{logwatch_scripts}/services/%{name} +%{logwatch_scripts}/shared/applycyphesisdate + %files selinux %defattr(-,root,root,-) %doc SELinux/*.?? @@ -185,8 +216,12 @@ rm -rf %{buildroot} %changelog +* Sat Feb 24 2007 Wart 0.5.11-2 +- Add logwatch subpackage +- Move log file to /var/log directory + * Wed Jan 24 2007 Wart 0.5.11-1 -- Update to 0.5.11 with python 1.5 support +- Update to 0.5.11 with builtin python 2.5 support - Updated selinux policy * Thu Dec 14 2006 Wart 0.5.10-4 diff --git a/logwatch.logconf.cyphesis b/logwatch.logconf.cyphesis new file mode 100644 index 0000000..3a8e6f1 --- /dev/null +++ b/logwatch.logconf.cyphesis @@ -0,0 +1,10 @@ +########################################################################## +########################################################################## + +# What actual file? Defaults to LogPath if not absolute path.... +LogFile = /var/tmp/cyphesis_event.log + +# Keep only the lines in the proper date range... +*ApplyCyphesisDate + +# vi: shiftwidth=3 tabstop=3 et diff --git a/logwatch.script.cyphesis b/logwatch.script.cyphesis new file mode 100755 index 0000000..bed1baa --- /dev/null +++ b/logwatch.script.cyphesis @@ -0,0 +1,136 @@ +########################################################################## +########################################################################## + +use strict; + +my ($junk, $Msg, $total); +my %Action = (); +my %Start = (); +my %Login = (); +my %TakeChar = (); +my %DropChar = (); +my %Logout = (); + +my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0; + +# Interesting events: +#2007-02-17 12:45:22 START - - - Standalone server startup +#2007-02-17 12:56:58 LOGIN 2158 2159 - Create account wart +#2007-02-17 12:57:03 TAKE_CHAR 2158 2159 2160 Created character wart(settler) by account wart +#2007-02-17 12:57:43 DROP_CHAR 2158 - 2160 Logout character wart(settler) +#2007-02-17 12:57:43 LOGOUT 2158 2159 - Logout account wart + + +while (defined(my $ThisLine = )) { + chomp($ThisLine); + if ( ($Msg) = ($ThisLine =~ /START - - - (.*)$/)) { + $Start{$Msg}++; + } + if ( ($Msg) = ($ThisLine =~ /LOGIN [-0-9]+ [-0-9]+ [-0-9]+ (.*)$/)) { + $Login{$Msg}++; + } + if ( ($Msg) = ($ThisLine =~ /TAKE_CHAR [-0-9]+ [-0-9]+ [-0-9]+ (.*)$/)) { + $TakeChar{$Msg}++; + } + if ( ($Msg) = ($ThisLine =~ /DROP_CHAR [-0-9]+ [-0-9]+ [-0-9]+ (.*)$/)) { + $DropChar{$Msg}++; + } + if ( ($Msg) = ($ThisLine =~ /LOGOUT [-0-9]+ [-0-9]+ [-0-9]+ (.*)$/)) { + $Logout{$Msg}++; + } +} + +if (keys %Start) { + if ($Detail >= 5) { + foreach my $Msg (sort keys %Start) { + if ($Start{$Msg} > 1) { + print "$Msg ($Start{$Msg} times)\n" + } else { + print "$Msg\n" + } + } + } else { + my $total; + foreach my $Msg (sort keys %Start) { + $total += $Start{$Msg}; + } + print "Server started $total times\n"; + } +} + +if (keys %Login) { + if ($Detail >= 5) { + foreach my $Msg (sort keys %Login) { + if ($Login{$Msg} > 1) { + print "$Msg ($Login{$Msg} times)\n" + } else { + print "$Msg\n" + } + } + } else { + my $total; + foreach my $Msg (sort keys %Login) { + $total += $Login{$Msg}; + } + print "$total Users logged in\n"; + } +} + +if (keys %TakeChar) { + if ($Detail >= 5) { + foreach my $Msg (sort keys %TakeChar) { + if ($TakeChar{$Msg} > 1) { + print "$Msg ($TakeChar{$Msg} times)\n" + } else { + print "$Msg\n" + } + } + } else { + my $total; + foreach my $Msg (sort keys %TakeChar) { + $total += $TakeChar{$Msg}; + } + print "$total characters entered the world\n"; + } +} + +if (keys %DropChar) { + if ($Detail >= 5) { + foreach my $Msg (sort keys %DropChar) { + if ($DropChar{$Msg} > 1) { + print "$Msg ($DropChar{$Msg} times)\n" + } else { + print "$Msg\n" + } + } + } else { + my $total; + foreach my $Msg (sort keys %DropChar) { + $total += $DropChar{$Msg}; + } + print "$total characters left the world\n"; + } +} + +if (keys %Logout) { + if ($Detail >= 5) { + foreach my $Msg (sort keys %Logout) { + if ($Logout{$Msg} > 1) { + print "$Msg ($Logout{$Msg} times)\n" + } else { + print "$Msg\n" + } + } + } else { + my $total; + foreach my $Msg (sort keys %Logout) { + $total += $Logout{$Msg}; + } + print "$total players logged out\n"; + } +} + +exit(0); + +# vi: shiftwidth=3 tabstop=3 syntax=perl et + diff --git a/logwatch.serviceconf.cyphesis b/logwatch.serviceconf.cyphesis new file mode 100644 index 0000000..67a5c74 --- /dev/null +++ b/logwatch.serviceconf.cyphesis @@ -0,0 +1,19 @@ +########################################################################### +########################################################################### + +# You can put comments anywhere you want to. They are effective for the +# rest of the line. + +# this is in the format of = . Whitespace at the beginning +# and end of the lines is removed. Whitespace before and after the = sign +# is removed. Everything is case *insensitive*. + +# Yes = True = On = 1 +# No = False = Off = 0 + +Title = "Cyphesis" + +# Which logfile group... +LogFile = cyphesis + +# vi: shiftwidth=3 tabstop=3 et diff --git a/logwatch.shared.applycyphesisdate b/logwatch.shared.applycyphesisdate new file mode 100755 index 0000000..134e933 --- /dev/null +++ b/logwatch.shared.applycyphesisdate @@ -0,0 +1,30 @@ +########################################################################## +# $Id$ +########################################################################## + +######################################################## +# This was written and is maintained by: +# Kirk Bauer +# +# Please send all comments, suggestions, bug reports, +# etc, to logwatch-devel@logwatch.org +######################################################## + +use Logwatch ':dates'; + +my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0; + +$SearchDate = TimeFilter('%Y-%m-%d %H:%M:%S'); + +if ( $Debug > 5 ) { + print STDERR "DEBUG: Inside ApplyCyphesisDate...\n"; + print STDERR "DEBUG: Looking For: " . $SearchDate . "\n"; +} + +while (defined($ThisLine = )) { + if ($ThisLine =~ m/^$SearchDate /o) { + print $ThisLine; + } +} + +# vi: shiftwidth=3 syntax=perl tabstop=3 et