mirror of
https://github.com/mtan93/Apps-Community.git
synced 2026-03-18 21:02:59 +00:00
Create plexsync.yml
This commit is contained in:
112
apps/plexsync.yml
Normal file
112
apps/plexsync.yml
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
#!/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: '1700'
|
||||||
|
extport: '1700'
|
||||||
|
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'
|
||||||
|
- '/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/:/mnt/DB2
|
||||||
|
- '/etc/localtime:/etc/localtime:ro'
|
||||||
|
|
||||||
|
- name: 'Setting PG ENV'
|
||||||
|
set_fact:
|
||||||
|
pg_env:
|
||||||
|
USER_ID: 1000
|
||||||
|
GROUP_ID: 1000
|
||||||
|
KEEP_APP_RUNNING: 1
|
||||||
|
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: "/mnt/DB2"
|
||||||
|
S2_START: "cd /; docker start plex"
|
||||||
|
S2_STOP: "cd /; docker stop plex"
|
||||||
|
BACKUP: "true"
|
||||||
|
# DRYRUN: "true"
|
||||||
|
|
||||||
|
# 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 7 Seconds'
|
||||||
|
wait_for:
|
||||||
|
timeout: 7
|
||||||
|
|
||||||
|
- name: Stop Container
|
||||||
|
docker_container:
|
||||||
|
name: '{{pgrole}}'
|
||||||
|
state: stopped
|
||||||
|
|
||||||
|
# ENDING FOR PLEXSYNC ###########################################################
|
||||||
|
|
||||||
|
# - 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
|
||||||
Reference in New Issue
Block a user