-
-
Notifications
You must be signed in to change notification settings - Fork 309
/
db_cache_size_settings.yml
80 lines (68 loc) · 2.92 KB
/
db_cache_size_settings.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
##########################################################################
# Title: Plex - DB Cache Size Settings #
# Author(s): desimaniac #
# URL: https://github.com/cloudbox/cloudbox #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
##########################################################################
# GNU General Public License v3.0 #
##########################################################################
---
- name: Wait for Plex DB to be created
wait_for:
path: "/opt/plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"
state: present
timeout: 600
- name: Get Current Plex DB Cache Size
shell: sqlite3 "/opt/plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" "PRAGMA default_cache_size;"
args:
executable: /bin/bash
register: current_db_cache_size
- name: Set 'default_db_cache_size' variable
set_fact:
default_db_cache_size: '2000'
- name: Check if 'plex.db_cache_size' was specified
set_fact:
db_cache_size_is_specified: "{{ true if not (
(plex.db_cache_size is undefined)
or
(plex.db_cache_size is none)
or
(plex.db_cache_size | trim | length == 0)
)
else false }}"
- name: Get Desired Plex DB Cache Size
set_fact:
desired_db_cache_size: "{{ default_db_cache_size
if ( (not db_cache_size_is_specified) or (plex.db_cache_size == 'default') )
else ( (plex.db_cache_size) | regex_replace(',', '') | int ) }}"
- name: Make Plex DB Edits
block:
- name: Stop Plex Container
docker_container:
name: plex
state: stopped
- name: Display Desired Plex DB Cache Size
debug:
msg: "Desired Plex DB Cache Size is '{{ desired_db_cache_size }}'"
- name: "Set Plex DB Cache Size"
shell: |
sqlite3 "/opt/plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" \
"PRAGMA default_cache_size = '{{ desired_db_cache_size | int }}';"
args:
executable: /bin/bash
- name: Get Current Plex DB Cache Size
shell: |
sqlite3 "/opt/plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" \
"PRAGMA default_cache_size;"
args:
executable: /bin/bash
register: new_db_cache_size
- name: Display Current Plex DB Cache Size
debug:
msg: "Plex DB cache size is now set to '{{ new_db_cache_size.stdout | int }}'."
- name: Start Plex Container
docker_container:
name: plex
state: started
when: ( current_db_cache_size.stdout | int ) != ( desired_db_cache_size | regex_replace(',', '') | int )