Updatemythtv

From MattWiki

Change Log since 1.8.8

  • 1.9.2 - Miner Bug Fixes
  • 1.9.1 - Added MythStream Support under the "full" install.
  • 1.9.0 - Added 'clean-download' to remove the SVN dirs and download a fresh copy, then backup the just downloaded copy.
  • 1.8.9.2 - Do NOT kill mythbackend during Mythbackend install.
  • 1.8.9.1 - Fixed Backend bug, Only copy 'etc.rc.d.init.d.mythbackend' if /etc/sysconfig/mythbackend is missing.
  • 1.8.9.0 - Fixed OSD bug, Now shows the currect SVN number for the OSD

The Script

# /bin/bash
# By Matt Rude [email protected]
# System Varables
REV="Rev 1.9.2  2007-April-19"
URL=http://svn.mythtv.org/svn/trunk
#URL=http://svn.mythtv.org/svn/branches/release-0-20-fixes
SVNDIR=/tmp/svn
BULIDDIR=/usr/local
HTTPDIR=/var/www/html

# Most likly you will have no reson to change anything below here.
###############################################################################
LOG=$SVNDIR/log/build.log
MLOG=$SVNDIR/log/mythtv-compile.log
PLOG=$SVNDIR/log/mythplugings-compile.log
TLOG=$SVNDIR/log/myththemes-compile.log
SVNLOG=$SVNDIR/log/svn.log
ELOG=$SVNDIR/log/build-error.log
MELOG=$SVNDIR/log/mythtv-compile-error.log
PELOG=$SVNDIR/log/mythplugings-compile-error.log
TELOG=$SVNDIR/log/myththemes-compile-error.log

clear

log () {
  tee -a $LOG
}

