-
Notifications
You must be signed in to change notification settings - Fork 6
/
nzbget
241 lines (208 loc) · 7.14 KB
/
nzbget
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/bin/bash
############# https://github.com/plexguide/PlexGuide.com/graphs/contributors ###
nzbget () {
container_reset
# VARIABLES ####################################################################
pgrole="nzbget"
port_inside01="6789"
port_outside01="6789"
traefik_extport="6789"
common_fcreate_silent /pg/complete/nzbget
common_fcreate_silent /pg/incomplete/nzbget
common_fcreate_silent /pg/nzb/$pgrole
common_fcreate_silent /pg/scripts/$pgrole
container_path /pg /pg
container_path /pg/data/$pgrole /config
container_path /etc/localtime /etc/localtime:ro
container_permissions PUID 1000
container_permissions PGID 1000
container_permissions LC_ALL C
# IMAGES EXPORT - 1ST IS DEFAULT ###############################################
cat <<- EOF > "/pg/images/$pgrole.images"
linuxserver/nzbget:latest
linuxserver/nzbget:testing
EOF
# YML EXPORT ###################################################################
container_core
cat <<- EOF > "/pg/apps/$pgrole.yml"
$container_header
### ALIGN WITH THE A ################################## START - EXTRAS #########
- name: 'Checking for existing app data'
stat:
path: '/pg/data/$pgrole/nzbget.conf'
register: confcheck
####### ALIGN WITH THE A ############################## CORE ###################
$container_start
published_ports:
- '${portcheck_add}${port_outside01}:${port_inside01}'
env:
$container_permissions
labels:
$container_traefik
$container_oddball
$container_ending
### ALIGN WITH THE A ################################## END - EXTRAS ###########
- name: 'Waiting for $pgrole to initialize'
wait_for:
path: '/pg/data/$pgrole/nzbget.conf'
state: present
delay: 5
- name: 'Stopping $pgrole'
docker_container:
name: '$pgrole'
state: stopped
- name: Set Main Location
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^MainDir\s*=.*'
line: 'MainDir=/config'
state: present
- name: Set download location
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^DestDir\s*=.*'
line: 'DestDir=/pg/complete/$pgrole'
state: present
- name: Set incomplete location
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^InterDir\s*=.*'
line: 'InterDir=/pg/incomplete/$pgrole'
state: present
- name: Set TempDir
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^TempDir\s*=.*'
line: 'TempDir=/tmp'
state: present
- name: Set NzbDir Location
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^NzbDir\s*=.*'
line: 'NzbDir=/pg/nzb/$pgrole'
state: present
- name: ScriptDir
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^ScriptDir\s*=.*'
line: 'ScriptDir=/pg/scripts/$pgrole'
state: present
# FIRST TIME CONFIGURATION #############################################################
- name: 'Configuring $pgrole for first time use'
block:
- name: Lowercase & Set Movie Category
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^Category1.Name\s*=.*'
line: 'Category1.Name=movies'
state: present
- name: Set Location of Movies
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^Category1.DestDir\s*=.*'
line: 'Category1.DestDir='
state: present
- name: Lowercase & Set TV Category
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^Category2.Name\s*=.*'
line: 'Category2.Name=tv'
state: present
- name: Set Location of TV
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^Category2.DestDir\s*=.*'
line: 'Category2.DestDir='
state: present
- name: Lowercase & Set Music Category
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^Category3.Name\s*=.*'
line: 'Category3.Name=music'
state: present
- name: Set Location of Music
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^Category3.DestDir\s*=.*'
line: 'Category3.DestDir='
state: present
- name: Lowercase & Set EBook Category
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^Category4.Name\s*=.*'
line: 'Category4.Name=ebooks'
state: present
- name: Set Location of EBooks
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^Category4.DestDir\s*=.*'
line: 'Category4.DestDir='
state: present
- name: Lowercase & Set abook Category
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: 'Category5.Name\s*=.*'
line: 'Category5.Name=abooks'
state: present
- name: Set Location of aBooks
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: 'Category5.DestDir\s*=.*'
line: 'Category5.DestDir='
state: present
- name: Default User
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^ControlUsername\s*=.*'
line: 'ControlUsername='
state: present
- name: Default Password
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: 'ControlPassword\s*=.*'
line: 'ControlPassword='
state: present
- name: DirectUnpack Set to On
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^DirectUnpack\s*=.*'
line: 'DirectUnpack=yes'
state: present
- name: HealthCheck
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^HealthCheck\s*=.*'
line: 'HealthCheck=Delete'
state: present
- name: Set DiskSpace
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '^DiskSpace\s*=.*'
line: 'DiskSpace=25000'
state: present
- name: Remove Generic Task
lineinfile:
path: '/pg/data/$pgrole/nzbget.conf'
regexp: '{{ item.regexp }}'
state: absent
with_items:
- { regexp: '.Task1\.Time\=' }
- { regexp: '.Task1\.WeekDays\=' }
- { regexp: '.Task1\.Command\=' }
- { regexp: '.Task1\.Param\=' }
- name: Unpause
blockinfile:
path: '/pg/data/$pgrole/nzbget.conf'
block: |
Task1.Time=*,*:00,*:30
Task1.WeekDays=1-7
Task1.Command=UnpauseDownload
Task1.Param=
insertafter: '^### SCHEDULER'
when: not confcheck.stat.exists
- name: 'Restart $pgrole'
docker_container:
name: '$pgrole'
state: started
EOF
}