mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	Refactor: Tdarr (#6969)
This commit is contained in:
		
							
								
								
									
										36
									
								
								ct/tdarr.sh
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								ct/tdarr.sh
									
									
									
									
									
								
							@@ -20,18 +20,30 @@ color
 | 
				
			|||||||
catch_errors
 | 
					catch_errors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function update_script() {
 | 
					function update_script() {
 | 
				
			||||||
    header_info
 | 
					  header_info
 | 
				
			||||||
    check_container_storage
 | 
					  check_container_storage
 | 
				
			||||||
    check_container_resources
 | 
					  check_container_resources
 | 
				
			||||||
    if [[ ! -d /opt/tdarr ]]; then
 | 
					  if [[ ! -d /opt/tdarr ]]; then
 | 
				
			||||||
        msg_error "No ${APP} Installation Found!"
 | 
					    msg_error "No ${APP} Installation Found!"
 | 
				
			||||||
        exit
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
    msg_info "Updating $APP LXC"
 | 
					 | 
				
			||||||
    $STD apt-get update
 | 
					 | 
				
			||||||
    $STD apt-get -y upgrade
 | 
					 | 
				
			||||||
    msg_ok "Updated $APP LXC"
 | 
					 | 
				
			||||||
    exit
 | 
					    exit
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					  msg_info "Updating $APP LXC"
 | 
				
			||||||
 | 
					  $STD apt-get update
 | 
				
			||||||
 | 
					  $STD apt-get -y upgrade
 | 
				
			||||||
 | 
					  rm -rf /opt/tdarr/Tdarr_Updater
 | 
				
			||||||
 | 
					  cd /opt/tdarr
 | 
				
			||||||
 | 
					  RELEASE=$(curl -fsSL https://f000.backblazeb2.com/file/tdarrs/versions.json | grep -oP '(?<="Tdarr_Updater": ")[^"]+' | grep linux_x64 | head -n 1)
 | 
				
			||||||
 | 
					  curl -fsSL "$RELEASE" -o Tdarr_Updater.zip
 | 
				
			||||||
 | 
					  $STD unzip Tdarr_Updater.zip
 | 
				
			||||||
 | 
					  chmod +x Tdarr_Updater
 | 
				
			||||||
 | 
					  $STD ./Tdarr_Updater
 | 
				
			||||||
 | 
					  msg_ok "Updated $APP LXC"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  msg_info "Cleaning up"
 | 
				
			||||||
 | 
					  rm -rf /opt/tdarr/Tdarr_Updater.zip
 | 
				
			||||||
 | 
					  msg_ok "Cleaned"
 | 
				
			||||||
 | 
					  msg_ok "$APP has been successfully updated!"
 | 
				
			||||||
 | 
					  exit
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
start
 | 
					start
 | 
				
			||||||
@@ -41,4 +53,4 @@ description
 | 
				
			|||||||
msg_ok "Completed Successfully!\n"
 | 
					msg_ok "Completed Successfully!\n"
 | 
				
			||||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
 | 
					echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
 | 
				
			||||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
 | 
					echo -e "${INFO}${YW} Access it using the following URL:${CL}"
 | 
				
			||||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8265${CL}"
 | 
					echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8265${CL}"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,7 @@
 | 
				
			|||||||
  ],
 | 
					  ],
 | 
				
			||||||
  "date_created": "2024-05-02",
 | 
					  "date_created": "2024-05-02",
 | 
				
			||||||
  "type": "ct",
 | 
					  "type": "ct",
 | 
				
			||||||
  "updateable": false,
 | 
					  "updateable": true,
 | 
				
			||||||
  "privileged": false,
 | 
					  "privileged": false,
 | 
				
			||||||
  "interface_port": 8265,
 | 
					  "interface_port": 8265,
 | 
				
			||||||
  "documentation": null,
 | 
					  "documentation": null,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,16 @@ msg_info "Installing Dependencies"
 | 
				
			|||||||
$STD apt-get install -y handbrake-cli
 | 
					$STD apt-get install -y handbrake-cli
 | 
				
			||||||
msg_ok "Installed Dependencies"
 | 
					msg_ok "Installed Dependencies"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Installing Tdarr"
 | 
				
			||||||
 | 
					mkdir -p /opt/tdarr
 | 
				
			||||||
 | 
					cd /opt/tdarr
 | 
				
			||||||
 | 
					RELEASE=$(curl -fsSL https://f000.backblazeb2.com/file/tdarrs/versions.json | grep -oP '(?<="Tdarr_Updater": ")[^"]+' | grep linux_x64 | head -n 1)
 | 
				
			||||||
 | 
					curl -fsSL "$RELEASE" -o Tdarr_Updater.zip
 | 
				
			||||||
 | 
					$STD unzip Tdarr_Updater.zip
 | 
				
			||||||
 | 
					chmod +x Tdarr_Updater
 | 
				
			||||||
 | 
					$STD ./Tdarr_Updater
 | 
				
			||||||
 | 
					msg_ok "Installed Tdarr"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Setting Up Hardware Acceleration"
 | 
					msg_info "Setting Up Hardware Acceleration"
 | 
				
			||||||
$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
 | 
					$STD apt-get -y install {va-driver-all,ocl-icd-libopencl1,intel-opencl-icd,vainfo,intel-gpu-tools}
 | 
				
			||||||
if [[ "$CTTYPE" == "0" ]]; then
 | 
					if [[ "$CTTYPE" == "0" ]]; then
 | 
				
			||||||
@@ -25,29 +35,14 @@ if [[ "$CTTYPE" == "0" ]]; then
 | 
				
			|||||||
  chmod 660 /dev/dri/*
 | 
					  chmod 660 /dev/dri/*
 | 
				
			||||||
  $STD adduser $(id -u -n) video
 | 
					  $STD adduser $(id -u -n) video
 | 
				
			||||||
  $STD adduser $(id -u -n) render
 | 
					  $STD adduser $(id -u -n) render
 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
msg_ok "Set Up Hardware Acceleration"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
msg_info "Installing Tdarr"
 | 
					 | 
				
			||||||
mkdir -p /opt/tdarr
 | 
					 | 
				
			||||||
cd /opt/tdarr
 | 
					 | 
				
			||||||
RELEASE=$(curl -fsSL https://f000.backblazeb2.com/file/tdarrs/versions.json | grep -oP '(?<="Tdarr_Updater": ")[^"]+' | grep linux_x64 | head -n 1)
 | 
					 | 
				
			||||||
curl -fsSL "$RELEASE" -o $(basename "$RELEASE")
 | 
					 | 
				
			||||||
$STD unzip Tdarr_Updater.zip
 | 
					 | 
				
			||||||
rm -rf Tdarr_Updater.zip
 | 
					 | 
				
			||||||
chmod +x Tdarr_Updater
 | 
					 | 
				
			||||||
./Tdarr_Updater &>/dev/null
 | 
					 | 
				
			||||||
if [[ "$CTTYPE" == "0" ]]; then
 | 
					 | 
				
			||||||
  sed -i -e 's/^sgx:x:104:$/render:x:104:root/' -e 's/^render:x:106:root$/sgx:x:106:/' /etc/group
 | 
					  sed -i -e 's/^sgx:x:104:$/render:x:104:root/' -e 's/^render:x:106:root$/sgx:x:106:/' /etc/group
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
  sed -i -e 's/^sgx:x:104:$/render:x:104:/' -e 's/^render:x:106:$/sgx:x:106:/' /etc/group
 | 
					  sed -i -e 's/^sgx:x:104:$/render:x:104:/' -e 's/^render:x:106:$/sgx:x:106:/' /etc/group
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					msg_ok "Set Up Hardware Acceleration"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_ok "Installed Tdarr"
 | 
					cat <<EOF >/etc/systemd/system/tdarr-server.service
 | 
				
			||||||
 | 
					[Unit]
 | 
				
			||||||
msg_info "Creating Service"
 | 
					 | 
				
			||||||
service_path="/etc/systemd/system/tdarr-server.service"
 | 
					 | 
				
			||||||
echo "[Unit]
 | 
					 | 
				
			||||||
Description=Tdarr Server Daemon
 | 
					Description=Tdarr Server Daemon
 | 
				
			||||||
After=network.target
 | 
					After=network.target
 | 
				
			||||||
# Enable if using ZFS, edit and enable if other FS mounting is required to access directory
 | 
					# Enable if using ZFS, edit and enable if other FS mounting is required to access directory
 | 
				
			||||||
@@ -56,20 +51,20 @@ After=network.target
 | 
				
			|||||||
[Service]
 | 
					[Service]
 | 
				
			||||||
User=root
 | 
					User=root
 | 
				
			||||||
Group=root
 | 
					Group=root
 | 
				
			||||||
 | 
					 | 
				
			||||||
Type=simple
 | 
					Type=simple
 | 
				
			||||||
WorkingDirectory=/opt/tdarr/Tdarr_Server
 | 
					WorkingDirectory=/opt/tdarr/Tdarr_Server
 | 
				
			||||||
ExecStartPre=/opt/tdarr/Tdarr_Updater                  
 | 
					ExecStartPre=/opt/tdarr/Tdarr_Updater
 | 
				
			||||||
ExecStart=/opt/tdarr/Tdarr_Server/Tdarr_Server
 | 
					ExecStart=/opt/tdarr/Tdarr_Server/Tdarr_Server
 | 
				
			||||||
TimeoutStopSec=20
 | 
					TimeoutStopSec=20
 | 
				
			||||||
KillMode=process
 | 
					KillMode=process
 | 
				
			||||||
Restart=on-failure
 | 
					Restart=on-failure
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[Install]
 | 
					[Install]
 | 
				
			||||||
WantedBy=multi-user.target" >$service_path
 | 
					WantedBy=multi-user.target
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
service_path="/etc/systemd/system/tdarr-node.service"
 | 
					cat <<EOF >/etc/systemd/system/tdarr-node.service
 | 
				
			||||||
echo "[Unit]
 | 
					[Unit]
 | 
				
			||||||
Description=Tdarr Node Daemon
 | 
					Description=Tdarr Node Daemon
 | 
				
			||||||
After=network.target
 | 
					After=network.target
 | 
				
			||||||
Requires=tdarr-server.service
 | 
					Requires=tdarr-server.service
 | 
				
			||||||
@@ -77,7 +72,6 @@ Requires=tdarr-server.service
 | 
				
			|||||||
[Service]
 | 
					[Service]
 | 
				
			||||||
User=root
 | 
					User=root
 | 
				
			||||||
Group=root
 | 
					Group=root
 | 
				
			||||||
 | 
					 | 
				
			||||||
Type=simple
 | 
					Type=simple
 | 
				
			||||||
WorkingDirectory=/opt/tdarr/Tdarr_Node
 | 
					WorkingDirectory=/opt/tdarr/Tdarr_Node
 | 
				
			||||||
ExecStart=/opt/tdarr/Tdarr_Node/Tdarr_Node
 | 
					ExecStart=/opt/tdarr/Tdarr_Node/Tdarr_Node
 | 
				
			||||||
@@ -86,16 +80,16 @@ KillMode=process
 | 
				
			|||||||
Restart=on-failure
 | 
					Restart=on-failure
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[Install]
 | 
					[Install]
 | 
				
			||||||
WantedBy=multi-user.target" >$service_path
 | 
					WantedBy=multi-user.target
 | 
				
			||||||
systemctl enable --now -q tdarr-server.service
 | 
					EOF
 | 
				
			||||||
systemctl enable --now -q tdarr-node.service
 | 
					systemctl enable --now -q tdarr-server tdarr-node
 | 
				
			||||||
msg_ok "Created Service"
 | 
					msg_ok "Created Service"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
motd_ssh
 | 
					motd_ssh
 | 
				
			||||||
customize
 | 
					customize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msg_info "Cleaning up"
 | 
					msg_info "Cleaning up"
 | 
				
			||||||
rm -rf Tdarr_Updater.zip
 | 
					rm -rf /opt/tdarr/Tdarr_Updater.zip
 | 
				
			||||||
$STD apt-get -y autoremove
 | 
					$STD apt-get -y autoremove
 | 
				
			||||||
$STD apt-get -y autoclean
 | 
					$STD apt-get -y autoclean
 | 
				
			||||||
msg_ok "Cleaned"
 | 
					msg_ok "Cleaned"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user