Difference between revisions of "User:Pvr4me"

From MythTV Official Wiki
Jump to: navigation, search
(Doc test)
(remove old, update MacPorts list)
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
__TOC__
 
__TOC__
  
==Building Myth for Mac with MacPorts==
+
== MacPorts ==
The following walks through the process of building MythTV (version 0.25.1) on Mac OS X (10.6.x ONLY).
+
I maintain the myth* ports for Mac OS X at [[MacPorts]]Currently, that is mythtv-core.27, mythweb.27 along with the older mythtv-core.25, mythweb.25, mythtv-core.26 and myth web.26.
 
 
10.7 (Lion) WON'T WORK.  Stay tuned.
 
 
 
===Install XCode and MacPorts===
 
 
 
If you haven't already, you need to download and install XCode, including the separate install for the command line tools, and then install MacPorts.  The MacPorts wiki has detailed instructions at http://www.macports.org/install.php
 
 
 
===Download, build and install Myth and supporting software===
 
Once you have MacPorts installed, a couple of simple (but time-consuming) steps are all that is required.  Use Apple's Terminal app (Applications>Utilities) to issue the following command exactly as shown.
 
 
 
<pre>sudo install qt4-mac +mysql
 
</pre>
 
{{Note box|The "+mysql" part is essential.  Nokia's Qt software is essential and Myth relies on an optional module for communication with the MySQL databaseThe default build of Qt via MacPorts does not include this module.  This is also the reason that the build takes so long--all of Qt's source code, including MySQL support, and build from scratch.  A fast machine, say a quad-core i7, may complete the build in 2 hours, plus or minus.  A less-capable machine may take several times that long.}}
 
 
 
When Qt eventually finishes, the next command will install Myth's frontend, backend, and all the ancillary programs like mythtv-setup, mythfilldatabase, mythcommflag, mythtranscode, mythmetadatalookup, etc.. 
 
 
 
<pre>
 
sudo install mythtv-core.25
 
</pre>
 
 
If you feel particularly adventurous, you many also want to install the MythTV plugins for Mac OS X.
 
 
 
<pre>sudo install mythtv-plugins.25</pre>  << currently experimental
 
{{Note box|Plugins on OS X are experimental at this stage.  More work is planned to support some--but not all--of Myth's plugins.}}
 
 
 
===Uninstall===
 
Sorry to hear that you want to rid your machine of Myth!  MacPorts makes it a pretty painless operation to either deactivate software or entirely remove it from your machine.
 
If you've been using this machine as a production Myth backend, you probably used launchctl to ensure that the backend would automatically run at system startup.  Make sure mythbackend not running.
 
 
 
<pre>
 
sudo deactivate mythtv-plugins.25
 
sudo deactivate mythtv-core.25
 
</pre>
 
 
The MacPorts deactivate command removes the executable programs (and other supporting libraries, etc) but leaves an archive image. If you decide you want to re-install Myth, you can do so very quickly with the command:
 
 
 
<pre>
 
sudo activate mythtv-core.25
 
</pre>
 
 
 
The activate command takes a short time because you don't have to re-download and build the software--just copy it out of the archive and install it in the normal location.
 
 
 
However, if you want to make Myth go away entirely and reclaim the disk space it occupied, use one of the following commands:
 
 
 
<pre>
 
sudo uninstall mythtv-plugins.25 --follow-dependents
 
 
 
OR
 
 
 
sudo uninstall mythtv-core.25 --follow-dependents
 
</pre>
 
 
 
 
 
== MythConverg database maintenance ==
 
The Perl script [[optimize mythdb.pl]] does not work for me...I can't get the DBI/DBD module installed correctly.  I'm running Myth on Mac OS X; I don't know Perl.  I've tried various incantations to fix the problem but the OS X/perl neophyte combination makes it tough to find the solution.
 
 
 
Eventually, I noticed that mySQL includes a couple of utility programs that essentially do the same as optimize_mythdb.pl.
 
 
 
I've whipped up a script to do the mySQL maintenance even though I only know enough shell scripting to be dangerous!  ;-)  Suggestions, enhancements and wholesale re-writes are welcome.
 
 
 
First, the script uses mysqldump to back up mythconverg. If that succeeds, it calls mysqlcheck  with the --auto-repair option to straighten out any data problems.  If that succeeds, it uses mysqlcheck with the --optimize and --analyze options to reclaim free space and tune up the indexes, respectively.  The three invocations of mysqlcheck use the --silent option to suppress the list of tables worked on.  I hope that any errors will still be reported but I haven't experienced any yet.  The reported results are accumulated in a log file and the script emails it to me for my perusal. 
 
 
 
You'll need to edit your mysql userid and password if they're not mythtv/mythtv.  Probably need to fix some paths...
 
 
 
=== optimizeMythDB.sh ===
 
<pre>
 
#!/bin/sh
 
#
 
# A shell script to optimize Myth's database since I can't make the perl script work
 
# Under Mac OS X launchd, stdout and stderr can be redirected to wherever we want.
 
#
 
# Last modifed: 21Aug2009 -- absolute paths to mysql utilities
 
# 23Aug2009 -- tweaks
 
# Craig Treleaven  ctreleaven@cogeco.ca
 
#
 
# To do ...
 
# better way to mail?
 
# zip the database backup
 
#
 
#
 
 
 
mu=mythtv
 
mp=mythtv
 
mdb=mythconverg
 
mbak="/Volumes/Theatre/MythBackup/mythconverg_backup_before_repair.sql"
 
mlog="/tmp/OptimizeMythDBResults.txt"
 
sender="ctreleaven@cogeco.ca"
 
wholist="/Applications/AudioVisualMusic/OptimizeMythDB/who_to"
 
 
 
 
 
echo >  $mlog
 
echo Check, optimize and analyse $mdb >> $mlog
 
echo ========================================== >> $mlog
 
echo >> $mlog
 
echo $(date) >> $mlog
 
echo Backing up $mdb database >> $mlog
 
 
 
/usr/local/mysql/bin/mysqldump --user=$mu --password=$mp --extended-insert --result-file=$mbak $mdb >> $mlog 2>&1
 
 
 
if [ $? = 0 ] ; then
 
echo $(date) >> $mlog
 
echo Checking and repairing, if necessary $mdb... >> $mlog
 
/usr/local/mysql/bin/mysqlcheck --user=$mu --password=$mp --check --auto-repair --silent $mdb >> $mlog 2>&1
 
 
 
    if [ $? = 0 ] ; then
 
echo $(date) >> $mlog
 
echo Optimizing and analyzing $mdb... >> $mlog
 
/usr/local/mysql/bin/mysqlcheck --user=$mu --password=$mp --optimize --silent $mdb >> $mlog 2>&1
 
/usr/local/mysql/bin/mysqlcheck --user=$mu --password=$mp --analyze --silent $mdb >> $mlog 2>&1
 
    fi
 
fi
 
 
 
# Email the results
 
#
 
echo $(date) >> $mlog
 
echo Done >> $mlog
 
/usr/bin/python /Applications/AudioVisualMusic/OptimizeMythDB/smtp.py $sender $wholist "Optimize Myth DB $(date)" $mlog
 
</pre>
 
 
 
The last step in the script above mails out a log file.  I hope that errors are going to show despite the --silent options.  The following is the python code  You need to add your own smtp mail server address.  You also need to create a file containing the email addresses the report should go to.  I've used a file called 'who_to'.  Obviously, you can comment out this step if you don't want to fool with mail.
 
 
 
=== smtp.py ===
 
 
 
<pre>
 
#!/usr/bin/env python
 
 
 
import smtplib, sys, time
 
 
 
# change this to a new SMTP server if desired
 
#smtpHost = 'some.smtp.mail.server'
 
smtpHost = 'smtp.cogeco.ca'
 
 
 
# sys.argv[1] is the sender
 
# sys.argv[2] is the filename pointing to the list of recipients
 
# sys.argv[3] is the subject
 
# sys.argv[4] is the message content
 
 
 
if len(sys.argv) != 5:
 
  print 'Usage: ./smtp <sender> <recipient FN> <subj> <msg FN>'
 
  sys.exit(1)
 
 
 
# each recipient takes one line; '#' signals comments
 
rList = []
 
for line in open(sys.argv[2]).readlines():
 
  r = line.split('#')[0].strip()
 
  if r: rList.append(r)
 
 
 
sender = sys.argv[1]
 
subj = sys.argv[3]
 
date = time.ctime(time.time())
 
msg = 'From: %s\nTo: %s\nDate: %s\nSubject: %s\n%s' \
 
      % (sender, ', '.join(rList), date, subj, open(sys.argv[4]).read())
 
 
 
server = smtplib.SMTP(smtpHost) # connect, no login step
 
failed = server.sendmail(sender, rList, msg)
 
server.quit()
 
 
 
if failed:
 
  print 'smtp.py: Failed recipients:', failed
 
else:
 
  print 'smtp.py: No errors.'
 
</pre>
 
----
 
 
 
== Mac OS X Periodic Execution ==
 
I want to run the database maintenance once a day.  Starting with 10.4, Apple encourages the use of launchd for things that cron did.  The easiest way I've found to set up the schedule is with Peter Borg's [http://sourceforge.net/projects/lingon/ Lingon].  Peter isn't developing Lingon any more but it seems to work fine with 10.5.7.
 
 
 
I've set this up as a 'user agent', so the plist is stored in ~/Library/LaunchAgents/. 
 
=== org.mythtv.optimizeMythDB.plist ===
 
<pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 
<plist version="1.0">
 
<dict>
 
<key>Label</key>
 
<string>org.mythtv.optimizeMythDB</string>
 
<key>ProgramArguments</key>
 
<array>
 
<string>/Applications/AudioVisualMusic/OptimizeMythDB/OptimizeMythDB.sh</string>
 
</array>
 
<key>StartCalendarInterval</key>
 
<dict>
 
<key>Hour</key>
 
<integer>4</integer>
 
<key>Minute</key>
 
<integer>22</integer>
 
</dict>
 
</dict>
 
</plist>
 
 
 
</pre>
 

Revision as of 19:40, 26 August 2014

Contents

MacPorts

I maintain the myth* ports for Mac OS X at MacPorts. Currently, that is mythtv-core.27, mythweb.27 along with the older mythtv-core.25, mythweb.25, mythtv-core.26 and myth web.26.