From 5e888f1eabe71d3bf51f1af7f6920a9794d979f6 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Sat, 11 Feb 2023 23:05:55 -0500
Subject: linhes-system: lh_system_start.sh: start mythfrontend and log to
 syslog and don't start if ~/.dontstartmythfrontend exists

lh_log_care: add to cron.daily
---
 linhes/linhes-system/PKGBUILD           |  8 +++++---
 linhes/linhes-system/lh_log_care.cron   | 16 ++++++++++++++++
 linhes/linhes-system/lh_system_start.sh |  6 ++++--
 3 files changed, 25 insertions(+), 5 deletions(-)
 create mode 100755 linhes/linhes-system/lh_log_care.cron

diff --git a/linhes/linhes-system/PKGBUILD b/linhes/linhes-system/PKGBUILD
index 28fe77a..e87ffad 100755
--- a/linhes/linhes-system/PKGBUILD
+++ b/linhes/linhes-system/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=linhes-system
 pkgver=9.0.0
-pkgrel=40
+pkgrel=41
 arch=('x86_64')
 #install=$pkgname.install
 pkgdesc="Everything that makes LinHES a system"
@@ -18,7 +18,7 @@ binfiles="add_storage.py balance_storage_groups.py empty_storage_groups.py remov
           myth2mkv myth2mp3 udev_link.sh"
 source=($binfiles
     'myth_mtc.cron' 'paccache.cron' 'flatpak_update.cron' 'xfs_defrag.cron'
-    'readme_is_xml' 'add_storage.readme' 'LinHES-release'
+    'readme_is_xml' 'add_storage.readme' 'LinHES-release' 'lh_log_care.cron'
     '79-cronie.hook' 'fstrim.hook' 'openssh.hook' 'plex_lib.conf' 'rsyslog.hook'
     '10-monitor.conf' 'x11vnc.override.conf' 'lh_lighttpd.conf' 'lh_php.ini'
     'system-sudo.rules' 'linhes-profile.sh' 'lh_sqlserver.cnf'
@@ -30,7 +30,7 @@ sha256sums=('525bfe29b63d3ec5a17a32fa29745e24070020490c3f5b6dd6b03250348fb324'
             'c7a2b2de44645e3a905b39d7411e5b8b27b60bd2944533fd4655c3b175755da1'
             'ae34515e144830f424d3bd3f6b1b446892d62beed20bca6f0fb19b0bbb779f27'
             '5e6d128f879b0fe7c1a190cccd75d4e5d00afc161f3bc9e92ffa2d87242cc9df'
-            '1c4f9f7b2b3e5c7b6e0208b6ba47d8748da1052dc33a89182aa1315f9c95fe32'
+            '644414148e514e4a56d68959cb427ddde4129a961cbf09cd1a0a39129d58a0b1'
             '6d4fb0ed1a5ed961b3a3884dce093118e50c2981a9cd5837d20abc5a6d4fd8aa'
             '87875d9e5f5ce18208f419698ce69b6bcbcd08955a57a4a13940e715af58b787'
             '91bdec992bb2c933e15625c181f2195c402060b879168ebf35944cb064c904b9'
@@ -56,6 +56,7 @@ sha256sums=('525bfe29b63d3ec5a17a32fa29745e24070020490c3f5b6dd6b03250348fb324'
             '5f502b1bc8815d69c802320790745e4526d5817fd8ecc7b00cf8b16078f8d440'
             '12e424432bdf2d50afe3e632c018fef847e860a35a53525eccbe656b9c4118aa'
             'ee745056d018f860572f8363ed5e730ba501394c23cdd6f316719d7141c10050'
+            '77fc99fee33387a91e158c0a4e6f3d99601e4d27d04e26d3f815634f48de6a79'
             '0fbc05f521aea83157c5e6f8bd29a422873093bb6cded965cb7ffe98ff776fa4'
             '4c29e0b71071ae9556cf2dbd75de560d028577fe5eb993113105112c4b445eac'
             '890482242434e333024c7819e8bf3c889dc16548d0a1745479c8523930fb32f7'
@@ -124,6 +125,7 @@ package() {
     install -Dm755 $srcdir/xfs_defrag.cron $pkgdir/etc/cron.weekly/xfs_defrag
     install -Dm755 $srcdir/myth_mtc.cron $pkgdir/etc/cron.hourly/myth_mtc
     install -Dm755 $srcdir/flatpak_update.cron $pkgdir/etc/cron.daily/flatpak_update
+    install -Dm755 $srcdir/lh_log_care.cron $pkgdir/etc/cron.daily/lh_log_care
 
     #hooks
 	install -Dm0644 $srcdir/79-cronie.hook "${pkgdir}"/usr/share/libalpm/hooks/79-cronie.hook
diff --git a/linhes/linhes-system/lh_log_care.cron b/linhes/linhes-system/lh_log_care.cron
new file mode 100755
index 0000000..ace0534
--- /dev/null
+++ b/linhes/linhes-system/lh_log_care.cron
@@ -0,0 +1,16 @@
+#!/bin/bash
+MYTH_RUN_STATUS=1
+. /etc/profile
+
+BackupDir="/var/log/20*-*-*"
+KeepBackups=14
+NumBackups=`ls -d $BackupDir | wc -l`
+
+if [[ $NumBackups > $KeepBackups ]]; then
+    echo "Deleting old log files"
+    numdel=$(($NumBackups-$KeepBackups))
+    rm -rf `ls -d $BackupDir | head -$numdel`
+fi
+
+echo "Compressing log files"
+find $BackupDir -type f -mtime +6 \( ! -iname "*.gz" \) -exec gzip -9 {} \;
diff --git a/linhes/linhes-system/lh_system_start.sh b/linhes/linhes-system/lh_system_start.sh
index 715af91..a4cee16 100755
--- a/linhes/linhes-system/lh_system_start.sh
+++ b/linhes/linhes-system/lh_system_start.sh
@@ -141,8 +141,10 @@ function first_configure(){
 }
 
 function start_myth() {
-    STARTCMD="/usr/bin/mythfrontend --systemd-journal"
-    $STARTCMD 2>&1 &
+    STARTCMD="/usr/bin/mythfrontend --syslog local6"
+    if [ ! -f ~/.dontrunmythfrontend ]; then
+        $STARTCMD 2>&1 &
+    fi
 }
 
 #-------MAIN-------
-- 
cgit v0.12