Skip to content

Commit

Permalink
well done now
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDoobPG authored and MrDoobPG committed Nov 27, 2019
1 parent eb33987 commit 77fcd84
Show file tree
Hide file tree
Showing 34 changed files with 1,080 additions and 26 deletions.
3 changes: 2 additions & 1 deletion menu/pg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
- { role: plex_autoscan, tags: ['plex_autoscan'] }
- { role: plex_dupefinder, tags: ['plex_dupefinder'] }
- { role: plexpatrol, tags: ['plexpatrol'] }
- { role: remove, tags: ['remove'] }
- { role: remove, tags: ['remove'] }
- { role: traktarr, tags: ['traktarr'] }
185 changes: 185 additions & 0 deletions menu/roles/traktarr/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
#########################################################################
# Title: Cloudbox: traktarr Role #
# Author(s): l3uddz #
# URL: https://github.com/cloudbox/cloudbox #
# YML creator : MrDoob for PTS #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: Check old Service's Existance
stat:
path: '/etc/systemd/system/traktarr.service'
register: pgp

- name: Stop old service
service:
name: traktarr
state: stopped
when: pgp.stat.exists
ignore_errors: yes

- name: Daemon - Traktarr stop
systemd: state=stopped name=traktarr daemon_reload=yes enabled=no
ignore_errors: yes

- name: Remove old Basic Directories
file: 'path={{item}} state=absent mode=0775 owner=1000 group=1000'
with_items:
- '/opt/appdata/traktarr/'
- '/etc/systemd/system/traktarr.service'
when: pgp.stat.exists == true
ignore_errors: yes

- name: Check Folder Existance
stat:
path: '/opt/appdata/traktarr/'
register: traktarr

- debug: msg="Final Notes Traktarr is now removed"
when: traktarr.stat.exists == False

- name: Remove old symlink /usr/local/bin/traktarr
shell: 'rm -rf /usr/local/bin/traktarr'
ignore_errors: True

- name: Remove old symlink /bin/traktarr
shell: 'rm -rf /bin/traktarr'
ignore_errors: True

- name: Server ID
shell: 'cat /var/plexguide/pg.serverid'
register: serverid

- name: Sonarr API
shell: 'cat /var/plexguide/traktarr/pgtrak.sapi'
register: sapi
ignore_errors: True

- name: Radarr API
shell: 'cat /var/plexguide/traktarr/pgtrak.rapi'
register: rapi
ignore_errors: True

- name: Sonarr Profile
shell: 'cat /var/plexguide/traktarr/pgtrak.sprofile'
register: sprofile
ignore_errors: True

- name: Radarr Profile
shell: 'cat /var/plexguide/traktarr/pgtrak.rprofile'
register: rprofile
ignore_errors: True

- name: Trakt.tv Client
shell: 'cat /var/plexguide/traktarr/pgtrak.client'
register: client
ignore_errors: True

- name: Trakt.tv Secret
shell: 'cat /var/plexguide/traktarr/pgtrak.secret'
register: secret
ignore_errors: True

- name: Radarr Path
shell: 'cat /var/plexguide/traktarr/pgtrak.rpath'
register: rpath
ignore_errors: True

- name: Sonnar Path
shell: 'cat /var/plexguide/traktarr/pgtrak.spath'
register: spath
ignore_errors: True

- name: Max allowed Year
shell: 'cat /var/plexguide/traktarr/pgtrakyear.max'
register: year
ignore_errors: True

- name: Remove old Install
shell: 'sudo rm -rf /opt/appdata/traktarr'

- name: Create traktarr directories
file: "path={{ item }} state=directory mode=0775 owner=1000 group=1000 recurse=yes"
with_items:
- /opt/appdata/traktarr

- name: Clone l3uddz/traktarr == HEAD
git:
repo: https://github.com/l3uddz/traktarr.git
dest: /opt/appdata/traktarr
clone: yes
version: HEAD
force: yes
ignore_errors: yes

- name: Clone l3uddz/traktarr repo == master
git:
repo: https://github.com/l3uddz/traktarr.git
dest: /opt/appdata/traktarr
clone: yes
version: master
force: yes
ignore_errors: yes

- name: Install pip requirements
pip:
requirements: /opt/appdata/traktarr/requirements.txt
executable: pip3

- name: Check config exists
stat:
path: "/opt/appdata/traktarr/config.json"
register: traktarr_config

- name: Import default config
template:
src: config.json.j2
dest: /opt/appdata/traktarr/config.json
owner: '1000'
group: '1000'
mode: 0775
force: yes

- name: Set traktarr.py as executable
file:
path: /opt/appdata/traktarr/traktarr.py
owner: '1000'
group: '1000'
mode: a+x

- name: Set directory permissions
file: "path=/opt/appdata/traktarr state=directory owner=1000 group=1000 recurse=yes"

- name: "Create /usr/local/bin symlink"
shell: 'sudo ln -s /opt/appdata/traktarr/traktarr.py /usr/local/bin/traktarr'

- name: Traktarr Service
template:
src: traktarr.service.j2
dest: /etc/systemd/system/traktarr.service
force: yes

