From db5e198de1e368a2202460089f9d00a52947d4f6 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Wed, 7 Dec 2011 13:18:43 -0600
Subject: rsyslog: first build, this replaces syslog-ng /var/log will now have
 the format of /var/log/$DATE/$log_files

---
 abs/core/rsyslog/PKGBUILD            | 58 ++++++++++++++++++++++++
 abs/core/rsyslog/log_care.sh         |  8 ++++
 abs/core/rsyslog/rsyslog             | 39 ++++++++++++++++
 abs/core/rsyslog/rsyslog.conf.d      |  6 +++
 abs/core/rsyslog/rsyslog.conf.linhes | 86 ++++++++++++++++++++++++++++++++++++
 abs/core/rsyslog/rsyslog.install     | 16 +++++++
 6 files changed, 213 insertions(+)
 create mode 100644 abs/core/rsyslog/PKGBUILD
 create mode 100644 abs/core/rsyslog/log_care.sh
 create mode 100644 abs/core/rsyslog/rsyslog
 create mode 100644 abs/core/rsyslog/rsyslog.conf.d
 create mode 100644 abs/core/rsyslog/rsyslog.conf.linhes
 create mode 100644 abs/core/rsyslog/rsyslog.install

diff --git a/abs/core/rsyslog/PKGBUILD b/abs/core/rsyslog/PKGBUILD
new file mode 100644
index 0000000..0422880
--- /dev/null
+++ b/abs/core/rsyslog/PKGBUILD
@@ -0,0 +1,58 @@
+# $Id: PKGBUILD 58329 2011-11-11 14:26:11Z spupykin $
+# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
+
+pkgname=rsyslog
+pkgver=5.8.6
+pkgrel=1
+pkgdesc="An enhanced multi-threaded syslogd with a focus on security and reliability"
+url="http://www.rsyslog.com/"
+arch=('i686' 'x86_64')
+license=('GPL3')
+depends=('zlib')
+makedepends=( 'libmysqlclient'  'gnutls')
+optdepends=( 'libmysqlclient: MySQL Database Support'
+	    'gnutls')
+backup=('etc/rsyslog.conf' \
+	'etc/logrotate.d/rsyslog'
+	'etc/conf.d/rsyslog')
+conflicts=('syslog-ng')
+replaces=('syslog-ng')
+groups=('base')
+ 
+options=('strip' 'zipman' '!libtool')
+install=('rsyslog.install')
+source=("http://www.rsyslog.com/files/download/rsyslog/rsyslog-$pkgver.tar.gz"
+	'rsyslog'
+	'rsyslog.logrotate'
+	'rsyslog.conf.d' 'rsyslog.conf.linhes' log_care.sh)
+
+build() {
+  cd ${srcdir}/${pkgname}-${pkgver}
+  ./configure --prefix=/usr \
+              --enable-mysql \
+              --enable-mail \
+              --enable-imfile \
+              --enable-imtemplate \
+              --enable-gnutls \
+              --enable-inet \
+              --with-systemdsystemunitdir=/lib/systemd/system
+  make
+}
+package() {
+  cd ${srcdir}/${pkgname}-${pkgver}
+  make install DESTDIR=${pkgdir}
+  # Install Daemons and Configuration Files
+  install -D -m755 ${srcdir}/${pkgname} ${pkgdir}/etc/rc.d/${pkgname}d
+  install -D -m644 $srcdir/${pkgname}.conf.linhes ${pkgdir}/etc/${pkgname}.conf
+  mkdir -p  ${pkgdir}/etc/rsyslog.d/
+  touch ${pkgdir}/etc/rsyslog.d/empty.conf
+  install -D -m644 $srcdir/${pkgname}.logrotate ${pkgdir}/etc/logrotate.d/${pkgname}
+  install -D -m644 ${srcdir}/${pkgname}.conf.d ${pkgdir}/etc/conf.d/${pkgname}
+  install -D -m755 ${srcdir}/log_care.sh ${pkgdir}/etc/cron.daily/log_care
+}
+md5sums=('c46db0496066b82faf735bd4222208d7'
+         'a18bbcbb6ebdaa13a6ec6d9f3d9eb2da'
+         '8065db4bef3061a4f000ba58779f6829'
+         '1a0cd4530dd5d1439456d5ae230574d9'
+         '1e4a87a2ffea61c066a0b01fc9392849'
+         '5a4719b7283bba9fc497013848bf5c5c')
diff --git a/abs/core/rsyslog/log_care.sh b/abs/core/rsyslog/log_care.sh
new file mode 100644
index 0000000..4337828
--- /dev/null
+++ b/abs/core/rsyslog/log_care.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+. /etc/profile
+DATE=`date +%Y`
+echo "compressing log files"
+find /var/log/$DATE* -mtime  +1 -exec gzip -9 {} \;
+echo "Deleting older log files"
+find /var/log/$DATE*  -mtime +7  -exec rm -rf {} \;
+
diff --git a/abs/core/rsyslog/rsyslog b/abs/core/rsyslog/rsyslog
new file mode 100644
index 0000000..ee01454
--- /dev/null
+++ b/abs/core/rsyslog/rsyslog
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /etc/conf.d/rsyslog
+
+PID=`pidof -o %PPID /usr/sbin/rsyslogd`
+case "$1" in
+  start)
+    stat_busy "Starting RSyslogd"
+    [ -z "$PID" ] && /usr/sbin/rsyslogd $RSYSLOGD_ARGS
+    if [ $? -gt 0 ]; then
+      stat_fail
+    else
+      add_daemon rsyslogd
+      stat_done
+    fi
+    ;;
+  stop)
+    stat_busy "Stopping RSyslogd"
+    [ ! -z "$PID" ]  && kill $PID &> /dev/null
+    if [ $? -gt 0 ]; then
+      stat_fail
+    else
+      rm -f /var/run/rsyslogd.pid
+      rm -f /var/rsyslogd.persist
+      rm_daemon rsyslogd
+      stat_done
+    fi
+    ;;
+  restart)
+    $0 stop
+    sleep 1
+    $0 start
+    ;;
+  *)
+    echo "usage: $0 {start|stop|restart}"  
+esac
+exit 0
diff --git a/abs/core/rsyslog/rsyslog.conf.d b/abs/core/rsyslog/rsyslog.conf.d
new file mode 100644
index 0000000..e39f8c3
--- /dev/null
+++ b/abs/core/rsyslog/rsyslog.conf.d
@@ -0,0 +1,6 @@
+#
+# Parameters to be passed to rsyslogd
+# This should almost certainly include at least the current compatability
+# level, e.g. -c4
+#
+RSYSLOGD_ARGS="-c4"
diff --git a/abs/core/rsyslog/rsyslog.conf.linhes b/abs/core/rsyslog/rsyslog.conf.linhes
new file mode 100644
index 0000000..ab6d56f
--- /dev/null
+++ b/abs/core/rsyslog/rsyslog.conf.linhes
@@ -0,0 +1,86 @@
+# if you experience problems, check
+# http://www.rsyslog.com/troubleshoot for assistance
+
+# rsyslog v3: load input modules
+# If you do not load inputs, nothing happens!
+# You may need to set the module load path if modules are not found.
+
+$ModLoad immark   # provides --MARK-- message capability
+$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
+$ModLoad imklog   # kernel logging (formerly provided by rklogd)
+$FileCreateMode 0644
+$DirCreateMode 0755
+
+# Log all kernel messages to the console.
+# Logging much else clutters up the screen.
+#kern.*                                                 /dev/console
+$template DailyPerHostLogs,"/var/log//%$YEAR%-%$MONTH%-%$DAY%/%HOSTNAME%_messages.log"
+$template DynFile,"/var/log/%$YEAR%-%$MONTH%-%$DAY%/%HOSTNAME%_%programname%.log"
+$template DynMail,"/var/log/%$YEAR%-%$MONTH%-%$DAY%/%HOSTNAME%_maillog"
+$template DynCron,"/var/log/%$YEAR%-%$MONTH%-%$DAY%/%HOSTNAME%_cron"
+$template DynBoot,"/var/log/%$YEAR%-%$MONTH%-%$DAY%/%HOSTNAME%_boot.log"
+$template DynSpooler,"/var/log/%$YEAR%-%$MONTH%-%$DAY%/%HOSTNAME%_spooler"
+
+if $programname contains 'lighttpd' then ?DynFile
+& ~
+# Log anything (except mail) of level info or higher.
+# Don't log private authentication messages!
+#*.info;mail.none;authpriv.none;cron.none                -/var/log/messages
+*.info;mail.none;authpriv.none;cron.none                -?DailyPerHostLogs
+
+# The authpriv file has restricted access.
+#authpriv.*                                              /var/log/secure
+authpriv.*                                              ?DynFile
+
+# Log all the mail messages in one place.
+#mail.*                                                  -/var/log/maillog
+mail.*                                                  ?DynMail
+
+
+# Log cron stuff
+#cron.*                                                  -/var/log/cron
+cron.*                                                  ?DynCron
+
+# Everybody gets emergency messages
+*.emerg                                                 *
+
+# Save news errors of level crit and higher in a special file.
+#uucp,news.crit                                          -/var/log/spooler
+uucp,news.crit                                          -?DynSpooler
+
+# Save boot messages also to boot.log
+#local7.*                                                /var/log/boot.log
+local7.*                                                ?DynBoot
+
+# Remote Logging (we use TCP for reliable delivery)
+# An on-disk queue is created for this action. If the remote host is
+# down, messages are spooled to disk and sent when it is up again.
+#$WorkDirectory /rsyslog/spool # where to place spool files
+#$ActionQueueFileName uniqName # unique name prefix for spool files
+#$ActionQueueMaxDiskSpace 1g   # 1gb space limit (use as much as possible)
+#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
+#$ActionQueueType LinkedList   # run asynchronously
+#$ActionResumeRetryCount -1    # infinite retries if host is down
+
+$IncludeConfig /etc/rsyslog.d/*.conf
+
+# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
+
+#*.* @@localhost:514
+
+# ######### Receiving Messages from Remote Hosts ########## 
+# TCP Syslog Server:
+# provides TCP syslog reception and GSS-API (if compiled to support it)
+#$ModLoad imtcp.so  # load module
+#$InputTCPServerRun 514 # start up TCP listener at port 514
+# UDP Syslog Server:
+#$ModLoad imudp.so  # provides UDP syslog reception
+#$UDPServerRun 514 # start a UDP syslog server at standard port 514
+
+
+
+
+#$ModLoad ommysql # load MySQL functionality
+
+#*.* :ommysql:vmbe,Syslog,syslog,passwd
+
diff --git a/abs/core/rsyslog/rsyslog.install b/abs/core/rsyslog/rsyslog.install
new file mode 100644
index 0000000..2153832
--- /dev/null
+++ b/abs/core/rsyslog/rsyslog.install
@@ -0,0 +1,16 @@
+# arg 1:  the new package version
+# arg 2:  the old package version
+
+post_install() {
+   remove_service.sh syslog-ng
+   add_service.sh rsyslog
+   if [ ! -e /var/log/old_syslog ]
+   then
+   	mkdir -p /var/log/old_sysng
+        mv /var/log/*log* /var/log/old_sysng
+	echo "#########################################"
+	echo "/var/log/old_sysng contains old log files"
+	echo "it may be removed at your convenience"
+	echo "#########################################"
+   fi
+}
-- 
cgit v0.12