From 3d78c42740c266b4efdceda1f410f06cd4ea01f5 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Mon, 28 May 2018 19:06:17 +0000
Subject: runit-scripts: mysql run: add check of length of .err file

---
 abs/core/runit-scripts/PKGBUILD                        | 2 +-
 abs/core/runit-scripts/runitscripts/services/mysql/run | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/abs/core/runit-scripts/PKGBUILD b/abs/core/runit-scripts/PKGBUILD
index d762d43..777d89f 100755
--- a/abs/core/runit-scripts/PKGBUILD
+++ b/abs/core/runit-scripts/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=runit-scripts
 pkgver=8.5
-pkgrel=1
+pkgrel=2
 pkgdesc="collection of startup scripts for runit"
 url="http://smarden.org/runit/"
 license=('BSD')
diff --git a/abs/core/runit-scripts/runitscripts/services/mysql/run b/abs/core/runit-scripts/runitscripts/services/mysql/run
index de76962..8fad493 100755
--- a/abs/core/runit-scripts/runitscripts/services/mysql/run
+++ b/abs/core/runit-scripts/runitscripts/services/mysql/run
@@ -35,6 +35,15 @@ if [ ! -d /var/run/mysqld ]; then
   mkdir -p /var/run/mysqld
   chown mysql /var/run/mysqld
 fi
+
+#check .err and truncate if more than 30000 lines
+ErrFile="/data/srv/mysql/`hostname`.err"
+if [[ $(wc -l < $ErrFile) -gt 30000 ]]
+then
+    tail -n 30000 "$ErrFile" > "$ErrFile.tmp" && mv "$ErrFile.tmp" "$ErrFile"
+    chown mysql.mysql "$ErrFile"
+fi
+
 HOME=/etc/mysql/
 MYSQLADMIN='/usr/bin/mysqladmin'
 
-- 
cgit v0.12

