-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup.sh
771 lines (708 loc) · 25.4 KB
/
setup.sh
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
#!/bin/sh
clear
### SET GLOBAL VARIABLES ###
TEMPDIR="/tmp/pijarr"
APPLIST="jackett sonarr lidarr radarr readarr prowlarr bazarr qbittorrent-nox"
# Set terminal global variable for colors if supported.
if [ -t 1 ]; then
RED=$(printf '\033[31m')
GREEN=$(printf '\033[32m')
YELLOW=$(printf '\033[33m')
BLUE=$(printf '\033[34m')
MAGENTA=$(printf '\033[35m')
CYAN=$(printf '\033[36m')
BOLD=$(printf '\033[1m')
RESET=$(printf '\033[0m')
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
BOLD=""
RESET=""
fi
# Temporary directory for application sources
make_temp_dir() {
task_start "Creating temporary directory ${TEMPDIR}..."
mkdir -p "${TEMPDIR}" 2>/dev/null
check_result
}
remove_temp_dir() {
task_start "Removing temporary directory and files ${TEMPDIR}..."
rm -Rf "${TEMPDIR}" 2>/dev/null
check_result
}
task_start() {
printf "\r[TASK] ${1}$(tput el)"
}
task_fail() {
printf "\r[${RED}FAIL${RESET}] ${1}\n"
}
task_pass() {
printf "\r[${GREEN}PASS${RESET}] ${1}\n"
}
task_skip() {
printf "\r[${BLUE}SKIP${RESET}] ${1}\n"
}
task_info() {
printf "\r[${CYAN}INFO${RESET}] ${1}$(tput el)\n"
}
task_warn() {
printf "\r[${CYAN}WARN${RESET}] ${1}$(tput el)\n"
}
task_dbug() {
printf "\r[${YELLOW}DBUG${RESET}] ${1}$(tput el)\n"
}
title_case() {
printf "%s" "${1}" | tr '[:upper:]' '[:lower:]' | awk '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2) }}1'
}
lower_case() {
printf "%s" "${1}" | tr '[:upper:]' '[:lower:]'
}
upper_case() {
printf "%s" "${1}" | tr '[:lower:]' '[:upper:]'
}
check_result() {
if [ $? -eq 0 ]; then
task_pass
else
task_fail
fi
}
### START CHECK SYSTEM REQUIREMENTS AND ARCHITECTURE ###
if cat /proc/cpuinfo >/dev/null 2>&1; then
check_cpu=$(cat /proc/cpuinfo | grep 'model name' | head -1 | cut -d':' -f2 | xargs)
check_model=$(cat /proc/cpuinfo | grep Model | head -1 | cut -d':' -f2 | xargs)
if [ -z "${check_cpu}" ]; then
result="${check_model}"
else
result="${check_cpu}"
fi
if [ -n "${result}" ]; then
cpuBoardInfo="${result}"
fi
elif sysctl -a >/dev/null 2>&1; then
result=$(sysctl -a | egrep -i 'hw.model' | sed 's/[^ ]* //')
if [ -n "${result}" ]; then
cpuBoardInfo="${result}"
fi
fi
if command -v lsb_release >/dev/null 2>&1; then
dist=$(lsb_release -d --short)
osInfo="${dist}"
fi
if $(command -v uname) >/dev/null 2>&1; then
arch=$(uname -m)
kernel=$(uname -r)
kname=$(uname -s)
if [ -z "${dist}" ]; then
osInfo="${kname}"
fi
kernelInfo="${kernel}"
archInfo="${arch}"
fi
task_info "Checking hardware requirements..."
task_info "Detected: ${cpuBoardInfo}"
task_info "Detected: ${osInfo} ${kernelInfo}"
systemInfo="${cpuBoardInfo} ${kname} ${osInfo} ${kernelInfo} ${archInfo}"
case "${systemInfo}" in
*x86_64* | *X86_64* | *amd64* | *AMD64*)
task_pass "Detected: x86 64-Bit Architecture$(tput el)"
JACKETT_ARCH="AMDx64"
SERVARR_ARCH="x64"
;;
esac
case "${systemInfo}" in
*aarch64* | *AARCH64* | *arm64* | *ARM64* | *armv8* | *ARMV8*)
task_pass "Detected: ARM 64-Bit Architecture$(tput el)"
JACKETT_ARCH="ARM64"
SERVARR_ARCH="arm64"
;;
esac
case "${systemInfo}" in
*aarch32* | *AARCH32* | *arm32* | *ARM32* | *armv7l* | *ARMV7L*)
task_pass "Detected: ARM 32-Bit Architecture$(tput el)"
JACKETT_ARCH="ARM32"
SERVARR_ARCH="arm"
;;
esac
case "${systemInfo}" in
*linux* | *Linux* | *LINUX*) task_pass "Detected: Linux based OS$(tput el)" ;;
*)
task_fail "Linux required. Not detected. Exiting...$(tput el)"
echo ""
exit 1
;;
esac
### END CHECK SYSTEM REQUIREMENTS AND ARCHITECTURE ###
# Fetch latest jackett release from https://github.com/Jackett/Jackett/releases
if command -v curl >/dev/null 2>&1; then
# Run the curl command
jackett_latest=$(curl -s https://github.com/Jackett/Jackett/releases | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep Linux${JACKETT_ARCH}.tar.gz -A 0 | head -n 1)
jackett_src_url="https://github.com${jackett_latest}"
else
# Run the wget command
jackett_latest=$(wget -qO- https://github.com/Jackett/Jackett/releases | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep Linux${JACKETT_ARCH}.tar.gz -A 0 | head -n 1)
jackett_src_url="https://github.com${jackett_latest}"
fi
# Fetch latest radarr, lidarr and sonarr builds. Links below select latest release.
radarr_src_url="https://radarr.servarr.com/v1/update/master/updatefile?os=linux&runtime=netcore&arch=${SERVARR_ARCH}"
lidarr_src_url="https://lidarr.servarr.com/v1/update/master/updatefile?os=linux&runtime=netcore&arch=${SERVARR_ARCH}"
prowlarr_src_url="http://prowlarr.servarr.com/v1/update/master/updatefile?os=linux&runtime=netcore&arch=${SERVARR_ARCH}"
readarr_src_url="http://readarr.servarr.com/v1/update/develop/updatefile?os=linux&runtime=netcore&arch=${SERVARR_ARCH}"
sonarr_src_url="https://services.sonarr.tv/v1/download/main/latest?version=4&os=linux&arch=${SERVARR_ARCH}"
bazarr_src_url="https://github.com/morpheus65535/bazarr/releases/latest/download/bazarr.zip"
qbittorrent_nox_src_url="Not applicable. Installed via apt."
check_sources() {
task_info "Application Installation Source URLs"
for app in ${APPLIST}; do
app_var_name=$(echo "${app}" | tr '-' '_') # Replace hyphens with underscores
src_url_var="${app_var_name}_src_url"
src_url=$(eval echo \$"$src_url_var")
task_info "${app} src: ${src_url}"
done
}
# Function to pause script and check if the user wishes to continue.
check_continue() {
local response
while true; do
read -r -p "[${GREEN}USER${RESET}] Do you wish to continue (y/N)? " response
case "${response}" in
[yY][eE][sS] | [yY])
echo
break
;;
*)
echo
exit
;;
esac
done
}
press_any_key() {
echo ""
printf "%s " "[${GREEN}USER${RESET}] Press enter to continue..."
read ans
}
# Function to check if superuser or running using sudo
check_superuser() {
if [ "$(id -u)" -ne 0 ]; then
task_fail "Script must be run by superuser or using sudo command\n"
exit 1
fi
}
pkg_updates() {
task_info "Updating and upgrading packages using apt..."
apt update
apt upgrade -y
apt --fix-broken install -y
apt autoclean -y 2>/dev/null
apt autoremove -y 2>/dev/null
}
# Function to check if packages are installed and install them if they are not found.
pkg_install() {
for pkg in "${@}"; do
task_start "Checking for required package > ${pkg}"
pkgStatus=$(dpkg -s "${pkg}" 2>/dev/null)
result=$?
if [ "${result}" -ne 0 ]; then
task_warn "Package ${pkg} not installed.$(tput el)"
task_info "Installing ${pkg}..."
apt install -y "${pkg}"
else
task_pass "Package ${pkg} already installed.$(tput el)"
fi
done
}
pkg_remove() {
for pkg in "${@}"; do
task_start "Checking for required package > ${pkg}"
pkgStatus=$(dpkg -s "${pkg}" 2>/dev/null)
result=$?
if [ "${result}" -eq 0 ]; then
task_warn "Package ${pkg} installed.$(tput el)"
task_info "Removing ${pkg}..."
apt remove -y "${pkg}"
else
task_pass "Package ${pkg} not installed.$(tput el)"
fi
done
}
# Function to install all the dependencies including packages and server keys.
setup_dependencies() {
task_info "Installing required dependencies..."
pkg_install curl unzip apt-transport-https dirmngr gnupg ca-certificates
task_info "Installing mono, sqlite3 and supporting libraries..."
pkg_install mono-complete mediainfo sqlite3 libmono-cil-dev libchromaprint-tools
}
setup_bazarr_dependencies() {
task_info "Installing required Bazarr dependencies..."
pkg_install python3-dev python3-pip python3-libxml2 python3-lxml unrar-free unar ffmpeg libxml2-dev libxslt1-dev libatlas-base-dev
python_version=$(python3 -V 2>&1 | grep -Po '(?<=Python )\d+\.\d+')
# Attempt to install specific python3-venv version
if ! pkg_install python${python_version}-venv; then
# If installation fails, install the default python3-venv
pkg_install python3-venv
fi
}
# Function to output PiJARR ascii and details of script.
banner_info() {
printf '%s\n' "
${RED}▓▓▓▓▓▓▓▓▓▓▓▓ ${GREEN}▓▓▓▓${RESET} ▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓
${RED}▓▓▓▓ ▓▓▓▓ ${RESET} ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓
${RED}▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓${RESET} ▓▓▓▓ ▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓
${RED}▓▓▓▓ ▓▓▓▓${RESET} ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓
${RED}▓▓▓▓ ▓▓▓▓${RESET} ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓ ▓▓▓▓▓
"
}
script_info() {
banner_info
printf '%s\n' "
Description: Installer for Jackett, Sonarr, Radarr, Lidarr, Readarr, Prowler, and *Bazarr
Tested with Raspberry Pi 3 & 4 running offical Raspberry Pi OS 64-Bit.
Compatibility with other Intel AMD x64 (64-bit only) Debian based Linux distros
Author: github.com/pijarr
Notes: Requiries sudo/root superuser permissions to run.
*Bazarr requires Python3 and additional packages to be downloaded. It will be run
in a Python virtual environment (venv) to avoid dependency issues.
Commands \"apt update upgrade autoclean autoremove\" will be run upon continue.
This is to ensure all packages are up to date and latest versions are used.
If they are not already installed the required dependencies including
Mono (Cross platform, open source .NET framework) may take a while to
download and install.
After initial setup the web interface for the application may need a short time
to start before being available on the nominated host port.
"
}
# Primary function to install and configure the applications.
# Function can take one or more apps ie. setup_app jackett sonarr lidarr radarr
setup_app() {
clear
make_temp_dir
setup_dependencies
for app in "${@}"; do
if [ $(systemctl is-active "${app}") = "active" ]; then
task_skip "A service for ${app} is already exists."
continue
fi
date_stamp="$(date '+%Y-%m-%d %H%M')"
app_name="$(lower_case ${app})"
app_opt_path="/opt/$(title_case ${app_name})"
app_lib_path="/var/lib/${app}"
app_config_path="/var/lib/${app_name}/.config/$(title_case ${app_name})"
if [ "${app}" = "bazarr" ]; then
setup_bazarr_dependencies
file_extension="zip"
else
file_extension="tar.gz"
fi
app_user="${app_name}"
app_group="media"
src_url=${app_name}\_src_url
src_url=$(eval echo \$"$src_url")
new_file="${app_name}.${file_extension}"
task_info "Commencing install for ${app_name}..."
task_start "Adding ${app_user} service user..."
if id "${app_user}" >/dev/null 2>&1; then
task_pass "User account for ${app_user} already exists."
else
useradd -s /usr/sbin/nologin -d "/var/lib/${app_user}" -r -m -U "${app_user}" 2>/dev/null
check_result
fi
task_start "Adding ${app_group} service group..."
if getent group "${app_group}" >/dev/null 2>&1; then
task_pass "Group ${app_group} already exists."
else
groupadd "${app_group}" 2>/dev/null
check_result
fi
task_start "Adding ${app_user} to ${app_group} service group..."
if id "$app_user" | grep -qE "\b${app_group}\b"; then
task_pass "User $app_user is already a member of the ${app_group} group."
else
usermod -a -G "${app_group}" "$app_user"
check_result
fi
# Determine the actual username (not sudo or root)
actual_user="${SUDO_USER:-$USER}"
task_start "Adding ${actual_user} to ${app_group} service group..."
if id "$actual_user" | grep -qE "\b${app_group}\b"; then
task_pass "User $actual_user is already a member of the ${app_group} group."
else
usermod -a -G "${app_group}" "$actual_user"
check_result
fi
task_info "Download source URL: ${src_url}"
wget -O "${temp_dir}"/"${new_file}" -q --show-progress --progress=bar:force "${src_url}" 2>&1 &&
task_pass "Source file downloaded. SHA256: $(sha256sum ${temp_dir}/${new_file} | cut -d ' ' -f 1)$(tput el)"
task_info "Extracting ${temp_dir}/${new_file} to ${app_opt_path}..."
if [ "${app_name}" = "bazarr" ]; then
unzip "${temp_dir}/${new_file}" -d "${app_opt_path}"
task_info "Creating Python virtual environment (venv) for bazarr..."
python3 -m venv "${app_opt_path}/venv"
task_start "Activate Python venv for bazarr to install requirements..."
# /bin/sh alternative for source command
. "${app_opt_path}/venv/bin/activate"
check_result
task_info "Installing Bazarr Python import module requirements..."
pip install -r "${app_opt_path}/requirements.txt"
task_start "Deactivate Python venv..."
deactivate
check_result
else
tar -xf "${temp_dir}/${new_file}" -C "/opt/"
fi
task_start "Setting user permissions on ${app_opt_path}..."
chown -R "${app_user}":"${app_group}" "${app_opt_path}"
check_result
# Just in case some apps have permission problems with their /var/lib config working directories.
task_start "Creating /var/lib config files..."
mkdir -p "${app_config_path}"
check_result
task_start "Setting user permissions on ${app_lib_path}..."
chown -R "${app_user}":"${app_group}" "${app_lib_path}" &&
chmod 775 "${app_lib_path}"
check_result
# Begin writting out the service configuration file. Minor change needed for Jackett.
if [ "${app_name}" = "jackett" ]; then
app_exec="${app_opt_path}/${app_name}_launcher.sh"
elif [ "${app_name}" = "sonarr" ]; then
app_exec="${app_opt_path}/$(title_case ${app_name}) -nobrowser -data=${app_lib_path}"
elif [ "${app_name}" = "bazarr" ]; then
app_exec="${app_opt_path}/venv/bin/python ${app_opt_path}/bazarr.py"
else
app_exec="${app_opt_path}/$(title_case ${app_name})"
fi
task_start "Writing service configuration file /etc/systemd/system/${app_name}.service..."
tee /etc/systemd/system/"${app_name}".service 1>/dev/null <<EOF
# Generated by PiJARR ${date_stamp}
[Unit]
Description=$(title_case ${app_name}) Daemon
After=syslog.target network.target
[Service]
WorkingDirectory=${app_opt_path}
User=${app_user}
Group=${app_group}
UMask=0002
SyslogIdentifier=${app_name}
Restart=on-failure
RestartSec=5
Type=simple
ExecStart=${app_exec}
KillSignal=SIGINT
TimeoutStopSec=20
ExecStartPre=/bin/sleep 10
[Install]
WantedBy=multi-user.target
EOF
check_result
task_start "Reloading systemctl daemon..."
systemctl daemon-reload 2>/dev/null
check_result
task_start "Enabling auto start for ${app_name} service..."
systemctl enable "${app_name}" 2>/dev/null
check_result
task_start "Starting ${app_name} service..."
systemctl start "${app_name}" 2>/dev/null
check_result
check_service ${app_name}
task_info "Completed install for ${app_name}\n"
done
remove_temp_dir
}
# Function to assist in removing the applications and their configuration files
# Function can take one or more apps ie. remove_app jackett sonarr lidarr radarr
remove_app() {
clear
for app in "${@}"; do
app=$(lower_case "${app}")
app_opt_path="/opt/$(title_case "${app}")"
app_lib_path="/var/lib/${app}"
task_warn "You are about to delete all settings and files for ${app}..."
check_continue
task_info "Deleting existing settings or files for ${app}..."
task_start "Stopping ${app} service..."
systemctl stop "${app}" 2>/dev/null
task_pass
task_start "Removing ${app_opt_path}..."
if [ "${app_opt_path}" != "/opt" ] && [ "${app_opt_path}" != "/opt/" ]; then
rm -rf "${app_opt_path}" 2>/dev/null
task_pass
else
task_skip "Skipping removal of default /opt/ directory."
fi
task_start "Removing ${app_lib_path}..."
if [ "${app_lib_path}" != "/var/lib" ] && [ "${app_lib_path}" != "/var/lib/" ]; then
rm -rf "${app_lib_path}" 2>/dev/null
task_pass
else
task_skip "Skipping removal of default /var/lib/ directory."
fi
task_start "Removing service config /etc/systemd/system/${app}.service..."
rm "/etc/systemd/system/${app}.service"* 2>/dev/null
task_pass
task_info "Removing ${app} service user account..."
deluser "${app}" 2>/dev/null
task_start "Reloading systemctl daemon..."
systemctl daemon-reload 2>/dev/null
task_pass
task_info "${app} deleted.\n"
done
}
setup_qbittorrent_nox() {
date_stamp="$(date '+%Y-%m-%d %H%M')"
app_name="qbittorrent-nox"
app_user="${app_name}"
app_lib_path="/var/lib/${app_name}"
app_group="media"
task_info "Commencing install for ${app_name}..."
task_start "Adding ${app_user} service user..."
if id "${app_user}" >/dev/null 2>&1; then
task_pass "User account for ${app_user} already exists."
else
useradd -s /usr/sbin/nologin -d "/var/lib/${app_user}" -r -m -U "${app_user}" 2>/dev/null
check_result
fi
task_start "Adding ${app_group} service group..."
if getent group "${app_group}" >/dev/null 2>&1; then
task_pass "Group ${app_group} already exists."
else
groupadd "${app_group}" 2>/dev/null
check_result
fi
task_start "Adding ${app_user} to ${app_group} service group..."
if id "$app_user" | grep -qE "\b${app_group}\b"; then
task_pass "User $app_user is already a member of the ${app_group} group."
else
usermod -a -G "${app_group}" "$app_user"
check_result
fi
# Determine the actual username (not sudo or root)
actual_user="${SUDO_USER:-$USER}"
task_start "Adding ${actual_user} to ${app_group} service group..."
if id "$actual_user" | grep -qE "\b${app_group}\b"; then
task_pass "User $actual_user is already a member of the ${app_group} group."
else
usermod -a -G "${app_group}" "$actual_user"
check_result
fi
task_info "Installing ${app_name} package..."
pkg_install qbittorrent-nox
task_start "Setting user permissions on ${app_lib_path}..."
chown -R "${app_user}":"${app_group}" "${app_lib_path}" &&
chmod 775 "${app_lib_path}"
check_result
task_start "Writing service configuration file /etc/systemd/system/${app_name}.service..."
tee /etc/systemd/system/"${app_name}".service 1>/dev/null <<EOF
# Generated by PiJARR ${date_stamp}
[Unit]
Description=$(title_case ${app_name}) Daemon
After=syslog.target network.target
[Service]
User=${app_user}
Group=${app_group}
UMask=0002
SyslogIdentifier=${app_name}
Restart=on-failure
RestartSec=5
Type=forking
ExecStart=/usr/bin/qbittorrent-nox -d --webui-port=8080
KillSignal=SIGINT
TimeoutStopSec=20
[Install]
WantedBy=multi-user.target
EOF
check_result
task_start "Reloading systemctl daemon..."
systemctl daemon-reload 2>/dev/null
check_result
task_start "Enabling auto start for ${app_name} service..."
systemctl enable "${app_name}" 2>/dev/null
check_result
task_start "Starting ${app_name} service..."
systemctl start "${app_name}" 2>/dev/null
check_result
check_service "${app_name}"
task_info "Completed install for ${app_name}\n"
task_info "Default qBittorrent username: admin password: adminadmin"
task_info "Default qBittorrent save directory /var/lib/qbittorrent-nox/Downloads"
}
remove_qbittorrent_nox() {
app_name="qbittorrent-nox"
app_lib_path="/var/lib/${app_name}"
task_warn "You are about to delete all settings and files for ${app_name}..."
check_continue
task_info "Deleting existing settings or files for ${app_name}..."
task_start "Stopping ${app_name} service..."
systemctl stop "${app_name}" 2>/dev/null
task_pass
task_start "Removing service config /etc/systemd/system/${app_name}.service..."
rm "/etc/systemd/system/${app_name}.service"* 2>/dev/null
task_pass
pkg_remove qbittorrent-nox
task_info "Removing ${app} service user account..."
deluser "${app_name}" 2>/dev/null
task_start "Removing ${app_lib_path}..."
if [ "${app_lib_path}" != "/var/lib" ] && [ "${app_lib_path}" != "/var/lib/" ]; then
rm -rf "${app_lib_path}" 2>/dev/null
task_pass
else
task_skip "Skipping removal of default /var/lib/ directory."
fi
task_info "${app_name} deleted.\n"
}
active_services() {
task_info "Active Services"
for app in ${APPLIST}; do
if [ $(systemctl is-active "${app}") = "active" ]; then
task_pass "${app} service is active and running."
fi
done
}
check_service() {
task_start "Checking service status for ${1}..."
if [ $(systemctl is-active "$1") = "active" ]; then
task_pass
else
task_fail
fi
}
default_ports() {
task_info "Default Application Ports"
task_info "Jackett: http://hostip:9117"
task_info "Sonarr: http://hostip:8989"
task_info "Lidarr: http://hostip:8686"
task_info "Radarr: http://hostip:7878"
task_info "Readarr: http://hostip:8787"
task_info "Prowlarr: http://hostip:9696"
task_info "Bazarr: http://hostip:6767"
task_info "qBittorrent-nox: http://hostip:8080"
}
# Display a list of menu items for selection
display_menu() {
clear
banner_info
echo "=============="
echo " Menu Options "
echo "=============="
echo
printf "1. Install ALL (jackett sonarr lidarr radarr readarr prowlarr bazarr)\n"
printf "2. Install jackett only\n"
printf "3. Install sonarr only\n"
printf "4. Install lidarr only\n"
printf "5. Install radarr only\n"
printf "6. Install readarr only\n"
printf "7. Install prowlarr only\n"
printf "8. Install bazarr only\n"
printf "\n9. Install qbittorrent-nox (headless BitTorrent client)\n"
printf "\n10. Remove ALL (jackett sonarr lidarr radarr readarr prowlarr bazarr)\n"
printf "11. Remove jackett only\n"
printf "12. Remove sonarr only\n"
printf "13. Remove lidarr only\n"
printf "14. Remove radarr only\n"
printf "15. Remove readarr only\n"
printf "16. Remove prowlarr only\n"
printf "17. Remove bazarr only\n"
printf "\n18. Remove qbittorrent-nox\n"
printf "\n19. Show active services\n"
printf "20. Show application default ports\n"
printf "21. Show application source urls\n"
printf "\n22. Exit\n"
echo
printf " Enter option [1-22]: "
while :; do
read choice
case ${choice} in
1)
setup_app jackett sonarr lidarr radarr readarr prowlarr bazarr
;;
2)
setup_app jackett
;;
3)
setup_app sonarr
;;
4)
setup_app lidarr
;;
5)
setup_app radarr
;;
6)
setup_app readarr
;;
7)
setup_app prowlarr
;;
8)
setup_app bazarr
;;
9)
setup_qbittorrent_nox
;;
10)
remove_app jackett sonarr lidarr radarr readarr prowlarr bazarr
;;
11)
remove_app jackett
;;
12)
remove_app sonarr
;;
13)
remove_app lidarr
;;
14)
remove_app radarr
;;
15)
remove_app readarr
;;
16)
remove_app prowlarr
;;
17)
remove_app bazarr
;;
18)
remove_qbittorrent_nox
;;
19)
clear
active_services
;;
20)
clear
default_ports
;;
21)
clear
check_sources
;;
22)
printf "\nExiting...\n"
exit
;;
*)
clear
display_menu
;;
esac
printf "\nSelection [${choice}] completed.\n"
press_any_key
clear
display_menu
done
}
main() {
check_sources
script_info
check_superuser
check_continue
pkg_updates
check_status
display_menu
}
main