Skip to content

Commit be6cc7d

Browse files
authored
Refactor: Tdarr (#6969)
1 parent 615049c commit be6cc7d

File tree

3 files changed

+47
-41
lines changed

3 files changed

+47
-41
lines changed

ct/tdarr.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,30 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
header_info
24-
check_container_storage
25-
check_container_resources
26-
if [[ ! -d /opt/tdarr ]]; then
27-
msg_error "No ${APP} Installation Found!"
28-
exit
29-
fi
30-
msg_info "Updating $APP LXC"
31-
$STD apt-get update
32-
$STD apt-get -y upgrade
33-
msg_ok "Updated $APP LXC"
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
if [[ ! -d /opt/tdarr ]]; then
27+
msg_error "No ${APP} Installation Found!"
3428
exit
29+
fi
30+
msg_info "Updating $APP LXC"
31+
$STD apt-get update
32+
$STD apt-get -y upgrade
33+
rm -rf /opt/tdarr/Tdarr_Updater
34+
cd /opt/tdarr
35+
RELEASE=$(curl -fsSL https://f000.backblazeb2.com/file/tdarrs/versions.json | grep -oP '(?<="Tdarr_Updater": ")[^"]+' | grep linux_x64 | head -n 1)
36+
curl -fsSL "$RELEASE" -o Tdarr_Updater.zip
37+
$STD unzip Tdarr_Updater.zip
38+
chmod +x Tdarr_Updater
39+
$STD ./Tdarr_Updater
40+
msg_ok "Updated $APP LXC"
41+
42+
msg_info "Cleaning up"
43+
rm -rf /opt/tdarr/Tdarr_Updater.zip
44+
msg_ok "Cleaned"
45+
msg_ok "$APP has been successfully updated!"
46+
exit
3547
}
3648

3749
start
@@ -41,4 +53,4 @@ description
4153
msg_ok "Completed Successfully!\n"
4254
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
4355
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
44-
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8265${CL}"
56+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8265${CL}"

frontend/public/json/tdarr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"date_created": "2024-05-02",
88
"type": "ct",
9-
"updateable": false,
9+
"updateable": true,
1010
"privileged": false,
1111
"interface_port": 8265,
1212
"documentation": null,

install/tdarr-install.sh

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ msg_info "Installing Dependencies"
1717
$STD apt-get install -y handbrake-cli
1818
msg_ok "Installed Dependencies"
1919

20+
msg_info "Installing Tdarr"
21+
mkdir -p /opt/tdarr
22+
cd /opt/tdarr
23+
RELEASE=$(curl -fsSL https://f000.backblazeb2.com/file/tdarrs/versions.json | grep -oP '(?<="Tdarr_Updater": ")[^"]+' | grep linux_x64 | head -n 1)
24+
curl -fsSL "$RELEASE" -o Tdarr_Updater.zip
25+
$STD unzip Tdarr_Updater.zip
26+
chmod +x Tdarr_Updater
27+
$STD ./Tdarr_Updater
28+
msg_ok "Installed Tdarr"
29+
2030
msg_info "Setting Up Hardware Acceleration"
2131
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
2232
if [[ "$CTTYPE" == "0" ]]; then
@@ -25,29 +35,14 @@ if [[ "$CTTYPE" == "0" ]]; then
2535
chmod 660 /dev/dri/*
2636
$STD adduser $(id -u -n) video
2737
$STD adduser $(id -u -n) render
28-
fi
29-
msg_ok "Set Up Hardware Acceleration"
30-
31-
msg_info "Installing Tdarr"
32-
mkdir -p /opt/tdarr
33-
cd /opt/tdarr
34-
RELEASE=$(curl -fsSL https://f000.backblazeb2.com/file/tdarrs/versions.json | grep -oP '(?<="Tdarr_Updater": ")[^"]+' | grep linux_x64 | head -n 1)
35-
curl -fsSL "$RELEASE" -o $(basename "$RELEASE")
36-
$STD unzip Tdarr_Updater.zip
37-
rm -rf Tdarr_Updater.zip
38-
chmod +x Tdarr_Updater
39-
./Tdarr_Updater &>/dev/null
40-
if [[ "$CTTYPE" == "0" ]]; then
4138
sed -i -e 's/^sgx:x:104:$/render:x:104:root/' -e 's/^render:x:106:root$/sgx:x:106:/' /etc/group
4239
else
4340
sed -i -e 's/^sgx:x:104:$/render:x:104:/' -e 's/^render:x:106:$/sgx:x:106:/' /etc/group
4441
fi
42+
msg_ok "Set Up Hardware Acceleration"
4543

46-
msg_ok "Installed Tdarr"
47-
48-
msg_info "Creating Service"
49-
service_path="/etc/systemd/system/tdarr-server.service"
50-
echo "[Unit]
44+
cat <<EOF >/etc/systemd/system/tdarr-server.service
45+
[Unit]
5146
Description=Tdarr Server Daemon
5247
After=network.target
5348
# Enable if using ZFS, edit and enable if other FS mounting is required to access directory
@@ -56,28 +51,27 @@ After=network.target
5651
[Service]
5752
User=root
5853
Group=root
59-
6054
Type=simple
6155
WorkingDirectory=/opt/tdarr/Tdarr_Server
62-
ExecStartPre=/opt/tdarr/Tdarr_Updater
56+
ExecStartPre=/opt/tdarr/Tdarr_Updater
6357
ExecStart=/opt/tdarr/Tdarr_Server/Tdarr_Server
6458
TimeoutStopSec=20
6559
KillMode=process
6660
Restart=on-failure
6761
6862
[Install]
69-
WantedBy=multi-user.target" >$service_path
63+
WantedBy=multi-user.target
64+
EOF
7065

71-
service_path="/etc/systemd/system/tdarr-node.service"
72-
echo "[Unit]
66+
cat <<EOF >/etc/systemd/system/tdarr-node.service
67+
[Unit]
7368
Description=Tdarr Node Daemon
7469
After=network.target
7570
Requires=tdarr-server.service
7671
7772
[Service]
7873
User=root
7974
Group=root
80-
8175
Type=simple
8276
WorkingDirectory=/opt/tdarr/Tdarr_Node
8377
ExecStart=/opt/tdarr/Tdarr_Node/Tdarr_Node
@@ -86,16 +80,16 @@ KillMode=process
8680
Restart=on-failure
8781
8882
[Install]
89-
WantedBy=multi-user.target" >$service_path
90-
systemctl enable --now -q tdarr-server.service
91-
systemctl enable --now -q tdarr-node.service
83+
WantedBy=multi-user.target
84+
EOF
85+
systemctl enable --now -q tdarr-server tdarr-node
9286
msg_ok "Created Service"
9387

9488
motd_ssh
9589
customize
9690

9791
msg_info "Cleaning up"
98-
rm -rf Tdarr_Updater.zip
92+
rm -rf /opt/tdarr/Tdarr_Updater.zip
9993
$STD apt-get -y autoremove
10094
$STD apt-get -y autoclean
10195
msg_ok "Cleaned"

0 commit comments

Comments
 (0)