The abbey has a few TV tuners and a subscription to [[https://schedulesdirect.org/][Schedules Direct]]
for North American TV broadcast schedules. It uses one (master)
-MythTV server and its MythWeb interface to make and serve recordings
-of area broadcasts.
+MythTV server to make and serve recordings of area broadcasts.
-The Abbey TVR Role installs the MythTV backend and the MythWeb web
-interface on the master server. It configures the Apache web server
-to serve MythWeb pages at e.g. ~http://new/mythweb/~.
-
-** Building MythTV and MythWeb
-
-Neither Debian nor the MythTV project provide binary packages of
-MythTV and MythWeb. The project recommends building from source
-according to their [[https://www.mythtv.org/wiki/Build_from_Source][Build from Source]] wiki page. To do this, the
-target host will need several dozen "developer" packages installed.
-Thus the abbey's TVR role proceeds in two phases.
-
-In the first phase, the MythTV project's Ansible code, in
-=mythtv-ansible/=, is used to assemble a list of packages needed
-during the build. The packages are installed and the rest of the
-role's tasks are skipped. This allows the administrator to manually
-build and install MythTV, creating =/usr/local/bin/mythtv-setup=.
-The administrator will also download and install MythWeb before
-running the TVR role again for its second phase. The administrator
-will /not/ be able to run ~mythtv-setup~ before completing the second
-phase.
-
-In the second phase, the role finds =mythtv-setup= has been installed
-on the target host and so proceeds with the "Post-installation tasks"
-section of the wiki page. This still leaves a number of manual steps
-to be performed with the ~mythtv-setup~ program, e.g. configuring a
-video source and capture card, after which the backend can be started.
-
-** TVR Machine Setup
+The MythTV backend stores recordings in =/home/mythtv/Recordings/= and
+database dumps in =/home/mythtv/Backups/=. Apache is
+configured to serve MythTV pages at e.g. ~http://new/mythweb/~.
A new TVR machine needs only [[*Cloistering][Cloistering]] to prepare it for
Ansible. As part of that process, it should be added to the ~tvrs~
group in the =hosts= file. An existing server can become a TVR
-machine simply by adding it to the ~tvrs~ group.
+machine by adding it to the ~tvrs~ group.
** Include Abbey Variables
include_vars: ../private/vars-abbey.yml
#+END_SRC
-** Install MythTV Build Requisites
-
-A number of developer packages are needed to build MythTV. The wiki
-page recommends Ansible playbooks to assemble the appropriate list of
-package names (several dozen count) depending on the target OS
-version. The playbooks are in [[https://github.com/MythTV/ansible]] which
-contains a =README.md=.
-
-The instructions in the =README.md= are to clone the repository and
-run ~sudo ansible-playbook -i hosts qt5.yml~ on the build machine.
-However the abbey prefers to keep the Ansible code on an
-administrator's machine with the rest of the abbey's roles. The
-following commands were used to create a =mythtv-ansible/=
-subdirectory. (A ~git pull origin~ command in this subdirectory might
-be appropriate to download updates.)
-
-#+BEGIN_SRC sh
-git clone https://github.com/MythTV/ansible mythtv-ansible
-cd mythtv-ansible
-git checkout fixes/32
-#+END_SRC
-
-The ~abbey-tvr~ role uses a couple tasks files in =mythtv-ansible/=
-directly, bypassing the inventories, playbooks and roles, /after/
-"fixing" the final ~apt~ tasks by adding ~become: yes~. After making
-these edits, the ~git diff~ command should produce something like the
-following.
-
-#+BEGIN_SRC diff
-diff --git a/roles/mythtv-deb/tasks/main.yml b/roles/mythtv-deb/tasks
-index 868c9b7..3dcf115 100644
---- a/roles/mythtv-deb/tasks/main.yml
-+++ b/roles/mythtv-deb/tasks/main.yml
-@@ -366,6 +366,7 @@
- '{{ lookup("flattened", deb_pkg_lst) }}'
-
- - name: install packages
-+ become: yes
- apt:
- name:
- '{{ lookup("flattened", deb_pkg_lst ) }}'
-diff --git a/roles/qt5/tasks/qt5-deb.yml b/roles/qt5/tasks/qt5-deb.ym
-index 7a1a0bc..26ba782 100644
---- a/roles/qt5/tasks/qt5-deb.yml
-+++ b/roles/qt5/tasks/qt5-deb.yml
-@@ -25,6 +25,7 @@
- '{{ lookup("flattened", deb_pkg_lst) }}'
-
- - name: install deb qt5 packages
-+ become: yes
- apt:
- name:
- '{{ lookup("flattened", deb_pkg_lst ) }}'
-#+END_SRC
-
-#+CAPTION: [[file:roles_t/abbey-tvr/tasks/mains.yml][=roles_t/abbey-tvr/tasks/mains.yml=]]
-#+BEGIN_SRC conf :tangle roles_t/abbey-tvr/tasks/main.yml
-
-- name: Install MythTV runtime requisites.
- become: yes
- apt:
- pkg: [ mariadb-server, xmltv ]
-
-- name: Install MythTV build requisites.
- include_tasks: "{{ item }}"
- loop:
- - ../mythtv-ansible/roles/mythtv-deb/tasks/main.yml
- - ../mythtv-ansible/roles/qt5/tasks/qt5-deb.yml
-#+END_SRC
-
-The tasks above install runtime and compile-time requisites during the
-"first" run of e.g. ~./abbey config new~. The "first" run can be
-repeated until successful. The remaining tasks are skipped until
-MythTV is built and installed.
+** Manually Build and Install MythTV
-** Build and Install MythTV
+Neither Debian nor the MythTV project provide binary packages of
+MythTV. Since PEP668 (~error: externally-managed-
+environment~) we install Debian packages built with the scripts in the
+MythTV distribution Packaging project.
-After a successful "first" run of e.g. ~./abbey config new~, the
-target machine is prepared to build (and install) MythTV. The
-following commands are used.
+It is assumed the build scripts will install any requisite developer
+packages.
#+BEGIN_SRC sh
-cd /usr/local/src/
-git clone https://github.com/MythTV/mythtv
-cd mythtv/
-git checkout fixes/32
-cd mythtv/
-./configure
-make
-sudo make install
-#+END_SRC
-
-The ~make install~ command does not need to be run as ~root~ if
-=bin/=, =lib/=, =include/=, =share/= in =/usr/local/= and
-=dist-packages/= in =/usr/local/lib/python3.9/= on the target machine
-are writable by the builder.
-
-The following task probes for the =mythtv-setup= program, installed in
-=/usr/local/bin/=, to detect that the build/install process has
-completed. It registers the results in the ~mythtv~ variable.
-Several of the remaining installation steps are skipped unless
-~mythtv.stat.exists~.
-
-#+CAPTION: [[file:roles_t/abbey-tvr/tasks/main.yml][=roles_t/abbey-tvr/tasks/main.yml=]]
-#+BEGIN_SRC conf :tangle roles_t/abbey-tvr/tasks/main.yml
-
-- name: Test for MythTV binary packages.
- stat:
- path: /usr/local/bin/mythtv-setup
- register: mythtv
-- debug:
- msg: "/usr/local/bin/mythtv-setup does not yet exist"
- when: not mythtv.stat.exists
-#+END_SRC
-
-** Create MythTV User
-
-MythTV Backend needs to run as its own user: ~mythtv~.
-
-#+CAPTION: [[file:roles_t/abbey-tvr/tasks/main.yml][=roles_t/abbey-tvr/tasks/main.yml=]]
-#+BEGIN_SRC conf :tangle roles_t/abbey-tvr/tasks/main.yml
-
-- name: Create mythtv.
- become: yes
- user:
- name: mythtv
- system: yes
-#+END_SRC
-
-** Create MythTV DB
-
-MythTV's MariaDB database is created by the following task, when the
-~mysql_db~ Ansible module supports ~check_implicit_admin~.
-
-#+BEGIN_SRC conf
-
-- name: Create MythTV DB.
- become: yes
- mysql_db:
- check_implicit_admin: yes
- name: mythconverg
- collation: utf8mb4_general_ci
- encoding: utf8mb4
-#+END_SRC
-
-Unfortunately it does not currently, yet the institute prefers the
-more secure Unix socket authentication method. Rather than create a
-privileged DB user, the ~mythconverg~ database is created manually
-(below).
-
-** Create MythTV DB User
-
-The DB user's password is taken from the ~mythtv_dbpass~ variable,
-kept in =private/vars-abbey.yml=, and generated e.g. with the ~apg -n
-1 -x 12 -m 12~ command.
-
-#+CAPTION: [[file:private_ex/vars-abbey.yml][=private_ex/vars-abbey.yml=]]
-#+BEGIN_SRC conf :tangle private_ex/vars-abbey.yml
-mythtv_dbpass: daJkibpoJkag
-#+END_SRC
-
-The following task would create the DB user (~mysql_user~ supports
-~check_implicit_admin~) /but/ the ~mythconverg~ database was not
-created above.
-
-#+BEGIN_SRC conf
-
-- name: Create MythTV DB user.
- become: yes
- mysql_user:
- check_implicit_admin: yes
- name: mythtv
- password: "{{ mythtv_dbpass }}"
- priv: "mythconverg.*:all"
-#+END_SRC
-
-** Manually Create MythTV DB and DB User
-
-The MythTV database and database user are created manually with the
-following SQL (with the ~mythtv_dbpass~ spliced in). The SQL commands
-are entered at the SQL prompt of the ~sudo mysql~ command, or perhaps
-piped into the command.
-
-#+BEGIN_SRC sql
-create database mythconverg
- character set utf8mb4
- collate utf8mb4_general_ci;
-create user 'mythtv'@'%' identified by '{{ mythtv_dbpass }}';
-create user 'mythtv'@'localhost' identified by '{{ mythtv_dbpass }}';
-grant all privileges on mythconverg.*
- to 'mythtv'@'%' with grant option;
-grant all privileges on mythconverg.*
- to 'mythtv'@'localhost' with grant option;
-flush privileges;
-exit;
-#+END_SRC
-
-** Load DB Timezone Info
+cd $top
+git clone https://github.com/MythTV/packaging.git \
+ -b fixes/35 mythtv-v35-packaging
+cd mythtv-v35-packaging/deb/
+./build-debs.sh fixes/35
+dpkg-scanpackages . | gzip --best > Packages.gz
+echo "deb [trusted=yes] file://$top/mythtv-v35-packaging/deb ./" \
+| sudo tee /etc/apt/sources.list.d/mythtv35.list
+sudo apt update
+sudo apt install mythtv-backend
+#+END_SRC
+
+** Restore MythTV
+
+Restoring MythTV from a backup copy to a fresh TVR host:
+
+- Apply the TVR role to the new host thus installing build requisites.
+- Manually load SQL timezone info.
+- Manually build and install (as described above).
+- Restore =/home/mythtv/=.
+- Restore the database from backup.
+ : sudo -u mythtv -i
+ : cd /home/mythtv/
+ : /usr/share/mythtv/mythconverg_restore.pl
+ The =.mythtv/config.xml= file should provide the DB particulars
+ (name, user, password).
+- Reboot or start the service.
+- Configure the backend (as described below).
+
+** Manually Load DB Timezone Info
Starting with MythTV version 0.26, the time zone tables must be loaded
-into MySQL. The MariaDB installed by Debian 11 seems to need this
+into MySQL. The MariaDB installed by Debian 12 seems to need this
too. The test SQL produced ~NULL~.
#+BEGIN_SRC sql
mysql_tzinfo_to_sql /usr/share/zoneinfo | sudo mysql mysql
#+END_SRC
-** Create MythTV Backend Service
-
-This task installs the =mythtv-backend.service= file.
-
-#+CAPTION: [[file:roles_t/abbey-tvr/tasks/mains.yml][=roles_t/abbey-tvr/tasks/mains.yml=]]
-#+BEGIN_SRC conf :tangle roles_t/abbey-tvr/tasks/main.yml
-
-- name: Create mythtv-backend service.
- become: yes
- copy:
- content: |
- [Unit]
- Description=MythTV Backend
- Documentation=https://www.mythtv.org/wiki/Mythbackend
- After=mysql.service network.target
-
- [Service]
- User=mythtv
- ExecStartPre=/bin/sleep 30
- #TimeoutStartSec=infinity
- ExecStart=/usr/local/bin/mythbackend --quiet --syslog local7
- StartLimitBurst=10
- StartLimitInterval=10m
- Restart=on-failure
- RestartSec=1
-
- [Install]
- WantedBy=multi-user.target
- dest: /etc/systemd/system/mythtv-backend.service
- when: mythtv.stat.exists
- notify: Reload Systemd.
-#+END_SRC
-
-#+CAPTION: [[file:roles_t/abbey-tvr/handlers/main.yml][=roles_t/abbey-tvr/handlers/main.yml=]]
-#+BEGIN_SRC conf :tangle roles_t/abbey-tvr/handlers/main.yml :mkdirp yes
----
-- name: Reload Systemd.
- become: yes
- command: systemctl daemon-reload
-#+END_SRC
-
-** Set PHP Timezone
-
-This task checks PHP's timezone. If unset, MythTV's backend logs
-bitter complaints.
-
-#+CAPTION: [[file:roles_t/abbey-tvr/tasks/main.yml][=roles_t/abbey-tvr/tasks/main.yml=]]
-#+BEGIN_SRC conf :tangle roles_t/abbey-tvr/tasks/main.yml
-
-- name: Get the local timezone.
- shell: readlink /etc/localtime | sed s,/usr/share/zoneinfo/,,
- delegate_to: localhost
- changed_when: false
- check_mode: false
- register: timezone
-
-- name: Configure PHP date.timezone.
- become: yes
- lineinfile:
- regexp: date.timezone *=
- line: date.timezone = {{ timezone.stdout }}
- path: "{{ item }}"
- loop:
- - /etc/php/8.2/cli/php.ini
- - /etc/php/8.2/apache2/php.ini
- when: mythtv.stat.exists
- notify: Restart Apache2.
-#+END_SRC
-
-#+CAPTION: [[file:roles_t/abbey-tvr/handlers/main.yml][=roles_t/abbey-tvr/handlers/main.yml=]]
-#+BEGIN_SRC conf :tangle roles_t/abbey-tvr/handlers/main.yml :mkdirp yes
----
-- name: Restart Apache2.
- become: yes
- systemd:
- service: apache2
- state: restarted
- tags: actualizer
-#+END_SRC
-
** Create MythTV Storage Area
The backend does not have a default storage area for its recordings.
** Configure MythTV Backend
-With MythTV built and installed, and the post-installation tasks
-addressed, MythTV Setup (the ~mythtv-setup~ program) can be run. It
-must be run by the ~mythtv~ user, whose home directory will contain
-the MythTV (and XMLTV) configuration files. The program is best run
-remotely (unless there is a graphical desktop on the server) by a
-command like ~ssh -X mythtv@new mythtv-setup~.
-
-Patience is required. The ~mythtv-setup~ program was not written for
-X11 and the X11 adapter has a difficult job. It is often hard to
-determine what button is selected or how to proceed (sometimes simply
-with ~ESC~!). Sticking to the arrow, enter and escape keys best
-emulates a TV remote (for which the interface was designed).
+With MythTV built and installed, the post-installation tasks
+addressed, and ~mythtv-backend.service~ started, go to the web page
+at [[http://new:6544]] and make the following selections.
-In MythTV Setup:
-
-- In the initial MythTV Startup Status ("Unable to connect to
- Database."), use the "Setup" button to get to "Database
- Configuration". Leave the default hostname (~localhost~), port
- (~3306~), database name (~mythconverg~) and user (~mythtv~). Enter
- the value of ~mythtv_dbpass~ (in =private/vars-abbey.yml=) for the
- password. Leave the rest of the settings at their default values.
- Leave "Database Configuration" by pressing Escape and confirming
- "Save and Exit".
-
-- Once in MythTV Setup proper, you will see the main menu. Scroll
- down and choose "Storage Directories". In the Local Storage Groups
- dialog, add to the "Local 'Default' Storage Group Directories" a new
- directory: =/home/mythtv/Recordings=.
+ + Select MythTV Setup (gear icon in the left sidebar).
+ + Select "Storage Groups".
+ + Select "Default" and choose =/home/mythtv/Recordings/=.
+ + Select "DB Backups" and choose =/home/mythtv/Backups/=.
** Configure Tuner
--output /tmp/mythFUBAR
#+END_SRC
-** Configure MythTV Backend Logging
-
-The abbey directs MythTV log messages to =/var/log/mythtv.log= (and
-away from =/var/log/syslog=) and rotates the log file.
-
-#+CAPTION: [[file:roles_t/abbey-tvr/tasks/main.yml][=roles_t/abbey-tvr/tasks/main.yml=]]
-#+BEGIN_SRC conf :tangle roles_t/abbey-tvr/tasks/main.yml
-
-- name: Install =/etc/rsyslog.d/40-mythtv.conf.
- become: yes
- copy:
- content: |
- :msg,startswith," myth" -/var/log/mythtv.log
- & stop
- dest: /etc/rsyslog.d/40-mythtv.conf
-
-- name: Install =/etc/logrotate.d/mythtv=.
- become: yes
- copy:
- content: |
- /var/log/mythtv.log {
- daily
- size=10M
- rotate 7
- notifempty
- copytruncate
- missingok
- postrotate
- reload rsyslog >/dev/null 2>&1 || true
- endscript
- }
- dest: /etc/logrotate.d/mythtv
-#+END_SRC
-
-** Start MythTV Backend
-
-After configuring with ~mythtv-setup~ as discussed above, start and
-enable (at boot time) the ~mythtv-backend~ service.
-
-#+BEGIN_SRC sh
-sudo systemctl enable mythtv-backend
-sudo systemctl start mythtv-backend
-systemctl status -l mythtv-backend
-sudo -u mythtv mythfilldatabase
-#+END_SRC
-
-** Install MythWeb
-
-MythWeb, like MythTV, is installed from a Git repository. The
-following commands create =/usr/local/share/mythtv/mythweb/= by
-cloning the MythWeb repository in =/usr/local/src/mythweb/=, checking
-out the appropriate branch, and copying the appropriate portion.
-
-#+BEGIN_SRC sh
-cd /usr/local/src/
-git clone https://github.com/MythTV/mythweb
-( cd mythweb/; git checkout fixes/32 )
-rsync -C mythweb /usr/local/share/mythtv/
-#+END_SRC
-
-The following tasks take care of the rest of the installation.
-
-#+CAPTION: [[file:roles_t/abbey-tvr/tasks/main.yml][=roles_t/abbey-tvr/tasks/main.yml=]]
-#+BEGIN_SRC conf :tangle roles_t/abbey-tvr/tasks/main.yml
-
-- name: Install MythWeb requisites.
- become: yes
- apt:
- pkg: [ apache2, php, php-mysql ]
-
-- name: Install MythWeb in web server DocumentRoot.
- file:
- state: link
- src: /usr/local/share/mythtv/mythweb
- dest: /var/www/html/mythweb
-
-- name: Configure MythWeb data directory.
- file:
- state: directory
- dest: /var/www/html/mythweb/data
- group: www-data
- mode: u=rwx,g+rwx,o=rx
-
-- name: Install MythWeb configuration.
- become: yes
- template:
- src: mythweb.conf.j2
- dest: /etc/apache2/sites-available/mythweb.conf
- notify: Restart Apache2.
-
-- name: Enable MythWeb configuration.
- become: yes
- command:
- cmd: a2ensite -q mythweb
- creates: /etc/apache2/sites-enabled/mythweb.conf
- notify: Restart Apache2.
-#+END_SRC
-
-#+CAPTION: [[file:roles_t/abbey-tvr/templates/mythweb.conf.j2][=roles_t/abbey-tvr/templates/mythweb.conf.j2=]]
-#+BEGIN_SRC conf :tangle roles_t/abbey-tvr/templates/mythweb.conf.j2 :mkdirp yes
-#
-# Apache configuration directives for MythWeb.
-#
-# Note that this file is maintained by the network administration.
-<Directory "/var/www/html/mythweb/data">
- # For Apache 2.2
- #Options -All +FollowSymLinks +IncludesNoExec
- # For Apache 2.4+
- Options +FollowSymLinks +IncludesNoExec
-</Directory>
-<Directory "/var/www/html/mythweb" >
- <Files mythweb.*>
- setenv db_server "127.0.0.1"
- setenv db_name "mythconverg"
- setenv db_login "mythtv"
- setenv db_password "{{ mythtv_dbpass }}"
- </Files>
- <Files *.php>
- php_value file_uploads 0
- php_value allow_url_fopen On
- php_value zlib.output_handler Off
- php_value memory_limit 64M
- php_value max_execution_time 30
- php_value display_startup_errors On
- php_value display_errors On
- </Files>
- RewriteEngine on
- RewriteRule \
-^(css|data|images|js|themes|skins|README|INSTALL|[a-z_]+\.(php|pl))(/|$)\
- - [L]
- RewriteRule ^(pl(/.*)?)$ mythweb.pl/$1 [QSA,L]
- RewriteRule ^(.+)$ mythweb.php/$1 [QSA,L]
- RewriteRule ^(.*)$ mythweb.php [QSA,L]
- AllowOverride All
- Options FollowSymLinks
- AddType video/nuppelvideo .nuv
- AddType image/x-icon .ico
- <IfModule deflate_module>
- BrowserMatch ^Mozilla/4 gzip-only-text/html
- BrowserMatch ^Mozilla/4\.0[678] no-gzip
- BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
- AddOutputFilterByType DEFLATE text/html
- AddOutputFilterByType DEFLATE text/css
- AddOutputFilterByType DEFLATE application/x-javascript
- </IfModule>
- <IfModule headers_module>
- Header append Vary User-Agent env=!dont-vary
- </IfModule>
- <Files *.pl>
- SetHandler cgi-script
- Options +ExecCGI
- </Files>
-
-</Directory>
-#+END_SRC
-
** Change Broadcast Area
The abbey changes location almost weekly, so its HDTV broadcast area
state: restarted
loop: [ mysql, mythtv-backend ]
when: new_tz.changed
-
-- hosts: core
- tasks:
- - name: Update PHP date.timezone.
- become: yes
- lineinfile:
- regexp: date.timezone *=
- line: date.timezone = {{ city.stdout }}
- path: "{{ item }}"
- loop:
- - /etc/php/8.2/cli/php.ini
- - /etc/php/8.2/apache2/php.ini
- notify: Restart Apache2.
- handlers:
- - name: Restart Apache2.
- become: yes
- systemd:
- service: apache2
- state: restarted
#+END_SRC
** Abbey Command Help