summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/myth_mtc.cron
blob: d3dc50ac632c0eb557f45a6822b9c1a8c833fd1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
MYTH_RUN_STATUS=1
. /etc/profile

date=`date +%Y-%m-%d`
timestamp=`date +'%Y-%m-%d %H:%M'`
hostname=`hostname`
logFile="/var/log/${date}/${hostname}_myth_mtc.log"
log="logger -t myth_mtc -p local6.info"

if [ ! -f $logFile ]; then
    touch $logFile
    echo "" | $log
fi

#check logfile for Finished and if not run myth_mtc.py
if ! grep -q "Finished Maintenance" $logFile
then
    if ! grep -q "Finished Optimize" $logFile
    then
        MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --optimize | $log
        if [ $? = 0 ]
        then
            echo "" | $log
        else
            echo "Time Exceeded" | $log
            exit
        fi
    fi

    if ! grep -q "Finished Backup" $logFile && grep -q "Finished Optimize" $logFile
    then
        MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --backup | $log
        if [ $? = 0 ]
        then
            echo "" | $log
        else
            echo "Time Exceeded" | $log
            exit
        fi
    fi

    if ! grep -q "Finished Update" $logFile
    then
        MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py --update | $log
        if [ $? = 0 ]
        then
            echo "" | $log
        else
            echo "Time Exceeded" | $log
            exit
        fi
    fi

    if grep -q "Finished Optimize" $logFile && grep -q "Finished Backup" $logFile && grep -q "Finished Update" $logFile
    then
        echo "Finished Maintenance" | $log
    fi
fi