- name: Daemon-Reload for Traktarr
systemd: state=stopped name=traktarr daemon_reload=yes enabled=no

- name: Start Traktarr Service
systemd: state=started name=traktarr enabled=yes

# scripts permissions
- name: 'Setting permissions on scripts'
shell: 'chown -cR 1000:1000 /opt/appdata/traktarr'

# scripts permissions
- name: 'Setting permissions on scripts'
shell: 'chmod -cR 775 /opt/appdata/traktarr'

- name: Remove .githube folder and .git files
file: "path={{ item }} state=absent"
with_items:
- '/opt/appdata/traktarr/.git'
- '/opt/appdata/traktarr/.github'
- '/opt/appdata/traktarr/assets'
- '/opt/appdata/traktarr/.gitignore'
122 changes: 122 additions & 0 deletions menu/roles/traktarr/templates/config.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"automatic": {
"movies": {
"anticipated": 3,
"boxoffice": 10,
"interval": 20,
"popular": 3,
"trending": 3,
"watched": 2,
"played_all": 2
},
"shows": {
"anticipated": 10,
"interval": 48,
"popular": 1,
"trending": 1,
"played": 2,
"watched_monthly": 2
}
},
"core": {
"debug": false
},
"filters": {
"movies": {
"disabled_for": [],
"allowed_countries": [
"us",
"gb",
"ca"
],
"allowed_languages": [
"en"
],
"blacklisted_genres": [
"documentary",
"music",
"animation"
],
"blacklisted_max_runtime": 0,
"blacklisted_max_year": {{year.stdout}},
"blacklisted_min_runtime": 60,
"blacklisted_min_year": 1980,
"blacklisted_title_keywords": [
"untitled",
"barbie",
"ufc"
],
"blacklisted_tmdb_ids": [],
"disabled_for": [],
"rotten_tomatoes": ""
},
"shows": {
"disabled_for": [],
"allowed_countries": [
"us",
"gb",
"ca"
],
"allowed_languages": [],
"blacklisted_genres": [
"animation",
"game-show",
"talk-show",
"home-and-garden",
"children",
"reality",
"anime",
"news",
"documentary",
"special-interest"
],
"blacklisted_networks": [
"twitch",
"youtube",
"nickelodeon",
"hallmark",
"reelzchannel",
"disney",
"cnn",
"cbbc",
"the movie network",
"teletoon",
"cartoon network",
"espn",
"yahoo!",
"fox sports"
],
"blacklisted_max_runtime": 0,
"blacklisted_min_runtime": 15,
"blacklisted_min_year": 1980,
"blacklisted_max_year": {{year.stdout}},
"blacklisted_title_keywords": [],
"blacklisted_tvdb_ids": []
}
},
"notifications": {
"verbose": true
},
"omdb": {
"api_key": ""
},
"radarr": {
"api_key": "{{rapi.stdout}}",
"minimum_availability": "released",
"quality": "{{rprofile.stdout}}",
"root_folder": "{{rpath.stdout}}",
"url": "http://localhost:7878/"
},
"sonarr": {
"api_key": "{{sapi.stdout}}",
"language": "English",
"quality": "{{sprofile.stdout}}",
"root_folder":"{{spath.stdout}}",
"tags": {},
"url": "http://localhost:8989/"
},
"trakt": {
"client_id": "{{client.stdout}}",
"client_secret": "{{secret.stdout}}"
}
}
17 changes: 17 additions & 0 deletions menu/roles/traktarr/templates/traktarr.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description='Traktarr'
After=multi-user.target network-online.target

[Service]
User=0
Group=0
Type=simple
Environment="LC_ALL=C.UTF-8"
Environment="LANG=C.UTF-8"
WorkingDirectory=/opt/appdata/traktarr/
ExecStart=/usr/bin/python3 /opt/appdata/traktarr/traktarr.py run
Restart=always
RestartSec=10

[Install]
WantedBy=default.target
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions menu/traktarr/##old/traktarr-list/prefillallow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
#
# Title: Traktarr auto deploy
# Mod from MrDoobPG for PTS
# GNU: General Public License v3.0
# Origin: https://github.com/l3uddz/plex_patrol
################################################################################
---
- hosts: localhost
gather_facts: false
tasks:

- name: Add Traktarr prefilling list @ daily
cron:
name: "Traktarr prefilling list @ daily"
special_time: 'daily'
job: 'bash /opt/plexguide/menu/traktarr/traktarr-list/traktarr.sh >/dev/null 2>&1'
state: present

18 changes: 18 additions & 0 deletions menu/traktarr/##old/traktarr-list/prefillremove.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
#
# Title: Traktarr auto deploy
# Mod from MrDoobPG for PTS
# GNU: General Public License v3.0
# Origin: https://github.com/l3uddz/plex_patrol
################################################################################
---
- hosts: localhost
gather_facts: false
tasks:

- name: Remove Traktarr prefilling list @ daily
cron:
name: "Traktarr prefilling list @ daily"
special_time: 'daily'
job: 'bash /opt/plexguide/menu/traktarr/traktarr-list/traktarr.sh >/dev/null 2>&1'
state: absent
Loading

0 comments on commit 77fcd84

Please sign in to comment.