|
| 1 | +{% from "tc2/rtl8821au/map.jinja" import rtl8821au with context %} |
| 2 | +{% set device_present = salt['cacophony.has_usb_device'](rtl8821au['device_ids']) %} |
| 3 | +{% set install_marker = rtl8821au['install_marker'] %} |
| 4 | +{% set already_installed = salt['file.file_exists'](install_marker) %} |
| 5 | +{% set should_install = rtl8821au['auto_update'] or not already_installed %} |
| 6 | +{% set install_command = "./install-driver.sh" %} |
| 7 | +{% if rtl8821au['install_args'] %} |
| 8 | + {% set install_command = install_command + " " + " ".join(rtl8821au['install_args']) %} |
| 9 | +{% endif %} |
| 10 | +
|
| 11 | +{% if device_present %} |
| 12 | +
|
| 13 | +{% if rtl8821au['packages'] %} |
| 14 | +rtl8821au-deps: |
| 15 | + pkg.installed: |
| 16 | + - pkgs: {{ rtl8821au['packages'] }} |
| 17 | +{% endif %} |
| 18 | +
|
| 19 | +{% if should_install %} |
| 20 | +rtl8821au-source: |
| 21 | + git.latest: |
| 22 | + - name: {{ rtl8821au['repo'] }} |
| 23 | + - target: {{ rtl8821au['source_dir'] }} |
| 24 | + - depth: 1 |
| 25 | + - rev: {{ rtl8821au['branch'] }} |
| 26 | + - require: |
| 27 | +{% if rtl8821au['packages'] %} |
| 28 | + - pkg: rtl8821au-deps |
| 29 | +{% endif %} |
| 30 | + - user: root |
| 31 | +{% if not rtl8821au['auto_update'] %} |
| 32 | + - unless: test -f "{{ install_marker }}" |
| 33 | +{% endif %} |
| 34 | +
|
| 35 | +rtl8821au-install: |
| 36 | + cmd.run: |
| 37 | + - name: {{ install_command }} |
| 38 | + - cwd: {{ rtl8821au['source_dir'] }} |
| 39 | + - unless: modinfo 8821au |
| 40 | + - require: |
| 41 | + - git: rtl8821au-source |
| 42 | +
|
| 43 | +rtl8821au-reinstall: |
| 44 | + cmd.run: |
| 45 | + - name: {{ install_command }} |
| 46 | + - cwd: {{ rtl8821au['source_dir'] }} |
| 47 | + - onlyif: modinfo 8821au |
| 48 | + - onchanges: |
| 49 | + - git: rtl8821au-source |
| 50 | + - require: |
| 51 | + - git: rtl8821au-source |
| 52 | +
|
| 53 | +rtl8821au-marker: |
| 54 | + file.managed: |
| 55 | + - name: {{ install_marker }} |
| 56 | + - contents: installed |
| 57 | + - makedirs: True |
| 58 | + - onlyif: modinfo 8821au |
| 59 | + - require: |
| 60 | + - git: rtl8821au-source |
| 61 | + - unless: test -f "{{ install_marker }}" |
| 62 | +{% else %} |
| 63 | +rtl8821au-installed: |
| 64 | + test.nop: |
| 65 | + - name: rtl8821au |
| 66 | + - comment: Driver already installed ({{ install_marker }}) |
| 67 | +{% endif %} |
| 68 | +
|
| 69 | +rtl8821au-modprobe-options: |
| 70 | + file.line: |
| 71 | + - name: /etc/modprobe.d/8821au.conf |
| 72 | + - mode: replace |
| 73 | + - match: ^options 8821au |
| 74 | + - content: options 8821au rtw_led_ctrl=1 rtw_vht_enable=2 rtw_power_mgnt=0 rtw_dfs_region_domain=3 |
| 75 | + - onlyif: test -f /etc/modprobe.d/8821au.conf |
| 76 | +{% if should_install %} |
| 77 | + - require: |
| 78 | + - cmd: rtl8821au-install |
| 79 | +{% endif %} |
| 80 | +
|
| 81 | +{% else %} |
| 82 | +rtl8821au-not-required: |
| 83 | + test.nop: |
| 84 | + - name: rtl8821au |
| 85 | + - comment: Driver not installed. device_present={{ device_present }} |
| 86 | +{% endif %} |
0 commit comments