Difference between revisions of "Build from Source"
m (→Setup mysql database mythconverge) |
(→Prerequisites: added perl and python prerequisites) |
||
(104 intermediate revisions by 38 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{User_Manual_TOC}} | |
− | There are four key parts to MythTV, and setup roughly in this order | + | This page is up-to-date to MythTV version 0.21, the current release is {{CurrentRelease}} |
− | # Start system services that MythTV | + | |
− | # Initialize the system database, mythconverg | + | ==Introduction== |
− | # Setup system preferences and tune your | + | |
− | # Start main MythTV server, mythtvbackend | + | There are different ways to get Mythtv installed on your system: |
− | # Start MythTV, mythfrontend | + | |
+ | # From source; | ||
+ | # Using apt-get; | ||
+ | # Using a MythTV Linux distribution (e.g. MythBuntu, MythDora, etc.) [[MythTV distros |more info]]. | ||
+ | |||
+ | In this guide we will discuss how to install from source. | ||
+ | |||
+ | This guide is will allow you to build the latest version of MythTV on Ubuntu and Fedora. | ||
+ | |||
+ | == Prerequisites == | ||
+ | |||
+ | First install required packages (Version: 0.27): | ||
+ | |||
+ | <code><pre> | ||
+ | sudo apt-get install build-essential liblircclient-dev libasound2-dev libdts-dev libdvdnav-dev \ | ||
+ | libxv-dev libxxf86vm-dev transcode libmp3lame-dev subversion qt4-dev-tools libqt4-dev libsamplerate0 \ | ||
+ | libxvidcore4 liba52-0.7.4-dev libcdio-dev msttcorefonts libasound2-doc libmad0-dev \ | ||
+ | libid3tag0-dev libvorbis-dev libflac-dev libcdaudio-dev libcdparanoia0-dev fftw3-dev libfaad-dev \ | ||
+ | libsmpeg-dev libmp4v2-dev libtag1-dev mysql-server libvisual-0.4-dev libexif-dev libxvmc-dev \ | ||
+ | libxinerama-dev uuid-dev libicu-dev | ||
+ | </pre></code> | ||
+ | |||
+ | Note: Version 0.24 requires also '''libfreetype6-dev'''; not required but advised: '''yasm''', '''ccache'''. | ||
+ | |||
+ | Note: Version 0.21 and earlier use QT3 instad of QT4, so you need: '''libqt3-mt-dev''' and '''libqt3-mt-mysql'''. | ||
+ | |||
+ | |||
+ | To install css support use: | ||
+ | <code><pre> | ||
+ | /usr/share/doc/libdvdread3/install-css.sh | ||
+ | </pre></code> | ||
+ | or on newer distributions: | ||
+ | <code><pre> | ||
+ | /usr/share/doc/libdvdread4/install-css.sh | ||
+ | </pre></code> | ||
+ | |||
+ | If you want mythweb as well - you need | ||
+ | <code><pre> | ||
+ | sudo apt-get install apache2 php5 libapache2-mod-php5 php5-mysql | ||
+ | </pre></code> | ||
+ | On some systems (might be already installed on your system) you have to install the following to prevent issues with downloading recordings | ||
+ | <code><pre> | ||
+ | sudo apt-get install libcpandb-perl | ||
+ | </pre></code> | ||
+ | If you want VAAPI support you will need libva-dev | ||
+ | <code><pre> | ||
+ | sudo apt-get install libva-dev | ||
+ | </pre></code> | ||
+ | |||
+ | To compile and use '''perl bindings''' install | ||
+ | <code><pre> | ||
+ | sudo apt-get install libnet-upnp-perl | ||
+ | </pre></code> | ||
+ | |||
+ | To compile and use '''python bindings''' install | ||
+ | <code><pre> | ||
+ | sudo apt-get install python-lxml python-mysqldb python-urlgrabber | ||
+ | </pre></code> | ||
+ | |||
+ | ==Getting and compiling the source code== | ||
+ | |||
+ | Get the [http://code.mythtv.org/trac latest code] for MythTV. In general, you should probably choose the stable version. If you don't mind if your MythTV system is non-functional or has serious bugs that may prevent proper operation/result in lost recordings or inability to play back recordings, you may try using the unstable, development code. If using unstable, development code, you should follow the [http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-commits mythtv-commits] and [http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev mythtv-dev] mailing lists. | ||
+ | |||
+ | Then, simply go in each directory and configure and build each component: | ||
+ | <code><pre> | ||
+ | ./configure --enable-proc-opt | ||
+ | make | ||
+ | make install | ||
+ | </pre></code> | ||
+ | |||
+ | Note that adding any other configure arguments (with the possible exception of --prefix) to the main MythTV configure command is almost definitely a bad idea and shouldn't be required. | ||
+ | |||
+ | For mythplugins, if you don't want some modules you might want to disable them (run "./configure --help" in each directory to see the options you can set for the build). | ||
+ | For example: | ||
+ | <code><pre> | ||
+ | ./configure --disable-mythgame --disable-mythnetflix | ||
+ | make | ||
+ | make install | ||
+ | </pre></code> | ||
+ | |||
+ | Note: If you want to be able to easily uninstall later, for example to update to new set of fixes, use "checkinstall" rather than "make install". "checkinstall" keeps track of all files installed by a "make install" or equivalent, creates a Slackware, RPM, or Debian package with those files, and adds it to the installed packages database, allowing for easy package removal or distribution. "checkinstall" will prompt for a package description, and then you must supply a version number by following the prompts. | ||
+ | <code><pre> | ||
+ | ./configure | ||
+ | make | ||
+ | checkinstall | ||
+ | </pre></code> | ||
+ | |||
+ | == Post-install tasks == | ||
+ | === Creating the mythtv user === | ||
+ | to run MythTV as its own user I created one (so the backend doesnt run as root) | ||
+ | <code><pre> | ||
+ | sudo useradd mythtv | ||
+ | </pre></code> | ||
+ | |||
+ | === MythTV database setup === | ||
+ | |||
+ | You have to create a file for mythtv for database connections <code>~mythtv/.mythtv/mysql.txt</code> | ||
+ | {{Code box|~mythtv/.mythtv/mysql.txt|<pre> | ||
+ | DBHostName=localhost | ||
+ | |||
+ | # By default, Myth tries to ping the DB host to see if it exists. | ||
+ | # If your DB host or network doesn't accept pings, set this to no: | ||
+ | # | ||
+ | DBHostPing=no | ||
+ | |||
+ | DBHostName=localhost | ||
+ | DBUserName=mythtv | ||
+ | DBName=mythconverg | ||
+ | DBPassword=mythtv | ||
+ | |||
+ | # Set the following if you want to use something other than this | ||
+ | # machine's real hostname for identifying settings in the database. | ||
+ | # This is useful if your hostname changes often, as otherwise you | ||
+ | # will need to reconfigure mythtv (or futz with the DB) every time. | ||
+ | # TWO HOSTS MUST NOT USE THE SAME VALUE | ||
+ | # | ||
+ | LocalHostName=MYCOOLMYTHTVHOST | ||
+ | |||
+ | # If you want your frontend to be able to wake your MySQL server | ||
+ | # using WakeOnLan, have a look at the following settings: | ||
+ | # | ||
+ | # | ||
+ | # The time the frontend waits (in seconds) between reconnect tries. | ||
+ | # This should be the rough time your MySQL server needs for startup | ||
+ | # | ||
+ | #WOLsqlReconnectWaitTime=0 | ||
+ | # | ||
+ | # | ||
+ | # This is the number of retries to wake the MySQL server | ||
+ | # until the frontend gives up | ||
+ | # | ||
+ | #WOLsqlConnectRetry=5 | ||
+ | # | ||
+ | # | ||
+ | # This is the command executed to wake your MySQL server. | ||
+ | # | ||
+ | #WOLsqlCommand=echo 'WOLsqlServerCommand not set' | ||
+ | |||
+ | </pre>}} | ||
+ | |||
+ | Then you have to create a database and let the user set above access it | ||
+ | <pre> | ||
+ | mysql -u root -p | ||
+ | create database mythconverg; | ||
+ | create user 'mythtv'@'%' identified by 'mythtv'; | ||
+ | create user 'mythtv'@'localhost' identified by 'mythtv'; | ||
+ | set password for 'mythtv'@'%' = password('mythtv'); | ||
+ | set password for 'mythtv'@'localhost' = password('mythtv'); | ||
+ | connect mythconverg; | ||
+ | grant all privileges on *.* to 'mythtv'@'%' with grant option; | ||
+ | grant all privileges on *.* to 'mythtv'@'localhost' with grant option; | ||
+ | flush privileges; | ||
+ | exit; | ||
+ | </pre> | ||
+ | |||
+ | Run <code>mythbackend</code> to test. This will automatically upgrade your previous mythconverg database schema to the latest version: | ||
+ | <pre>mythbackend</pre> | ||
+ | If mythbackend is running OK, test mythfrontend: | ||
+ | <pre>mythfrontend</pre> | ||
+ | |||
+ | === Running MythTV on start === | ||
+ | I use a slightly modified script from mythbuntu for that. Just copy the content to <code>/etc/init.d/mythtv-backend</code> - chmod it with <code>sudo chmod 755 /etc/init.d/mythtv-backend</code> | ||
+ | |||
+ | To start every time you still have to add it to the rc: | ||
+ | <code>update-rc.d mythtv-backend defaults</code> | ||
+ | |||
+ | Also create a log directory for mythtv: | ||
+ | <code><pre> | ||
+ | sudo mkdir /var/log/mythtv | ||
+ | sudo chown mythtv:mythtv /var/log/mythtv | ||
+ | </pre></code> | ||
+ | |||
+ | {{Code box|/etc/init.d/mythtv-backend|<pre> | ||
+ | #! /bin/sh | ||
+ | ### BEGIN INIT INFO | ||
+ | # Provides: mythtv-backend | ||
+ | # Required-Start: $local_fs $remote_fs $network | ||
+ | # Required-Stop: $local_fs | ||
+ | # Default-Start: 2 3 4 5 | ||
+ | # Default-Stop: 0 1 6 | ||
+ | # Short-Description: Start/Stop the MythTV server. | ||
+ | ### END INIT INFO | ||
+ | |||
+ | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | ||
+ | DAEMON=/usr/local/bin/mythbackend | ||
+ | NAME="mythbackend" | ||
+ | DESC="MythTV server" | ||
+ | |||
+ | test -x $DAEMON || exit 0 | ||
+ | |||
+ | . /lib/lsb/init-functions | ||
+ | |||
+ | set -e | ||
+ | |||
+ | prime_firewire() | ||
+ | { | ||
+ | if [ "$ENABLE_FIREWIRE" = "TRUE" ]; then | ||
+ | log_daemon_msg "Priming Firewire " | ||
+ | su - $USER -c "/usr/bin/mythprime" | ||
+ | log_end_msg $? | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | USER=mythtv | ||
+ | USER_HOME=$(grep ^$USER /etc/passwd | awk -F : '{print $6}') | ||
+ | RUNDIR=/var/run/mythtv | ||
+ | ARGS="--daemon --logpath /var/log/mythtv --pidfile $RUNDIR/$NAME.pid" | ||
+ | EXTRA_ARGS="" | ||
+ | NICE=0 | ||
+ | |||
+ | if [ -f /etc/default/mythtv-backend ]; then | ||
+ | . /etc/default/mythtv-backend | ||
+ | fi | ||
+ | |||
+ | ARGS="$ARGS $EXTRA_ARGS" | ||
+ | |||
+ | mkdir -p $RUNDIR | ||
+ | chown -R $USER $RUNDIR | ||
+ | |||
+ | unset DISPLAY | ||
+ | unset SESSION_MANAGER | ||
+ | |||
+ | #create a symbolic link for mysql.txt so it can't be overwritten | ||
+ | mkdir -p $USER_HOME/.mythtv | ||
+ | chown -R $USER $USER_HOME/.mythtv | ||
+ | if [ ! -e $USER_HOME/.mythtv/mysql.txt ]; then | ||
+ | ln -s /etc/mythtv/mysql.txt $USER_HOME/.mythtv/mysql.txt | ||
+ | fi | ||
+ | |||
+ | case "$1" in | ||
+ | start) | ||
+ | if [ -e $RUNDIR/$NAME.pid ]; then | ||
+ | PIDDIR=/proc/$(cat $RUNDIR/$NAME.pid) | ||
+ | if [ -d ${RUNDIR} -a "$(readlink -f ${RUNDIR}/exe)" = "${DAEMON}" ]; then | ||
+ | log_success_msg "$DESC already started; use restart instead." | ||
+ | exit 1 | ||
+ | else | ||
+ | log_success_msg "Removing stale PID file $RUNDIR/$NAME" | ||
+ | rm -f $RUNDIR/$NAME.pid | ||
+ | fi | ||
+ | fi | ||
+ | prime_firewire | ||
+ | log_daemon_msg "Starting $DESC: $NAME " | ||
+ | start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \ | ||
+ | --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS | ||
+ | log_end_msg $? | ||
+ | ;; | ||
+ | stop) | ||
+ | log_daemon_msg "Stopping $DESC: $NAME " | ||
+ | start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \ | ||
+ | --chuid $USER --exec $DAEMON -- $ARGS | ||
+ | log_end_msg $? | ||
+ | test -e $RUNDIR/$NAME.pid && rm $RUNDIR/$NAME.pid | ||
+ | ;; | ||
+ | restart|force-reload) | ||
+ | log_daemon_msg "Restarting $DESC: $NAME " | ||
+ | start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \ | ||
+ | --chuid $USER --exec $DAEMON -- $ARGS | ||
+ | sleep 3 | ||
+ | prime_firewire | ||
+ | start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \ | ||
+ | --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS | ||
+ | log_end_msg $? | ||
+ | ;; | ||
+ | status) | ||
+ | # We want to maintain backward compatibility with Hardy, | ||
+ | # so we're not going to use status_of_proc() | ||
+ | pidofproc -p $RUNDIR/$NAME.pid $DAEMON >/dev/null && status=0 || status=$? | ||
+ | if [ $status -eq 0 ]; then | ||
+ | log_success_msg "$NAME is running" | ||
+ | else | ||
+ | log_failure_msg "$NAME is not running" | ||
+ | fi | ||
+ | exit $status | ||
+ | ;; | ||
+ | *) | ||
+ | N=/etc/init.d/$NAME | ||
+ | echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 | ||
+ | exit 2 | ||
+ | ;; | ||
+ | esac | ||
+ | |||
+ | exit 0 | ||
+ | </pre>}} | ||
+ | |||
+ | === Autostarting the frontend in Xubuntu / Ubuntu === | ||
+ | |||
+ | Create a file in <code>~/.config/autostart/mythfrontend.desktop</code>: | ||
+ | {{Code box|~/.config/autostart/mythfrontend.desktop|<pre> | ||
+ | [Desktop Entry] | ||
+ | Encoding=UTF-8 | ||
+ | Version=0.9.9 | ||
+ | Type=Application | ||
+ | Name=MythTV Frontend | ||
+ | Comment= | ||
+ | Exec=mythfrontend | ||
+ | StartupNotify=false | ||
+ | Terminal=false | ||
+ | Hidden=false | ||
+ | </pre>}} | ||
+ | |||
+ | === Mythweb === | ||
+ | For mythweb I just created a symlink to the checked out mythweb in the <code>/var/www</code>: | ||
+ | <code><pre> | ||
+ | sudo ln -s /usr/local/src/mythtv/mythplugins/mythweb /var/www/mythweb | ||
+ | # make sure data is writeable | ||
+ | sudo chown -R www-data /usr/local/src/mythtv/mythplugins/mythweb/data | ||
+ | </pre></code> | ||
+ | |||
+ | you have to enable mod-rewrite | ||
+ | <code><pre> | ||
+ | sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load | ||
+ | </pre></code> | ||
+ | |||
+ | you also need to have a version of php which has session, mysql, pcre, posix and json support | ||
+ | |||
+ | and copy/edit the apache config | ||
+ | |||
+ | <code><pre> | ||
+ | sudo cp mythplugins/mythweb/mythweb.conf.apache /etc/apache2/sites-available/mythweb.conf | ||
+ | sudo ln -s /etc/apache2/sites-available/mythweb.conf /etc/apache2/sites-enabled/mythweb.conf | ||
+ | </pre></code> | ||
+ | |||
+ | after that restart and have fun: | ||
+ | <code><pre> | ||
+ | sudo /etc/init.d/apache2 restart | ||
+ | </pre></code> | ||
+ | |||
+ | == Something didn't work? == | ||
+ | With this you should be able to compile and install mythtv on a new (x)ubuntu box. Most problems come with mythtv setup (config files, database initialization etc.) Please refer to the other wiki pages/documentation for info on that. Before doing that It's best to do some investigation yourself. | ||
+ | |||
+ | The best way to debug problems is to check the output of the backend and frontend tasks: | ||
+ | |||
+ | To check the backend for error messages: | ||
+ | |||
+ | tail -f /var/log/mythtv/mythbackend.log | ||
+ | |||
+ | To check the frontend for errors, you have two options: | ||
+ | |||
+ | 1) run it from the command line. You can ALT+TAB to see the output in the terminal window while the frontend is running: | ||
+ | |||
+ | mythfrontend | ||
+ | |||
+ | 2) check the frontend log for error messages: | ||
+ | |||
+ | tail -f /var/log/mythtv/mythfrontend.log | ||
+ | |||
+ | ==System settings== | ||
+ | |||
+ | When setting up your HTPC / MythTV system, its best to set the following | ||
+ | |||
+ | '''For Ubuntu''' | ||
+ | Volume: the volume control is on the top panel by default. Set this to max. | ||
+ | Power Management: System->Preferences->Power Management - "Put display to sleep when inactive for" move the slider to the far right (never) | ||
+ | Screensaver: System->Preferences->Screensaver - uncheck "Activate screensaver when computer is idle" | ||
+ | System Bell: System->Preferences->Sound - in the "System Beep" tab, uncheck "Enable system beep" and check "Visual System Beep". | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==Setup MythTV backend preferences and tune TV cards== | ||
+ | |||
+ | Open a Terminal Window and type | ||
+ | |||
+ | > mythtv-setup | ||
+ | |||
+ | You will now see the GUI for MythTV to setup the backend server and in particular the channel tuning for our broadcast streams. You will need to set up: | ||
+ | |||
+ | #General — General Backend settings, most user can use the defaults | ||
+ | #Capture Cards — you will configure your capture cards/devices here | ||
+ | #Video Sources — create guide data. | ||
+ | #Input connections — connect the Capture Card name to the Video Source | ||
+ | #Channel Editor — scan for your channels here | ||
+ | #Storage Groups — Configure which folders your recordings will be saved. | ||
+ | |||
+ | On entering each screen, the cursor is positioned at the bottom right on the "Next" button. The cursor may not be visible. Use the up, down, left, and right cursor keys to make selections. Fields marked with up and down arrows can be modified by pressing the PageUp and PageDown keys or the left and right cursor keys; in some cases, the action is different. For example, when setting times, cursor left and cursor right change the time by minutes, while Page Up and Page Down change by half hours. Some fields, notably text fields, accept direct keyboard input. For many fields, context-sensitive help appears in the bottom part of the screen when you position on the field. | ||
+ | |||
+ | ===Multiple tuner cards=== | ||
+ | |||
+ | If you have more than one TV card, you only need to do the channel scan on one of the cards. All cards of the same type should point to the same video source. For example let's say you have two cards both for Freeview (UK Network). Create a Video Source called FreeviewUK, now connect both cards to this Video source. | ||
+ | |||
+ | [DVB1] DVB card 1->FreeviewUK | ||
+ | |||
+ | [DVB0] DVB card 2->FreeviewUK | ||
+ | |||
+ | http://acaciaclose.co.uk/mediac/400_0/media/mythtune.jpg | ||
+ | |||
+ | When you scan for your channels make sure that you put in a frequency that corresponds to the transmitter that you will be receiving from, for instance Crystal Palace. You can find out the frequency on the web for your country and region. | ||
+ | |||
+ | Older TV cards may need all of the parameters from the transmitters tab to be entered, and not just left as "auto". The next version of MythTV (0.19) should have a "blind" scan, and it should just find the channels for you. | ||
+ | |||
+ | Alternatively users in the USA using Schedules Direct can fetch there lineups form Schedules Direct in Input Connections to automatically configure channel lineups. | ||
+ | |||
+ | |||
+ | =More info= | ||
+ | |||
+ | [1] See [[Ubuntu Installation Guides]] for installing on other Ubuntu versions. | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | =Previous information to integrated in the text above= | ||
+ | |||
+ | ==The setup== | ||
+ | |||
+ | There are four key parts to MythTV, and setup roughly in this order: | ||
+ | #Start system services that MythTV needs | ||
+ | #Initialize the system database, mythconverg | ||
+ | #Setup system preferences and tune your TV card using mythtv-setup | ||
+ | #Start main MythTV server, mythtvbackend | ||
+ | #Start MythTV, mythfrontend | ||
'''Create a user called mythtv and do all of the following steps as this user''' | '''Create a user called mythtv and do all of the following steps as this user''' | ||
Line 12: | Line 423: | ||
Its a good idea to run these from a terminal window to start with, so we can see that everything is as it should be. Once all has been set up and complete, then we can run mysql/mythbackend/frontend as background server processes. | Its a good idea to run these from a terminal window to start with, so we can see that everything is as it should be. Once all has been set up and complete, then we can run mysql/mythbackend/frontend as background server processes. | ||
− | + | ==Start system services== | |
− | == Start system services == | ||
We need to have both "mysql" and "mythbackend" running on startup | We need to have both "mysql" and "mythbackend" running on startup | ||
− | + | [[Image:Geeko_head48.png|25px]] openSUSE | |
Start YaST -> System ->System Services ( RunLevel) | Start YaST -> System ->System Services ( RunLevel) | ||
Line 25: | Line 435: | ||
Select ntp click "enable" Click OK after popup dialog | Select ntp click "enable" Click OK after popup dialog | ||
− | Notice there is a mythbackend option, would suggest that you do not enable | + | Notice there is a mythbackend option, would suggest that you do not enable "mythbackend" just yet, until you have tried running in a terminal window as below. If all steps below work then enable this to run. |
− | |||
− | |||
− | |||
+ | ==Setup mysql database mythconverg== | ||
Set the root password for the mysql database. (replace mysqlpassword with your own) | Set the root password for the mysql database. (replace mysqlpassword with your own) | ||
Line 37: | Line 445: | ||
> mysqladmin -u root password mysqlpassword | > mysqladmin -u root password mysqlpassword | ||
− | Setup the initial database | + | Setup the initial database. |
− | The following command will prompt for password | + | Note - the mc.sql file should have been installed along with the mythtv documentation onto your system. The default location for this file is shown below, however it may have been relocated elsewhere according to your distribution's documentation rules, so you may have to use a search (find, locate, etc) tool to reveal its whereabouts. |
+ | Suse 11.0 -- mc.sql is at "/usr/share/doc/packages/mythtv-doc/database/mc.sql" | ||
+ | (The following command will prompt for password) | ||
> mysql -u root -p < /usr/share/mythtv/database/mc.sql | > mysql -u root -p < /usr/share/mythtv/database/mc.sql | ||
− | + | '''How to Reset the Root Password (Slackware):''' | |
− | + | Login as a root | |
+ | > su - | ||
− | + | Stop the database | |
− | > | + | > /etc/rc.d/rc.mysqld stop |
− | + | Set the initial file for a new root database password | |
− | + | > echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');" > /var/lib/mysql/mysql-init | |
− | |||
− | |||
− | |||
− | |||
− | + | Change the user and group ownership | |
+ | > chown mysql.mysql /var/lib/mysql/mysql-init | ||
− | + | Start a database manually | |
− | + | > /usr/bin/mysqld_safe --init-file=/var/lib/mysql/mysql-init & | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Login to the database as a root with a new password | |
− | + | > mysql -u root -p new_password | |
+ | [http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html How to Reset the Root Password] | ||
− | + | [[Category:HOWTO]] | |
+ | [[Category:Distribution_Specific_Install_Guides]] | ||
+ | [[Category:Ubuntu]] |
Revision as of 11:18, 1 February 2014
This page is up-to-date to MythTV version 0.21, the current release is 34.0
Contents
Introduction
There are different ways to get Mythtv installed on your system:
- From source;
- Using apt-get;
- Using a MythTV Linux distribution (e.g. MythBuntu, MythDora, etc.) more info.
In this guide we will discuss how to install from source.
This guide is will allow you to build the latest version of MythTV on Ubuntu and Fedora.
Prerequisites
First install required packages (Version: 0.27):
sudo apt-get install build-essential liblircclient-dev libasound2-dev libdts-dev libdvdnav-dev \
libxv-dev libxxf86vm-dev transcode libmp3lame-dev subversion qt4-dev-tools libqt4-dev libsamplerate0 \
libxvidcore4 liba52-0.7.4-dev libcdio-dev msttcorefonts libasound2-doc libmad0-dev \
libid3tag0-dev libvorbis-dev libflac-dev libcdaudio-dev libcdparanoia0-dev fftw3-dev libfaad-dev \
libsmpeg-dev libmp4v2-dev libtag1-dev mysql-server libvisual-0.4-dev libexif-dev libxvmc-dev \
libxinerama-dev uuid-dev libicu-dev
Note: Version 0.24 requires also libfreetype6-dev; not required but advised: yasm, ccache.
Note: Version 0.21 and earlier use QT3 instad of QT4, so you need: libqt3-mt-dev and libqt3-mt-mysql.
To install css support use:
/usr/share/doc/libdvdread3/install-css.sh
or on newer distributions:
/usr/share/doc/libdvdread4/install-css.sh
If you want mythweb as well - you need
sudo apt-get install apache2 php5 libapache2-mod-php5 php5-mysql
On some systems (might be already installed on your system) you have to install the following to prevent issues with downloading recordings
sudo apt-get install libcpandb-perl
If you want VAAPI support you will need libva-dev
sudo apt-get install libva-dev
To compile and use perl bindings install
sudo apt-get install libnet-upnp-perl
To compile and use python bindings install
sudo apt-get install python-lxml python-mysqldb python-urlgrabber
Getting and compiling the source code
Get the latest code for MythTV. In general, you should probably choose the stable version. If you don't mind if your MythTV system is non-functional or has serious bugs that may prevent proper operation/result in lost recordings or inability to play back recordings, you may try using the unstable, development code. If using unstable, development code, you should follow the mythtv-commits and mythtv-dev mailing lists.
Then, simply go in each directory and configure and build each component:
./configure --enable-proc-opt
make
make install
Note that adding any other configure arguments (with the possible exception of --prefix) to the main MythTV configure command is almost definitely a bad idea and shouldn't be required.
For mythplugins, if you don't want some modules you might want to disable them (run "./configure --help" in each directory to see the options you can set for the build). For example:
./configure --disable-mythgame --disable-mythnetflix
make
make install
Note: If you want to be able to easily uninstall later, for example to update to new set of fixes, use "checkinstall" rather than "make install". "checkinstall" keeps track of all files installed by a "make install" or equivalent, creates a Slackware, RPM, or Debian package with those files, and adds it to the installed packages database, allowing for easy package removal or distribution. "checkinstall" will prompt for a package description, and then you must supply a version number by following the prompts.
./configure
make
checkinstall
Post-install tasks
Creating the mythtv user
to run MythTV as its own user I created one (so the backend doesnt run as root)
sudo useradd mythtv
MythTV database setup
You have to create a file for mythtv for database connections ~mythtv/.mythtv/mysql.txt
DBHostName=localhost # By default, Myth tries to ping the DB host to see if it exists. # If your DB host or network doesn't accept pings, set this to no: # DBHostPing=no DBHostName=localhost DBUserName=mythtv DBName=mythconverg DBPassword=mythtv # Set the following if you want to use something other than this # machine's real hostname for identifying settings in the database. # This is useful if your hostname changes often, as otherwise you # will need to reconfigure mythtv (or futz with the DB) every time. # TWO HOSTS MUST NOT USE THE SAME VALUE # LocalHostName=MYCOOLMYTHTVHOST # If you want your frontend to be able to wake your MySQL server # using WakeOnLan, have a look at the following settings: # # # The time the frontend waits (in seconds) between reconnect tries. # This should be the rough time your MySQL server needs for startup # #WOLsqlReconnectWaitTime=0 # # # This is the number of retries to wake the MySQL server # until the frontend gives up # #WOLsqlConnectRetry=5 # # # This is the command executed to wake your MySQL server. # #WOLsqlCommand=echo 'WOLsqlServerCommand not set'
Then you have to create a database and let the user set above access it
mysql -u root -p create database mythconverg; create user 'mythtv'@'%' identified by 'mythtv'; create user 'mythtv'@'localhost' identified by 'mythtv'; set password for 'mythtv'@'%' = password('mythtv'); set password for 'mythtv'@'localhost' = password('mythtv'); connect mythconverg; grant all privileges on *.* to 'mythtv'@'%' with grant option; grant all privileges on *.* to 'mythtv'@'localhost' with grant option; flush privileges; exit;
Run mythbackend
to test. This will automatically upgrade your previous mythconverg database schema to the latest version:
mythbackend
If mythbackend is running OK, test mythfrontend:
mythfrontend
Running MythTV on start
I use a slightly modified script from mythbuntu for that. Just copy the content to /etc/init.d/mythtv-backend
- chmod it with sudo chmod 755 /etc/init.d/mythtv-backend
To start every time you still have to add it to the rc:
update-rc.d mythtv-backend defaults
Also create a log directory for mythtv:
sudo mkdir /var/log/mythtv
sudo chown mythtv:mythtv /var/log/mythtv
#! /bin/sh ### BEGIN INIT INFO # Provides: mythtv-backend # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop the MythTV server. ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/bin/mythbackend NAME="mythbackend" DESC="MythTV server" test -x $DAEMON || exit 0 . /lib/lsb/init-functions set -e prime_firewire() { if [ "$ENABLE_FIREWIRE" = "TRUE" ]; then log_daemon_msg "Priming Firewire " su - $USER -c "/usr/bin/mythprime" log_end_msg $? fi } USER=mythtv USER_HOME=$(grep ^$USER /etc/passwd | awk -F : '{print $6}') RUNDIR=/var/run/mythtv ARGS="--daemon --logpath /var/log/mythtv --pidfile $RUNDIR/$NAME.pid" EXTRA_ARGS="" NICE=0 if [ -f /etc/default/mythtv-backend ]; then . /etc/default/mythtv-backend fi ARGS="$ARGS $EXTRA_ARGS" mkdir -p $RUNDIR chown -R $USER $RUNDIR unset DISPLAY unset SESSION_MANAGER #create a symbolic link for mysql.txt so it can't be overwritten mkdir -p $USER_HOME/.mythtv chown -R $USER $USER_HOME/.mythtv if [ ! -e $USER_HOME/.mythtv/mysql.txt ]; then ln -s /etc/mythtv/mysql.txt $USER_HOME/.mythtv/mysql.txt fi case "$1" in start) if [ -e $RUNDIR/$NAME.pid ]; then PIDDIR=/proc/$(cat $RUNDIR/$NAME.pid) if [ -d ${RUNDIR} -a "$(readlink -f ${RUNDIR}/exe)" = "${DAEMON}" ]; then log_success_msg "$DESC already started; use restart instead." exit 1 else log_success_msg "Removing stale PID file $RUNDIR/$NAME" rm -f $RUNDIR/$NAME.pid fi fi prime_firewire log_daemon_msg "Starting $DESC: $NAME " start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \ --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS log_end_msg $? ;; stop) log_daemon_msg "Stopping $DESC: $NAME " start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \ --chuid $USER --exec $DAEMON -- $ARGS log_end_msg $? test -e $RUNDIR/$NAME.pid && rm $RUNDIR/$NAME.pid ;; restart|force-reload) log_daemon_msg "Restarting $DESC: $NAME " start-stop-daemon --stop --oknodo --pidfile $RUNDIR/$NAME.pid \ --chuid $USER --exec $DAEMON -- $ARGS sleep 3 prime_firewire start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \ --chuid $USER --nicelevel $NICE --exec $DAEMON -- $ARGS log_end_msg $? ;; status) # We want to maintain backward compatibility with Hardy, # so we're not going to use status_of_proc() pidofproc -p $RUNDIR/$NAME.pid $DAEMON >/dev/null && status=0 || status=$? if [ $status -eq 0 ]; then log_success_msg "$NAME is running" else log_failure_msg "$NAME is not running" fi exit $status ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 exit 2 ;; esac exit 0
Autostarting the frontend in Xubuntu / Ubuntu
Create a file in ~/.config/autostart/mythfrontend.desktop
:
[Desktop Entry] Encoding=UTF-8 Version=0.9.9 Type=Application Name=MythTV Frontend Comment= Exec=mythfrontend StartupNotify=false Terminal=false Hidden=false
Mythweb
For mythweb I just created a symlink to the checked out mythweb in the /var/www
:
sudo ln -s /usr/local/src/mythtv/mythplugins/mythweb /var/www/mythweb
# make sure data is writeable
sudo chown -R www-data /usr/local/src/mythtv/mythplugins/mythweb/data
you have to enable mod-rewrite
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
you also need to have a version of php which has session, mysql, pcre, posix and json support
and copy/edit the apache config
sudo cp mythplugins/mythweb/mythweb.conf.apache /etc/apache2/sites-available/mythweb.conf
sudo ln -s /etc/apache2/sites-available/mythweb.conf /etc/apache2/sites-enabled/mythweb.conf
after that restart and have fun:
sudo /etc/init.d/apache2 restart
Something didn't work?
With this you should be able to compile and install mythtv on a new (x)ubuntu box. Most problems come with mythtv setup (config files, database initialization etc.) Please refer to the other wiki pages/documentation for info on that. Before doing that It's best to do some investigation yourself.
The best way to debug problems is to check the output of the backend and frontend tasks:
To check the backend for error messages:
tail -f /var/log/mythtv/mythbackend.log
To check the frontend for errors, you have two options:
1) run it from the command line. You can ALT+TAB to see the output in the terminal window while the frontend is running:
mythfrontend
2) check the frontend log for error messages:
tail -f /var/log/mythtv/mythfrontend.log
System settings
When setting up your HTPC / MythTV system, its best to set the following
For Ubuntu Volume: the volume control is on the top panel by default. Set this to max. Power Management: System->Preferences->Power Management - "Put display to sleep when inactive for" move the slider to the far right (never) Screensaver: System->Preferences->Screensaver - uncheck "Activate screensaver when computer is idle" System Bell: System->Preferences->Sound - in the "System Beep" tab, uncheck "Enable system beep" and check "Visual System Beep".
Setup MythTV backend preferences and tune TV cards
Open a Terminal Window and type
> mythtv-setup
You will now see the GUI for MythTV to setup the backend server and in particular the channel tuning for our broadcast streams. You will need to set up:
- General — General Backend settings, most user can use the defaults
- Capture Cards — you will configure your capture cards/devices here
- Video Sources — create guide data.
- Input connections — connect the Capture Card name to the Video Source
- Channel Editor — scan for your channels here
- Storage Groups — Configure which folders your recordings will be saved.
On entering each screen, the cursor is positioned at the bottom right on the "Next" button. The cursor may not be visible. Use the up, down, left, and right cursor keys to make selections. Fields marked with up and down arrows can be modified by pressing the PageUp and PageDown keys or the left and right cursor keys; in some cases, the action is different. For example, when setting times, cursor left and cursor right change the time by minutes, while Page Up and Page Down change by half hours. Some fields, notably text fields, accept direct keyboard input. For many fields, context-sensitive help appears in the bottom part of the screen when you position on the field.
Multiple tuner cards
If you have more than one TV card, you only need to do the channel scan on one of the cards. All cards of the same type should point to the same video source. For example let's say you have two cards both for Freeview (UK Network). Create a Video Source called FreeviewUK, now connect both cards to this Video source.
[DVB1] DVB card 1->FreeviewUK
[DVB0] DVB card 2->FreeviewUK
http://acaciaclose.co.uk/mediac/400_0/media/mythtune.jpg
When you scan for your channels make sure that you put in a frequency that corresponds to the transmitter that you will be receiving from, for instance Crystal Palace. You can find out the frequency on the web for your country and region.
Older TV cards may need all of the parameters from the transmitters tab to be entered, and not just left as "auto". The next version of MythTV (0.19) should have a "blind" scan, and it should just find the channels for you.
Alternatively users in the USA using Schedules Direct can fetch there lineups form Schedules Direct in Input Connections to automatically configure channel lineups.
More info
[1] See Ubuntu Installation Guides for installing on other Ubuntu versions.
Previous information to integrated in the text above
The setup
There are four key parts to MythTV, and setup roughly in this order:
- Start system services that MythTV needs
- Initialize the system database, mythconverg
- Setup system preferences and tune your TV card using mythtv-setup
- Start main MythTV server, mythtvbackend
- Start MythTV, mythfrontend
Create a user called mythtv and do all of the following steps as this user
Its a good idea to run these from a terminal window to start with, so we can see that everything is as it should be. Once all has been set up and complete, then we can run mysql/mythbackend/frontend as background server processes.
Start system services
We need to have both "mysql" and "mythbackend" running on startup
Start YaST -> System ->System Services ( RunLevel)
Select mysql click "enable" Click OK after popup dialog
Select ntp click "enable" Click OK after popup dialog
Notice there is a mythbackend option, would suggest that you do not enable "mythbackend" just yet, until you have tried running in a terminal window as below. If all steps below work then enable this to run.
Setup mysql database mythconverg
Set the root password for the mysql database. (replace mysqlpassword with your own)
Open a Terminal window
> mysqladmin -u root password mysqlpassword
Setup the initial database. Note - the mc.sql file should have been installed along with the mythtv documentation onto your system. The default location for this file is shown below, however it may have been relocated elsewhere according to your distribution's documentation rules, so you may have to use a search (find, locate, etc) tool to reveal its whereabouts. Suse 11.0 -- mc.sql is at "/usr/share/doc/packages/mythtv-doc/database/mc.sql" (The following command will prompt for password)
> mysql -u root -p < /usr/share/mythtv/database/mc.sql
How to Reset the Root Password (Slackware):
Login as a root
> su -
Stop the database
> /etc/rc.d/rc.mysqld stop
Set the initial file for a new root database password
> echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');" > /var/lib/mysql/mysql-init
Change the user and group ownership
> chown mysql.mysql /var/lib/mysql/mysql-init
Start a database manually
> /usr/bin/mysqld_safe --init-file=/var/lib/mysql/mysql-init &
Login to the database as a root with a new password
> mysql -u root -p new_password