mirror of
https://github.com/mtan93/Apps-Community.git
synced 2026-03-08 05:31:59 +00:00
108 lines
3.5 KiB
Bash
108 lines
3.5 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Title: Plex Database Sync for PlexGuide Community
|
|
# Author(s): timekills
|
|
# URL: https://plexguide.com - https://github.com/timekills
|
|
# GNU: General Public License v3.0
|
|
################################################################################
|
|
---
|
|
- hosts: localhost
|
|
gather_facts: false
|
|
tasks:
|
|
# FACTS #######################################################################
|
|
|
|
- name: 'Set Known Facts'
|
|
set_fact:
|
|
pgrole: 'plexsync'
|
|
# intport: '5800'
|
|
# extport: '5800'
|
|
image: 'nowsci/plex-db-sync'
|
|
|
|
# CORE (MANDATORY) ############################################################
|
|
- name: 'Including cron job'
|
|
include_tasks: '/opt/plexguide/containers/_core.yml'
|
|
|
|
# LABELS ######################################################################
|
|
- name: 'Adding Traefik'
|
|
set_fact:
|
|
pg_labels:
|
|
traefik.enable: 'true'
|
|
traefik.port: '{{intport}}'
|
|
traefik.frontend.auth.forward.address: '{{gauth}}'
|
|
traefik.frontend.rule: 'Host:plexsync.{{domain.stdout}},{{tldset}}'
|
|
|
|
- name: 'Setting PG Volumes'
|
|
set_fact:
|
|
pg_volumes:
|
|
- '/opt/appdata/{{pgrole}}:/config:rw'
|
|
- 'S1_SSH_KEY=/sshkey'
|
|
- 'S1_SSH_USER=root'
|
|
- 'S1_SSH_HOST=ssh.timekills.info'
|
|
- 'S1_SSH_PORT=22'
|
|
- 'S1_SSH_PATH=/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases'
|
|
- "S1_START=ssh -oStrictHostKeyChecking=no -i /sshkey root@ssh.timekills.info 'cd /; docker start plex'"
|
|
- "S1_STOP=ssh -oStrictHostKeyChecking=no -i /sshkey root@ssh.timekills.info 'cd /; docker stop plex'"
|
|
- 'S2_DB_PATH=/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/'
|
|
- 'S2_START=cd /; docker start plex'
|
|
- 'S2_STOP=cd /; docker stop plex'
|
|
- '/etc/localtime:/etc/localtime:ro'
|
|
|
|
- name: 'Setting PG ENV'
|
|
set_fact:
|
|
pg_env:
|
|
USER_ID: 1000
|
|
GROUP_ID: 1000
|
|
|
|
# MAIN DEPLOYMENT #############################################################
|
|
- name: 'Deploying {{pgrole}}'
|
|
docker_container:
|
|
name: '{{pgrole}}'
|
|
image: '{{image}}'
|
|
pull: yes
|
|
published_ports:
|
|
- '{{ports.stdout}}{{extport}}:{{intport}}'
|
|
volumes: '{{pg_volumes}}'
|
|
env: '{{pg_env}}'
|
|
restart_policy: unless-stopped
|
|
networks:
|
|
- name: plexguide
|
|
aliases:
|
|
- '{{pgrole}}'
|
|
state: started
|
|
labels: '{{pg_labels}}'
|
|
|
|
- name: 'Wait 6 Seconds'
|
|
wait_for:
|
|
timeout: 6
|
|
|
|
- name: Stop Container
|
|
docker_container:
|
|
name: '{{pgrole}}'
|
|
state: stopped
|
|
|
|
# ENDING FOR HANDBRAKE ###########################################################
|
|
|
|
# - name: 'Waiting for {{pgrole}} to initialize'
|
|
# wait_for:
|
|
# path: '/opt/appdata/{{pgrole}}/core.conf'
|
|
# state: present
|
|
|
|
- name: 'Configuring {{pgrole}} for first time use'
|
|
block:
|
|
- name: 'Stopping {{pgrole}}'
|
|
docker_container:
|
|
name: '{{pgrole}}'
|
|
state: stopped
|
|
|
|
# - name: Setting plugins directory
|
|
# lineinfile:
|
|
# path: '/opt/appdata/{{pgrole}}/core.conf'
|
|
# regexp: '"plugins_location"'
|
|
# line: '"plugins_location": "/config/plugins",'
|
|
# state: present
|
|
|
|
- name: Restart Container
|
|
docker_container:
|
|
name: '{{pgrole}}'
|
|
state: started
|