mirror of
https://github.com/mtan93/Apps-Community.git
synced 2026-03-08 05:31:59 +00:00
145 lines
4.2 KiB
Bash
145 lines
4.2 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Title: Jdownloader2 for PlexGuide (OAuth security)
|
|
# Author(s): timekills
|
|
# URL: https://plexguide.com - https://github.com/timekills/jdownloader2-for-Plexguide
|
|
# GNU: General Public License v3.0
|
|
################################################################################
|
|
---
|
|
- hosts: localhost
|
|
gather_facts: false
|
|
tasks:
|
|
# FACTS #######################################################################
|
|
|
|
- name: 'Set Known Facts'
|
|
set_fact:
|
|
pgrole: 'jdownloader2'
|
|
intport: '5800'
|
|
extport: '5802'
|
|
intport2: '5902'
|
|
extport2: '5902'
|
|
intport3: '3129'
|
|
extport3: '3129'
|
|
image: 'jlesage/jdownloader-2'
|
|
|
|
# CORE (MANDATORY) ############################################################
|
|
- name: 'Including cron job'
|
|
include_tasks: '/opt/plexguide/containers/_core.yml'
|
|
|
|
# MIGRATIONS (REMOVE SECTION ON MARCH 1st) #############################################################
|
|
- name: 'Check for old volumes'
|
|
stat:
|
|
path: '{{path.stdout}}/{{pgrole}}'
|
|
register: oldcheck
|
|
|
|
- name: 'Migrations'
|
|
block:
|
|
- name: 'Creating new downloads location'
|
|
command: 'mkdir -p {{path.stdout}}/incomplete/{{pgrole}}'
|
|
|
|
- name: 'Chown download folder'
|
|
shell: 'chown -R 1000:1000 {{path.stdout}}/incomplete/{{pgrole}}/'
|
|
|
|
- name: 'Chmod download folder'
|
|
shell: 'chmod -R 775 {{path.stdout}}/incomplete/{{pgrole}}/'
|
|
|
|
- name: 'Ini Check'
|
|
stat:
|
|
path: /opt/appdata/{{pgrole}}/core.conf
|
|
register: inicheck
|
|
|
|
# LABELS ######################################################################
|
|
- name: 'Adding Traefik'
|
|
set_fact:
|
|
pg_labels:
|
|
traefik.enable: 'true'
|
|
traefik.port: '{{intport}}'
|
|
traefik.frontend.auth.forward.address: '{{gauth}}'
|
|
traefik.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}},{{tldset}}'
|
|
|
|
- name: 'Setting PG Volumes'
|
|
set_fact:
|
|
pg_volumes:
|
|
- '/opt/appdata/{{pgrole}}:/config'
|
|
- '{{path.stdout}}:{{path.stdout}}'
|
|
- '/mnt/unionfs:/unionfs'
|
|
- '{{path.stdout}}/incomplete/{{pgrole}}/:/output:rw'
|
|
- '/etc/localtime:/etc/localtime:ro'
|
|
|
|
- name: 'Setting PG ENV'
|
|
set_fact:
|
|
pg_env:
|
|
UID: 1000
|
|
GID: 1000
|
|
|
|
# MAIN DEPLOYMENT #############################################################
|
|
- name: 'Create scripts directory for {{pgrole}}'
|
|
file:
|
|
path: /opt/appdata/{{pgrole}}/scripts
|
|
state: directory
|
|
owner: 1000
|
|
group: 1000
|
|
mode: 0755
|
|
|
|
# - name: 'Create plugins directory for {{pgrole}}'
|
|
# file:
|
|
# path: /opt/appdata/{{pgrole}}/plugins
|
|
# state: directory
|
|
# owner: 1000
|
|
# group: 1000
|
|
# mode: 0755
|
|
|
|
- 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 JDOWNLOADER2 ###########################################################
|
|
|
|
# - 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
|
|
|
|
when: not inicheck.stat.exists
|