diff --git a/Manual.org b/Manual.org index 2119276..9d0a47c 100644 --- a/Manual.org +++ b/Manual.org @@ -9,20 +9,97 @@ #+HTML_HEAD: #+OPTIONS: ^:nil #+PROPERTY: header-args :mkdirp yes +#+TITLE: Ansible Playbooks for yaVDR 0.7 +#+Author: Alexander Grothe :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 +- 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 :PROPERTIES: :export nil -:END: +: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]]. @@ -67,6 +144,7 @@ The ~yavdr07.yml~ playbook sets up a fully-featured yaVDR installation: become: true roles: - yavdr-common # install and configure the basic system + - autoinstall-ubuntu-drivers # use ubuntu-drivers to install proprietary dirvers (e.g. nvidia, virtualbox) - vdr # install vdr and related packages - yavdr-network # enable network client capabilities - samba-install # install samba server @@ -79,6 +157,8 @@ The ~yavdr07.yml~ playbook sets up a fully-featured yaVDR installation: - autoinstall-imonlcd # install vdr-plugin-imonlcd if a matchind display is connected #- autoinstall-pv350 # install vdr-plugin-pvr350 if a matching card is detected #- autoinstall-dvbsddevice # install vdr-plugin-dvbsddevice if a matching card is detected + - kodi + - dvd - grub-config # configure grub handlers: @@ -115,7 +195,7 @@ localhost connection=local #+END_SRC * Group Variables -** default text for templates +** default text for templates used by ansible #+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes # file: group_vars/all @@ -124,15 +204,15 @@ ansible_managed_file: "*** YAVDR: ANSIBLE MANAGED FILE ***" #+END_SRC ** PPAs #+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes -branch: unstable -ppa_owner: 'ppa:yavdr' -# a list of all package repositories to be added to the installation -repositories: - - '{{ ppa_owner }}/main' - - '{{ ppa_owner }}/unstable-main' - - '{{ ppa_owner }}/{{branch}}-vdr' - - '{{ ppa_owner }}/{{branch}}-yavdr' - - '{{ ppa_owner }}/{{branch}}-kodi' + branch: unstable + ppa_owner: 'ppa:yavdr' + # a list of all package repositories to be added to the installation + repositories: + - '{{ ppa_owner }}/main' + - '{{ ppa_owner }}/unstable-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 @@ -196,6 +276,43 @@ grub: boot_options: quiet nosplash #+END_SRC * Roles +** install-dependencies +*** tasks +**** main.yml +#+BEGIN_SRC yaml :tangle roles/install-packages/tasks/main.yml :mkdirp yes +--- + +- name: apt | install packages + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + '{{ packages }}' +#+END_SRC + +** nvidia-381 drivers +install nvidia-381 from ppa:graphics-drivers/ppa +*** tasks +**** main.yml +#+BEGIN_SRC yaml :tangle roles/nvidia-381/tasks/main.yml :mkdirp yes +--- + +- name: add ppa:graphics-drivers/ppa + apt_repository: + repo: 'ppa:graphics-drivers/ppa' + state: present + update_cache: yes + +- name: install nvidia-381 and other required packages + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + - nvidia-381 + - 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 @@ -257,12 +374,6 @@ vdr: *** tasks yavdr-common executes the following tasks: **** main.yml - #+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :exports none :mkdirp yes ---- - -# This playbook sets up the basic packages an directories for a yaVDR installation -# file: roles/yavdr-common/tasks/main.yml - #+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/main.yml :mkdirp yes @@ -335,6 +446,7 @@ yavdr-common executes the following tasks: - at - bash-completion - biosdevname + - debconf-utils - linux-firmware - psmisc - python-kmodpy @@ -342,7 +454,6 @@ yavdr-common executes the following tasks: - python3-usb - software-properties-common - ssh - - ubuntu-drivers-common - wget - wpasupplicant - usbutils @@ -483,8 +594,8 @@ install_avahi: true #+BEGIN_SRC yaml :tangle roles/yavdr-network/tasks/main.yml :mkdirp yes --- # this playbook sets up network services for a yaVDR installation -# -- name: install network packages + +- name: apt |install packages for network services apt: name: '{{ item }}' state: present @@ -505,18 +616,30 @@ install_avahi: true # with_items: '{% for interface in ansible_interfaces if interface != 'lo' and interface != 'bond0' %}' #+END_SRC -** STARTED nfs-server +** nfs-server *** tasks -#+BEGIN_SRC yaml :tanlge roles/nfs-server/tasks/main.yml :mkdirp yes -- name: install and configure nfs-kernel-server +#+BEGIN_SRC yaml :tangle roles/nfs-server/tasks/main.yml :mkdirp yes +- name: install nfs server packages apt: - name: "{{ item }}" - state: present - install_recommends: no + name: '{{ item }}' + state: present + install_recommends: no with_items: - - nfs-kernel-server - when: - - '{{ install_nfs_server }}' + - nfs-kernel-server + - nfs-common + +- name: create /etc/exports + template: + src: templates/nfs-exports.j2 + dest: /etc/exports + notify: [ 'Restart NFS Kernel Server' ] +#+END_SRC +*** templates +#+BEGIN_SRC conf :tangle roles/nfs-server/templates/nfs-exports.j2 :mkdirp yes + /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 ** TODO yavdr-remote *** default variables @@ -603,7 +726,6 @@ Section "Monitor" EndSection #+END_SRC - **** DONE Start X-server with debug-output #+BEGIN_SRC conf # /etc/systemd/system/x-debug@.service @@ -913,6 +1035,26 @@ b'\xde\xad\xbe\xef' --- # file: roles/yavdr-xorg/tasks/main.yml + +# TODO: use hooks or requirements instead +- name: Stop VDR + systemd: + name: vdr.service + state: stopped + enabled: yes + notify: ['Start VDR'] + +- name: Stop xlogin + systemd: + name: xlogin@vdr.service + state: stopped + enabled: yes + +- name: Stop x + systemd: + name: x@vt7.service + state: stopped + - name: install packages for xorg apt: name: '{{ item }}' @@ -969,7 +1111,7 @@ b'\xde\xad\xbe\xef' group: '{{ vdr.group }}' with_items: - '{{ vdr.home }}/.config/systemd/user' - - '{{ vdr.home }}/.config/openbox/autostart' + - '{{ vdr.home }}/.config/openbox/' ### TODO: move to yavdr-xorg package? ### - name: create folder for customizations of vdr.service @@ -978,6 +1120,22 @@ b'\xde\xad\xbe\xef' dest: /etc/systemd/system/vdr.service.d mode: '0775' +- name: create folder for systemd user configuration + file: + state: directory + dest: '{{ vdr.home }}/.config/systemd/user' + mode: '0775' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + +- name: create folder for openbox configuration + file: + state: directory + dest: '{{ vdr.home }}/.config/openbox' + mode: '0775' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + - name: add dependency to X-server for vdr.service using a drop-in template: src: templates/vdr-xorg.conf @@ -987,7 +1145,7 @@ b'\xde\xad\xbe\xef' - name: create .xinitrc for vdr user template: src: 'templates/.xinitrc.j2' - dest: '/var/lib/vdr/.xinitrc' + dest: '{{ vdr.home }}/.xinitrc' mode: 0755 owner: '{{ vdr.user }}' group: '{{ vdr.group }}' @@ -995,7 +1153,23 @@ b'\xde\xad\xbe\xef' - name: populate autostart for openbox template: src: 'templates/autostart.j2' - dest: '/var/lib/vdr/.config/openbox/autostart' + 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: 0755 + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + +- name: create yavdr.target for the user session + template: + src: 'templates/yavdr-desktop.target.j2' + dest: '{{ vdr.home }}/.config/systemd/user/yavdr-desktop.target' mode: 0755 owner: '{{ vdr.user }}' group: '{{ vdr.group }}' @@ -1040,14 +1214,28 @@ ExecStart=/usr/bin/x-daemon -logverbose 6 -noreset %I [Unit] After=x@vt7.service Wants=x@vt7.service -BindsTo=x@vt7.service +#BindsTo=x@vt7.service #+END_SRC #+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/.xinitrc.j2 :mkdirp yes #!/bin/bash # {{ ansible_managed_file }} exec openbox-session #+END_SRC -#+BEGIN_SRC shell tangle: ansible/yavdr-ansible/roles/yavdr-xorg/templates/autostart.j2 :mkdirp yes + +#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/yavdr-desktop.target.j2 :mkdirp yes +[Unit] +Description=yaVDR Desktop +Requires=default.target +After=default.target pulseaudio.service +Wants=dbus.service pulseaudio.service +AllowIsolate=yes +#+END_SRC +#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/xorg.conf.yavdr :mkdirp yes + +#+END_SRC +**** openbox +****** autostart +#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/autostart.j2 :mkdirp yes 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 @@ -1055,42 +1243,829 @@ if which dbus-update-activation-environment >/dev/null 2>&1; then dbus-update-activation-environment DISPLAY XAUTHORITY XDG_RUNTIME_DIR fi -### -# Needed to start pulseaudio before VDR if softhddevice is attached at startup -# (so the frontend-skript can't force pulseaudio to free the soundcard) -### -# pactl list sinks 2>&1 >> /tmp/audio.dbg +# 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 + + + + + + + + + + + + + + + + + client-menu + + + + + + 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 + + + + + + + + + + + + + + + + + + + + + + + client-menu + + + + + + + top + + + + + + + left + + + + + + + right + + + + + + + bottom + + + + + + + client-menu + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + client-menu + + + + + + + client-menu + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vertical + + + + + horizontal + + + + + + + + + + + + + + + + + previous + + + + + next + + + + + previous + + + + + next + + + + + previous + + + + + next + + + + + + + + + + + + + + + + client-list-combined-menu + + + + + root-menu + + + + + + + previous + + + + + next + + + + + previous + + + + + next + + + + + + + + + /var/lib/openbox/debian-menu.xml + menu.xml + 200 + + no + + 100 + + 400 + + yes + + yes + + + + + + no + true + + yes + + + no + true + + yes + + + no + true + + yes + + +
#+END_SRC -#+BEGIN_SRC conf :tangle roles/yavdr-org/templates/xorg.conf.yavdr :mkdirp yes - -#+END_SRC -** nfs-server -*** tasks -#+BEGIN_SRC yaml :tangle roles/nfs-server/tasks/main.yml :mkdirp yes -- 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' ] -#+END_SRC -*** templates -#+BEGIN_SRC conf :tangle roles/nfs-server/templates/nfs-exports.j2 :mkdirp yes -/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 -** nfs-config ** samba-install *** tasks #+BEGIN_SRC yaml :tangle roles/samba-install/tasks/main.yml :mkdirp yes @@ -1114,7 +2089,7 @@ fi # file: roles/samba-config/tasks/main.yml # TODO: -#- name: divert original smbd.conf +# - name: divert original smbd.conf - name: touch smb.conf.custom file: @@ -1235,7 +2210,7 @@ fi #+BEGIN_SRC yaml :tangle roles/samba-config/templates/smb.conf.j2 :mkdirp yes include = /etc/samba/smb.conf.custom #+END_SRC -** TODO autoinstall-drivers +** STARTED autoinstall-drivers It would be nice to be able to detect if it is suitable to install those drivers: *** sundtek for Sundtek devices (local or network connection) Vendor-IDs: @@ -1246,7 +2221,29 @@ Vendor-IDs: *** 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 + --- + # file roles/autoinstall-ubuntu-drivers/tasks/main.yml + + - name: apt | install ubuntu-drivers-common + apt: + name: ubuntu-drivers-common + state: present + + - name: ensure /etc/yavdr exists + file: + path: /etc/yavdr + state: directory + mode: 0755 + + - name: let ubuntu-drivers automatically install additional drivers + command: ubuntu-drivers --package-list /etc/yavdr/autoinstalled autoinstall +#+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 --- @@ -1348,6 +2345,73 @@ Problem: woher kommt der Treiber (AFAIK noch nicht im Kernel)? Die Firmware soll - '"dvb_ttpci" in modules' notify: [ 'Restart VDR' ] #+END_SRC +** dvd +*** tasks +**** install libdvd-pkg +#+BEGIN_SRC yaml :tangle roles/dvd/tasks/main.yml :mkdirp yes +--- +# file: roles/dvd/tasks/main.yml + +- name: preconfigure libdvd-pkg + shell: | + echo 'libdvd-pkg libdvd-pkg/post-invoke_hook-install boolean true' | debconf-set-selections + echo 'libdvd-pkg libdvd-pkg/build boolean true' | debconf-set-selections + +- name: apt | install libdvd-pkg + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + - libdvd-pkg +#+END_SRC + +** kodi +*** tasks +**** Install KODI +#+BEGIN_SRC yaml :tangle roles/kodi/tasks/main.yml :mkdirp yes +--- + +- name: change udev rule to allow KODI to eject optical disks + shell: sed 's/--lock-media //' /lib/udev/rules.d/60-cdrom_id.rules > /etc/udev/rules.d/60-cdrom_id.rules + args: + creates: /etc/udev/rules.d/60-cdrom_id.rules + +- name: apt | install kodi packages + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + - kodi + - kodi-pvr-vdr-vnsi + - kodi-eventclients-xbmc-send + +- name: create kodi.service for the user session + template: + src: 'templates/kodi.service.j2' + dest: '{{ vdr.home }}/.config/systemd/user/kodi.service' + mode: 0755 + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + +#+END_SRC +*** templates +**** kodi.service +#+BEGIN_SRC conf :tangle roles/kodi/templates/kodi.service.j2 :mkdirp yes +[Unit] +Description=Start kodi in user session + +[Service] +Type=simple +PassEnvironment=DISPLAY XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS +ExecStartPre=-/usr/bin/set-kodi-display +ExecStart=/usr/bin/kodi +ExecStop=/bin/bash -c "/usr/bin/kodi-send --action=QUIT; while /usr/bin/pgrep kodi; do sleep 1; done; sleep 1" +TimeoutStopSec=10 +SuccessExitStatus=0 127 +Restart=on-failure +#+END_SRC ** template-test #+BEGIN_SRC yaml :tangle roles/template-test/tasks/main.yml --- @@ -1643,132 +2707,132 @@ fi 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 -#!/usr/bin/env python + #!/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 + # 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 + 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 + 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) -notes: - - requres python-pyusb and python-kmodpy -requirements: [ ] -author: "Alexander Grothe " -''' + gpus: + required: False + default: True + description: + - return a list of devices of the pci gpu class (0x030000) + 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 -- debug: - var: usb -- debug - var: pci -- debug - var: modules -- debug - var: gpus -''' + EXAMPLES = ''' + - name: get information about usb and pci hardware and loaded kernel modules + hardware_facts: + usb: True + pci: True + modules: 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 glob + import json + import os + import sys + import usb.core + from collections import namedtuple -import kmodpy -from ansible.module_utils.basic import * + import kmodpy + from ansible.module_utils.basic import * -PCIDevice = namedtuple("PCIDevice", ['idVendor', 'idProduct', 'idClass']) + PCIDevice = namedtuple("PCIDevice", 'idVendor idProduct idClass pciPath') -def get_pci_devices(): - for device in glob.glob('/sys/devices/pci*/*:*:*/'): - 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) + def get_pci_devices(): + for device in glob.glob('/sys/devices/pci*/*:*:*/'): + 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) -def format_device_list(iterator): - return ["{:04x}:{:04x}".format(d.idVendor, d.idProduct) for d in iterator] + 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 ("{:04x}:{:04x}".format(d.idVendor, d.idProduct)) - return [entry for entry in get_entries(iterator)] + def format_gpu_device_list(iterator): + def get_entries(iterator): + for d in iterator: + if d.idClass == 0x030000: + yield ("{:04x}:{:04x}".format(d.idVendor, d.idProduct)) + return [entry for entry in get_entries(iterator)] -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), - } + 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), + } -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'] - if collect_usb: - usb_devices = format_device_list(usb.core.find(find_all=True)) - else: - usb_device = [] - if collect_pci: - pci_devices = format_device_list(get_pci_devices()) - else: - pci_devices = [] - if collect_modules: - k = kmodpy.Kmod() - modules = [m[0] for m in k.loaded()] - else: - modules = [] - if collect_gpus: - gpus = format_gpu_device_list(get_pci_devices()) - else: - gpus = [] - data = {'usb': usb_devices, 'pci': pci_devices, 'modules': modules, 'gpus': gpus} - module.exit_json(changed=False, ansible_facts=data, msg=data) + 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'] + if collect_usb: + usb_devices = format_device_list(usb.core.find(find_all=True)) + else: + usb_device = [] + if collect_pci: + pci_devices = format_device_list(get_pci_devices()) + else: + pci_devices = [] + if collect_modules: + k = kmodpy.Kmod() + modules = [m[0] for m in k.loaded()] + else: + modules = [] + if collect_gpus: + gpus = format_gpu_device_list(get_pci_devices()) + else: + gpus = [] + data = {'usb': usb_devices, 'pci': pci_devices, 'modules': modules, 'gpus': gpus} + module.exit_json(changed=False, ansible_facts=data, msg=data) -if __name__ == '__main__': - main() + if __name__ == '__main__': + main() #+END_SRC ** satip_facts.py #+BEGIN_SRC python :tangle library/satip_facts.py diff --git a/group_vars/all b/group_vars/all index dd92388..d6db646 100644 --- a/group_vars/all +++ b/group_vars/all @@ -1,3 +1,4 @@ + # file: group_vars/all # this is the standard text to put in templates diff --git a/handlers/main.yml b/handlers/main.yml index 840b674..d7fd733 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,3 +1,4 @@ + - name: Restart Samba systemd: name: smbd.service diff --git a/install-yavdr.sh b/install-yavdr.sh index d3bd2d8..d8aa931 100755 --- a/install-yavdr.sh +++ b/install-yavdr.sh @@ -1,4 +1,5 @@ #!/bin/bash + if (( $EUID != 0 )); then echo "This script must be run using sudo or as root" exit diff --git a/library/hardware_facts.py b/library/hardware_facts.py index 30bca4f..4eb11f0 100644 --- a/library/hardware_facts.py +++ b/library/hardware_facts.py @@ -1,3 +1,4 @@ + #!/usr/bin/env python # This Module collects the vendor- and device ids for USB- and PCI(e)-devices and currently loaded kernel modules. @@ -65,7 +66,7 @@ import kmodpy from ansible.module_utils.basic import * -PCIDevice = namedtuple("PCIDevice", ['idVendor', 'idProduct', 'idClass']) +PCIDevice = namedtuple("PCIDevice", 'idVendor idProduct idClass pciPath') def get_pci_devices(): for device in glob.glob('/sys/devices/pci*/*:*:*/'): @@ -75,7 +76,7 @@ def get_pci_devices(): 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) + yield PCIDevice(idVendor=vendor_id, idProduct=product_id, idClass=class_id, pciPath=device) def format_device_list(iterator): return ["{:04x}:{:04x}".format(d.idVendor, d.idProduct) for d in iterator] diff --git a/library/satip_facts.py b/library/satip_facts.py index 7b2d4c5..0025178 100644 --- a/library/satip_facts.py +++ b/library/satip_facts.py @@ -1,3 +1,4 @@ + #!/usr/bin/env python2 DOCUMENTATION = ''' diff --git a/library/xrandr_facts.py b/library/xrandr_facts.py index b8a47bd..4bcbfb9 100644 --- a/library/xrandr_facts.py +++ b/library/xrandr_facts.py @@ -1,3 +1,4 @@ + #!/usr/bin/env python2 from __future__ import print_function import ast @@ -42,6 +43,11 @@ options: 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" diff --git a/localhost_inventory b/localhost_inventory index a51c139..9974433 100644 --- a/localhost_inventory +++ b/localhost_inventory @@ -1,2 +1,3 @@ + [localhost] localhost connection=local diff --git a/roles/autoinstall-dvbhddevice/tasks/main.yml b/roles/autoinstall-dvbhddevice/tasks/main.yml index 0c6bb22..c697e93 100644 --- a/roles/autoinstall-dvbhddevice/tasks/main.yml +++ b/roles/autoinstall-dvbhddevice/tasks/main.yml @@ -1,3 +1,4 @@ + --- # file roles/autoinstall-dvbhddevice/tasks/main.yml diff --git a/roles/autoinstall-dvbsddevice/tasks/main.yml b/roles/autoinstall-dvbsddevice/tasks/main.yml index 78a7243..ef4fbad 100644 --- a/roles/autoinstall-dvbsddevice/tasks/main.yml +++ b/roles/autoinstall-dvbsddevice/tasks/main.yml @@ -1,3 +1,4 @@ + --- # file roles/autoinstall-dvbsddevice/tasks/main.yml diff --git a/roles/autoinstall-imonlcd/tasks/main.yml b/roles/autoinstall-imonlcd/tasks/main.yml index d5bae07..bf16cb9 100644 --- a/roles/autoinstall-imonlcd/tasks/main.yml +++ b/roles/autoinstall-imonlcd/tasks/main.yml @@ -1,3 +1,4 @@ + --- # file roles/autoinstall-imonlcd/tasks/main.yml diff --git a/roles/autoinstall-libcecdaemon/tasks/main.yml b/roles/autoinstall-libcecdaemon/tasks/main.yml index 131abf7..38d55a2 100644 --- a/roles/autoinstall-libcecdaemon/tasks/main.yml +++ b/roles/autoinstall-libcecdaemon/tasks/main.yml @@ -1,3 +1,4 @@ + --- # file roles/autoinstall-libcec-daemon/tasks/main.yml diff --git a/roles/autoinstall-pvr350/tasks/main.yml b/roles/autoinstall-pvr350/tasks/main.yml index 6a25230..f61142d 100644 --- a/roles/autoinstall-pvr350/tasks/main.yml +++ b/roles/autoinstall-pvr350/tasks/main.yml @@ -1,3 +1,4 @@ + --- # file roles/autoinstall-pvr350/tasks/main.yml diff --git a/roles/autoinstall-satip/tasks/main.yml b/roles/autoinstall-satip/tasks/main.yml index 9b3733d..9e6b9df 100644 --- a/roles/autoinstall-satip/tasks/main.yml +++ b/roles/autoinstall-satip/tasks/main.yml @@ -1,3 +1,4 @@ + --- # file roles/autoinstall-satip/tasks/main.yml diff --git a/roles/autoinstall-targavfd/tasks/main.yml b/roles/autoinstall-targavfd/tasks/main.yml index fd30030..071a8c4 100644 --- a/roles/autoinstall-targavfd/tasks/main.yml +++ b/roles/autoinstall-targavfd/tasks/main.yml @@ -1,3 +1,4 @@ + --- # file roles/autoinstall-targavfd/tasks/main.yml diff --git a/roles/autoinstall-ubuntu-drivers/tasks/main.yml b/roles/autoinstall-ubuntu-drivers/tasks/main.yml new file mode 100644 index 0000000..f538585 --- /dev/null +++ b/roles/autoinstall-ubuntu-drivers/tasks/main.yml @@ -0,0 +1,17 @@ + +--- +# file roles/autoinstall-ubuntu-drivers/tasks/main.yml + +- name: apt | install ubuntu-drivers-common + apt: + name: ubuntu-drivers-common + state: present + +- name: ensure /etc/yavdr exists + file: + path: /etc/yavdr + state: directory + mode: 0755 + +- name: let ubuntu-drivers automatically install additional drivers + command: ubuntu-drivers --package-list /etc/yavdr/autoinstalled autoinstall diff --git a/roles/dvd/tasks/main.yml b/roles/dvd/tasks/main.yml new file mode 100644 index 0000000..c789213 --- /dev/null +++ b/roles/dvd/tasks/main.yml @@ -0,0 +1,16 @@ + +--- +# file: roles/dvd/tasks/main.yml + +- name: preconfigure libdvd-pkg + shell: | + echo 'libdvd-pkg libdvd-pkg/post-invoke_hook-install boolean true' | debconf-set-selections + echo 'libdvd-pkg libdvd-pkg/build boolean true' | debconf-set-selections + +- name: apt | install libdvd-pkg + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + - libdvd-pkg diff --git a/roles/grub-config/defaults/main.yml b/roles/grub-config/defaults/main.yml index 61b5b5a..f7a6ab4 100644 --- a/roles/grub-config/defaults/main.yml +++ b/roles/grub-config/defaults/main.yml @@ -1,3 +1,4 @@ + system: shutdown: poweroff grub: diff --git a/roles/grub-config/handlers/main.yml b/roles/grub-config/handlers/main.yml index a7e3e2c..354640d 100644 --- a/roles/grub-config/handlers/main.yml +++ b/roles/grub-config/handlers/main.yml @@ -1,3 +1,4 @@ + - name: Update GRUB command: update-grub failed_when: ('error' in grub_register_update.stderr) diff --git a/roles/grub-config/tasks/main.yml b/roles/grub-config/tasks/main.yml index 6a24bad..1268ffe 100644 --- a/roles/grub-config/tasks/main.yml +++ b/roles/grub-config/tasks/main.yml @@ -1,3 +1,4 @@ + - name: custom grub configuration for timeout and reboot halt template: src: templates/50_custom.j2 diff --git a/roles/grub-config/templates/50_custom.j2 b/roles/grub-config/templates/50_custom.j2 index 74a944b..079cee9 100644 --- a/roles/grub-config/templates/50_custom.j2 +++ b/roles/grub-config/templates/50_custom.j2 @@ -1,3 +1,4 @@ + #!/bin/sh exec tail -n +3 $0 diff --git a/roles/kodi/tasks/main.yml b/roles/kodi/tasks/main.yml new file mode 100644 index 0000000..0dca20e --- /dev/null +++ b/roles/kodi/tasks/main.yml @@ -0,0 +1,25 @@ + +--- + +- name: change udev rule to allow KODI to eject optical disks + shell: sed 's/--lock-media //' /lib/udev/rules.d/60-cdrom_id.rules > /etc/udev/rules.d/60-cdrom_id.rules + args: + creates: /etc/udev/rules.d/60-cdrom_id.rules + +- name: apt | install kodi packages + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + - kodi + - kodi-pvr-vdr-vnsi + - kodi-eventclients-xbmc-send + +- name: create kodi.service for the user session + template: + src: 'templates/kodi.service.j2' + dest: '{{ vdr.home }}/.config/systemd/user/kodi.service' + mode: 0755 + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' diff --git a/roles/kodi/templates/kodi.service.j2 b/roles/kodi/templates/kodi.service.j2 new file mode 100644 index 0000000..a508b24 --- /dev/null +++ b/roles/kodi/templates/kodi.service.j2 @@ -0,0 +1,13 @@ + +[Unit] +Description=Start kodi in user session + +[Service] +Type=simple +PassEnvironment=DISPLAY XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS +ExecStartPre=-/usr/bin/set-kodi-display +ExecStart=/usr/bin/kodi +ExecStop=/bin/bash -c "/usr/bin/kodi-send --action=QUIT; while /usr/bin/pgrep kodi; do sleep 1; done; sleep 1" +TimeoutStopSec=10 +SuccessExitStatus=0 127 +Restart=on-failure diff --git a/roles/nfs-server/tasks/main.yml b/roles/nfs-server/tasks/main.yml index cc0be13..c047b03 100644 --- a/roles/nfs-server/tasks/main.yml +++ b/roles/nfs-server/tasks/main.yml @@ -1,3 +1,4 @@ + - name: install nfs server packages apt: name: '{{ item }}' diff --git a/roles/nfs-server/templates/nfs-exports.j2 b/roles/nfs-server/templates/nfs-exports.j2 index eabb162..42f6913 100644 --- a/roles/nfs-server/templates/nfs-exports.j2 +++ b/roles/nfs-server/templates/nfs-exports.j2 @@ -1,3 +1,4 @@ + /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 '' }}) diff --git a/roles/samba-config/tasks/main.yml b/roles/samba-config/tasks/main.yml index e9388da..ccbd7f7 100644 --- a/roles/samba-config/tasks/main.yml +++ b/roles/samba-config/tasks/main.yml @@ -1,7 +1,8 @@ + # file: roles/samba-config/tasks/main.yml # TODO: -#- name: divert original smbd.conf +# - name: divert original smbd.conf - name: touch smb.conf.custom file: diff --git a/roles/samba-config/templates/smb.conf.j2 b/roles/samba-config/templates/smb.conf.j2 index befd2b7..aae856f 100644 --- a/roles/samba-config/templates/smb.conf.j2 +++ b/roles/samba-config/templates/smb.conf.j2 @@ -1,3 +1,4 @@ + {{ ansible_managed_file | comment }} #======================= Global Settings ======================= diff --git a/roles/samba-install/tasks/main.yml b/roles/samba-install/tasks/main.yml index 2c6358a..a51e3fe 100644 --- a/roles/samba-install/tasks/main.yml +++ b/roles/samba-install/tasks/main.yml @@ -1,3 +1,4 @@ + # file: roles/samba-install/tasks/main.yml - name: install samba server diff --git a/roles/template-test/defaults/main.yml b/roles/template-test/defaults/main.yml index da426aa..efd58a0 100644 --- a/roles/template-test/defaults/main.yml +++ b/roles/template-test/defaults/main.yml @@ -1,3 +1,4 @@ + foo: - bar - baz diff --git a/roles/template-test/tasks/main.yml b/roles/template-test/tasks/main.yml index a2a30b2..6e321e9 100644 --- a/roles/template-test/tasks/main.yml +++ b/roles/template-test/tasks/main.yml @@ -1,3 +1,4 @@ + --- - name: show vars debug: diff --git a/roles/vdr/tasks/main.yml b/roles/vdr/tasks/main.yml index e4b3c69..71f9293 100644 --- a/roles/vdr/tasks/main.yml +++ b/roles/vdr/tasks/main.yml @@ -1,3 +1,4 @@ + --- # file: roles/vdr/tasks/main.yml diff --git a/roles/yavdr-common/defaults/main.yml b/roles/yavdr-common/defaults/main.yml index 1f53b94..64ccb77 100644 --- a/roles/yavdr-common/defaults/main.yml +++ b/roles/yavdr-common/defaults/main.yml @@ -1,3 +1,4 @@ + --- # file: roles/yavdr-common/defaults/main.yml @@ -13,10 +14,10 @@ drivers: sundtek: auto ddvb-dkms: auto - extra_packages: - - vim - - tree - - w-scan +extra_packages: + - vim + - tree + - w-scan vdr: user: vdr diff --git a/roles/yavdr-common/tasks/main.yml b/roles/yavdr-common/tasks/main.yml index 6b809e9..4d5c5f4 100644 --- a/roles/yavdr-common/tasks/main.yml +++ b/roles/yavdr-common/tasks/main.yml @@ -1,7 +1,3 @@ ---- - -# This playbook sets up the basic packages an directories for a yaVDR installation -# file: roles/yavdr-common/tasks/main.yml - name: apt | prevent automatic installation of recommended packages template: @@ -59,6 +55,7 @@ - at - bash-completion - biosdevname + - debconf-utils - linux-firmware - psmisc - python-kmodpy @@ -66,7 +63,6 @@ - python3-usb - software-properties-common - ssh - - ubuntu-drivers-common - wget - wpasupplicant - usbutils diff --git a/roles/yavdr-common/templates/90-norecommends.j2 b/roles/yavdr-common/templates/90-norecommends.j2 index e58919b..5263087 100644 --- a/roles/yavdr-common/templates/90-norecommends.j2 +++ b/roles/yavdr-common/templates/90-norecommends.j2 @@ -1,3 +1,4 @@ + {{ ansible_managed_file | comment('c') }} // Recommends are as of now still abused in many packages APT::Install-Recommends "0"; diff --git a/roles/yavdr-network/main.yml b/roles/yavdr-network/main.yml index 8db1b64..b69c9b5 100644 --- a/roles/yavdr-network/main.yml +++ b/roles/yavdr-network/main.yml @@ -1 +1,2 @@ + install_avahi: true diff --git a/roles/yavdr-network/tasks/main.yml b/roles/yavdr-network/tasks/main.yml index b058c4e..6ad1c23 100644 --- a/roles/yavdr-network/tasks/main.yml +++ b/roles/yavdr-network/tasks/main.yml @@ -1,7 +1,8 @@ + --- # this playbook sets up network services for a yaVDR installation -# -- name: install network packages + +- name: apt |install packages for network services apt: name: '{{ item }}' state: present diff --git a/roles/yavdr-xorg/read_xrandr.py b/roles/yavdr-xorg/read_xrandr.py new file mode 100644 index 0000000..9626568 --- /dev/null +++ b/roles/yavdr-xorg/read_xrandr.py @@ -0,0 +1,51 @@ +#!/usr/bin/ env python3 +import subprocess + + +xrandr_data = subprocess.check_output(['xrandr', '-q'], universal_newlines=True) + + +def print_modelines(resolutions): + if resolutions: + for resolution, refreshrates in reversed(sorted(resolutions.items())): + for refreshrate in refreshrates: + print("{}_{}".format(resolution, refreshrate)) + + +def cleanup_refreshrate(refreshrate): + return refreshrate.replace('+', '').replace('*', '') + +resolutions = {} +for line in xrandr_data.splitlines(): + if line.startswith('Screen'): + print_modelines(resolutions) + new_connection = False + screen = line.split(':', maxsplit=1)[0].split()[-1] + new_screen = True + print('Screen: {}'.format(screen)) + + elif new_screen and not new_connection and ' connected ' in line: + connection = line.split()[0] + new_screen = False + new_connection = True + print('Connection: {}'.format(connection)) + resolutions = {} + + elif new_connection and line.startswith(' '): + resolution, *refreshrates = line.split() + res_x, res_y = resolution.split('x') + resolution = (int(res_x), int(res_y)) + r = [] + for refreshrate in refreshrates: + if '+' in refreshrate: + current_mode = (resolution, + cleanup_refreshrate(refreshrate)) + print('Current Mode: {}@{}'.format(*current_mode)) + if '*' in refreshrate: + preferred_mode = (resolution, + cleanup_refreshrate(refreshrate)) + print('Preferred Mode: {}@{}'.format(*preferred_mode)) + r.append(cleanup_refreshrate(refreshrate)) + resolutions[resolution] = r + +print_modelines(resolutions) diff --git a/roles/yavdr-xorg/tasks/main.yml b/roles/yavdr-xorg/tasks/main.yml index ef66c5c..4cf9ddd 100644 --- a/roles/yavdr-xorg/tasks/main.yml +++ b/roles/yavdr-xorg/tasks/main.yml @@ -1,6 +1,27 @@ + --- # file: roles/yavdr-xorg/tasks/main.yml + +# TODO: use hooks or requirements instead +- name: Stop VDR + systemd: + name: vdr.service + state: stopped + enabled: yes + notify: ['Start VDR'] + +- name: Stop xlogin + systemd: + name: xlogin@vdr.service + state: stopped + enabled: yes + +- name: Stop x + systemd: + name: x@vt7.service + state: stopped + - name: install packages for xorg apt: name: '{{ item }}' @@ -57,7 +78,7 @@ group: '{{ vdr.group }}' with_items: - '{{ vdr.home }}/.config/systemd/user' - - '{{ vdr.home }}/.config/openbox/autostart' + - '{{ vdr.home }}/.config/openbox/' ### TODO: move to yavdr-xorg package? ### - name: create folder for customizations of vdr.service @@ -66,6 +87,22 @@ dest: /etc/systemd/system/vdr.service.d mode: '0775' +- name: create folder for systemd user configuration + file: + state: directory + dest: '{{ vdr.home }}/.config/systemd/user' + mode: '0775' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + +- name: create folder for openbox configuration + file: + state: directory + dest: '{{ vdr.home }}/.config/openbox' + mode: '0775' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + - name: add dependency to X-server for vdr.service using a drop-in template: src: templates/vdr-xorg.conf @@ -75,7 +112,7 @@ - name: create .xinitrc for vdr user template: src: 'templates/.xinitrc.j2' - dest: '/var/lib/vdr/.xinitrc' + dest: '{{ vdr.home }}/.xinitrc' mode: 0755 owner: '{{ vdr.user }}' group: '{{ vdr.group }}' @@ -83,7 +120,23 @@ - name: populate autostart for openbox template: src: 'templates/autostart.j2' - dest: '/var/lib/vdr/.config/openbox/autostart' + 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: 0755 + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + +- name: create yavdr.target for the user session + template: + src: 'templates/yavdr-desktop.target.j2' + dest: '{{ vdr.home }}/.config/systemd/user/yavdr-desktop.target' mode: 0755 owner: '{{ vdr.user }}' group: '{{ vdr.group }}' @@ -97,6 +150,11 @@ groups: '{{ vdr.group }}' append: yes +# TODO: run xorg-debug and parse xrandr output +# TODO: expand template for xorg.conf (or snippets) +# with respect for the available graphics card driver +# nvidia, noveau, intel, radeon + - name: enable and start xlogin for the user vdr systemd: daemon_reload: yes diff --git a/roles/yavdr-xorg/templates/.xinitrc.j2 b/roles/yavdr-xorg/templates/.xinitrc.j2 index deb9862..37b71fa 100644 --- a/roles/yavdr-xorg/templates/.xinitrc.j2 +++ b/roles/yavdr-xorg/templates/.xinitrc.j2 @@ -1,3 +1,4 @@ + #!/bin/bash # {{ ansible_managed_file }} exec openbox-session diff --git a/roles/yavdr-xorg/templates/autostart.j2 b/roles/yavdr-xorg/templates/autostart.j2 index cf7a3dc..6b6c0d7 100644 --- a/roles/yavdr-xorg/templates/autostart.j2 +++ b/roles/yavdr-xorg/templates/autostart.j2 @@ -1,2 +1,10 @@ + env | grep "DISPLAY\|DBUS_SESSION_BUS_ADDRESS\|XDG_RUNTIME_DIR" > ~/.session-env -systemctl --user import-environment +systemctl --user import-environment DISPLAY XAUTHORITY XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS + +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 diff --git a/roles/yavdr-xorg/templates/openbox_rc.xml.j2 b/roles/yavdr-xorg/templates/openbox_rc.xml.j2 new file mode 100644 index 0000000..d866a8c --- /dev/null +++ b/roles/yavdr-xorg/templates/openbox_rc.xml.j2 @@ -0,0 +1,816 @@ + + + + + 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 + + + + + + + + + + + + + + + + + client-menu + + + + + + 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 + + + + + + + + + + + + + + + + + + + + + + + client-menu + + + + + + + top + + + + + + + left + + + + + + + right + + + + + + + bottom + + + + + + + client-menu + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + client-menu + + + + + + + client-menu + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vertical + + + + + horizontal + + + + + + + + + + + + + + + + + previous + + + + + next + + + + + previous + + + + + next + + + + + previous + + + + + next + + + + + + + + + + + + + + + + client-list-combined-menu + + + + + root-menu + + + + + + + previous + + + + + next + + + + + previous + + + + + next + + + + + + + + + /var/lib/openbox/debian-menu.xml + menu.xml + 200 + + no + + 100 + + 400 + + yes + + yes + + + + + + no + true + + yes + + + no + true + + yes + + + no + true + + yes + + +
diff --git a/roles/yavdr-xorg/templates/vdr-xorg.conf b/roles/yavdr-xorg/templates/vdr-xorg.conf index 73ca70f..94c2104 100644 --- a/roles/yavdr-xorg/templates/vdr-xorg.conf +++ b/roles/yavdr-xorg/templates/vdr-xorg.conf @@ -1,7 +1,8 @@ + # file: roles/yavdr-xorg/templates/vdr-xorg.conf # {{ ansible_managed_file }} [Unit] After=x@vt7.service Wants=x@vt7.service -BindsTo=x@vt7.service +#BindsTo=x@vt7.service diff --git a/roles/yavdr-xorg/templates/x-verbose@.service.j2 b/roles/yavdr-xorg/templates/x-verbose@.service.j2 index 028dc95..eb7f0c2 100644 --- a/roles/yavdr-xorg/templates/x-verbose@.service.j2 +++ b/roles/yavdr-xorg/templates/x-verbose@.service.j2 @@ -1,3 +1,4 @@ + [Unit] Description=X with verbose logging on %I Wants=graphical.target diff --git a/roles/yavdr-xorg/templates/yavdr-desktop.target.j2 b/roles/yavdr-xorg/templates/yavdr-desktop.target.j2 new file mode 100644 index 0000000..72a9ab6 --- /dev/null +++ b/roles/yavdr-xorg/templates/yavdr-desktop.target.j2 @@ -0,0 +1,7 @@ + +[Unit] +Description=yaVDR Desktop +Requires=default.target +After=default.target pulseaudio.service +Wants=dbus.service pulseaudio.service +AllowIsolate=yes diff --git a/yavdr07-headless.yml b/yavdr07-headless.yml index 9de97fc..f465b4d 100644 --- a/yavdr07-headless.yml +++ b/yavdr07-headless.yml @@ -1,3 +1,4 @@ + --- # file: yavdr07-headless.yml # this playbook set up a headless yaVDR 0.7 installation diff --git a/yavdr07.yml b/yavdr07.yml index 0ee68c0..a2ef381 100644 --- a/yavdr07.yml +++ b/yavdr07.yml @@ -1,3 +1,4 @@ + --- # file: yavdr07.yml # this playbook sets up a complete yaVDR 0.7 installation @@ -7,6 +8,7 @@ become: true roles: - yavdr-common # install and configure the basic system + - autoinstall-ubuntu-drivers # use ubuntu-drivers to install proprietary dirvers (e.g. nvidia, virtualbox) - vdr # install vdr and related packages - yavdr-network # enable network client capabilities - samba-install # install samba server @@ -19,6 +21,8 @@ - autoinstall-imonlcd # install vdr-plugin-imonlcd if a matchind display is connected #- autoinstall-pv350 # install vdr-plugin-pvr350 if a matching card is detected #- autoinstall-dvbsddevice # install vdr-plugin-dvbsddevice if a matching card is detected + - kodi + - dvd - grub-config # configure grub handlers: