diff options
Diffstat (limited to 'linhes/linhes-system/lh_mtc.cron')
| -rw-r--r-- | linhes/linhes-system/lh_mtc.cron | 86 | 
1 files changed, 86 insertions, 0 deletions
| diff --git a/linhes/linhes-system/lh_mtc.cron b/linhes/linhes-system/lh_mtc.cron new file mode 100644 index 0000000..75610b5 --- /dev/null +++ b/linhes/linhes-system/lh_mtc.cron @@ -0,0 +1,86 @@ +#!/bin/bash +MYTH_RUN_STATUS=1 +. /etc/systemconfig +. /etc/profile + +date=`date +%Y-%m-%d` +timestamp=`date +'%Y-%m-%d %H:%M'` +hostname=`/usr/bin/hostnamectl hostname` +logFile="/var/log/${date}/${hostname}_lh_mtc.log" +log="logger -t lh_mtc -p local6.info" + +if [ ! -f $logFile ]; then +    touch $logFile +    echo "" | $log +fi + +#check logfile for Finished and if not run lh_mtc.py +if ! grep -q "Finished Maintenance" $logFile +then + +    if ! grep -q "Finished checking size of MythTV home" $logFile +    then +        sudo -u mythtv bash -c "MYTHCONFDIR=/usr/share/mythtv unbuffer lh_mtc.py --check_home | $log" +        if [ $? = 0 ] +        then +            echo "" | $log +        else +            echo "Time Exceeded" | $log +            exit +        fi +    fi + +    if ! grep -q "Finished Optimize" $logFile +    then +        if [ $SystemType = MasterBackend ] +        then +            sudo -u mythtv bash -c "MYTHCONFDIR=/usr/share/mythtv unbuffer lh_mtc.py --optimize | $log" +            if [ $? = 0 ] +            then +                echo "" | $log +            else +                echo "Time Exceeded" | $log +                exit +            fi +        else +            echo "Will not run Optimize on Frontend or Desktop Only systems." | $log +            echo "Finished Optimize" | $log +        fi +    fi + +    if ! grep -q "Finished Backup" $logFile && grep -q "Finished Optimize" $logFile +    then +        if [ $SystemType != DesktopOnly ] +        then +            sudo -u mythtv bash -c "MYTHCONFDIR=/usr/share/mythtv unbuffer lh_mtc.py --backup | $log" +            if [ $? = 0 ] +            then +                echo "" | $log +            else +                echo "Time Exceeded" | $log +                exit +            fi +        else +            echo "Will not run Backup on Desktop Only systems." | $log +            echo "Finished Backup" | $log +        fi +    fi + +#    if ! grep -q "Finished Update" $logFile +#    then +#        sudo -u mythtv bash -c "MYTHCONFDIR=/usr/share/mythtv unbuffer lh_mtc.py --update | $log" +#        if [ $? = 0 ] +#        then +#            echo "" | $log +#        else +#            echo "Time Exceeded" | $log +#            exit +#        fi +#    fi + +#    if grep -q "Finished checking size of MythTV home" $logFile && grep -q "Finished Optimize" $logFile && grep -q "Finished Backup" $logFile && grep -q "Finished Update" $logFile +    if grep -q "Finished checking size of MythTV home" $logFile && grep -q "Finished Optimize" $logFile && grep -q "Finished Backup" $logFile +    then +        echo "Finished Maintenance" | $log +    fi +fi | 
