-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdoublearrinstall.sh
More file actions
274 lines (246 loc) · 7.85 KB
/
Copy pathdoublearrinstall.sh
File metadata and controls
274 lines (246 loc) · 7.85 KB
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/bin/bash
. /etc/swizzin/sources/globals.sh
. /etc/swizzin/sources/functions/utils
# Script by @ComputerByte
# For Double *Arr Installs
# Log to Swizzin.log
export log=/root/logs/swizzin.log
touch $log
# Set variables
user=$(_get_master_username)
_sonarr4kinstall() {
echo_progress_start "Making data directory and owning it to ${user}"
mkdir -p "/home/$user/.config/sonarr4k"
chown -R "$user":"$user" /home/$user/.config/sonarr4k
echo_progress_done "Data Directory created and owned."
echo_progress_start "Installing systemd service file"
cat >/etc/systemd/system/sonarr4k.service <<-SERV
# This file is owned by the sonarr package, DO NOT MODIFY MANUALLY
# Instead use 'dpkg-reconfigure -plow sonarr' to modify User/Group/UMask/-data
# Or use systemd built-in override functionality using 'systemctl edit sonarr'
[Unit]
Description=Sonarr Daemon
After=network.target
[Service]
User=${user}
Group=${user}
UMask=0002
Type=simple
ExecStart=/opt/Sonarr/Sonarr -nobrowser -data=/home/${user}/.config/sonarr4k
TimeoutStopSec=20
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
SERV
echo_progress_done "Sonarr 4K service installed"
# This checks if nginx is installed, if it is, then it will install nginx config for sonarr4k
if [[ -f /install/.nginx.lock ]]; then
echo_progress_start "Installing nginx config"
cat >/etc/nginx/apps/sonarr4k.conf <<-NGX
location ^~ /sonarr4k {
proxy_pass http://127.0.0.1:8882;
proxy_set_header Host \$proxy_host;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host \$host;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection \$http_connection;
auth_basic "What's the password?";
auth_basic_user_file /etc/htpasswd.d/htpasswd.${user};
}
# Allow the API External Access via NGINX
location ^~ /sonarr4k/api {
auth_basic off;
proxy_pass http://127.0.0.1:8882;
}
NGX
# Reload nginx
systemctl reload nginx
echo_progress_done "Nginx config applied"
fi
echo_progress_start "Generating configuration"
# Start sonarr to config
systemctl stop sonarr.service >>$log 2>&1
cat > /home/${user}/.config/sonarr4k/config.xml << EOSC
<Config>
<LogLevel>info</LogLevel>
<UpdateMechanism>BuiltIn</UpdateMechanism>
<Branch>main</Branch>
<BindAddress>127.0.0.1</BindAddress>
<Port>8882</Port>
<SslPort>9898</SslPort>
<EnableSsl>False</EnableSsl>
<LaunchBrowser>False</LaunchBrowser>
<AuthenticationMethod>None</AuthenticationMethod>
<UrlBase>sonarr4k</UrlBase>
<UpdateAutomatically>False</UpdateAutomatically>
</Config>
EOSC
chown -R ${user}:${user} \/home/${user}/.config/sonarr4k/
systemctl enable --now sonarr.service >>$log 2>&1
sleep 10
systemctl enable --now sonarr4k.service >>$log 2>&1
echo_progress_start "Patching panel."
systemctl start sonarr4k.service >>$log 2>&1
#Install Swizzin Panel Profiles
if [[ -f /install/.panel.lock ]]; then
cat <<EOF >>/opt/swizzin/core/custom/profiles.py
class sonarr4k_meta:
name = "sonarr4k"
pretty_name = "Sonarr 4K"
baseurl = "/sonarr4k"
systemd = "sonarr4k"
check_theD = False
img = "sonarr"
class sonarr_meta(sonarr_meta):
systemd = "sonarr"
check_theD = False
EOF
fi
touch /install/.sonarr4k.lock >>$log 2>&1
echo_progress_done "Panel patched."
systemctl restart panel >>$log 2>&1
echo_progress_done "Done."
}
_radarr4kinstall() {
echo_progress_start "Making data directory and owning it to ${user}"
mkdir -p "/home/$user/.config/radarr4k"
chown -R "$user":"$user" /home/$user/.config/radarr4k
echo_progress_done "Data Directory created and owned."
echo_progress_start "Installing systemd service file"
cat >/etc/systemd/system/radarr4k.service <<-SERV
[Unit]
Description=Radarr 4K
After=syslog.target network.target
[Service]
# Change the user and group variables here.
User=${user}
Group=${user}
Type=simple
# Change the path to Radarr or mono here if it is in a different location for you.
ExecStart=/opt/Radarr/Radarr -nobrowser --data=/home/${user}/.config/radarr4k
TimeoutStopSec=20
KillMode=process
Restart=on-failure
# These lines optionally isolate (sandbox) Radarr from the rest of the system.
# Make sure to add any paths it might use to the list below (space-separated).
#ReadWritePaths=/opt/Radarr /path/to/movies/folder
#ProtectSystem=strict
#PrivateDevices=true
#ProtectHome=true
[Install]
WantedBy=multi-user.target
SERV
echo_progress_done "Radarr 4K service installed"
# This checks if nginx is installed, if it is, then it will install nginx config for radarr4k
if [[ -f /install/.nginx.lock ]]; then
echo_progress_start "Installing nginx config"
cat >/etc/nginx/apps/radarr4k.conf <<-NGX
location ^~ /radarr4k {
proxy_pass http://127.0.0.1:7888/radarr4k;
proxy_set_header Host \$host;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host \$host;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection \$http_connection;
auth_basic "What's the password?";
auth_basic_user_file /etc/htpasswd.d/htpasswd.${user};
}
# Allow the API External Access via NGINX
location ^~ /radarr4k/api {
auth_basic off;
proxy_pass http://127.0.0.1:7888;
}
NGX
# Reload nginx
systemctl reload nginx
echo_progress_done "Nginx config applied"
fi
echo_progress_start "Generating configuration"
# Start radarr to config
systemctl stop radarr.service >>$log 2>&1
cat > /home/${user}/.config/radarr4k/config.xml << EOSC
<Config>
<LogLevel>info</LogLevel>
<UpdateMechanism>BuiltIn</UpdateMechanism>
<Branch>master</Branch>
<BindAddress>127.0.0.1</BindAddress>
<Port>7888</Port>
<SslPort>6969</SslPort>
<EnableSsl>False</EnableSsl>
<LaunchBrowser>False</LaunchBrowser>
<AuthenticationMethod>None</AuthenticationMethod>
<UrlBase>radarr4k</UrlBase>
<UpdateAutomatically>False</UpdateAutomatically>
</Config>
EOSC
chown -R ${user}:${user} /home/${user}/.config/radarr4k/config.xml
systemctl enable --now radarr.service >>$log 2>&1
sleep 10
systemctl enable --now radarr4k.service >>$log 2>&1
echo_progress_start "Patching panel."
systemctl start radarr4k.service >>$log 2>&1
#Install Swizzin Panel Profiles
if [[ -f /install/.panel.lock ]]; then
cat <<EOF >>/opt/swizzin/core/custom/profiles.py
class radarr4k_meta:
name = "radarr4k"
pretty_name = "Radarr 4K"
baseurl = "/radarr4k"
systemd = "radarr4k"
check_theD = False
img = "radarr"
class radarr_meta(radarr_meta):
systemd = "radarr"
check_theD = False
EOF
fi
touch /install/.radarr4k.lock >>$log 2>&1
echo_progress_done "Panel patched."
systemctl restart panel >>$log 2>&1
echo_progress_done "Done."
}
#Asks if they'd like to install sonarr.
if [[ ! -f /install/.sonarr.lock ]]; then
echo -n "We see you dont have sonarr installed, would you like to install?(y/n) "
read -r VAR
if [[ $VAR == 'y' ]]; then
box install sonarr
if [[ $VAR == 'n' ]]; then
echo -n We wont install sonarr.
fi
fi
fi
#After confirming sonarr1, asks if theyd like another instance.
if [[ -f /install/.sonarr.lock ]]; then
echo -n "Would you like to install another instance of sonarr?(y/n) "
read -r VAR
if [[ $VAR == 'y' ]]; then
_sonarr4kinstall
fi
fi
#Asks if they'd like to install radarr.
if [[ ! -f /install/.radarr.lock ]]; then
echo -n "We see you dont have radarr installed, would you like to install?(y/n) "
read -r VAR
if [[ $VAR == 'y' ]]; then
box install radarr
if [[ $VAR == 'n' ]]; then
echo -n We wont install radarr.
fi
fi
fi
#After confirming radarr1, asks if theyd like another instance.
if [[ -f /install/.radarr.lock ]]; then
echo -n "Would you like to install another instance of radarr?(y/n) "
read -r VAR
if [[ $VAR == 'y' ]]; then
_radarr4kinstall
fi
fi