summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Smee <strerror@gentoo.org>2006-09-19 15:41:10 +0000
committerBenjamin Smee <strerror@gentoo.org>2006-09-19 15:41:10 +0000
commit1404d3047c73f58d2471a43a22db1918766b6a01 (patch)
tree343a45790c4abd9ee9a0a13a6ace62082fe44edb /app-admin/phpsyslogng/files
parentadded channel-logo support (diff)
downloadgentoo-2-1404d3047c73f58d2471a43a22db1918766b6a01.tar.gz
gentoo-2-1404d3047c73f58d2471a43a22db1918766b6a01.tar.bz2
gentoo-2-1404d3047c73f58d2471a43a22db1918766b6a01.zip
Change to fix bug #141004. Thanks to Wolf Giesen
(Portage version: 2.1.2_pre1)
Diffstat (limited to 'app-admin/phpsyslogng/files')
-rw-r--r--app-admin/phpsyslogng/files/digest-phpsyslogng-2.82
-rw-r--r--app-admin/phpsyslogng/files/digest-phpsyslogng-2.8-r13
-rw-r--r--app-admin/phpsyslogng/files/logrotate.php140
3 files changed, 145 insertions, 0 deletions
diff --git a/app-admin/phpsyslogng/files/digest-phpsyslogng-2.8 b/app-admin/phpsyslogng/files/digest-phpsyslogng-2.8
index 334fe1e2f3d4..bbe6a62e4859 100644
--- a/app-admin/phpsyslogng/files/digest-phpsyslogng-2.8
+++ b/app-admin/phpsyslogng/files/digest-phpsyslogng-2.8
@@ -1 +1,3 @@
MD5 752ec0c597f81bb8756d27b111b420f4 phpsyslogng-2.8.tar.gz 35686
+RMD160 38daab0986b42cd964a5e5f420c22408de38d1d1 phpsyslogng-2.8.tar.gz 35686
+SHA256 da1b15ac04e66f4e81aef7c7332a33004ee910fe8bd1df7756eb3f4d12b195ad phpsyslogng-2.8.tar.gz 35686
diff --git a/app-admin/phpsyslogng/files/digest-phpsyslogng-2.8-r1 b/app-admin/phpsyslogng/files/digest-phpsyslogng-2.8-r1
new file mode 100644
index 000000000000..bbe6a62e4859
--- /dev/null
+++ b/app-admin/phpsyslogng/files/digest-phpsyslogng-2.8-r1
@@ -0,0 +1,3 @@
+MD5 752ec0c597f81bb8756d27b111b420f4 phpsyslogng-2.8.tar.gz 35686
+RMD160 38daab0986b42cd964a5e5f420c22408de38d1d1 phpsyslogng-2.8.tar.gz 35686
+SHA256 da1b15ac04e66f4e81aef7c7332a33004ee910fe8bd1df7756eb3f4d12b195ad phpsyslogng-2.8.tar.gz 35686
diff --git a/app-admin/phpsyslogng/files/logrotate.php b/app-admin/phpsyslogng/files/logrotate.php
new file mode 100644
index 000000000000..d3e1d42577e3
--- /dev/null
+++ b/app-admin/phpsyslogng/files/logrotate.php
@@ -0,0 +1,140 @@
+#!/usr/bin/php
+<?php
+// Copyright (C) 2005 Claus Lund, clauslund@gmail.com
+
+echo "\nStarting logrotate\n";
+echo date("Y-m-d H:i:s\n");
+
+$APP_ROOT = '/data/www/localhost/htdocs/phpsyslogng';
+
+include_once "$APP_ROOT/includes/common_funcs.php";
+include_once "$APP_ROOT/config/config.php";
+
+$dbLink = db_connect_syslog(DBADMIN, DBADMINPW);
+
+echo "Dropping temp".DEFAULTLOGTABLE." if it exists ... ";
+// Drop temp table if it exists
+$query = "DROP TABLE IF EXISTS temp".DEFAULTLOGTABLE;
+perform_query($query, $dbLink);
+echo "ok.\n";
+
+echo "Creating ".DEFAULTLOGTABLE." ... ";
+// Create new table
+$query = "SHOW CREATE TABLE ".DEFAULTLOGTABLE;
+$result = perform_query($query, $dbLink);
+echo "ok.\n";
+
+$row = mysql_fetch_array($result);
+$createQuery = $row[1];
+$search = "CREATE TABLE `".DEFAULTLOGTABLE."`";
+$replace = "CREATE TABLE `temp".DEFAULTLOGTABLE."`";
+$createQuery = str_replace($search, $replace, $createQuery);
+perform_query($createQuery, $dbLink);
+
+$today = date("Ymd");
+
+// Drop the merge table
+if(defined('MERGELOGTABLE') && MERGELOGTABLE)
+ {
+ $query = "FLUSH TABLES";
+ perform_query($query, $dbLink);
+
+ echo "Dropping ".MERGELOGTABLE." if it exists ... ";
+ $query = "DROP TABLE IF EXISTS ".MERGELOGTABLE;
+ perform_query($query, $dbLink);
+ echo "ok.\n";
+ }
+
+// Rename the two tables
+echo "Renaming ".DEFAULTLOGTABLE." to ".DEFAULTLOGTABLE.$today." and temp".DEFAULTLOGTABLE." to ".DEFAULTLOGTABLE." ... ";
+$query = "RENAME TABLE ".DBNAME.".".DEFAULTLOGTABLE." TO ".DBNAME.".".DEFAULTLOGTABLE.$today.", ".DBNAME.".temp".DEFAULTLOGTABLE." TO ".DBNAME.".".DEFAULTLOGTABLE;
+perform_query($query, $dbLink);
+echo "ok.\n";
+
+echo "\nLog rotate ended successfully.\n";
+echo "Now optimizing old logs.\n";
+$query = "OPTIMIZE TABLE ".DBNAME.".".DEFAULTLOGTABLE.$today;
+perform_query($query, $dbLink);
+
+// Re-create the merge table
+if(defined('MERGELOGTABLE') || defined('LOGROTATERETENTION'))
+ {
+ echo "Getting list of log tables.\n";
+ $logTableArray = get_logtables($dbLink);
+ }
+
+if(defined('LOGROTATERETENTION') && LOGROTATERETENTION)
+ {
+ echo "Retention is in use, searching for tables to drop:";
+ foreach($logTableArray as $value)
+ {
+ if(preg_match("/[0-9]+$/", $value))
+ {
+ // determine is datestamp is old enough
+ $tableDate = strrev(substr(strrev($value), 0, 8));
+ $cutoffDate = date("Ymd", mktime(0, 0, 0, date("m"), date("d")-LOGROTATERETENTION, date("Y")));
+
+// printf(" [cutoffDate: %s tableDate %s] ", $cutoffDate, (intval($cutoffDate) > intval($tableDate)) ? ">":"<=", $tableDate);
+
+ if(intval($cutoffDate) > intval($tableDate))
+ {
+ $query = "DROP TABLE ".$value;
+ perform_query($query, $dbLink);
+ }
+ }
+ }
+ }
+
+if(defined('MERGELOGTABLE') && MERGELOGTABLE)
+ {
+ echo "Creating merge table:\n";
+ $query = "SHOW CREATE TABLE ".DEFAULTLOGTABLE;
+
+ $result = perform_query($query, $dbLink);
+ $row = mysql_fetch_array($result);
+ $createQuery = $row[1];
+
+ $oldStr = "CREATE TABLE `".DEFAULTLOGTABLE."`";
+ $newStr = "CREATE TABLE `".MERGELOGTABLE."`";
+ $createQuery = str_replace($oldStr, $newStr, $createQuery);
+
+ $oldStr = "ENGINE=MyISAM";
+ $newStr = "ENGINE=MRG_MyISAM";
+ $createQuery = str_replace($oldStr, $newStr, $createQuery);
+ $oldStr = "TYPE=MyISAM";
+ $newStr = "ENGINE=MRG_MyISAM";
+ $createQuery = str_replace($oldStr, $newStr, $createQuery);
+
+ $createQuery = str_replace('PRIMARY KEY', 'INDEX', $createQuery);
+
+ // Re-create the merge table data (after some stuff has been dropped above by cutoffDate
+ if(defined('MERGELOGTABLE') || defined('LOGROTATERETENTION'))
+ {
+ echo "Getting list of log tables.\n";
+ $logTableArray = get_logtables($dbLink);
+ }
+
+ $unionStr = " UNION=(";
+ foreach($logTableArray as $value)
+ {
+ $unionStr = $unionStr.$value.", ";
+ }
+ $unionStr = rtrim($unionStr, ", ");
+ $unionStr = $unionStr.")";
+
+ $createQuery = $createQuery.$unionStr;
+
+ $flushQuery = "FLUSH TABLES";
+ perform_query($flushQuery, $dbLink);
+
+ perform_query($createQuery, $dbLink);
+
+ $flushQuery = "FLUSH TABLES";
+ perform_query($flushQuery, $dbLink);
+
+ echo "ok,\n";
+ }
+
+echo "\n".date("Y-m-d H:i:s")."\n";
+echo "All done!\n";
+?>