From 8b949bcf26ef6db82d0b6284ec09aa20a8f0b3ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20M=E4kinen?= Date: Thu, 8 Oct 2009 21:09:32 +0300 Subject: [PATCH] Added cron job for running myth.find_orphans.pl into mythtv::backend. --- mythtv/files/mythorphans | 43 ++++++++++++++++++++++++++++++++++++++++ mythtv/manifests/init.pp | 18 ++++++++++++++--- 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100755 mythtv/files/mythorphans diff --git a/mythtv/files/mythorphans b/mythtv/files/mythorphans new file mode 100755 index 0000000..4936ab4 --- /dev/null +++ b/mythtv/files/mythorphans @@ -0,0 +1,43 @@ +#!/bin/sh + +# read in configs +. /etc/mythtv/mysql.txt +MYTHVERSION="`rpm -q --queryformat='%{VERSION}\n' mythtv-docs`" + +if [ -z "${LocalHostName}" ]; then + LocalHostName=`hostname` +fi + +# check if we have storage directories with at least 1 video +mysql -h "${DBHostName}" -u"${DBUserName}" -p"${DBPassword}" -s \ + -e "SELECT COUNT(*) FROM recorded WHERE hostname='${LocalHostName}'" \ + "${DBName}" | egrep -q "^[1-9][0-9]*\$" || exit 0 + +# find orphans and print stats if found +perl /usr/share/doc/mythtv-docs-${MYTHVERSION}/contrib/myth.find_orphans.pl \ + --dbhost="${DBHostName}" \ + --database="${DBName}" \ + --user="${DBUserName}" \ + --pass="${DBPassword}" | awk ' + BEGIN { + data = ""; + ok = 0; + } + { + if (/[0-9]* orphaned thumbnails with no corresponding recording/) { + if ($1 > 0) { + ok = 1; + } + } + if (/[0-9]* unknown files using [0-9]*/) { + if ($1 > 0) { + ok = 1; + } + } + data = data "\n" $0 + } + END { + if (ok) { + print data; + } + }' diff --git a/mythtv/manifests/init.pp b/mythtv/manifests/init.pp index cb666a6..1db1896 100644 --- a/mythtv/manifests/init.pp +++ b/mythtv/manifests/init.pp @@ -27,7 +27,11 @@ class mythtv::backend { $mythtv_dbname = "mythconverg" } - package { ["mythtv-backend", "mythtv-setup", "mythtv-docs"]: + package { ["mythtv-backend", + "mythtv-setup", + "mythtv-docs", + "perl-DBD-MySQL", + "mysql", ]: ensure => installed, } @@ -63,6 +67,14 @@ class mythtv::backend { require => Package["mythtv-backend"], } + file { "/etc/cron.daily/mythorphans": + ensure => present, + source => "puppet:///mythtv/mythorphans", + mode => 0755, + owner => root, + group => root, + } + } @@ -72,7 +84,7 @@ class mythtv::backend { # class mythtv::cron inherits mythtv::backend { - package { [ "perl-MythTV", "perl-Net-UPnP", "perl-DBD-MySQL" ]: + package { [ "perl-MythTV", "perl-Net-UPnP" ]: ensure => installed, } @@ -111,4 +123,4 @@ class mythtv::mythweb { require => Package["mythweb"], } -} \ No newline at end of file +}