# -*- mode: org; -*-
* Settings for Export :noexport:
:DOCUMENT_OPTIONS:
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+OPTIONS: ^:nil
# Local Variables:
# org-src-preserve-indentation: t
# End:
#+PROPERTY: header-args :mkdirp yes :padline no
#+TITLE: Ansible Playbooks for yaVDR 0.7
#+Author: Alexander Grothe
#+STARTUP: latexpreview
#+LATEX_CLASS_OPTIONS: [ngerman,a4paper,locale=DE,koma,palatino,DIV=15,BCOR=15mm]
#+LATEX_HEADER: \usepackage[margin=3.0cm]{geometry}
#+LATEX_HEADER: \usepackage[ngerman]{babel}
#+LATEX_HEADER: \usepackage{palatino}
#+LATEX_HEADER: \renewcommand*\ttdefault{cmvtt}
#+LATEX_HEADER: \usepackage{rotating}
#+LATEX_HEADER: \usepackage{paralist}
#+LATEX_HEADER: \usepackage{booktabs}
#+LATEX_HEADER: \usepackage{titlesec}
#+LATEX_HEADER: \usepackage[locale=DE,seperr,repeatunits=true,trapambigerr=false,tophrase={{ bis }}]{siunitx}
#+LATEX_HEADER: \usemintedstyle{lovelace}
#+LATEX: \defaultfontfeatures{Ligatures=TeX}
#+LATEX_HEADER: \usepackage{parskip}
# #+LATEX_HEADER_EXTRA:
#+EXCLUDE_TAGS: noexport
:END:
* User Stories
** yavdr-full
A User wants to install yaVDR without customization and relies on full automation.
After installing a supported Ubuntu Server version and (if needed) setting up the network connection, the install script is downloaded and started.
The install script adds the ansible PPA, installs ansible and other basic dependencies and runs the automated installation process.
Several roles are used to tie everything together:
- yavdr-common :: installs the basic set of packages needed and preconfigures the system (package sources, package manager settings, entires for network ports, directory structure etc.). Also collects information about the system
- autoinstall-ubuntu-drivers :: uses Ubuntu's automatic detection for additional drivers (e.g. proprietary nvidia driver, microcode updates, VirtualBox guest additions)
- vdr :: install the vdr package and required plugins
- pulseaudio :: install and preconfigure pulseaudio
- yavdr-network :: configure WOL, add nfs client capabilites, install avahi-linker
- samba-server :: install and preconfigure a samba server
- nfs-server :: install nfs-kernelserver and preconfigure nfs exports (and avahi-announcements)
- autoinstall-satip :: install vdr-plugin-satip if a Sat>IP server has been found
- autoinstall-targavfd :: install vdr-plugin-targavfd if display is connected
- autoinstall-imonlcd :: install vdr-plugin-imonlcd if a matchind display is connected
- yavdr-xorg :: install and configure a systemd user session with a running X-server. A frontend script will manage VDR's frontend and other applications like KODI. Also choose the best possible output plugin.
- grub-config :: update grub configuration based on executed roles
*** Using vdr, pulseaudio and xorg together
* Notes :noexport:
:PROPERTIES:
:noexport: nil
:END:
** TODO [#A] optimize and document data structure for xorg parsing script
** TODO [#A] xorg.conf templates for intel, nvidia, noveau and radeon drivers
*** STARTED BusID für (nvidia) Grafikkarten aus lspci auslesen
Format: "%d:%d:%d" (lspci liefert es als "%04x:%02x:%02x.%x", domain, bus, device, function)
- Wie mit mehreren GPUs umgehen? Priorität bzw. Reihenfolge?
- Was ist mit NVidia Optimus/Bumblebee (AFAIK keine VDPAU-Funktionalität)?
- Wie BusID der xrandr-Ausgabe zuordnen?
*** NVIDIA-Dokumentation zur BusID:
**** What is the format of a PCI Bus ID?
Different tools have different formats for the PCI Bus ID of a PCI device.
The X server's "BusID" X configuration file option interprets the BusID string in the format "bus@domain:device:function" (the "@domain" portion is only needed if the PCI domain is non-zero), in decimal. More specifically,
"%d@%d:%d:%d", bus, domain, device, function
in printf(3) syntax. NVIDIA X driver logging, nvidia-xconfig, and nvidia-settings match the X configuration file BusID convention.
The lspci(8) utility, in contrast, reports the PCI BusID of a PCI device in the format "domain:bus:device.function", printing the values in hexadecimal. More specifically,
"%04x:%02x:%02x.%x", domain, bus, device, function
in printf(3) syntax. The "Bus Location" reported in the /proc/driver/nvidia/gpus/0..N/information files matches the lspci format.
**** Parsen der /proc/driver/nvidia/gpus/*/information Dateien
#+BEGIN_SRC python
# read the BusID for nvidia cards and the model name
# from the /proc/driver/nvidia/gpus/*/information file(s)
from __future__ import print_function
import glob
import re
BusID_RE = re.compile((
'(?P[0-9a-fA-F]+)'
':'
'(?P[0-9a-fA-F]+)'
':'
'(?P[0-9a-fA-F]+)'
'\.'
'(?P[0-9a-fA-F]+)'
))
Model_RE = re.compile('Model:\s+(.*)')
def get_BusIDs():
for gpu_info in glob.glob('/proc/driver/nvidia/gpus/*/information'):
with open(gpu_info) as f:
data = f.read()
match = BusID_RE.search(data)
if match:
BusID = "{:d}@{:d}:{:d}:{:d}".format(*(int(n, 16) for n in match.groups()))
yield BusID, Model_RE.match(data).groups()[0]
if __name__ == '__main__':
BusIDs = [BusID for BusID in get_BusIDs()]
print(BusIDs)
#+END_SRC
** TODO [#B] plan for customization of xorg settings by the user
either directly or using a configuration wizard or a web frontend
** SOMEDAY [#C] select best frontend based on GPU
- intel :: softhddevice-vpp
- amd :: softhddevice-vpp
- nvidia :: softhddevice-openglosd (if no HEVC channels are needed)
* Introduction
One of the major problems we faced with customized Ubuntu ISO files as installation media for prior yaVDR versions has been the limited hardware support and the time consuming process to create and update them. An interesting alternative to this approach is to enable the user to choose the installation medium himself so point releases, kernel versions and additional drivers can be chosen deliberately. After the basic setup is complete (and a working internet connection is available), a fully customizable install script completes the yaVDR installation.
* Installing and configuring yaVDR with Ansible
This is an experimental feature which allows to set up a yaVDR installation based on a normal Ubuntu Server 16.04.x installation using [[http://ansible.com][Ansible]].
This Manual is written in org-mode for Emacs and can rewrite the complete ansible configuration if you call ~org-babel-tangle~ from within emacs.
To use this playbook on a Ubuntu Server Installation you need to run the following commands:
#+BEGIN_SRC shell
sudo apt-get install git
git clone https://github.com/yavdr/yavdr-ansible.git
cd yavdr-ansible
sudo ./install-yavdr.sh
#+END_SRC
** Install script for local usage
#+BEGIN_SRC shell :tangle install-yavdr.sh :shebang "#!/bin/bash"
if (( $EUID != 0 )); then
echo "This script must be run using sudo -H or as root"
exit
fi
apt-get -y install software-properties-common
# Add repository for ansible
add-apt-repository -y ppa:yavdr/experimental-main
# update packages
apt-get update
# install required packages
apt-get -y install --no-install-recommends ansible
# TODO: run ansible on local host
ansible-playbook yavdr07.yml -b -i 'localhost_inventory' --connection=local --tags=install
#+END_SRC
* Playbooks
** yavdr07.yml
The ~yavdr07.yml~ playbook sets up a fully-featured yaVDR installation:
#+BEGIN_SRC yaml :tangle yavdr07.yml :mkdirp yes :padline no
---
# file: yavdr07.yml
# this playbook sets up a complete yaVDR 0.7 installation
- name: set up yaVDR
hosts: all
become: true
roles:
- yavdr-common # install and configure the basic system
- collect-facts # query system facts
- autoinstall-ubuntu-drivers # use ubuntu-drivers to install proprietary dirvers
# (e.g. nvidia, virtualbox)
- autoinstall-virtualbox-guest
# - nvidia-387 # install very recent nvidia-387 from ppa:graphics-drivers/ppa
- vdr # install vdr and related packages
- yavdr-network # enable network client capabilities
- samba-install # install samba server
- samba-config # configure samba server
- nfs-server # install nfs server
- pulseaudio # install pulseaudio
- yavdr-xorg # graphical session
- yavdr-remote # remote configuration files, services and scripts
- autoinstall-satip # install vdr-plugin-satip if a Sat>IP server has been found
- autoinstall-targavfd # install vdr-plugin-targavfd if display is connected
- autoinstall-imonlcd # install vdr-plugin-imonlcd if a matchind display is connected
- autoinstall-pvr350 # install vdr-plugin-pgvr350 if a matching card is detected
- autoinstall-hauppauge-pvr # install vdr-plugin-pvrinput if a matching card is found
- autoinstall-dvbsddevice # install vdr-plugin-dvbsddevice if a matching card is detected
- autoinstall-hardware-irmp # install yavdr-hardware-irmp if a matching usb device is detected
- autoinstall-dvbsky-firmware # download an install required firmware files for dvbsky cards
- kodi
- dvd # set up packages and a udev rule to allow kodi and other players
# to play and eject optical media
- wakeup # set up wakeup methods for rtc etc.
- grub-config # configure grub
tags:
- always
handlers:
- import_tasks: handlers/main.yml
#+END_SRC
** yavdr07-headless.yml
For a headless server installation ~yavdr07-headless.yml~ is a good choice
#+BEGIN_SRC yaml :tangle yavdr07-headless.yml :mkdirp yes :padline no
---
# file: yavdr07-headless.yml
# this playbook set up a headless yaVDR 0.7 installation
- name: set up a headless yaVDR server
hosts: all
become: true
roles:
- yavdr-common
- collect-facts # query system facts
- vdr
- yavdr-network
- samba-server
- samba-config
- nfs-server
- grub-config
- autoinstall-satip
- wakeup
tags:
- always
handlers:
- import_tasks: handlers/main.yml
#+END_SRC
* Hosts
This playbook can either be used to run the installation on the localhost or any other PC in the network that can be accessed via ssh. Simply add the host names or IP addresses to the hosts file in the respective section:
#+BEGIN_SRC conf :tangle localhost_inventory :mkdirp yes :padline no
[local]
localhost connection=local
#+END_SRC
* Group Variables
** default text for templates used by ansible
#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes :padline no
---
# file: group_vars/all
# this is the standard text to put in templates
ansible_managed_file: "*** YAVDR: ANSIBLE MANAGED FILE ***"
#+END_SRC
** PPAs
#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes
branch: experimental
ppa_owner: 'ppa:yavdr'
# add the following PPAs
repositories:
- '{{ ppa_owner }}/{{branch}}-main'
- '{{ ppa_owner }}/{{branch}}-vdr'
#- '{{ ppa_owner }}/{{branch}}-yavdr'
#- '{{ ppa_owner }}/{{branch}}-kodi'
#+END_SRC
** VDR user, directories, special configuration and plugins
#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes
# properties of the user vdr and vdr-related options
vdr:
user: vdr
group: vdr
uid: 666
gid: 666
home: /var/lib/vdr
confdir: /var/lib/vdr
recdir: /srv/vdr/video
hide_first_recording_level: false
safe_dirnames: true # escape characters (useful for windows clients and FAT/NTFS file systems)
override_vdr_charset: false
# add the vdr plugins you want to install
vdr_plugins:
- vdr-plugin-devstatus
- vdr-plugin-markad
- vdr-plugin-restfulapi
- vdr-plugin-softhddevice-vpp
#+END_SRC
** Media directories
#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes
# dictionary of directories for (shared) files. Automatically exported via NFS and Samba if those roles are enabled
media_dirs:
audio: /srv/audio
video: /srv/video
pictures: /srv/picture
files: /srv/files
backups: /srv/backups
recordings: '{{ vdr.recdir }}'
#+END_SRC
** NFS
#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes
nfs:
insecure: false # set to true for OS X clients or if you plan to use libnfs as unprivileged user (e.g. KODI)
#+END_SRC
** Samba
#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes
samba:
workgroup: YAVDR
windows_compatible: '{{ vdr.safe_dirnames }}' # set to true to disable unix extensions, enable follow symlinks and wide links
#+END_SRC
** Additional packages
#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes
# additional packages you want to install
extra_packages:
- bpython
- bpython3
- htop
- tree
- vim
- w-scan
#+END_SRC
** System pre-configuration
#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes
frontend: vdr
#system:
# shutdown: poweroff
wakeup_method: acpiwakeup
grub:
timeout: 0
boot_options: quiet nosplash
#+END_SRC
* Roles
** install-dependencies
*** tasks
**** main.yml
#+BEGIN_SRC yaml :tangle roles/install-packages/tasks/main.yml :mkdirp yes :padline no
---
- name: apt | install packages
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
'{{ packages }}'
#+END_SRC
** nvidia-387 drivers
install nvidia-387 from ppa:graphics-drivers/ppa
*** tasks
**** main.yml
#+BEGIN_SRC yaml :tangle roles/nvidia-387/tasks/main.yml :mkdirp yes :padline no
---
- name: add ppa:graphics-drivers/ppa
apt_repository:
repo: 'ppa:graphics-drivers/ppa'
state: present
update_cache: yes
- name: install nvidia-387 and other required packages
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
- nvidia-387
- nvidia-settings
#+END_SRC
** yavdr-common
This role is used to set up a basic yaVDR installation. It creates the directories, installs the vdr and other useful packages.
*** default variables
This section is for reference only, please use the files in ~global_vars~ for customizations.
#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes :padline no
---
# file: roles/yavdr-common/defaults/main.yml
#+END_SRC
**** Repositories
You can set a list of package repositories which provide the necessary packages. Feel free to use own PPAs if you need special customization to the VDR and it's plugins.
#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes :padline yes
branch: unstable
repositories:
- 'ppa:yavdr/main'
- 'ppa:yavdr/unstable-main'
- 'ppa:yavdr/{{branch}}-vdr'
- 'ppa:yavdr/{{branch}}-kodi'
- 'ppa:yavdr/{{branch}}-yavdr'
#+END_SRC
**** Drivers
Automatically installed drivers can be very useful, but if you know you need a certain driver, you can simply set it's value to *true*. If you don't want a driver to be installed, set it's value to *false*.
#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes :padline yes
drivers:
sundtek: auto
ddvb-dkms: auto
#+END_SRC
**** Additional Packages
Add additional packages you would like to have on your installation to this list
#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes :padline yes
extra_packages:
- vim
- tree
- w-scan
#+END_SRC
**** VDR
This section allows you to set the recording directory, the user and group that runs the vdr and it's home directory.
- user :: the vdr user name
- group :: the main group for the user vdr
- uid :: the user id for the user vdr
- gid :: the group id for the group vdr
- home :: the home directory for the user vdr
- recdir :: the recording directory used by VDR
- hide_first_recording_level :: let vdr hide the first directory level of it's recording directory so the content of multiple directories is shown merged together
- safe_dirnames :: replace special characters which are not compatible with Windows file systems and Samba shares
- override_vdr_charset :: workaround for channels with weird EPG encodings, e.g. Sky
#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes :padline yes
vdr:
user: vdr
group: vdr
uid: 666
gid: 666
home: /var/lib/vdr
recdir: /srv/vdr/video
hide_first_recording_level: false
safe_dirnames: true
override_vdr_charset: false
#+END_SRC
*** tasks
yavdr-common executes the following tasks:
**** main.yml
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :mkdirp yes :padline no
---
# file: roles/yavdr-common/tasks/main.yml
- name: basic installation
block:
- import_tasks: configure_apt.yml
- import_tasks: configure_system.yml
- import_tasks: create_directories.yml
tags: [install]
#+END_SRC
***** Disable default installation of recommended packages
This task prevents apt to automatically install all recommended dependencies for packages:
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/configure_apt.yml :mkdirp yes :padline no
---
- name: apt | prevent automatic installation of recommended packages
template:
src: templates/90-norecommends.j2
dest: /etc/apt/apt.conf.d/90norecommends
#+END_SRC
***** Set up package repositories
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/configure_apt.yml :mkdirp yes
- name: add PPAs
apt_repository:
repo: '{{ item }}'
state: present
update_cache: yes
with_items: '{{ repositories }}'
- name: run apt-get dist-upgrade
apt:
upgrade: dist
update_cache: yes
#+END_SRC
***** Use bash instead of dash
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/configure_system.yml :mkdirp yes
- name: use bash instead of dash
shell: |
echo "set dash/sh false" | debconf-communicate
dpkg-reconfigure -f noninteractive dash
#+END_SRC
***** create user vdr
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/configure_system.yml :exports none :mkdirp yes
- name: create vdr group
group:
gid: '{{ vdr.gid }}'
state: present
name: '{{ vdr.group }}'
- name: create vdr user
user:
name: '{{ vdr.user }}'
group: '{{ vdr.group }}'
uid: '{{ vdr.uid }}'
home: '{{ vdr.home }}'
shell: '/bin/bash'
state: present
append: true
#+END_SRC
***** Disable release-upgrade notifications
****** SOMEDAY move from lineinfile to template
:LOGBOOK:
- State "SOMEDAY" from "TODO" [2017-11-22 Mi 10:59]
:END:
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/configure_system.yml :mkdirp yes
- name: disable release-upgrade notifications
lineinfile:
dest: /etc/update-manager/release-upgrades
backrefs: yes
state: present
regexp: '^(Prompt=).*$'
line: '\1never'
ignore_errors: yes
with_first_found:
- files:
- /etc/update-manager/release-upgrades
skip: true
#+END_SRC
***** Install essential packages
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/configure_system.yml :mkdirp yes
- name: apt | install basic packages
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
- anacron
- acl
- at
- bash-completion
#- biosdevname # caution: may change device names after a minimal installation!
- debconf-utils
- linux-firmware
- psmisc
- python-kmodpy
- python-requests
- python-usb
- python3-usb
- software-properties-common
- ssh
- wget
- wpasupplicant
- usbutils
- xfsprogs
#+END_SRC
***** Install additional packages (user defined)
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/configure_system.yml
- name: apt | install extra packages
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
'{{ extra_packages }}'
#+END_SRC
***** create directories
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/create_directories.yml :exports none :mkdirp yes
- name: ensure /etc/yavdr exists
file:
path: /etc/yavdr
state: directory
mode: 0755
- name: create media directories
file:
dest: '{{ item.value }}'
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
state: directory
mode: '0777'
with_dict: '{{ media_dirs }}'
#+END_SRC
*** templates
#+BEGIN_SRC c :tangle roles/yavdr-common/templates/90-norecommends.j2 :mkdirp yes :padline no
{{ ansible_managed_file | comment('c') }}
// Recommends are as of now still abused in many packages
APT::Install-Recommends "0";
APT::Install-Suggests "0";
#+END_SRC
** collect facts about the system with custom modules
*** tasks
***** main.yml
#+BEGIN_SRC yaml :tangle roles/collect-facts/tasks/main.yml :mkdirp yes
- name: get information about usb and pci hardware and loaded kernel modules
hardware_facts:
usb: True
pci: True
modules: True
gpus: True
acpi_power_modes: True
- debug:
var: '{{ item }}'
verbosity: 1
with_items:
- usb
- pci
- gpus
- modules
- acpi_power_modes
- nvidia_detected
- intel_detected
- amd_detected
- virtualbox_detected
#+END_SRC
** vdr
*** tasks
**** install the basic vdr packages
#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes :padline no
---
# file: roles/vdr/tasks/main.yml
- name: apt | install basic vdr packages
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
- vdr
- vdrctl
- vdr-plugin-dbus2vdr
#+END_SRC
**** Add svdrp/svdrp-disc to /etc/services
#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes
- name: add svdrp and svdrp-disc to /etc/services
lineinfile:
dest: /etc/services
state: present
line: "{{ item }}"
with_items:
- "svdrp 6419/tcp"
- "svdrp-disc 6419/udp"
#+END_SRC
**** Set up the recording directory for the vdr user
#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes
- name: create vdr recdir
file:
state: directory
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
mode: 0775
dest: '{{ vdr.recdir }}'
- name: set option to use hide-first-recording-level patch
blockinfile:
dest: /etc/vdr/conf.d/04-vdr-hide-first-recordinglevel.conf
create: true
block: |
[vdr]
--hide-first-recording-level
when:
vdr.hide_first_recording_level
- name: create local dir in recdir
file:
state: directory
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
mode: '0775'
dest: '{{ vdr.recdir }}/local'
when:
vdr.hide_first_recording_level
# TODO: set recdir, user etc. in /etc/vdr/conf.d/
#+END_SRC
**** Install additional vdr plugins
The additional plugins to install can be set in the variable ~{{vdr_plugins}}~ in the group variables
#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes
- name: apt | install additional vdr plugins
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
'{{ vdr_plugins | default({}) }}'
notify: [ 'Restart VDR' ]
#+END_SRC
**** copy vdr configuration files (if they don't exist yet)
#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes
- name: ensure vdr is stopped
systemd:
name: vdr.service
state: stopped
notify: [ 'Start VDR' ]
- name: "vdr configuration | copy remote.conf if it doesn't exist yet"
copy:
src: files/remote.conf
dest: '{{ vdr.confdir }}/remote.conf'
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
mode: 0644
force: no
- name: "vdr configuration | copy keymacros.conf if it doesn't exist yet"
copy:
src: files/keymacros.conf
dest: '{{ vdr.confdir }}/keymacros.conf'
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
mode: 0644
force: no
#+END_SRC
*** templates
*** files
**** remote.conf
#+BEGIN_SRC conf :tangle roles/vdr/files/remote.conf :mkdirp yes :padline no
LIRC.Up KEY_UP
LIRC.Down KEY_DOWN
LIRC.Menu KEY_MENU
LIRC.Ok KEY_OK
LIRC.Back KEY_ESC
LIRC.Left KEY_LEFT
LIRC.Right KEY_RIGHT
LIRC.Red KEY_RED
LIRC.Green KEY_GREEN
LIRC.Yellow KEY_YELLOW
LIRC.Blue KEY_BLUE
LIRC.0 KEY_0
LIRC.1 KEY_1
LIRC.2 KEY_2
LIRC.3 KEY_3
LIRC.4 KEY_4
LIRC.5 KEY_5
LIRC.6 KEY_6
LIRC.7 KEY_7
LIRC.8 KEY_8
LIRC.9 KEY_9
LIRC.Info KEY_INFO
LIRC.Play KEY_PLAY
LIRC.Pause KEY_PAUSE
LIRC.Play/Pause KEY_PLAYPAUSE
LIRC.Stop KEY_STOP
LIRC.Record KEY_RECORD
LIRC.FastFwd KEY_FASTFORWARD
LIRC.FastRew KEY_REWIND
LIRC.Next KEY_NEXT
LIRC.Prev KEY_BACK
LIRC.Power KEY_POWER2
LIRC.Channel+ KEY_CHANNELUP
LIRC.Channel- KEY_CHANNELDOWN
LIRC.PrevChannel KEY_PREVIOUS
LIRC.Volume+ KEY_VOLUMEUP
LIRC.Volume- KEY_VOLUMEDOWN
LIRC.Mute KEY_MUTE
LIRC.Subtitles KEY_SUBTITLE
LIRC.Schedule KEY_EPG
LIRC.Channels KEY_CHANNEL
LIRC.Commands KEY_FAVORITES
LIRC.Audio KEY_MODE
LIRC.Timers KEY_TIME
LIRC.Recordings KEY_PVR
LIRC.Setup KEY_SETUP
LIRC.User0 KEY_TEXT
LIRC.User1 KEY_PROG1
LIRC.User2 KEY_PROG2
LIRC.User3 KEY_PROG3
LIRC.User4 KEY_PROG4
LIRC.User5 KEY_AUDIO
LIRC.User6 KEY_VIDEO
LIRC.User7 KEY_IMAGES
LIRC.User8 KEY_FN
LIRC.User9 KEY_SCREEN
XKeySym.Up Up
XKeySym.Down Down
XKeySym.Menu Home
XKeySym.Menu Tab
XKeySym.Menu KP_Home
XKeySym.Ok Return
XKeySym.Ok KP_Enter
XKeySym.Back BackSpace
XKeySym.Back KP_Separator
XKeySym.Left Left
XKeySym.Right Right
XKeySym.Up KP_Up
XKeySym.Down KP_Down
XKeySym.Left KP_Left
XKeySym.Right KP_Right
XKeySym.Red F1
XKeySym.Green F2
XKeySym.Yellow F3
XKeySym.Blue F4
XKeySym.0 0
XKeySym.1 1
XKeySym.2 2
XKeySym.3 3
XKeySym.4 4
XKeySym.5 5
XKeySym.6 6
XKeySym.7 7
XKeySym.8 8
XKeySym.9 9
XKeySym.0 KP_0
XKeySym.1 KP_1
XKeySym.2 KP_2
XKeySym.3 KP_3
XKeySym.4 KP_4
XKeySym.5 KP_5
XKeySym.6 KP_6
XKeySym.7 KP_7
XKeySym.8 KP_8
XKeySym.9 KP_9
XKeySym.Info End
XKeySym.Info KP_End
XKeySym.Pause F9
XKeySym.FastFwd F6
XKeySym.FastRew F5
XKeySym.Power Pause
XKeySym.Volume+ F12
XKeySym.Volume- F11
XKeySym.Volume+ KP_Add
XKeySym.Volume- KP_Subtract
XKeySym.Mute F10
XKeySym.User1 F5
XKeySym.User2 F6
XKeySym.User3 F7
XKeySym.User4 F8
XKeySym.User5 Print
XKeySym.User6 Scroll_Lock
XKeySym.User7 Insert
XKeySym.User8 KP_Divide
XKeySym.User9 KP_Multiply
XKeySym.Audio Menu
XKeySym.Channel+ Prior
XKeySym.Channel- Next
XKeySym.Channel+ KP_Prior
XKeySym.Channel- KP_Next
XKeySym.Volume+ XF86AudioRaiseVolume
XKeySym.Volume- XF86AudioLowerVolume
XKeySym.Mute XF86AudioMute
XKeySym.Stop XF86AudioStop
XKeySym.Play/Pause XF86AudioPlay
XKeySym.Prev XF86AudioPrev
XKeySym.Next XF86AudioNext
#+END_SRC
**** keymacros.conf
#+BEGIN_SRC conf :tangle roles/vdr/files/keymacros.conf :padline no
# Remote control key macros for VDR
#
# Format:
#
# macrokey key1 key2 key3...
# macrokey @plugin key1 key2 key3...
#
# See man vdr(5)
Red Recordings
Green Schedule
Yellow Info
Blue Timers
User0 @osdteletext
#+END_SRC
** STARTED yavdr-network
*** default variables
#+BEGIN_SRC yaml :tangle roles/yavdr-network/main.yml :mkdirp yes :padline no
install_avahi: true
#+END_SRC
*** tasks
#+BEGIN_SRC yaml :tangle roles/yavdr-network/tasks/main.yml :mkdirp yes :padline no
---
# this playbook sets up network services for a yaVDR installation
- name: apt |install packages for network services
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
- avahi-daemon
- avahi-utils
#- biosdevname # caution: this may change device names after a minimal installation!
- ethtool
- nfs-common
- vdr-addon-avahi-linker
- wakeonlan
# Does this really work? We need a way to check if an interface supports WOL - Python Skript?
# - name: check WOL capabilities of network interfaces
# shell: 'ethtool {{ item }} | grep -Po "(?<=Supports\sWake-on:\s).*$"'
# register: wol
# with_items: '{% for interface in ansible_interfaces if interface != 'lo' and interface != 'bond0' %}'
- name: restart autofs if running
systemd:
name: autofs
state: restarted
enabled: yes
masked: no
- name: ensure autofs is running
systemd:
name: autofs
state: started
enabled: yes
masked: no
- name: restart avahi-linker if running
systemd:
name: avahi-linker
state: restarted
enabled: yes
masked: no
- name: start avahi-linker
systemd:
name: avahi-linker
state: started
enabled: yes
masked: no
- name: enable and start additional services for avahi-linker
systemd:
name: '{{ item }}'
state: started
enabled: yes
masked: no
with_items:
- vdr-net-monitor
- vdr-update-monitor
- prevent-umount-on-pause
#+END_SRC
** nfs-server
*** TODO avahi-services für NFS beim Stoppen des nfs-kernel-servers depublizieren, beim Start wieder announcen
*** tasks
#+BEGIN_SRC yaml :tangle roles/nfs-server/tasks/main.yml :mkdirp yes :padline no
---
- name: install nfs server packages
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
- nfs-kernel-server
- nfs-common
- name: create /etc/exports
template:
src: templates/nfs-exports.j2
dest: /etc/exports
notify: [ 'Restart NFS Kernel Server' ]
- name: populate /etc/avahi/services
template:
src: templates/avahi/service.j2
dest: '/etc/avahi/services/yavdr-{{ item.key }}.service'
with_dict: '{{ media_dirs }}'
#+END_SRC
*** templates
**** /etc/exports
#+BEGIN_SRC conf :tangle roles/nfs-server/templates/nfs-exports.j2 :mkdirp yes :padline no
/srv *(rw,fsid=0,sync,no_subtree_check,all_squash,anongid={{ vdr.gid }},anonuid={{ vdr.uid }})
{% for name, path in media_dirs.iteritems() %}
{{ path }} *(rw,fsid={{ loop.index }},sync,no_subtree_check,all_squash,anongid={{ vdr.gid }},anonuid={{ vdr.uid }}{{ ',insecure' if nfs.insecure else '' }})
{% endfor %}
#+END_SRC
**** avahi services
#+BEGIN_SRC xml :tangle roles/nfs-server/templates/avahi/service.j2 :mkdirp yes :padline no
{{ item.key|capitalize }} on %h ## Name
_nfs._tcp
2049
path={{ item.value }} ## path to shared Folder
subtype={{ 'vdr' if item.key == 'recordings' else item.key }} ## subtype
#+END_SRC
** STARTED yavdr-remote
*** default variables
*** tasks
#+BEGIN_SRC yaml :tangle roles/yavdr-remote/tasks/main.yml :mkdirp yes :padline no
---
# This role is used to set up the yaVDR remote control configuration.
- name: apt | install yavdr-remote
apt:
name: yavdr-remote
state: present
- name: apt | install eventlircd
apt:
name: eventlircd
state: present
- name: apt | install lirc
apt:
name: lirc
state: present
- name: stop, mask and disable lircd.socket, lircd.service and lircd-uinput.service # (the default lirc configuration conflicts with eventlircd)
systemd:
name: '{{ item }}'
enabled: no
state: stopped
masked: yes
with_items:
- lircd.service
- lircd.socket
- lircd-uinput.service
ignore_errors: yes
- name: configure vdr to read from a lircd-compatible socket
template:
src: templates/03-vdr-lirc.conf.j2
dest: /etc/vdr/conf.d/03-vdr-lirc.conf
notify: ['Restart VDR']
# TODO: upload lircd2uinput package to PPA
#- name: install lircd2uinput
# tag: install
# apt:
# name: lircd2uinput
# state: present
# when:
# install_eventlircd is defined and install_eventlircd
#+END_SRC
*** templates
#+BEGIN_SRC conf :tangle roles/yavdr-remote/templates/03-vdr-lirc.conf.j2 :mkdirp yes :padline no
{% if frontend != 'kodi' %}
[vdr]
--lirc=/var/run/lirc/lircd
{% endif %}
#+END_SRC
*** files
** pulseaudio
*** tasks
#+BEGIN_SRC yaml :tangle roles/pulseaudio/tasks/main.yml :mkdirp yes :padline no
---
- name: apt | install pulseaudio and pavucontrol
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
- pulseaudio
- pavucontrol
- name: create /etc/asound.conf with pulseaudio as default device
template:
src: templates/alsa/asound.conf.j2
dest: /etc/asound.conf
#+END_SRC
*** templates
#+BEGIN_SRC conf :tangle roles/pulseaudio/templates/alsa/asound.conf.j2 :mkdirp yes :padline no
# Use PulseAudio by default
pcm.!default {
type pulse
fallback "sysdefault"
hint {
show on
description "Default ALSA Output (currently PulseAudio Sound Server)"
}
}
ctl.!default {
type pulse
fallback "sysdefault"
}
#+END_SRC
** yavdr-xorg
*** About the GUI session
The X-Server is started by using the two systemd units ~xlogin@.service~ and ~x@.service~ provided by the package *xlogin*. The former is enabled (and started) for the vdr user - which results (using the default settings for the user *vdr* with the uid *666*) in the activation of ~xlogin@vdr.service~ when reaching the graphical.target.
~x@vt7.service~ is started automatically as a dependency of ~xlogin@vdr.service~ and starts the X-server. ~xlogin@vdr.service~ also starts a systemd user session using ~user@666.service~.
To prevent stopping the X-server when vdr is running, additional dependencies are set up - see the drop-in rules created in ~/etc/systemd/system/vdr.service.d/~.
Basic Services like the session DBus, pulseaudio etc. are started for the ~default.target~ of the session.
The openbox autostart script is used to update the systemd session with the needed session variables. It creates a file =~/.session-env= which is used as an environment file by ~vdr.service~ (so the vdr knows the *DISPLAY* and can access pulseaudio).
The autostart script then enables all services to be pulled in by yavdr-desktop.target. As the last step ~yavdr-desktop.target~ is startet, which results in staring ~yavdr-frontend.service~ and additional Units for a second display (openbox and a browser for osd2eb, if available).
# TODO: describe yavdr-frontend
In order to achive a clean shutdown of the session, ~x@t7.service~ is set as a dependency of the systemd unit instance ~user@666.service~ and all processes within the session must be shutdown properly when stopping ~xlogin@vdr.service~. If systemd units are used within the user session, they must stop their process(es) successfully (you should set them up to accept expected exit codes appropriately). The window manager /openbox/ is started using the =~/.xinitrc= and stopped using the systemd unit ~exit-wm.service~ (which runs on stopping the jobs pulled in by the ~default.target~ of the session).
*** TODO automatic X-server configuration :noexport:
- [X] detect connected display
- [X] read EDID from displays
create a xorg.conf for
- [X] nvidia
- [ ] intel
- [ ] amd gpus
**** HOLD Nvidia-GPUs:read EDID:
#+BEGIN_SRC shell
$ nvidia-xconfig --extract-edids-from-file=/var/log/Xorg.0.log --extract-edids-output-file=/tmp/edid.bin.0
Found 2 EDIDs in "/var/log/Xorg.0.log".
Wrote EDID for "DELL 2407WFP (CRT-1)" to "/tmp/edid.bin.0.0" (128 bytes).
Wrote EDID for "ADI A715 (DFP-1)" to "/tmp/edid.bin.0.1" (128 bytes).
$ xrandr -q
Screen 0: minimum 8 x 8, current 3200 x 1200, maximum 8192 x 8192
DVI-I-0 disconnected primary (normal left inverted right x axis y axis)
VGA-0 connected 1920x1200+1280+0 (normal left inverted right x axis y axis) 519mm x 324mm
1920x1200 59.95*+
1680x1050 59.95
1280x1024 75.02 60.02
1152x864 75.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
DVI-I-1 disconnected (normal left inverted right x axis y axis)
HDMI-0 connected 1280x1024+0+0 (normal left inverted right x axis y axis) 338mm x 270mm
1280x1024 60.02*+
1024x768 60.00
800x600 60.32
640x480 59.95 59.94
$ parse-edid < /tmp/edid.bin.0.1
Checksum Correct
Section "Monitor"
Identifier "ADI A715"
ModelName "ADI A715"
VendorName "ADI"
# Monitor Manufactured week 15 of 2003
# EDID version 1.3
# Digital Display
DisplaySize 330 270
Gamma 2.20
Option "DPMS" "true"
#Not giving standard mode: 640x480, 60Hz
#Not giving standard mode: 800x600, 60Hz
#Not giving standard mode: 1024x768, 60Hz
#Not giving standard mode: 1280x1024, 60Hz
Modeline "Mode 0" 108.00 1280 1328 1440 1688 1024 1025 1028 1066 +hsync +vsync
Modeline "Mode 1" 40.00 800 840 968 1056 600 601 605 628 +hsync +vsync
EndSection
$ parse-edid < /tmp/edid.bin.0.0
Checksum Correct
Section "Monitor"
Identifier "DELL 2407WFP"
ModelName "DELL 2407WFP"
VendorName "DEL"
# Monitor Manufactured week 24 of 2007
# EDID version 1.3
# Analog Display
Option "SyncOnGreen" "true"
DisplaySize 520 330
Gamma 2.20
Option "DPMS" "true"
Horizsync 30-83
VertRefresh 56-76
# Maximum pixel clock is 170MHz
#Not giving standard mode: 1280x1024, 60Hz
#Not giving standard mode: 1600x1200, 60Hz
#Not giving standard mode: 1152x864, 75Hz
#Not giving standard mode: 1680x1050, 60Hz
Modeline "Mode 0" 154.00 1920 1968 2000 2080 1200 1203 1209 1235 +hsync -vsync
EndSection
#+END_SRC
**** DONE Start X-server with debug-output :noexport:
#+BEGIN_SRC conf
# /etc/systemd/system/x-debug@.service
[Unit]
Description=X with verbose logging on %I
Wants=graphical.target
Before=graphical.target
Conflicts=xlogin@vdr.service x@vt7.service
[Service]
Type=forking
ExecStart=/usr/bin/x-daemon -logverbose 6 -noreset %I -config xdiscover.conf
#+END_SRC
#+BEGIN_SRC conf
# /etc/X11/xdiscover.conf
Section "Device"
Identifier "nvidia"
Driver "nvidia"
Option "NoLogo" "true"
Option "DynamicTwinView" "true"
Option "NoFlip" "false"
# Option "FlatPanelProperties" "Scaling = Native"
# Option "ModeValidation" "NoVesaModes, NoXServerModes"
# Option "ModeDebug" "true"
# Option "HWCursor" "false"
EndSection
Section "Screen"
Identifier "screen"
Device "nvidia"
EndSection
Section "Extensions"
Option "Composite" "false"
EndSection
#+END_SRC
**** DONE python-script for parsing xrandr --verbose output
***** Example output
# ION-330-I
#+BEGIN_SRC shell :tangle library/xrandr_output.1
$ xrandr --verbose
Screen 0: minimum 8 x 8, current 1280 x 720, maximum 8192 x 8192
VGA-0 disconnected primary (normal left inverted right x axis y axis)
Identifier: 0x1c4
Timestamp: 18571
Subpixel: unknown
Clones:
CRTCs: 0 1
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
BorderDimensions: 4
supported: 4
Border: 0 0 0 0
range: (0, 65535)
SignalFormat: VGA
supported: VGA
ConnectorType: VGA
ConnectorNumber: 0
_ConnectorLocation: 1
HDMI-0 connected 1280x720+0+0 (0x1cb) normal (normal left inverted right x axis y axis) 885mm x 498mm
Identifier: 0x1c5
Timestamp: 18571
Subpixel: unknown
Gamma: 1.0:1.0:1.0
Brightness: 1.0
Clones:
CRTC: 0
CRTCs: 0 1fg
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
EDID:
00ffffffffffff004c2d800100000000
2c0e01038059328c0ae2bda15b4a9824
15474a20000001010101010101010101
010101010101011d007251d01e206e28
550075f23100001e011d00bc52d01e20
b828554075f23100001e000000fd0032
3d0f2e08000a202020202020000000fc
0053414d53554e470a20202020200181
02031971468413051403122309070783
01000065030c001000011d8018711c16
20582c250075f23100009e011d80d072
1c1620102c258075f23100009e8c0ad0
8a20e02d10103e960075f2310000188c
0ad090204031200c40550075f2310000
18000000000000000000000000000000
000000000000000000000000000000ca
BorderDimensions: 4
supported: 4
Border: 39 24 41 21
range: (0, 65535)
SignalFormat: TMDS
supported: TMDS
ConnectorType: HDMI
ConnectorNumber: 1
_ConnectorLocation: 2
1280x720 (0x1c6) 74.2MHz +HSync +VSync +preferred
h: width 1280 start 1390 end 1430 total 1650 skew 0 clock 45.0KHz
v: height 720 start 725 end 730 total 750 clock 60.0Hz
1920x1080 (0x1c7) 74.2MHz +HSync +VSync Interlace
h: width 1920 start 2008 e#nd 2052 total 2200 skew 0 clock 33.8KHz
v: height 1080 start 1084 end 1094 total 1124 clock 60.1Hz
1920x1080 (0x1c8) 74.2MHz +HSync +VSync Interlace
h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 33.7KHz
v: height 1080 start 1084 end 1094 total 1124 clock 60.0Hz
1920x1080 (0x1c9) 74.2MHz +HSync +VSync Interlace
h: width 1920 start 2448 end 2492 total 2640 skew 0 clock 28.1KHz
v: height 1080 start 1084 end 1094 total 1124 clock 50.0Hz
1280x720 (0x1ca) 74.2MHz +HSync +VSync
h: width 1280 start 1390 end 1430 total 1650 skew 0 clock 45.0KHz
v: height 720 start 725 end 730 total 750 clock 59.9Hz
1280x720 (0x1cb) 74.2MHz +HSync +VSync *current
h: width 1280 start 1720 end 1760 total 1980 skew 0 clock 37.5KHz
v: height 720 start 725 end 730 total 750 clock 50.0Hz
800x600 (0x1cc) 40.0MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.9KHz
v: height 600 start 601 end 605 total 628 clock 60.3Hz
800x600 (0x1cd) 36.0MHz +HSync +VSync
h: width 800 start 824 end 896 total 1024 skew 0 clock 35.2KHz
v: height 600 start 601 end 603 total 625 clock 56.2Hz
720x576 (0x1ce) 27.0MHz -HSync -VSync
h: width 720 start 732 end 796 total 864 skew 0 clock 31.2KHz
v: height 576 start 581 end 586 total 625 clock 50.0Hz
720x480 (0x1cf) 27.0MHz -HSync -VSync
h: width 720 start 736 end 798 total 858 skew 0 clock 31.5KHz
v: height 480 start 489 end 495 total 525 clock 59.9Hz
640x480 (0x1d0) 25.2MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.5KHz
v: height 480 start 490 end 492 total 525 clock 59.9Hz
320x240 (0x1d1) 12.6MHz -HSync -VSync DoubleScan
h: width 320 start 328 end 376 total 400 skew 0 clock 31.5KHz
v: height 240 start 245 end 246 total 262 clock 60.1Hz
#+END_SRC
# GT210
#+BEGIN_SRC shell :tangle library/xrandr_output.2
$ xrandr --verbose
Screen 0: minimum 8 x 8, current 3200 x 1200, maximum 8192 x 8192
DVI-I-0 disconnected primary (normal left inverted right x axis y axis)
Identifier: 0x1c4
Timestamp: 641679
Subpixel: unknown
Clones:
CRTCs: 0 1
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
BorderDimensions: 4
supported: 4
Border: 0 0 0 0
range: (0, 65535)
SignalFormat: VGA
supported: VGA
ConnectorType: DVI-I
ConnectorNumber: 0
_ConnectorLocation: 0
VGA-0 connected 1920x1200+1280+0 (0x1c6) normal (normal left inverted right x axis y axis) 519mm x 324mm
Identifier: 0x1c5
Timestamp: 641679
Subpixel: unknown
Gamma: 1.0:1.0:1.0
Brightness: 1.0
Clones:
CRTC: 1
CRTCs: 0 1
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
EDID:
00ffffffffffff0010ac16a0534b4431
181101030e342178eeee91a3544c9926
0f5054a54b008180a940714fb3000101
010101010101283c80a070b023403020
360007442100001a000000ff00555935
343537364531444b5320000000fc0044
454c4c20323430375746500a000000fd
00384c1e5311000a20202020202000f1
BorderDimensions: 4
supported: 4
Border: 0 0 0 0
range: (0, 65535)
SignalFormat: VGA
supported: VGA
ConnectorType: VGA
ConnectorNumber: 2
_ConnectorLocation: 2
1920x1200 (0x1c6) 154.000MHz +HSync -VSync *current +preferred
h: width 1920 start 1968 end 2000 total 2080 skew 0 clock 74.04KHz
v: height 1200 start 1203 end 1209 total 1235 clock 59.95Hz
1680x1050 (0x1c7) 146.250MHz -HSync +VSync
h: width 1680 start 1784 end 1960 total 2240 skew 0 clock 65.29KHz
v: height 1050 start 1053 end 1059 total 1089 clock 59.95Hz
1280x1024 (0x1c8) 135.000MHz +HSync +VSync
h: width 1280 start 1296 end 1440 total 1688 skew 0 clock 79.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 75.02Hz
1280x1024 (0x1c9) 108.000MHz +HSync +VSync
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz
1152x864 (0x1ca) 108.000MHz +HSync +VSync
h: width 1152 start 1216 end 1344 total 1600 skew 0 clock 67.50KHz
v: height 864 start 865 end 868 total 900 clock 75.00Hz
1024x768 (0x1cb) 78.750MHz +HSync +VSync
h: width 1024 start 1040 end 1136 total 1312 skew 0 clock 60.02KHz
v: height 768 start 769 end 772 total 800 clock 75.03Hz
1024x768 (0x1cc) 65.000MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz
v: height 768 start 771 end 777 total 806 clock 60.00Hz
800x600 (0x1cd) 49.500MHz +HSync +VSync
h: width 800 start 816 end 896 total 1056 skew 0 clock 46.88KHz
v: height 600 start 601 end 604 total 625 clock 75.00Hz
800x600 (0x1ce) 40.000MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz
v: height 600 start 601 end 605 total 628 clock 60.32Hz
640x480 (0x1cf) 31.500MHz -HSync -VSync
h: width 640 start 656 end 720 total 840 skew 0 clock 37.50KHz
v: height 480 start 481 end 484 total 500 clock 75.00Hz
640x480 (0x1d0) 25.175MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz
v: height 480 start 490 end 492 total 525 clock 59.94Hz
DVI-I-1 disconnected (normal left inverted right x axis y axis)
Identifier: 0x1d1
Timestamp: 641679
Subpixel: unknown
Clones:
CRTCs: 0 1
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
BorderDimensions: 4
supported: 4
Border: 0 0 0 0
range: (0, 65535)
SignalFormat: TMDS
supported: TMDS
ConnectorType: DVI-I
ConnectorNumber: 0
_ConnectorLocation: 0
HDMI-0 connected 1280x1024+0+0 (0x1c9) normal (normal left inverted right x axis y axis) 338mm x 270mm
Identifier: 0x1d2
Timestamp: 641679
Subpixel: unknown
Gamma: 1.0:1.0:1.0
Brightness: 1.0
Clones:
CRTC: 0
CRTCs: 0 1
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
EDID:
00ffffffffffff0004895d2320090000
0f0d0103e0211b782ac5c6a3574a9c23
124f5421080031404540614081800101
010101010101302a009851002a403070
1300520e1100001ea00f200031581c20
28801400520e1100001e000000ff0033
31355430324530323333360a000000fc
0041444920413731350a20202020002b
BorderDimensions: 4
supported: 4
Border: 0 0 0 0
range: (0, 65535)
SignalFormat: TMDS
supported: TMDS
ConnectorType: HDMI
ConnectorNumber: 1
_ConnectorLocation: 1
1280x1024 (0x1c9) 108.000MHz +HSync +VSync *current +preferred
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz
1024x768 (0x1cc) 65.000MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz
v: height 768 start 771 end 777 total 806 clock 60.00Hz
800x600 (0x1ce) 40.000MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz
v: height 600 start 601 end 605 total 628 clock 60.32Hz
640x480 (0x1d3) 25.180MHz -HSync -VSync
h: width 640 start 648 end 744 total 800 skew 0 clock 31.48KHz
v: height 480 start 482 end 484 total 525 clock 59.95Hz
640x480 (0x1d0) 25.175MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz
v: height 480 start 490 end 492 total 525 clock 59.94Hz
#+END_SRC
***** parse hex-strings
#+BEGIN_SRC python
>>> import binascii
>>> s = "deadbeef"
>>> binascii.a2b_hex(s)
b'\xde\xad\xbe\xef'
#+END_SRC
*** default variables
*** tasks
#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/main.yml :mkdirp yes :padline no
---
# file: roles/yavdr-xorg/tasks/main.yml
- import_tasks: setup-xorg.yml tags=install,update
- import_tasks: detect-xorg.yml tags=xorg:detect,install
- import_tasks: desktop-session.yml tags=install,update
#+END_SRC
#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/setup-xorg.yml :mkdirp yes :padline no
---
# file: roles/yavdr-xorg/tasks/setup-xorg.yml
- name: create directories for systemd drop-in files
file:
dest: '{{ item }}'
state: directory
with_items:
- "/etc/systemd/system/x@.service.d/"
- "/etc/systemd/system/vdr.service.d/"
- "/etc/systemd/system/user@{{ vdr.uid }}.service.d/"
- name: systemd-drop-in | add dependency to X-server for vdr.service
template:
src: templates/vdr-xorg.conf
dest: /etc/systemd/system/vdr.service.d/vdr-xorg.conf
- name: systemd-drop-in | start x@.service before xlogin@.service
template:
src: templates/x@service.d/xlogin.conf.j2
dest: /etc/systemd/system/x@.service.d/xlogin.conf
- name: systemd-drop-in | load environment file for vdr.service
template:
src: templates/systemd/vdr-environ.j2
dest: /etc/systemd/system/vdr.service.d/load-environ.conf
- name: systemd-drop-in | user@{{ vdr.uid }}.service depends on x@vt7.service
template:
src: templates/user@666.service.d/x-dependency.conf.j2
dest: '/etc/systemd/system/user@{{ vdr.uid }}.service.d/x-dependency.conf'
- name: vdr-config | start softhddevice detached and set audio to pulseaudio
lineinfile:
path: /etc/vdr/conf.avail/softhddevice.conf
line: '{{ item }}ys
with_items:
- '-D'
# - '-a pulse' # do we need this with our existing asound.conf?
- name: add a login shell for the user vdr
user:
name: '{{ vdr.user }}'
shell: '/bin/bash'
state: present
uid: '{{ vdr.uid }}'
groups: '{{ vdr.group }}'
append: yes
- name: apt | install packages for xorg
apt:
name: '{{ item }}'
state: present
with_items:
- xlogin
- xorg
- xserver-xorg-input-all
- xserver-xorg-video-all
- openbox
- python3-dbus2vdr
- python3-yavdrfrontend
- read-edid
- tmux
- vdr-plugin-desktop
#- yavdr-xorg
- name: apt | install desktop programs
apt:
name: '{{ item }}'
state: present
with_items:
- xterm
- firefox
- kiosk-browser
#+END_SRC
#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/detect-xorg.yml :mkdirp yes :padline no
---
# file: roles/yavdr-xorg/tasks/detect-xorg.yml
- name: "expand template for x-verbose@.service"
template:
src: "templates/systemd/system/x-verbose@.service.j2"
dest: "/etc/systemd/system/x-verbose@.service"
- name: "expand template for xorg-verbose.conf"
template:
src: "templates/xorg-verbose.conf.j2"
dest: "/etc/X11/xorg-verbose.conf"
- name: Stop VDR
systemd:
name: vdr.service
state: stopped
enabled: yes
notify: ['Start VDR']
- name: Stop xlogin
systemd:
name: 'xlogin@{{ vdr.user }}.service'
state: stopped
- name: Stop x
systemd:
name: x@vt7.service
state: stopped
- name: "wait a little bit before starting x-verbose@vt7.service (needed?)"
wait_for:
timeout: 3
- name: "start x-verbose@.service"
systemd:
name: "x-verbose@vt7.service"
state: started
enabled: false
masked: false
daemon_reload: true
- name: "wait a little bit, so X has some time to start up (needed?)"
wait_for:
timeout: 3
- name: "detect xorg configuration"
action: xrandr_facts
- debug:
var: xorg.primary
- debug:
var: xorg.secondary
when: xorg.secondary is defined
- name: "stop x-verbose@vt7.service"
systemd:
name: "x-verbose@vt7.service"
state: stopped
enabled: false
masked: true
- name: "wait a little bit, so X has some time to shut down (needed?)"
wait_for:
timeout: 3
# TODO: expand template for xorg.conf (or snippets)
# with respect for the available graphics card driver
# nvidia, noveau, intel, radeon
- name: nvidia related config
block:
- name: create xorg.conf (for nvidia driver)
template:
src: templates/xorg.conf.j2
dest: /etc/X11/xorg.conf
backup: yes
when:
- nvidia_detected
#+END_SRC
#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/desktop-session.yml :mkdirp yes :padline no
---
# file: roles/yavdr-xorg/tasks/desktop-session.yml
- name: create folders for user configuration files
file:
state: directory
dest: '{{ item }}'
mode: '0775'
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
with_items:
- '{{ vdr.home }}/.config/systemd/user'
- '{{ vdr.home }}/.config/openbox'
- '{{ vdr.home }}/.config/pulse'
- name: expand template for .xinitrc for vdr user
template:
src: 'templates/.xinitrc.j2'
dest: '{{ vdr.home }}/.xinitrc'
mode: 0755
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: expand template for openbox autostart
template:
src: 'templates/openbox/autostart.j2'
dest: '{{ vdr.home }}/.config/openbox/autostart'
mode: 0755
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: expand rc.xml for openbox
template:
src: 'templates/openbox/rc.xml.j2'
dest: '{{ vdr.home }}/.config/openbox/rc.xml'
mode: 0644
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: create yavdr-desktop.target for the user session
template:
src: 'templates/systemd/user/yavdr-desktop.target.j2'
dest: '{{ vdr.home }}/.config/systemd/user/yavdr-desktop.target'
mode: 0644
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: disable pulseaudio autospawning
lineinfile:
path: '{{ vdr.home }}/.config/pulse/client.conf'
line: 'autospawn = no'
create: yes
state: present
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: create tmux.service for the session
template:
src: roles/yavdr-xorg/templates/systemd/user/tmux.service.j2
dest: '{{ vdr.home }}/.config/systemd/user/tmux.service'
- name: create wm-exit.service for the session
template:
src: roles/yavdr-xorg/templates/systemd/user/wm-exit.service.j2
dest: '{{ vdr.home }}/.config/systemd/user/wm-exit.service'
- name: create detect-second-display.service for the session
template:
src: templates/systemd/user/detect-second-display.service.j2
dest: '{{ vdr.home }}/.config/systemd/user/detect-second-display.service'
- name: create openbox-second.service for the session
template:
src: templates/systemd/user/openbox-second.service.j2
dest: '{{ vdr.home }}/.config/systemd/user/openbox-second.service'
- name: create osd2web.service for the session
template:
src: templates/systemd/user/osd2web.service.j2
dest: '{{ vdr.home }}/.config/systemd/user/osd2web.service'
- name: link /usr/bin/start-desktop to /var/lib/vdr/plugins/desktop/starter
file:
src: /usr/bin/start-desktop
dest: /var/lib/vdr/plugins/desktop/starter
state: link
- name: enable and start xlogin for the vdr user
systemd:
daemon_reload: yes
name: 'xlogin@{{ vdr.user }}'
enabled: yes
state: started
#+END_SRC
*** templates
**** xorg
***** x-verbose@.service
#+BEGIN_SRC conf :tangle "roles/yavdr-xorg/templates/systemd/system/x-verbose@.service.j2" :padline no
# file: roles/yavdr-xorg/templates/systemd/system/x-verbose@.service.j2
[Unit]
Description=X with verbose logging on %I
Wants=graphical.target
Before=graphical.target
[Service]
Type=forking
ExecStart=/usr/bin/x-daemon -logverbose 6 -noreset %I -config /etc/X11/xorg-verbose.conf
#+END_SRC
***** Drop-in snippet for x@.service
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/x@service.d/xlogin.conf.j2 :mkdirp yes :padline no
[Unit]
Before=xlogin@{{ vdr.user }}.service
#+END_SRC
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/user@666.service.d/x-dependency.conf.j2 :mkdirp yes :padline no
[Unit]
Wants=x@vt7.service
After=x@vt7.service
[Service]
TimeoutStopSec=20
KillMode=mixed
#+END_SRC
***** Drop-in snippet for vdr.service
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/vdr-xorg.conf :mkdirp yes :padline no
# file: roles/yavdr-xorg/templates/vdr-xorg.conf
# {{ ansible_managed_file }}
[Unit]
After=x@vt7.service
Wants=x@vt7.service
#BindsTo=x@vt7.service
#+END_SRC
***** .xinitrc
#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/.xinitrc.j2 :mkdirp yes :padline no
#!/bin/bash
# {{ ansible_managed_file }}
exec openbox-session
#+END_SRC
***** xorg.conf
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/xorg-verbose.conf.j2
Section "Device"
Identifier "nvidia"
Driver "nvidia"
Option "NoLogo" "true"
Option "DynamicTwinView" "true"
Option "NoFlip" "false"
# Option "FlatPanelProperties" "Scaling = Native"
# Option "ModeValidation" "NoVesaModes, NoXServerModes"
# Option "ModeDebug" "true"
# Option "HWCursor" "false"
EndSection
Section "Screen"
Identifier "screen"
Device "nvidia"
EndSection
Section "Extensions"
Option "Composite" "false"
EndSection
#+END_SRC
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/xorg.conf.j2
{{ ansible_managed_file | comment }}
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
{% if xorg.secondary is defined %}
Screen 1 "Screen1" RightOf "Screen0"
{% endif %}
#InputDevice "Keyboard0" "CoreKeyboard"
#InputDevice "Mouse0" "CorePointer"
Option "Xinerama" "0"
EndSection
Section "InputClass"
Identifier "exclude eventlircd devices"
MatchTag "eventlircd"
Option "Ignore" "True"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "{{ xorg.primary.vendor }}"
ModelName "{{ xorg.primary.model }}"
Option "DPMS"
Option "ExactModeTimingsDVI" "True"
EndSection
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
Option "NoLogo" "true"
{% if xorg.primary.bus_id is defined %}
BoardName "{{ xorg.primary.gpu_name }}"
BusID "{{ xorg.primary.bus_id }}"
{% else %}
BoardName "Unknown"
{% endif %}
Screen 0
EndSection
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
Option "nvidiaXineramaInfoOrder" "{{ xorg.primary.connector }}"
Option "ConnectedMonitor" "{{ xorg.primary.connector }}{% if xorg.secondary is defined %}, {{ xorg.secondary.connector }}{% endif %}"
Option "UseDisplayDevice" "{{ xorg.primary.connector }}"
Option "CustomEDID" "{{ xorg.primary.connector }}:/etc/X11/edid.{{ xorg.primary.connector }}.bin"
Option "metamodes" "{{ xorg.primary.connector }}: {{ xorg.primary.mode }} +0+0"
Option "SLI" "Off"
Option "MultiGPU" "Off"
Option "BaseMosaic" "off"
SubSection "Display"
Depth 24
EndSubSection
EndSection
{% if xorg.secondary is defined %}
Section "Device"
Identifier "Device1"
Driver "nvidia"
VendorName "NVIDIA Corporation"
Option "NoLogo" "true"
{% if xorg.secondary.bus_id is defined %}
BoardName "{{ xorg.primary.gpu_name }}"
BusID "{{ xorg.primary.bus_id }}"
{% else %}
BoardName "Unknown"
{% endif %}
Screen 1
EndSection
Section "Monitor"
Identifier "Monitor1"
VendorName "{{ xorg.secondary.vendor }}"
ModelName "{{ xorg.secondary.model }}"
EndSection
Section "Screen"
Identifier "Screen1"
Device "Device1"
Monitor "Monitor1"
DefaultDepth 24
Option "nvidiaXineramaInfoOrder" "{{ xorg.secondary.connector }}"
Option "ConnectedMonitor" "{{ xorg.secondary.connector }}"
Option "UseDisplayDevice" "{{ xorg.secondary.connector }}"
Option "CustomEDID" "{{ xorg.secondary.connector }}:/etc/X11/edid.{{ xorg.secondary.connector }}.bin"
Option "metamodes" "{{ xorg.secondary.connector }}: {{ xorg.secondary.mode }} +0+0"
Option "SLI" "Off"
Option "MultiGPU" "Off"
Option "BaseMosaic" "off"
SubSection "Display"
Depth 24
EndSubSection
EndSection
{% endif %}
#+END_SRC
#+BEGIN_SRC shell :tangle roles/template-test/templates/xorg.conf_test.j2
{{ ansible_managed_file | comment }}
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0"
{% if xorg.best_tv_mode.secondary is defined %}
Screen 1 "Screen1" RightOf "Screen0"
{% endif %}
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection
# ignore devices with eventlircd tag
# ENV{ID_INPUT.tags}+="eventlircd"
# must be set by an udev rule
Section "InputClass"
Identifier "ignore eventlircd devices"
MatchTag "eventlircd"
Option "Ignore" "True"
EndSection
Section "InputDevice"
# generated from default
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "Unknown"
ModelName "Unknown"
{# TODO: VGA2SCART support (if needed)
{% if system.x11.display.0.default == "VGA2Scart_4_3" or system.x11.display.0.default == "VGA2Scart_16_9" %}
HorizSync 14-17
VertRefresh 49-61
{% if system.x11.display.0.default == "VGA2Scart_4_3" %}
Modeline "VGA2Scart_4_3" 13.875 720 744 808 888 576 580 585 625 -HSync -Vsync interlace
{% elif system.x11.display.0.default == "VGA2Scart_16_9" %}
Modeline "VGA2Scart_16_9" 19 1024 1032 1120 1216 576 581 586 625 -Hsync -Vsync interlace
{% endif %}
{% endif %}
#}
Option "DPMS"
Option "ExactModeTimingsDVI" "True"
EndSection
{% if xrandr.best_tv_mode.secondary is defined %}
Section "Monitor"
Identifier "Monitor1"
VendorName "Unknown"
ModelName "Unknown"
{#
{% if system.x11.display.1.default in ("VGA2Scart_4_3", "VGA2Scart_16_9") %}
HorizSync 14-17
VertRefresh 49-61
{% if system.x11.display.1.default == "VGA2Scart_4_3" %}
Modeline "VGA2Scart_4_3" 13.875 720 744 808 888 576 580 585 625 -HSync -Vsync interlace
{% elif system.x11.display.1.default == "VGA2Scart_16_9" %}
Modeline "VGA2Scart_16_9" 19 1024 1032 1120 1216 576 581 586 625 -Hsync -Vsync interlace
{% endif %}
Option "DPMS"
Option "ExactModeTimingsDVI" "True"
{% endif %}
#}
EndSection
{% endif %}
Section "Device"
Identifier "Device0"
{% if system.hardware.nvidia.detected %}
Driver "nvidia"
VendorName "NVIDIA Corporation"
{% endif %}
Screen 0
Option "DPI" "100x100"
{% if system.hardware.nvidia.busid is defined and system.hardware.busid %}
BusID "PCI: {{ system.hardware.nvidia.busid }}"
{% endif %}
Option "NoLogo" "True"
Option "UseEvents" "True"
Option "TripleBuffer" "False"
Option "AddARGBGLXVisuals" "True"
Option "TwinView" "0"
Option "DynamicTwinView" "0"
Option "OnDemandVBlankinterrupts" "on"
Option "FlatPanelProperties" "Scaling = Native"
EndSection
{% if xrandr.best_tv_mode.secondary is defined %}
Section "Device"
Identifier "Device1"
{% if system.hardware.nvidia.detected %}
Driver "nvidia"
VendorName "NVIDIA Corporation"
{% endif %}
Screen 1
{% if system.hardware.nvidia.busid is defined and system.hardware.nvidia.busid %}
BusID "PCI: {{ system.hardware.nvidia.busid }}"
{% endif %}
Option "NoLogo" "True"
Option "UseEvents" "True"
Option "TripleBuffer" "False"
Option "AddARGBGLXVisuals" "True"
Option "TwinView" "0"
Option "DynamicTwinView" "0"
EndSection
{% endif %}
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
{% if xrandr.best_tv_mode.primary is defined %}
Modes "{{ xrandr.best_tv_mode.primary.mode }}"{#{% for mode in xrandr %}{% if mode != system.x11.display.0.default %} "{{ mode }}"{% endif %}{% endfor %}#} nvidia-auto-select
{% elif system.hardware.nvidia.detected == 1 %}
Modes "nvidia-auto-select"
{% endif %}
EndSubSection
{% if system.x11.display.0.default or system.x11.default %}
{% if system.x11.display.0.device is definded and system.x11.display.0.device %}
Option "ConnectedMonitor" {{ system.x11.display.0.device }}
{% else %}
Option "ConnectedMonitor" {{ system.x11.default }}
{% endif %}
# Option "ConnectedMonitor" ", "
#Option "ConnectedMonitor"
"
, "
# Option "UseDisplayDevice" ""
#
#
# Option "CustomEDID" ":/etc/X11/edid.0.yavdr"
#
#
# Option "MetaModes" ": { ViewPortIn=x, ViewPortOut=x++ }"
#
# Option "MetaModes" ": { ViewPortIn=x, ViewPortOut=x++ }"
{% endif %}
EndSection
{% if system.x11.dualhead.enabled == "1" %}
Section "Screen"
Identifier "Screen1"
Device "Device1"
Monitor "Monitor1"
DefaultDepth 24
SubSection "Display"
Depth 24
{% if system.x11.display.0.default is defined and system.x11.display.0.default %}
Modes "{{ system.x11.display.1.default }}"{% for mode in system.x11.display.1.mode %}{% if mode != system.x11.display.1.default %} "{{ mode }}"{% endif %}{% endfor %}
{% elif system.hardware.nvidia.detected == "1" %}
Modes "nvidia-auto-select"
{% endif %}
EndSubSection
#
# Option "UseDisplayDevice" ""
#
#
# Option "CustomEDID" ":/etc/X11/edid.1.yavdr"
#
#
# Option "MetaModes" ": { ViewPortIn=x, ViewPortOut=x++ }"
#
# Option "MetaModes" ": { ViewPortIn=x, ViewPortOut=x++ }"
#
EndSection
{% endif %}
#+END_SRC
**** vdr
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/systemd/vdr-environ.j2
[Service]
Environment=XDG_RUNTIME_DIR=/run/user/{{ vdr.uid }}/
EnvironmentFile=-/var/lib/vdr/.session-env
#+END_SRC
**** Systemd User Session
***** yavdr-desktop.target
#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/systemd/user/yavdr-desktop.target.j2 :mkdirp yes :padline no
[Unit]
Description=yaVDR Desktop
Requires=default.target
After=default.target pulseaudio.service
Wants=dbus.service pulseaudio.service
AllowIsolate=yes
#+END_SRC
***** detect-second-display
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/systemd/user/detect-second-display.service.j2 :mkdirp yes :padline no
[Unit]
Description=Detect second DISPLAY using xrandr
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'export DISPLAY=$DISPLAY.1; xrandr -q | grep "connected" && echo "DISPLAY=$DISPLAY" > ~/.second_display || rm -f ~/.second_display'
[Install]
WantedBy=yavdr-desktop.target
#+END_SRC
***** openbox-second.service
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/systemd/user/openbox-second.service.j2 :mkdirp yes :padline no
[Unit]
Description=Start openbox on the second DISPLAY if it exists
After=detect-second-display.service
Wants=detect-second-display.service
Before=yavdr-frontend.service
ConditionFileNotEmpty=%h/.second_display
[Service]
PassEnvironment=XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS
EnvironmentFile=%h/.second_display
ExecStart=/usr/bin/openbox --config-file %h/.config/openbox/rc.xml
[Install]
WantedBy=yavdr-desktop.target
#+END_SRC
***** osd2web.service
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/systemd/user/osd2web.service.j2 :mkdirp yes :padline no
[Unit]
Description=Start a kiosk browser on the second DISPLAY if it exists
After=detect-second-display.service openbox-second.service
Wants=detect-second-display.service openbox-second.service
ConditionFileNotEmpty=%h/.second_display
[Service]
EnvironmentFile=%h/.second_display
PassEnvironment=XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS
ExecStart=/usr/bin/on_vdr -o -c 'kiosk-browser "http://localhost:4444/skins/horchiTft/index.html?theme=blue&onlyView=1"'
KillSignal=SIGINT
[Install]
WantedBy=yavdr-desktop.target
#+END_SRC
***** tmux.service
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/systemd/user/tmux.service.j2 :mkdirp yes :padline no
[Unit]
Description=Start tmux in detached session
[Service]
EnvironmentFile=-%h/.session-env
Type=forking
ExecStart=/usr/bin/tmux new-session -s use-session -d
ExecStop=/usr/bin/tmux kill-session -t %u
Restart=always
[Install]
WantedBy=default.target
#+END_SRC
***** wm-exit.service
#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/systemd/user/wm-exit.service.j2 :mkdirp yes :padline no
[Unit]
Description=exit window manager gracefully
[Service]
ExecStart=/bin/true
ExecStop=/usr/bin/openbox --exit
RemainAfterExit=True
[Install]
WantedBy=default.target
#+END_SRC
**** openbox
***** autostart
#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/openbox/autostart.j2 :mkdirp yes :shebang #!/bin/bash
# forward environment variables to an environment file and the systemd user session
env | grep "DISPLAY\|DBUS_SESSION_BUS_ADDRESS\|XDG_RUNTIME_DIR" > ~/.session-env
systemctl --user import-environment DISPLAY XAUTHORITY XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS
enabled_services=(
"tmux.service" "detect-second-display.service"
"openbox-second.service" "osd2web.service"
"yavdr-frontend.service" "pulseaudio.socket"
"pulseaudio.service" "wm-exit.service")
disabled_services=()
# enable configured services for the user session
for service in "${enabled_services[@]}"; do
systemctl --user enable "$service"
done
# disable unwanted services for the user session
for service in "${disabled_services[@]}"; do
systemctl --user disable "$service"
done
if which dbus-update-activation-environment >/dev/null 2>&1; then
dbus-update-activation-environment DISPLAY XAUTHORITY XDG_RUNTIME_DIR
fi
# start systemd units for the yavdr user session
systemctl --user isolate yavdr-desktop.target
#+END_SRC
***** rc.xml
#+BEGIN_SRC xml :tangle roles/yavdr-xorg/templates/openbox/rc.xml.j2 :mkdirp yes :padline no
10
20
yes
no
yes
no
200
no
Smart
yes
Active
Active
Onyx
NLIMC
yes
yes
sans
8
bold
normal
sans
8
bold
normal
sans
9
normal
normal
sans
9
normal
normal
sans
9
bold
normal
sans
9
bold
normal
2
1
875
yes
Nonpixel
Center
10
10
0
0
0
0
TopLeft
0
0
no
Above
Vertical
no
300
300
Middle
C-g
left
no
right
no
up
no
down
no
left
no
right
no
up
no
down
no
1
2
3
4
scrot -s
yes
yes
right
left
up
down
true
Konqueror
kfmclient openProfile filemanagement
scrot
1
500
400
false
previous
next
previous
next
previous
next
no
yes
top
left
right
bottom
vertical
horizontal
previous
next
previous
next
previous
next
previous
next
previous
next
no
true
no
no
true
yes
no
true
yes
#+END_SRC
** samba-install
*** tasks
#+BEGIN_SRC yaml :tangle roles/samba-install/tasks/main.yml :mkdirp yes :padline no
---
# file: roles/samba-install/tasks/main.yml
- name: install samba server
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
- samba
- samba-common
- samba-common-bin
- tdb-tools
#+END_SRC
** samba-config
*** tasks
#+BEGIN_SRC yaml :tangle roles/samba-config/tasks/main.yml :mkdirp yes :padline no
---
# file: roles/samba-config/tasks/main.yml
# TODO:
# - name: divert original smbd.conf
- name: touch smb.conf.custom
file:
state: touch
dest: '/etc/samba/smb.conf.custom'
notify: [ 'Restart Samba' ]
- name: expand template for smb.conf
template:
src: 'templates/smb.conf.j2'
dest: '/etc/samba/smb.conf'
#validate: 'testparm -s %s'
notify: [ 'Restart Samba' ]
#+END_SRC
*** templates
**** smb.conf
***** global settings
#+BEGIN_SRC yaml :tangle roles/samba-config/templates/smb.conf.j2 :mkdirp yes :padline no
{{ ansible_managed_file | comment }}
#======================= Global Settings =======================
[global]
## Browsing/Identification ###
# Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = {{ samba.workgroup }}
# server string is the equivalent of the NT Description field
server string = %h server (Samba, Ubuntu)
# This will prevent nmbd to search for NetBIOS names through DNS.
dns proxy = no
#### Debugging/Accounting ####
# This tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/log.%m
# Cap the size of the individual log files (in KiB).
max log size = 1000
# We want Samba to log a minimum amount of information to syslog. Everything
# should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log
# through syslog you should set the following parameter to something higher.
syslog = 0
# Do something sensible when Samba crashes: mail the admin a backtrace
panic action = /usr/share/samba/panic-action %d
####### Authentication #######
# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
# security = user
# You may wish to use password encryption. See the section on
# 'encrypt passwords' in the smb.conf(5) manpage before enabling.
encrypt passwords = true
# If you are using encrypted passwords, Samba will need to know what
# password database type you are using.
passdb backend = tdbsam
obey pam restrictions = yes
# This boolean parameter controls whether Samba attempts to sync the Unix
# password with the SMB password when the encrypted SMB password in the
# passdb is changed.
unix password sync = yes
# For Unix password sync to work on a Debian GNU/Linux system, the following
# parameters must be set (thanks to Ian Kahan < for
# sending the correct chat script for the passwd program in Debian Sarge).
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
# This boolean controls whether PAM will be used for password changes
# when requested by an SMB client instead of the program listed in
# 'passwd program'. The default is 'no'.
pam password change = yes
# This option controls how unsuccessful authentication attempts are mapped
# to anonymous connections
map to guest = bad user
{% if samba.windows_compatible %}
# disable unix extensions and enable following symlinks
unix extensions = no
follow symlinks= yes
wide links= yes
{% endif %}
#+END_SRC
***** media directories
#+BEGIN_SRC yaml :tangle roles/samba-config/templates/smb.conf.j2 :mkdirp yes
{% for name, path in media_dirs.iteritems() %}
[{{ name }}]
path = {{ path }}
comment = {{ name }} on %h
guest ok = yes
writeable = yes
browseable = yes
create mode = 0664
directory mode = 0775
force user = {{ vdr.user }}
force group = {{ vdr.group }}
follow symlinks = yes
wide links = yes
{% endfor %}
#+END_SRC
***** include custom samba exports
#+BEGIN_SRC yaml :tangle roles/samba-config/templates/smb.conf.j2 :mkdirp yes
include = /etc/samba/smb.conf.custom
#+END_SRC
** STARTED autoinstall-drivers
It would be nice to be able to detect if it is suitable to install those drivers:
*** TODO sundtek for Sundtek devices (local or network connection)
Vendor-IDs:
- eb1a:5[1b2] (alte Generation)
- 2659:* (neuere Sticks)
*** TODO dddvb-dkms if only newer DD cards are detected
*** TODO media-build-experimental (up to kernel 4.8) for "old" cards like TT S2-6400 FF
*** TODO newly merged DD drivers
from http://www.vdr-portal.de/board18-vdr-hardware/board102-dvb-karten/120817-treiber-der-cine-ctv6-ddbridge-ci-in-den-kernel-integrieren/
** autoinstall-ubuntu-drivers
The tool ubuntu-drivers is used to install the matching driver version for nvidia graphics cards, virtualbox guest additions and Intel and AMD microcode updates.
*** tasks
#+BEGIN_SRC yaml :tangle roles/autoinstall-ubuntu-drivers/tasks/main.yml :padline no
---
# file roles/autoinstall-ubuntu-drivers/tasks/main.yml
- name: autoinstall ubuntu-drivers-common
block:
- name: apt | install ubuntu-drivers-common
apt:
name: ubuntu-drivers-common
state: present
- name: use ubuntu-drivers to install additional drivers automatically
command: ubuntu-drivers --package-list /etc/yavdr/autoinstalled autoinstall
when: (ansible_virtualization_type != "virtualbox" and ansible_virtualization_role != "guest") or
ansible_distribution_version != "16.04"
# ubuntu-drivers-common tries to autoinstall
# conflicting packages for virtualbox in Ubuntu 16.04 :(
#+END_SRC
** autoinstall-virtualbox-guest
This role installs the guest additions for virtualbox guests on Ubuntu 16.04
#+BEGIN_SRC yaml :tangle roles/autoinstall-virtualbox-guest/tasks/main.yml :padline no
---
# file roles/autoinstall-virtualbox-guest/tasks/main.yml
- name: install virtualbox guest additions
block:
- name: install packages
apt:
state: present
name: '{{ item }}'
with_items:
- virtualbox-guest-dkms
- virtualbox-guest-x11
- dkms
# TODO: set xineliboutput as frontend
when:
- ansible_virtualization_type == "virtualbox"
- ansible_virtualization_role == "guest"
- ansible_distribution == "Ubuntu"
- ansible_distribution_version == "16.04"
#+END_SRC
** autoinstall-satip
If a Sat>IP Server responds to a discovery request, the package vdr-plugin-satip is installed.
*** tasks
#+BEGIN_SRC yaml :tangle roles/autoinstall-satip/tasks/main.yml :padline no
---
# file roles/autoinstall-satip/tasks/main.yml
- name: "detect SAT>IP Server(s) on the network"
action: satip_facts
- debug:
var: satip_devices
verbosity: 1
- name: apt | install vdr-plugin-satip if a Sat>IP server has been detected
apt:
name: vdr-plugin-satip
state: present
when: satip_devices
notify: [ 'Restart VDR' ]
#+END_SRC
** autoinstall-targavfd
*** tasks
#+BEGIN_SRC yaml :tangle roles/autoinstall-targavfd/tasks/main.yml :padline no
---
# file roles/autoinstall-targavfd/tasks/main.yml
- name: apt | install vdr-plugin-targavfd if connected
apt:
name: vdr-plugin-targavfd
when: '"19c2:6a11" in usb'
notify: [ 'Restart VDR' ]
#+END_SRC
** autoinstall-imonlcd
*** tasks
#+BEGIN_SRC yaml :tangle roles/autoinstall-imonlcd/tasks/main.yml :padline no
---
# file roles/autoinstall-imonlcd/tasks/main.yml
- name: apt | install vdr-plugin-imonlcd if connected
apt:
name: vdr-plugin-imonlcd
when: '"15c2:0038" in usb or "15c2:ffdc" in usb'
notify: [ 'Restart VDR' ]
#+END_SRC
** autoinstall-libcecdaemon
*** tasks
#+BEGIN_SRC yaml :tangle roles/autoinstall-libcecdaemon/tasks/main.yml :padline no
---
# file roles/autoinstall-libcec-daemon/tasks/main.yml
- name: apt | install libcec-daemon if connected
apt:
name: libcec-daemon
when:
- "2548:1002" in usb
#+END_SRC
** autoinstall-pvr350
*** tasks
#+BEGIN_SRC yaml :tangle roles/autoinstall-pvr350/tasks/main.yml :padline no
---
# file roles/autoinstall-pvr350/tasks/main.yml
- name: apt | install vdr-plugin-pvr350 if connected
apt:
name: vdr-plugin-pvr350
when: '"0070:4000" in pci'
notify: [ 'Restart VDR' ]
#+END_SRC
** autoinstall-hauppauge-pvr
#+BEGIN_SRC yaml :tangle roles/autoinstall-hauppauge-pvr/tasks/main.yml :padline no
---
# file roles/autoinstall-hauppauge-pvr/tasks/main.yml
- name: apt | install vdr-plugin-pvrinput if a haupauge pvr card is found
apt:
name: vdr-plugin-pvrinput
when: '"0070:4000" in pci or "4444:0016" in pci'
notify: [ 'Restart VDR' ]
#+END_SRC
** autoinstall-dvbsky-firmware
*** defaults
#+INCLUDE: "roles/autoinstall-dvbsky-firmware/defaults/main.yml" src yaml
*** tasks
#+INCLUDE: "roles/autoinstall-dvbsky-firmware/tasks/main.yml" src yaml
** TODO autoinstall-dvbhddevice
Problem: woher kommt der Treiber (AFAIK noch nicht im Kernel)? Die Firmware sollte in yavdr-firmware stecken
*** tasks
#+BEGIN_SRC yaml :tangle roles/autoinstall-dvbhddevice/tasks/main.yml :padline no
---
# file roles/autoinstall-dvbhddevice/tasks/main.yml
- name: apt | install vdr-plugin-dvbhddevice if connected
apt:
name: vdr-plugin-dvbhddevice
when: '"13c2:300a" in pci or "13c2:300b" in pci'
notify: [ 'Restart VDR' ]
#+END_SRC
** autoinstall-dvbsddevice
*** tasks
#+BEGIN_SRC yaml :tangle roles/autoinstall-dvbsddevice/tasks/main.yml :padline no
---
# file roles/autoinstall-dvbsddevice/tasks/main.yml
# TODO: install firmware
- name: apt | install vdr-plugin-dvbsddevice if module is loaded
apt:
name: vdr-plugin-dvbsddevice
when: '"dvb_ttpci" in modules'
notify: [ 'Restart VDR' ]
#+END_SRC
** autoinstall-hardware-irmp
*** tasks
#+BEGIN_SRC yaml :tangle roles/autoinstall-hardware-irmp/tasks/main.yml :padline no
---
# file roles/autoinstall-hardware-irmp/tasks/main.yml
- name: apt | install yavdr-hardware-irmp if connected
apt:
name: yavdr-hardware-irmp
state: present
when: '"1209:4444" in usb'
#+END_SRC
**** TODO add other device ids if necessary
** kodi
*** tasks
**** Install KODI
***** main.yml
:PROPERTIES:
:UNNUMBERED: t
:END:
#+INCLUDE: "roles/kodi/tasks/main.yml" src yaml
***** install-kodi.yml
#+INCLUDE: "roles/kodi/tasks/install-kodi.yml" src yaml
***** configure-kodi.yml
#+INCLUDE: "roles/kodi/tasks/configure-kodi.yml" src yaml
*** templates
**** kodi.service
This systemd unit for the user session starts (and stops) kodi.
#+INCLUDE: "roles/kodi/templates/kodi.service.j2" src conf
*** files
Those configuration files provide a preconfiguration for kodi which overrides the system wide configuration
**** Lircmap.xml
This file allows to map keys sent by remotes via eventlircd (which uses the name ~devinput~) to kodi key names.
#+INCLUDE: "roles/kodi/files/userdata/Lircmap.xml" src nxml
**** keymaps
This file maps the keys defined in Lircmap.xml to actions within kodi.
***** remote.xml
#+INCLUDE: "roles/kodi/files/userdata/keymaps/remote.xml" src xml
** dvd
*** tasks
**** install libdvd-pkg, allow programs to eject optical media
:PROPERTIES:
:UNNUMBERED: t
:END:
#+INCLUDE: "roles/dvd/tasks/main.yml" src yaml
** template-test
:PROPERTIES:
:EXPORT: nil
:END:
#+BEGIN_SRC yaml :tangle roles/template-test/tasks/main.yml :padline no
---
- name: show vars
debug:
var: '{{ system }}'
- name: test templates
template:
src: templates/test.j2
dest: /tmp/test.txt
#+END_SRC
#+BEGIN_SRC shell :tangle roles/template-test/templates/xorg.conf_test.j2
{{ ansible_managed_file | comment }}
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0"
{% if system.x11.dualhead.enabled %}
Screen 1 "Screen1" RightOf "Screen0"
{% endif %}
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection
# ignore devices with eventlircd tag
# ENV{ID_INPUT.tags}+="eventlircd"
# must be set by an udev rule
Section "InputClass"
Identifier "ignore eventlircd devices"
MatchTag "eventlircd"
Option "Ignore" "True"
EndSection
Section "InputDevice"
# generated from default
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "Unknown"
ModelName "Unknown"
{% if system.x11.display.0.default == "VGA2Scart_4_3" or system.x11.display.0.default == "VGA2Scart_16_9" %}
HorizSync 14-17
VertRefresh 49-61
{% if system.x11.display.0.default == "VGA2Scart_4_3" %}
Modeline "VGA2Scart_4_3" 13.875 720 744 808 888 576 580 585 625 -HSync -Vsync interlace
{% elif system.x11.display.0.default == "VGA2Scart_16_9" %}
Modeline "VGA2Scart_16_9" 19 1024 1032 1120 1216 576 581 586 625 -Hsync -Vsync interlace
{% endif %}
{% endif %}
Option "DPMS"
Option "ExactModeTimingsDVI" "True"
EndSection
{% if system.x11.dualhead.enabled == "1" %}
Section "Monitor"
Identifier "Monitor1"
VendorName "Unknown"
ModelName "Unknown"
{% if system.x11.display.1.default in ("VGA2Scart_4_3", "VGA2Scart_16_9") %}
HorizSync 14-17
VertRefresh 49-61
{% if system.x11.display.1.default == "VGA2Scart_4_3" %}
Modeline "VGA2Scart_4_3" 13.875 720 744 808 888 576 580 585 625 -HSync -Vsync interlace
{% elif system.x11.display.1.default == "VGA2Scart_16_9" %}
Modeline "VGA2Scart_16_9" 19 1024 1032 1120 1216 576 581 586 625 -Hsync -Vsync interlace
{% endif %}
Option "DPMS"
Option "ExactModeTimingsDVI" "True"
{% endif %}
EndSection
{% endif %}
Section "Device"
Identifier "Device0"
{% if system.hardware.nvidia.detected %}
Driver "nvidia"
VendorName "NVIDIA Corporation"
{% endif %}
Screen 0
Option "DPI" "100x100"
{% if system.hardware.nvidia.busid %}
BusID "PCI: {{ system.hardware.nvidia.busid }}"
{% endif %}
Option "NoLogo" "True"
Option "UseEvents" "True"
Option "TripleBuffer" "False"
Option "AddARGBGLXVisuals" "True"
Option "TwinView" "0"
Option "DynamicTwinView" "0"
Option "OnDemandVBlankinterrupts" "on"
Option "FlatPanelProperties" "Scaling = Native"
EndSection
{% if system.x11.dualhead.enabled == "1" %}
Section "Device"
Identifier "Device1"
{% if system.hardware.nvidia.detected %}
Driver "nvidia"
VendorName "NVIDIA Corporation"
{% endif %}
Screen 1
{% if system.hardware.nvidia.busid %}
BusID "PCI: {{ system.hardware.nvidia.busid }}"
{% endif %}
Option "NoLogo" "True"
Option "UseEvents" "True"
Option "TripleBuffer" "False"
Option "AddARGBGLXVisuals" "True"
Option "TwinView" "0"
Option "DynamicTwinView" "0"
EndSection
{% endif %}
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
{% if system.x11.display.0.default is defined and system.x11.display.0.default %}
Modes "{{ system.x11.display.0.default }}"{% for mode in system.x11.display.0.mode %}{% if mode != system.x11.display.0.default %} "{{ mode }}"{% endif %}{% endfor %}
{% elif system.hardware.nvidia.detected == 1 %}
Modes "nvidia-auto-select"
{% endif %}
EndSubSection
{% if system.x11.display.0.default or system.x11.default %}
{% if system.x11.display.0.device is definded and system.x11.display.0.device %}
Option "ConnectedMonitor" {{ system.x11.display.0.device }}
{% else %}
Option "ConnectedMonitor" {{ system.x11.default }}
{% endif %}
# Option "ConnectedMonitor" ", "
#Option "ConnectedMonitor"
"
, "
# Option "UseDisplayDevice" ""
#
#
# Option "CustomEDID" ":/etc/X11/edid.0.yavdr"
#
#
# Option "MetaModes" ": { ViewPortIn=x, ViewPortOut=x++ }"
#
# Option "MetaModes" ": { ViewPortIn=x, ViewPortOut=x++ }"
{% endif %}
EndSection
{% if system.x11.dualhead.enabled == "1" %}
Section "Screen"
Identifier "Screen1"
Device "Device1"
Monitor "Monitor1"
DefaultDepth 24
SubSection "Display"
Depth 24
{% if system.x11.display.0.default is defined and system.x11.display.0.default %}
Modes "{{ system.x11.display.1.default }}"{% for mode in system.x11.display.1.mode %}{% if mode != system.x11.display.1.default %} "{{ mode }}"{% endif %}{% endfor %}
{% elif system.hardware.nvidia.detected == "1" %}
Modes "nvidia-auto-select"
{% endif %}
EndSubSection
#
# Option "UseDisplayDevice" ""
#
#
# Option "CustomEDID" ":/etc/X11/edid.1.yavdr"
#
#
# Option "MetaModes" ": { ViewPortIn=x, ViewPortOut=x++ }"
#
# Option "MetaModes" ": { ViewPortIn=x, ViewPortOut=x++ }"
#
EndSection
{% endif %}
{% if not system.x11.use_compositing %}
Section "Extensions"
# if not open-gl OSD is needed (e.g. for vdr-sxfe):
Option "Composite" "Disable"
EndSection
{% endif %}
#+END_SRC
#+BEGIN_SRC yaml :tangle roles/template-test/defaults/main.yml
foo:
- bar
- baz
- spam
system:
hardware:
nvidia:
detected: "1"
busid: "000:2304:234"
x11:
dualhead:
enabled: "0"
display:
0:
mode:
- "1920x1080_50"
default: "nvidia-auto"
1:
mode:
- "1280x720_60"
#+END_SRC
** wakeup
*** defaults
#+BEGIN_SRC yaml :tangle roles/wakeup/defaults/main.yml :padline no
---
# file roles/wakeup/defaults/main.yml
wakeup_method: "acpiwakeup"
#+END_SRC
*** tasks
#+BEGIN_SRC yaml :tangle roles/wakeup/tasks/main.yml :padline no
---
# file roles/wakeup/tasks/main.yml
- name: install and configure vdr-addon-acpiwakeup
apt:
name: vdr-addon-acpiwakeup
state: present
when: wakeup_method == "acpiwakeup"
- name: expand template for /etc/vdr/vdr-addon-acpiwakeup.conf
template:
src: templates/vdr-addon-acpiwakeup.conf.j2
dest: /etc/vdr/vdr-addon-acpiwakeup.conf
#+END_SRC
*** templates
#+BEGIN_SRC jinja2 :tangle roles/wakeup/templates/vdr-addon-acpiwakeup.conf.j2 :padline no
{{ ansible_managed_file | comment }}
# Activate/deactivate ACPIWakeup with yes/no:
ACPI_ENABLED="{% if wakeup_method == 'acpiwakeup' %}yes{% else %}no{% endif %}"
# How many minutes should the machine wake up before the timer starts:
ACPI_START_AHEAD=5
# If you want your VDR machine to wakeup in regular intervals (i.e. for
# updating EPG data), specify the days of the week and the wakeup time.
#
# Days of the week for regular wakeup (not set=Disabled, 1=Monday...7=Sunday)
# ACPI_REGULAR_DAYS="1 2 3 4 5 6 7"
# Wakeup time
#ACPI_REGULAR_TIME=01:00 # HH:MM
#+END_SRC
** grub-config
*** default variables
#+BEGIN_SRC yaml :tangle roles/grub-config/defaults/main.yml :mkdirp yes :padline no
system:
shutdown: poweroff
grub:
timeout: 0
boot_options: quiet nosplash
#+END_SRC
*** tasks
#+BEGIN_SRC yaml :tangle roles/grub-config/tasks/main.yml :mkdirp yes :padline no
---
- name: custom grub configuration for timeout and reboot halt
template:
src: templates/50_custom.j2
dest: /etc/grub.d/50_custom
mode: '0775'
notify: [ 'Update GRUB' ]
# TODO: add special case if plymouth is used
- name: let the system boot quietly
lineinfile:
dest: /etc/default/grub
state: present
regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=")'
line: '\1{{ grub.boot_options}}"'
backrefs: yes
notify: [ 'Update GRUB' ]
#+END_SRC
*** templates
#+BEGIN_SRC shell :tangle roles/grub-config/templates/50_custom.j2 :mkdirp yes :padline no
#!/bin/sh
exec tail -n +3 $0
# This file is configured by the ansible configuration for yaVDR
{% if system.shutdown is defined and system.shutdown == 'reboot' %}
menuentry "PowerOff" {
halt
}
{% endif %}
if [ "${recordfail}" = 1 ]; then
set timeout={{ 3 if grub.timeout < 3 else grub.timeout }}
else
set timeout={{ grub.timeout if grub.timeout is defined else 0 }}
fi
#+END_SRC
*** handlers
#+BEGIN_SRC yaml :tangle roles/grub-config/handlers/main.yml :mkdirp yes :padline no
---
- name: Update GRUB
command: update-grub
failed_when: ('error' in grub_register_update.stderr)
register: grub_register_update
# TODO: Do we need to use grub-set-default?
# https://github.com/yavdr/yavdr-utils/blob/master/events/actions/update-grub
#+END_SRC
* Modules
This section contains custom modules for the yaVDR Playbooks. They are used to collect facts about the system and configure applications and daemons.
** hardware_facts.py
#+BEGIN_SRC python :tangle library/hardware_facts.py :shebang #!/usr/bin/env/python
# This Module collects the vendor- and device ids for USB- and PCI(e)-devices and currently loaded kernel modules.
DOCUMENTATION = '''
---
module: hardware_facts
short_description: collects facts for kernel modules, usb and pci devices
description:
- This Module collects the vendor- and device ids for USB- and PCI(e)-devices and
currently loaded kernel modules.
options:
usb:
required: False
default: True
description:
- return a list of vendor- and device ids for usb devices in '04x:04x' notation
pci:
required: False
default: True
description:
- return a list of vendor- and device ids for pci devices in '04x:04x' notation
modules:
required: False
default: True
description:
- return a list of currently loaded kernel modules
gpus:
required: False
default: True
description:
- return a list of devices of the pci gpu class (0x030000)
acpi_power_modes:
required: False
default: True
description:
- return a list of supported acpi power saving modes
notes:
- requres python-pyusb and python-kmodpy
requirements: [ ]
author: "Alexander Grothe "
'''
EXAMPLES = '''
- name: get information about usb and pci hardware and loaded kernel modules
hardware_facts:
usb: True
pci: True
modules: True
acpi_power_modes: True
- debug:
var: usb
- debug:
var: pci
- debug:
var: modules
- debug:
var: gpus
'''
import glob
import json
import os
import sys
import usb.core
from collections import namedtuple
import kmodpy
from ansible.module_utils.basic import *
PCIDevice = namedtuple("PCIDevice", 'idVendor idProduct idClass pciPath')
vendor_dict = {
0x10de: 'nvidia',
0x8086: 'intel',
0x1002: 'amd',
0x80ee: 'virtualbox',
}
def get_pci_devices():
for device in glob.glob('/sys/devices/pci*/*:*:*/*:*:*/'):
try:
with open(os.path.join(device, 'device')) as d:
product_id = int(d.read().strip(), 16)
with open(os.path.join(device, 'vendor')) as d:
vendor_id = int(d.read().strip(), 16)
with open(os.path.join(device, 'class')) as d:
class_id = int(d.read().strip(), 16)
yield PCIDevice(idVendor=vendor_id, idProduct=product_id, idClass=class_id, pciPath=device)
except IOError:
pass
def format_device_list(iterator):
return ["{:04x}:{:04x}".format(d.idVendor, d.idProduct) for d in iterator]
def format_gpu_device_list(iterator):
def get_entries(iterator):
for d in iterator:
if d.idClass == 0x030000:
yield {"VendorName": vendor_dict.get(d.idVendor, "unknown"),
"VendorID": d.idVendor, "ProductID": d.idProduct}
return [entry for entry in get_entries(iterator)]
def list_acpi_power_modes():
acpi_power_modes = []
try:
with open('/sys/power/state') as f:
acpi_power_modes = [l for l in f.readline().split()]
except IOError:
pass
return acpi_power_modes
arg_specs = {
'usb': dict(default=True, type='bool', required=False),
'pci': dict(default=True, type='bool', required=False),
'modules': dict(default=True, type='bool', required=False),
'gpus': dict(default=True, type='bool', required=False),
'acpi_power_modes': dict(default=True, type='bool', required=False),
}
def main():
module = AnsibleModule(argument_spec=arg_specs, supports_check_mode=True,)
collect_usb = module.params['usb']
collect_pci = module.params['pci']
collect_modules = module.params['modules']
collect_gpus = module.params['gpus']
collect_acpi_power_modes = module.params['acpi_power_modes']
usb_devices = []
pci_devices = []
modules = []
gpus = []
nvidia_detected = False
intel_detected = False
amd_detected = False
virtualbox_detected = False
acpi_power_modes = []
if collect_usb:
usb_devices = format_device_list(usb.core.find(find_all=True))
if collect_pci:
pci_devices = format_device_list(get_pci_devices())
if collect_modules:
k = kmodpy.Kmod()
modules = [m[0] for m in k.loaded()]
if collect_gpus:
gpus = format_gpu_device_list(get_pci_devices())
nvidia_detected = any((True for gpu in gpus if gpu['VendorName'] == 'nvidia'))
intel_detected = any((True for gpu in gpus if gpu['VendorName'] == 'intel'))
amd_detected = any((True for gpu in gpus if gpu['VendorName'] == 'amd'))
virtualbox_detected = any((True for gpu in gpus if gpu['VendorName'] == 'virtualbox'))
if collect_acpi_power_modes:
acpi_power_modes = list_acpi_power_modes()
data = {'usb': usb_devices, 'pci': pci_devices, 'modules': modules, 'gpus': gpus,
'acpi_power_modes': acpi_power_modes, 'nvidia_detected': nvidia_detected,
'intel_detected': intel_detected, 'amd_detected': amd_detected,
'virtualbox_detected': virtualbox_detected}
module.exit_json(changed=False, ansible_facts=data, msg=data)
if __name__ == '__main__':
main()
#+END_SRC
** satip_facts.py
#+BEGIN_SRC python :tangle library/satip_facts.py :shebang #!/usr/bin/env python2
DOCUMENTATION = '''
---
module: hardware_facts
short_description: "check if at least one SAT>IP server responds on the network"
description:
- This script sends a multicast message and awaits responses by Sat>IP servers.
Returns a list of detected SAT>IP servers with their name and capabilites.
'''
EXAMPLES = '''
- name: "detect SAT>IP Server on the network"
action: satip_facts
- debug:
var: satip_devices
'''
import json
import socket
import sys
import time
import xml.etree.ElementTree as ET
import requests
from contextlib import contextmanager
from ansible.module_utils.basic import *
SSDP_BIND = "0.0.0.0"
SSDP_ADDR = "239.255.255.250"
SSDP_PORT = 1900
# SSDP_MX = max delay for server response
# a value of 2s is recommended by the SAT>IP specification 1.2.2
SSDP_MX = 2
SSDP_ST = "urn:ses-com:device:SatIPServer:1"
ssdpRequest = "\r\n".join((
"M-SEARCH * HTTP/1.1",
"HOST: %s:%d" % (SSDP_ADDR, SSDP_PORT),
"MAN: \"ssdp:discover\"",
"MX: %d" % (SSDP_MX),
"ST: %s" % (SSDP_ST),
"\r\n"))
@contextmanager
def socket_manager(*args, **kwargs):
"""provide a context manager for socket"""
sock = socket.socket(*args, **kwargs)
sock.setblocking(False)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
except socket.error:
pass
sock.settimeout(SSDP_MX + 0.5)
sock.bind((SSDP_BIND, SSDP_PORT))
try:
yield sock
finally:
sock.close()
def parse_satip_xml(data):
""" Parse SAT>IP XML data.
Args:
data (str): XML input data..
Returns:
dict: Parsed SAT>IP device name and frontend information.
"""
result = {'name': '', 'frontends': {}}
if data:
root = ET.fromstring(data)
name = root.find('.//*/{urn:schemas-upnp-org:device-1-0}friendlyName')
result['name'] = name.text
satipcap = root.find('.//*/{urn:ses-com:satip}X_SATIPCAP')
if satipcap is None:
raise ValueError("Invalid SAT>IP device description")
caps = {}
for system in satipcap.text.split(","):
cap = system.split("-")
if cap:
count = int(cap[1])
if cap[0] in caps:
count = count + caps[cap[0]]
caps[cap[0]] = count
result['frontends'] = caps
return result
def main():
description_urls = []
device_list = []
module = AnsibleModule(argument_spec={}, supports_check_mode=True,)
with socket_manager(socket.AF_INET, socket.SOCK_DGRAM) as sock:
# according to Sat>IP Specification 1.2.2, p. 20
# a client should send three requests within 100 ms with a ttl of 2
for _ in range(3):
sock.sendto(ssdpRequest, (SSDP_ADDR, SSDP_PORT))
time.sleep(0.03)
try:
response = sock.recv(1024)
if response and "SERVER:" in response:
for line in response.splitlines():
if "LOCATION" in line:
url = line.split()[-1].strip()
if url not in description_urls:
description_urls.append(url)
info = requests.get(url, timeout=2)
device_list.append(parse_satip_xml(info.text))
else:
raise ValueError('No satip server detected')
except (socket.timeout, ValueError, ET.ParseError):
pass
module.exit_json(changed=False, ansible_facts={'satip_devices': device_list})
if __name__ == '__main__':
main()
#+END_SRC
** xrandr_facts.py
- [ ] support multiple screens (-d :0.0 .. :0.n)
#+BEGIN_SRC python :tangle library/xrandr_facts.py :shebang #!/usr/bin/env python2
from __future__ import print_function
import ast
import binascii
import csv
import re
import subprocess
from collections import namedtuple
from ansible.module_utils.basic import *
DOCUMENTATION = '''
---
module: xrandr_facts
short_description: "gather facts about connected monitors and available modelines"
description:
- This module needs a running x-server on a given display in order to successfully call xrandr.
Returns the dictionary "xrandr", wich contains all screens with output states, connected displays,
EDID info and their modes and a recommendation for the best fitting tv mode.
options:
display:
required: False
default: ":0"
description:
- the DISPLAY variable to use when calling xrandr
preferred_outpus:
required: False
default: ["HDMI", "DP", "DVI", "VGA", "TV": 0]
description:
- ranking of the preferred display connectors
preferred_refreshrates:
required: False
default: ["50", "60", "75", "30", "25"]
description:
- ranking of the preferred display refreshrate
preferred_resolutions:
required: False
default: ["7680x4320", "3840x2160", "1920x1080", "1280x720", "720x576"]
description:
- ranking of the preferred display resolutions
write_edids:
required: False
default: True
description:
- write edid data to /etc/X11/edid.{connector}.bin
'''
EXAMPLES = '''
- name: "collect facts for connected displays"
action: xserver_facts
display: ":0"
- debug:
var: xrandr
- debug:
var: xorg
'''
ARG_SPECS = {
'display': dict(default=":0", type='str', required=False),
'preferred_outputs': dict(
default=["HDMI", "DP", "DVI", "VGA", "TV"], type='list', required=False),
'preferred_refreshrates': dict(
default=[50, 60, 75, 30, 25], type='list', required=False),
'preferred_resolutions': dict(
default=[
"7680x4320", "3840x2160", "1920x1080", "1280x720", "720x576"],
type='list', required=False),
'write_edids': dict(default=True, type='bool', required=False),
}
SCREEN_REGEX = re.compile("^(?PScreen\s\d+:)(?:.*)")
CONNECTOR_REGEX = re.compile(
"^(?P.*-\d+)\s(?Pconnected|disconnected)\s(?Pprimary)?")
MODE_REGEX = re.compile("^\s+(?P\d{3,}x\d{3,}).*")
Mode = namedtuple('Mode', ['connection', 'resolution', 'refreshrate'])
def check_for_screen(line):
"""check line for screen information"""
match = re.match(SCREEN_REGEX, line)
if match:
return match.groupdict()['screen']
def check_for_connection(line):
"""check line for connection name and state"""
match = re.match(CONNECTOR_REGEX, line)
connector = None
is_connected = False
if match:
match = match.groupdict()
connector = match['connector']
is_connected = True if match['connection_state'] == 'connected' else False
return connector, is_connected
def get_indentation(line):
"""return the number of leading whitespace characters"""
return len(line) - len(line.lstrip())
def sort_mode(mode):
"""rate modes by several criteria"""
connection_score = 0
rrate_score = 0
resolution_score = 0
preferred_rrates = module.params['preferred_refreshrates']
# [50, 60]
preferred_resolutions = module.params['preferred_resolutions']
# ["7680x4320", "3840x2160", "1920x1080", "1280x720", "720x576"]
preferred_outputs = module.params['preferred_outputs']
# ["HDMI", "DP", "DVI", "VGA"]
if mode.refreshrate in preferred_rrates:
rrate_score = len(preferred_rrates) - preferred_rrates.index(mode.refreshrate)
if mode.resolution in preferred_resolutions:
resolution_score = len(preferred_resolutions) - preferred_resolutions.index(mode.resolution)
x_resolution, y_resolution = (int(n) for n in mode.resolution.split('x'))
connection = mode.connection.split('-')[0]
if connection in preferred_outputs:
connection_score = len(preferred_outputs) - preferred_outputs.index(connection)
return (rrate_score, resolution_score, x_resolution, y_resolution, connection_score)
def parse_xrandr_verbose(iterator):
"""parse the output of xrandr --verbose using an iterator delivering single lines"""
xorg = {}
is_connected = False
for line in iterator:
if line.startswith('Screen'):
screen = check_for_screen(line)
xorg[screen] = {}
elif 'connected' in line:
connector, is_connected = check_for_connection(line)
xorg[screen][connector] = {
'is_connected': is_connected,
'EDID': '',
'modes': {},
'preferred': '',
'current': '',
'auto': '',
}
elif is_connected and 'EDID:' in line:
edid_str = ""
outer_indentation = get_indentation(line)
while True:
line = next(iterator)
if get_indentation(line) > outer_indentation:
edid_str += line.strip()
else:
break
xorg[screen][connector]['EDID'] = edid_str
elif is_connected and "MHz" in line and not "Interlace" in line:
match = re.match(MODE_REGEX, line)
if match:
match = match.groupdict()
preferred = bool("+preferred" in line)
current = bool("*current" in line)
while True:
line = next(iterator)
if line.strip().startswith('v:'):
refresh_rate = ast.literal_eval(line.split()[-1][:-2])
rrate = int(round(refresh_rate))
if xorg[screen][connector]['modes'].get(match['resolution']) is None:
xorg[screen][connector]['modes'][match['resolution']] = []
if rrate not in xorg[screen][connector]['modes'][match['resolution']]:
xorg[screen][connector]['modes'][match['resolution']].append(rrate)
if preferred:
xorg[screen][connector]['preferred'] = "{}_{}".format(
match['resolution'], rrate)
if current:
xorg[screen][connector]['current'] = "{}_{}".format(
match['resolution'], rrate)
break
return xorg
def parse_edid_data(edid):
vendor = "Unknown"
model = "Unknown"
data = subprocess.check_output("parse-edid < {}".format(edid), shell=True, universal_newlines=True)
for line in data.splitlines():
if "VendorName" in line:
vendor = line.strip().split('"')[1]
if "ModelName" in line:
model = line.strip().split('"')[1]
return vendor, model
def collect_nvidia_data():
BusID_RE = re.compile((
'(?P[0-9a-fA-F]+)'
':'
'(?P[0-9a-fA-F]+)'
':'
'(?P[0-9a-fA-F]+)'
'\.'
'(?P[0-9a-fA-F]+)'
))
try:
data = subprocess.check_output(["nvidia-smi", "--query-gpu=name,pci.bus_id", "--format=csv", "-i0"],
universal_newlines=True)
except subprocess.CalledProcessError:
pass
except OSError:
# nvidia-smi is not installed
pass
else:
for row in csv.DictReader(data.splitlines(), delimiter=',', skipinitialspace=True):
name = row['name']
bus_id = row['pci.bus_id']
# pci.bus_id structure as reported by nvidia-smi: "domain:bus:device.function", in hex.
match = BusID_RE.search(bus_id)
if match:
domain, bus, device, function = (int(n, 16) for n in match.groups())
bus_id = "PCI:{:d}@{:d}:{:d}:{:d}".format(bus, domain, device, function)
return name, bus_id
raise ValueError
def output_data(data, write_edids=True):
if data:
modes = []
for _, screen_data in data.items():
for connector, connection_data in screen_data.items():
if connection_data.get('EDID') and write_edids:
with open('/etc/X11/edid.{}.bin'.format(connector), 'wb') as edid:
edid.write(binascii.a2b_hex(connection_data['EDID']))
for resolution, refreshrates in connection_data['modes'].items():
for refreshrate in refreshrates:
modes.append(Mode(connector, resolution, refreshrate))
if modes:
result = {}
try:
gpu_name, bus_id = collect_nvidia_data()
except ValueError:
gpu_name = None
bus_id = None
def create_entry(my_dict, name, connector, resolution, refreshrate, vendor, model):
my_dict[name] = {
'connector': connector,
'resolution': resolution,
'refreshrate': refreshrate,
'edid': '/etc/X11/edid.{}.bin'.format(connector),
'mode': "{}_{}".format(resolution, refreshrate),
'vendor': vendor,
'model': model,
}
if gpu_name and bus_id:
result[name]['gpu_name'] = gpu_name
result[name]['bus_id'] = bus_id
connector_0, resolution_0, refreshrate_0 = max(modes, key=sort_mode)[:3]
vendor_0, model_0 = parse_edid_data('/etc/X11/edid.{}.bin'.format(connector_0))
create_entry(result, 'primary', connector_0, resolution_0, refreshrate_0, vendor_0, model_0)
# check if additional monitors exist
other_modes = [mode for mode in modes if mode[0] != connector_0]
if other_modes:
connector_1, resolution_1, refreshrate_1 = max(other_modes, key=sort_mode)[:3]
vendor_1, model_1 = parse_edid_data('/etc/X11/edid.{}.bin'.format(connector_1))
create_entry(result, 'secondary', connector_1, resolution_1, refreshrate_1, vendor_1, model_1)
#print(json.dumps(data, sort_keys=True, indent=4))
module.exit_json(changed=True if write_edids else False, ansible_facts={'xrandr': data, 'xorg': result})
if __name__ == '__main__':
module = AnsibleModule(argument_spec=ARG_SPECS, supports_check_mode=False,)
try:
d = subprocess.check_output(['xrandr', '-d', module.params['display'], '--verbose'], universal_newlines=True).splitlines()
except subprocess.CalledProcessError:
xorg_data = {}
else:
xorg_data = parse_xrandr_verbose(iter(d))
output_data(xorg_data, module.params['write_edids'])
#+END_SRC
* Handlers
#+BEGIN_SRC yaml :tangle handlers/main.yml :mkdirp yes
- name: Reconfigure unattended upgrades with dpkg
command: '/usr/sbin/dpkg-reconfigure --frontend noninteractive unattended-upgrades'
- name: Trigger Udev
command: 'udevadm trigger '
- name: Restart Samba
systemd:
name: smbd.service
state: restarted
enabled: yes
#masked: no
register: samba_reload
- name: Restart NFS Kernel Server
systemd:
name: nfs-server.service
state: restarted
enabled: yes
#masked: no
register: nfs_reload
- name: Restart VDR
systemd:
name: vdr.service
state: restarted
enabled: yes
register: vdr_restart
- name: Stop VDR
systemd:
name: vdr.service
state: stopped
enabled: yes
register: vdr_stop
- name: Start VDR
systemd:
name: vdr.service
state: started
enabled: yes
register: vdr_start
- name: Stop xlogin
systemd:
name: xlogin@vdr.service
state: stopped
enabled: yes
register: xlogin_stop
- name: Stop x
systemd:
name: x@vt7.service
state: stopped
register: x_stop
#+END_SRC