mkdir -p $SVNDIR/log
echo "`date +%T` - Current Verison is: $REV"
Download-svn () {
  echo "`date +%T` - Removeing old svn config files & dirs"
  rm -rf $SVNDIR/log/*
  rm -rf $SVNDIR/*/config/
  rm -rf $SVNDIR/*/config.*
  echo "`date +%T` - Starting Mythtv Download from svn." |log
  SVN=`svn info $URL |grep "Last Changed Rev:" |awk '{print $4 }'`
  echo "`date +%T` - Current Mythtv SVN Version is $SVN" |log
  svn co $URL/mythtv $SVNDIR/mythtv  >> $SVNLOG 2> $ELOG
  svn co $URL/mythplugins $SVNDIR/mythplugins  >> $SVNLOG 2> $ELOG
  svn co $URL/myththemes $SVNDIR/myththemes  >> $SVNLOG 2> $ELOG
}

Clean-Download-svn () {
  echo "`date +%T` - Deleting Mythtv SVN Dirctory's"
  rm -rf $SVNDIR/log/*
  rm -rf $SVNDIR/mythtv
  rm -rf $SVNDIR/mythplugins
  rm -rf $SVNDIR/myththemes
  mkdir -p $SVNDIR/log
  echo "`date +%T` - Starting Mythtv Download from svn." |log
  SVN=`svn info $URL |grep "Last Changed Rev:" |awk '{print $4 }'`
  echo "`date +%T` - Current Mythtv SVN Version is $SVN" |log
  svn co $URL/mythtv $SVNDIR/mythtv  >> $SVNLOG 2> $ELOG
  svn co $URL/mythplugins $SVNDIR/mythplugins  >> $SVNLOG 2> $ELOG
  svn co $URL/myththemes $SVNDIR/myththemes  >> $SVNLOG 2> $ELOG
  echo "`date +%T` - Finished Mythtv Download from svn." |log
  echo "`date +%T` - Starting to Archiving Downloaded Files."
  echo "`date +%T` - Archiving Files to: $SVNDIR/Mythtv.svn$SVN.tgz"
  cd $SVNDIR
  tar -czf Mythtv.svn$SVN.tgz log mythtv mythplugins myththemes
  chmod 666 $SVNDIR/Mythtv.svn$SVN.tgz
  chown mythtv:mythtv $SVNDIR/Mythtv.svn$SVN.tgz
  echo "`date +%T` - Finished Archiving Downloaded Files." |log
}

Compile-Mythtv () {
  echo "`date +%T` - Starting to Compile Mythtv." >> $LOG
  echo "`date +%T` - Starting to Compile Mythtv."
  cd $SVNDIR/mythtv >> $LOG 2> $ELOG
  make distclean >> $LOG 2> $ELOG
  ./configure --prefix=/usr/local --with-bindings=perl --disable-firewire --disable-dbox2 --disable-hdhomerun --enable-xvmc-opengl --enable-xvmc --enable-opengl-vsync >> $LOG
  #./configure --prefix=/usr/local --compile-type=debug --with-bindings=perl --disable-firewire --disable-dbox2 --disable-hdhomerun --enable-xvmc-opengl --enable-xvmc --enable-opengl-vsync --xvmc-lib=XvMCNVIDIA --enable-xvmc-opengl>> $LOG
  qmake PREFIX=/usr/local mythtv.pro >> $LOG
  make >> $MLOG 2> $MELOG
  if [ -e $BULIDDIR/mythtv.diff ]; then
   cp -f $BULIDDIR/mythtv.diff $SVNDIR/mythtv/mythtv.diff
   cat mythtv.diff |patch -p0 -N >> $LOG 2> $ELOG
  else
    echo "" > /dev/null
  fi
  echo "`date +%T` - Finished Compiling Mythtv." >> $LOG
  echo "`date +%T` - Finished Compiling Mythtv."
}

Compile-MythPlugins () {
  echo "`date +%T` - Starting to Compile MythPlugins." >> $LOG
  echo "`date +%T` - Starting to Compile MythPlugins."
  cd $SVNDIR/mythplugins >> $LOG 2> $ELOG
  make distclean >> $LOG 2> $ELOG
  ./configure --prefix=/usr/local --enable-faad --enable-aac --disable-mythbrowser --disable-mythflix --disable-mythgallery --disable-mythgame --disable-mythnews --disable-mythphone --disable-zoneminder >> $LOG 2> $ELOG
  qmake mythplugins.pro >> $LOG 2> $ELOG
  make >> $PLOG 2> $PELOG
  if [ -e $BULIDDIR/mythplugins.diff ]; then
   cp -f $BULIDDIR/mythplugins.diff $SVNDIR/mythplugins/mythplugins.diff
   cat mythplugins.diff |patch -p0 -N >> $LOG 2> $ELOG
  else
    echo "" > /dev/null
  fi
  echo "`date +%T` - Finished Compiling MythPlugins." >> $LOG
  echo "`date +%T` - Finished Compiling MythPlugins."
}

Compile-MythThemes () {
  echo "`date +%T` - Starting to Compile MythThemes." |log
  cd $SVNDIR/myththemes >> $LOG 2> $ELOG
  make distclean >> $LOG 2> $ELOG
  ./configure --prefix=/usr/local >> $LOG 2> $ELOG
  make >> $TLOG 2> $TELOG
  if [ -e $BULIDDIR/myththemes.diff ]; then
   cp -f $BULIDDIR/myththemes.difvf $SVNDIR/myththemes/myththemes.diff
   cat myththemes.diff |patch -p0 -N >> $LOG 2> $ELOG
  else
    echo "" > /dev/null
  fi
  echo "`date +%T` - Finished Compiling MythThemes." |log
}

Install-MythPlugins () {
  echo "`date +%T` - Starting to Install MythPlugins." |log
  cd $SVNDIR/mythplugins
  make install >> $LOG 2> $ELOG
  echo "`date +%T` - Finished Installing MythPlugins." |log
}

Install-MythWeb () {
  echo "`date +%T` - Starting to configuring Mythweb." |log
  cd $SVNDIR/mythplugins >> $LOG 2> $ELOG
  rm -rf $HTTPDIR/mythweb >> $LOG 2> $ELOG
  cp -r mythweb $HTTPDIR/ >> $LOG 2> $ELOG
  rm -rf /etc/httpd/conf.d/mythweb.conf
  cp -p mythweb/mythweb.conf.apache /etc/httpd/conf.d/mythweb.conf
  chown apache:apache /etc/httpd/conf.d/mythweb.conf
  ln -s /mythtv/Music $HTTPDIR/mythweb/data/music |log
  chown -R apache:apache $HTTPDIR/mythweb
  echo "`date +%T` - Finished configuring Mythweb." |log
}

Install-MythThemes () {
  echo "`date +%T` - Starting to Install MythThemes." |log
  cd $SVNDIR/myththemes >> $LOG 2> $ELOG
  make install >> $LOG 2> $ELOG
  echo "`date +%T` - Finished Installing MythThemes." |log
}

Install-Mythtv() {
  echo "`date +%T` - Installing Mythtv-Frontend Mythtv-Backend & Mythtv-Setup" |log
  cd $SVNDIR/mythtv
  if [ "`ps -e |grep monit`" = "" ]; then
   echo "`date +%T` - Monit is not running"
  else
   echo "`date +%T` - Stopping Monit Monitoring of Mythbackend"
   monit unmonitor mythbackend
  fi
  echo -n "`date +%T` - " |tee -a $LOG
  /sbin/service mythbackend stop |tee -a $LOG
  sleep 5
  killall mythfrontend >> $LOG 2> $ELOG
# rpm -qa | grep myth | xargs rpm -e >> $LOG 2> $ELOG
  echo "`date +%T` - Installing Mythtv." |log
  make install >> $LOG 2> $ELOG
  echo "`date +%T` - Configuring Mythtv." |log
  cd $SVNDIR/mythtv/contrib >> $LOG 2> $ELOG
  if [ -e /etc/sysconfig/mythbackend ]; then
   echo "" > /dev/null
  else
   cp etc.rc.d.init.d.mythbackend /etc/rc.d/init.d/mythbackend >> $LOG 2> $ELOG
   chmod a+x /etc/rc.d/init.d/mythbackend >> $LOG 2> $ELOG
   cp etc.sysconfig.mythbackend /etc/sysconfig/mythbackend >> $LOG 2> $ELOG
   /sbin/chkconfig --level 345 mythbackend on >> $LOG 2> $ELOG
   echo "/usr/local/lib" >> /etc/ld.so.conf >> $LOG 2> $ELOG
   /sbin/chkconfig mythbackend on >> $LOG 2> $ELOG
   sleep 30
  fi
  echo -n "`date +%T` - " |tee -a $LOG
  /sbin/service mythbackend start |tee -a $LOG
  if [ "`ps -e |grep monit`" = "" ]; then
   echo "" > /dev/null
  else
   echo "`date +%T` - Starting Monit Monitoring of Mythbackend"
   monit monitor mythbackend
  fi
  /sbin/ldconfig >> $LOG 2> $ELOG
  echo "`date +%T` - Mythtv is now Configured." |log
  echo "`date +%T` - Finished Installing Mythtv-Frontend Mythtv-Backend & Mythtv-Setup" |log
}

MythStream () {
  echo "`date +%T` - Starting MythStream Download, Compile, & Install"
  cd /tmp/svn/ >> $LOG 2> $ELOG
  rm -rf mythstream* >> $LOG 2> $ELOG
  wget http://home.kabelfoon.nl/~moongies/sw9vc4htz2/mythstream-v0.17_2.tar.gz >> $LOG 2> $ELOG
  tar -xzf mythstream-v0.17_2.tar.gz >> $LOG 2> $ELOG
  mv mythstream-0.17_2 mythstream >> $LOG 2> $ELOG
  rm -f mythstream-v0.17_2.tar.gz >> $LOG 2> $ELOG
  cd mythstream >> $LOG 2> $ELOG
  echo "7,8c7,8 >> $LOG 2> $ELOG
< #PREFIX = /usr/local
< PREFIX = /usr
---
> PREFIX = /usr/local
> #PREFIX = /usr" > mythstream.diff
  echo -n "`date +%T` - MythStream is "
  patch settings.pro mythstream.diff
  qmake mythstream.pro >> $LOG 2> $ELOG
  make >> $LOG 2> $ELOG
  make install >> $LOG 2> $ELOG
  cd /tmp/svn/mythplugins/mythmusic/mythmusic
  echo "43a44,50
>       <type>STREAM</type>
>       <text>Internet Streams</text>
>       <action>PLUGIN mythstream</action>
>       <depends>mythstream</depends>
>    </button>
>
>    <button>
" > musicmenu.diff
  echo -n "`date +%T` - MythStream is "
  patch musicmenu.xml musicmenu.diff
  echo "43a44,50
>       <type>STREAM</type>
>       <text>Stream Settings</text>
>       <action>CONFIGPLUGIN mythstream</action>
>       <depends>mythstream</depends>
>    </button>
>
>    <button>
" > music_settings.diff
  echo -n "`date +%T` - MythStream is "
  patch music_settings.xml music_settings.diff >> $LOG 2> $ELOG
  echo "`date +%T` - MythStream is Finished"
}

Finishing-Up () {
  echo "`date +%T` - Mythtv Updating is Finished."
}

###############################################################################

AutoMythtv () {
  echo "`date +%T` - Removeing old Config files & dirs in Mythtv."
  rm -f $SVNDIR/mythtv/config.*
  rm -f $SVNDIR/mythtv/config/*
  echo "`date +%T` - Starting MythTV Download from svn." |log
  svn co $URL/mythtv $SVNDIR/mythtv  >> $SVNLOG 2> $ELOG
  Compile-Mythtv
  if [ -e $BULIDDIR/mythtv.diff ]; then
   rm -f $SVNDIR/mythtv/mythtv.diff
   cp $BULIDDIR/mythtv.diff $SVNDIR/mythtv/mythtv.diff
   cat $SVNDIR/mythtv/mythtv.diff |patch -p0 -N >> $LOG 2> $ELOG
  else
    echo "" > /dev/null
  fi
  echo "`date +%T` - Finished MythTV Download from svn." |log
  Install-Mythtv
}

AutoMythPlugins () {
  echo "`date +%T` - Removeing old Config files & dirs in MythPlugins."
  rm -f $SVNDIR/mythtv/config.*
  rm -f $SVNDIR/mythtv/config/*
  echo "`date +%T` - Starting MythPlugins Download from svn." |log
  svn co $URL/mythplugins $SVNDIR/mythplugins  >> $SVNLOG 2> $ELOG
  echo "`date +%T` - Finished MythPlugins Download from svn." |log
  Compile-MythPlugins
  if [ -e $BULIDDIR/mythplugins.diff ]; then
   rm -f $SVNDIR/mythplugins/mythplugins.diff
   cp $BULIDDIR/mythplugins.diff $SVNDIR/mythplugins/mythplugins.diff
   cat $SVNDIR/mythplugins/mythplugins.diff |patch -p0 -N >> $LOG 2> $ELOG
  else
    echo "" > /dev/null
  fi
  Install-MythPlugins
  Install-MythWeb
}

AutoMythThemes () {
  echo "`date +%T` - Removeing old Config files & dirs in MythThemes."
  rm -f $SVNDIR/myththems/config.*
  rm -f $SVNDIR/myththems/config/*
  echo "`date +%T` - Starting MythThemes Download from svn." |log
  svn co $URL/myththemes $SVNDIR/myththemes  >> $SVNLOG 2> $ELOG
  Compile-MythThemes
  if [ -e $BULIDDIR/myththemes.diff ]; then
   rm -f $SVNDIR/myththemes/myththemes.diff
   cp $BULIDDIR/myththemes.diff $SVNDIR/myththemes/myththemes.diff
   cat $SVNDIR/myththemes/mythtthemes.diff |patch -p0 -N >> $LOG 2> $ELOG
  else
    echo "" > /dev/null
  fi
  echo "`date +%T` - Finished MythThemes Download from svn." |log
  Install-MythThemes
}

###############################################################################

case "$1" in
  download)
    Download-svn
    ;;
  clean-download)
    Clean-Download-svn
    ;;
  compile)
    SVN=`svn info $SVNDIR/mythtv |grep "Revision: " |awk '{print $2 }'`
    Compile-Mythtv
    Compile-MythPlugins
    Compile-MythThemes
    mythtvosd --template=scroller --scroll_text="`hostname -s` is done compileing the latest updates.  Please install the updates. The current svn version number is: $SVN" > /dev/null
    ;;

  install)
    Install-Mythtv
    Install-MythPlugins
    Install-MythThemes
    Install-MythWeb
    Finishing-Up
    ;;

  full)
    Clean-Download-svn
    Compile-Mythtv
    Compile-MythPlugins
    Compile-MythThemes
    MythStream
    Install-Mythtv
    Install-MythPlugins
    Install-MythWeb
    Install-MythThemes
    Finishing-Up
    ;;

  status)
    echo "`date +%T` - Staring Mythtv Tunk Status Check."
    MYTHSVN=`svn info $URL/mythtv |grep "Last Changed Rev:" |awk '{print $4 }'`
    PLUGSVN=`svn info $URL/mythplugins |grep "Last Changed Rev:" |awk '{print $4 }'`
    THEMSVN=`svn info $URL/myththemes |grep "Last Changed Rev:" |awk '{print $4 }'`
    MYTHLOCSVN=`svn info $SVNDIR/mythtv |grep "Last Changed Rev:" |awk '{print $4 }'`
    PLUGLOCSVN=`svn info $SVNDIR/mythplugins |grep "Last Changed Rev:" |awk '{print $4 }'`
    THEMLOCSVN=`svn info $SVNDIR/myththemes |grep "Last Changed Rev:" |awk '{print $4 }'`

    if [ $MYTHSVN = $MYTHLOCSVN ] ; then
     echo "`date +%T` - Mythtv Dose NOT need to be updated Current Version is: $MYTHSVN"
    else
     echo "`date +%T` - Mythtv Should Be Updated"
     echo "`date +%T` - Mythtv's Local Install is at $MYTHLOCSVN"
     echo "`date +%T` - But the Current Version is at $MYTHSVN"
    fi

    if [ $PLUGSVN = $PLUGLOCSVN ] ; then
     echo "`date +%T` - MythPlugins Dose NOT need to be updated Current Version is: $PLUGSVN"
    else
     echo "`date +%T` - MythPlugins Should Be Updated"
     echo "`date +%T` - MythPlugins' Local Install is at $PLUGLOCSVN"
     echo "`date +%T` - But the Current Version is at $PLUGSVN"
    fi

    if [ $THEMSVN = $THEMLOCSVN ] ; then
     echo "`date +%T` - MythThemes Dose NOT need to be updated Current Version is: $THEMSVN"
    else
     echo "`date +%T` - MythThemes Should Be Updated"
     echo "`date +%T` - MythThemes' Local Install is at $THEMLOCSVN"
     echo "`date +%T` - But the Current Version is at $THEMSVN"
   fi
  ;;

  clear)
   echo "`date +%T` - Stopping and cleaning Mythtv"
   echo "`date +%T` - You will need to reinstall Mythtv when this is done."
   echo -n "`date +%T` - Do you wish to Delete all Mythtv Files? "
   read DELFILES
   case "$DELFILES" in
    y|Y|yes|YES|Yes)
     echo "`date +%T` - OK Here we go."
     ;;

    n|N|no|NO|No)
     echo "`date +%T` - Fine then I didn't wont to delete the files anyways."
     exit 0
     ;;

   *)
     echo "`date +%T` - You need to answer this Yes or No."
     exit 0
esac

  if [ "`ps -e |grep monit`" = "" ]; then
   echo "`date +%T` - Monit is not running"
  else
   echo "`date +%T` - Stopping Monit Monitoring of Mythbackend"
   monit unmonitor mythbackend
  fi
   echo -n "`date +%T` - "
  /sbin/service mythbackend stop
  sleep 5
  killall mythfrontend >> $LOG 2> $ELOG
  killall mythwelcome >> $LOG 2> $ELOG
  killall mtd >> $LOG 2> $ELOG
  rm -rf $BULIDDIR/bin/myth* $BULIDDIR/bin/mtd $BULIDDIR/include/mythtv $BULIDDIR/lib/libmyth* $BULIDDIR/lib/mythtv $BULIDDIR/share/mythtv >> $LOG 2> $ELOG
   echo "`date +%T` - Mythtv Cleaning is done."
  ;;

  auto)
    echo "`date +%T` - Staring Auto update of the Mythtv Tunk."
    MYTHSVN=`svn info $URL/mythtv |grep "Last Changed Rev:" |awk '{print $4 }'`
    PLUGSVN=`svn info $URL/mythplugins |grep "Last Changed Rev:" |awk '{print $4 }'`
    THEMSVN=`svn info $URL/myththemes |grep "Last Changed Rev:" |awk '{print $4 }'`

    if [ -e $SVNDIR/mythtv/README ]; then
      MYTHLOCSVN=`svn info $SVNDIR/mythtv |grep "Last Changed Rev:" |awk '{print $4 }'`
    else
      rm -rf $SVNDIR/mythtv
      MYTHLOCSVN=None
    fi

    if [ -e $SVNDIR/mythplugins/README ]; then
      PLUGLOCSVN=`svn info $SVNDIR/mythplugins |grep "Last Changed Rev:" |awk '{print $4 }'`
    else
      rm -rf $SVNDIR/mythplugins
      PLUGLOCSVN=None
    fi

    if [ -e $SVNDIR/myththemes/README ]; then
      THEMLOCSVN=`svn info $SVNDIR/myththemes |grep "Last Changed Rev:" |awk '{print $4 }'`
    else
      rm -rf $SVNDIR/myththemes
      THEMLOCSVN=None
    fi


    if [ $MYTHSVN = $MYTHLOCSVN ] ; then
     echo "`date +%T` - Mythtv Dose NOT need to be updated Current Version is: $MYTHSVN"
    else
     echo "`date +%T` - Mythtv Will Be Updated"
     echo "`date +%T` - Mythtv's Local Install is at $MYTHLOCSVN"
     echo "`date +%T` - But the Current Version is at $MYTHSVN"
     AUTOMYTH=AutoMythtv
    fi

    if [ $PLUGSVN = $PLUGLOCSVN ] ; then
     echo "`date +%T` - MythPlugins Dose NOT need to be updated Current Version is: $PLUGSVN"
    else
     echo "`date +%T` - MythPlugins Will Be Updated"
     echo "`date +%T` - MythPlugins' Local Install is at $PLUGLOCSVN"
     echo "`date +%T` - But the Current Version is at $PLUGSVN"
     AUTOPLUG=AutoMythPlugins
    fi

    if [ $THEMSVN = $THEMLOCSVN ] ; then
     echo "`date +%T` - MythThemes Dose NOT need to be updated Current Version is: $THEMSVN"
    else
     echo "`date +%T` - MythThemes Will Be Updated"
     echo "`date +%T` - MythThemes' Local Install is at $THEMLOCSVN"
     echo "`date +%T` - But the Current Version is at $THEMSVN"
     AUTOTHEM=AutoMythThemes
   fi
    $AUTOMYTH
    $AUTOPLUG
    $AUTOTHEM
    #Install-MythThemes
    Finishing-Up
    ;;

  *)
    echo ""
    echo "Updatemyth will check the current Mythtv SVN Release and if the"
    echo "system needs a update will download and install JUST the updates."
    echo "UpdateMyth's Valid Commands are:"
    echo ""
    echo "auto      # Check, Download, Compile & Install the Latest Release"
    echo "full      # Force a Clean Download, Compile & Install the Latest SVN Release"
    echo "download  # Download the Latest Release"
    echo "clean-download  # Delete the SVN dir, then Download the Latest Release"
    echo "compile   # Check, Download and Compile the Latest SVN Release"
    echo "install   # Install the Last Compiled SVN Release"
    echo "status    # Check to see if the current install is up to date"
    echo "clear     # This will stop and Clean out all the myth files on the system"
    echo ""
    exit 0
    ;;

esac

Update this Page

cat /home/mythtv/bin/updatemyth |sed 's/^/ /' > /mythtv/updatemyth.txt