forked from HawksRepos/PTS-Team
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MrDoobPG
authored and
MrDoobPG
committed
Sep 11, 2019
1 parent
642e023
commit 7ed2ccd
Showing
8 changed files
with
464 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
######################################################################### | ||
# Title: Cloudbox: Sub-Zero Plugin # | ||
# Author(s): desimaniac # | ||
# URL: https://github.com/cloudbox/cloudbox # | ||
# -- # | ||
# Part of the Cloudbox project: https://cloudbox.works # | ||
######################################################################### | ||
# GNU General Public License v3.0 # | ||
######################################################################### | ||
--- | ||
- name: Check for previously installed Sub-Zero Plugin | ||
stat: | ||
path: "/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Plug-ins/Sub-Zero.bundle" | ||
register: subzero_bundle | ||
|
||
- name: Tasks for previously installed Sub-Zero Plugin | ||
block: | ||
|
||
- name: Set default value for 'subzero_outdated' variable | ||
set_fact: | ||
subzero_outdated: false | ||
|
||
# https://stackoverflow.com/a/51109708/10975859 | ||
- name: Check version of previously installed Sub-Zero | ||
xml: | ||
path: "/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Plug-ins/Sub-Zero.bundle/Contents/Info.plist" | ||
xpath: /plist/dict/key[.='CFBundleVersion']/following-sibling::*[1] | ||
content: 'text' | ||
register: xmlresp | ||
|
||
- name: Set 'subzero_previously_installed_version' variable | ||
set_fact: | ||
subzero_previously_installed_version: "{{ xmlresp.matches[0].string }}" | ||
|
||
- name: Check latest available version for Sub-Zero | ||
shell: curl -s https://api.github.com/repos/pannal/Sub-Zero.bundle/releases/latest | jq -r .tag_name | ||
args: | ||
warn: no | ||
register: subzero_latest_version | ||
ignore_errors: yes | ||
|
||
- name: Compare installed Sub-Zero Plugin version with latest one | ||
set_fact: | ||
subzero_outdated: "{{ subzero_previously_installed_version is version(subzero_latest_version.stdout, '<') }}" | ||
ignore_errors: yes | ||
|
||
when: subzero_bundle.stat.exists | ||
|
||
- name: Install Sub-Zero Plugin | ||
block: | ||
|
||
- name: Stop Plex container | ||
docker_container: | ||
name: plex | ||
state: stopped | ||
when: ('sub-zero-plugin' in ansible_run_tags) or ('reinstall-sub-zero-plugin' in ansible_run_tags) | ||
|
||
- name: Remove outdated Sub-Zero Plugin | ||
file: | ||
path: "/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Plug-ins/Sub-Zero.bundle" | ||
state: absent | ||
|
||
- name: Get latest Sub-Zero Plugin URL | ||
shell: curl -s https://api.github.com/repos/pannal/Sub-Zero.bundle/releases/latest | jq -r ".assets[] | select(.name | test(\"Sub-Zero.bundle\")) | .browser_download_url" | ||
args: | ||
warn: no | ||
register: subzero_download_url | ||
ignore_errors: yes | ||
|
||
- name: Set 'subzero_download_url_backup' variable | ||
set_fact: | ||
subzero_download_url_backup: https://github.com/pannal/Sub-Zero.bundle/releases/download/2.6.5.3074/Sub-Zero.bundle-2.6.5.3074.zip | ||
|
||
- name: Install Sub-Zero Plugin | ||
unarchive: | ||
src: "{{ subzero_download_url.stdout | default('{{ subzero_download_url_backup }}',true) }}" | ||
dest: "/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Plug-ins" | ||
copy: no | ||
owner: "{{ user.name }}" | ||
group: "{{ user.name }}" | ||
mode: 0775 | ||
validate_certs: no | ||
ignore_errors: yes | ||
|
||
- name: Check version of newly installed Sub-Zero Plugin | ||
xml: | ||
path: "/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Plug-ins/Sub-Zero.bundle/Contents/Info.plist" | ||
xpath: /plist/dict/key[.='CFBundleVersion']/following-sibling::*[1] | ||
content: 'text' | ||
register: xmlresp | ||
|
||
- name: Set 'subzero_newly_installed_version' variable | ||
set_fact: | ||
subzero_newly_installed_version: "{{ xmlresp.matches[0].string }}" | ||
|
||
- name: Display Sub-Zero Plugin version | ||
debug: | ||
msg: "Sub-Zero Plugin version {{ subzero_newly_installed_version }} installed." | ||
ignore_errors: yes | ||
|
||
- name: Start Plex container | ||
docker_container: | ||
name: plex | ||
state: started | ||
when: ('sub-zero-plugin' in ansible_run_tags) or ('reinstall-sub-zero-plugin' in ansible_run_tags) | ||
|
||
when: (not subzero_bundle.stat.exists) or ((subzero_bundle.stat.exists) and (subzero_outdated)) or ('reinstall-sub-zero-plugin' in ansible_run_tags) | ||
|
||
- name: Sub-Zero Plugin was not updated | ||
debug: | ||
msg: "Sub-Zero is already installed." | ||
when: (subzero_bundle.stat.exists) and not (subzero_outdated) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
######################################################################### | ||
# Title: Cloudbox: Traktarr Role # | ||
# Author(s): l3uddz, desimaniac # | ||
# URL: https://github.com/cloudbox/cloudbox # | ||
# -- # | ||
# Part of the Cloudbox project: https://cloudbox.works # | ||
######################################################################### | ||
# GNU General Public License v3.0 # | ||
######################################################################### | ||
--- | ||
- name: Check if traktarr service exists | ||
stat: | ||
path: "/etc/systemd/system/traktarr.service" | ||
register: traktarr_service | ||
|
||
- name: Stop existing traktarr service | ||
systemd: state=stopped name=traktarr | ||
when: traktarr_service.stat.exists | ||
|
||
- name: Create traktarr directories | ||
file: "path={{ item }} state=directory mode=0775 owner={{ user.name }} group={{ user.name }} recurse=yes" | ||
with_items: | ||
- /opt/appdata/traktarr | ||
|
||
- name: Clone traktarr | ||
git: | ||
repo: https://github.com/l3uddz/traktarr.git | ||
dest: /opt/appdata/traktarr | ||
version: HEAD | ||
force: yes | ||
become: yes | ||
become_user: "{{ user.name }}" | ||
|
||
- name: Install pip requirements | ||
pip: | ||
requirements: /opt/appdata/traktarr/requirements.txt | ||
executable: pip3 | ||
|
||
- name: Check if traktarr config exists | ||
stat: | ||
path: "/opt/appdata/traktarr/config.json" | ||
register: traktarr_config | ||
|
||
- name: "Check if sonarr exists" | ||
stat: | ||
path: "/opt/appdata/sonarr/app/config.xml" | ||
register: sonarr_config | ||
when: not traktarr_config.stat.exists | ||
|
||
- name: "When sonarr exists, add api key to traktar config" | ||
block: | ||
|
||
- name: Pull sonarr api key | ||
xml: | ||
path: "/opt/appdata/sonarr/app/config.xml" | ||
xpath: /Config/ApiKey | ||
content: text | ||
register: xmlresp | ||
|
||
- name: Set sonarr api Key | ||
set_fact: | ||
sonarr_api_key: "{{ xmlresp.matches[0].ApiKey }}" | ||
|
||
when: (not traktarr_config.stat.exists) and (sonarr_config.stat.exists) | ||
|
||
- name: "Check if radarr exists" | ||
stat: | ||
path: "/opt/appdata/radarr/app/config.xml" | ||
register: radarr_config | ||
when: not traktarr_config.stat.exists | ||
|
||
- name: "When radarr exists, add api key to traktar config" | ||
block: | ||
|
||
- name: Pull radarr api key | ||
xml: | ||
path: "/opt/appdata/radarr/app/config.xml" | ||
xpath: /Config/ApiKey | ||
content: text | ||
register: xmlresp | ||
|
||
- name: Set radarr api Key | ||
set_fact: | ||
radarr_api_key: "{{ xmlresp.matches[0].ApiKey }}" | ||
|
||
when: (not traktarr_config.stat.exists) and (radarr_config.stat.exists) | ||
|
||
- name: Import default config | ||
template: | ||
src: config.json.j2 | ||
dest: /opt/appdata/traktarr/config.json | ||
owner: "{{ user.name }}" | ||
group: "{{ user.name }}" | ||
mode: 0775 | ||
force: yes | ||
when: not traktarr_config.stat.exists | ||
|
||
- name: Set traktarr.py as executable | ||
file: | ||
path: /opt/appdata/traktarr/traktarr.py | ||
owner: "{{ user.name }}" | ||
group: "{{ user.name }}" | ||
mode: a+x | ||
|
||
- name: Set directory permissions | ||
file: "path=/opt/appdata/traktarr state=directory owner={{ user.name }} group={{ user.name }} recurse=yes" | ||
|
||
- name: "Create /usr/local/bin symlink" | ||
file: | ||
src: "/opt/appdata/traktarr/traktarr.py" | ||
dest: "/usr/local/bin/traktarr" | ||
state: link | ||
|
||
- name: Import traktarr service | ||
template: | ||
src: traktarr.service.j2 | ||
dest: /etc/systemd/system/traktarr.service | ||
force: yes | ||
when: not traktarr_service.stat.exists | ||
|
||
- name: Load traktarr service | ||
systemd: | ||
name: traktarr | ||
state: "{{ traktarr_config.stat.exists | ternary('started','stopped') }}" | ||
enabled: "{{ traktarr_config.stat.exists | ternary('yes','no') }}" | ||
daemon_reload: yes |
Oops, something went wrong.