kaido/src/commands/install/install-transmission.sh

84 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
source /opt/kaido/src/libs/bash/lib.sh
# docs https://github.com/linuxserver/docker-transmission
# setup
imageName=docker.io/linuxserver/transmission:4.0.6-r4-ls294
containerName=transmission
dstBasePath="$KAIDO_CONTAINER_FOLDER/$containerName"
dstConfigPath="$dstBasePath/config"
dstDownloadPath="$dstBasePath/downloads"
dstWatchPath="$dstBasePath/watch"
# envs
externalPort=10101
torrentPort=51413
timezone="Europe/Rome"
themePath="/config/flood-for-transmission"
themeFileName="flood-for-transmission.zip"
themeDownloadUrl="https://github.com/johman10/flood-for-transmission/releases/download/latest/flood-for-transmission.zip"
secret_user=$containerName-user
secret_pass=$containerName-pass
if [ -f "$KAIDO_CONFIG_FOLDER/containers/$containerName/envs.sh" ]; then
source "$KAIDO_CONFIG_FOLDER/containers/$containerName/envs.sh"
fi
# pre install
create_folder "$dstConfigPath"
create_folder "$dstDownloadPath"
create_folder "$dstWatchPath"
stop_and_remove_container $containerName
res=0
secret_check $secret_user
res=$(($?+$res))
secret_check $secret_pass
res=$(($?+$res))
if [[ $res -gt 0 ]]; then
exit 1
fi
open_port $torrentPort/tcp
open_port $torrentPort/udp
# download theme
if [ ! -d "${dstBasePath}${themePath}" ]; then
mkdir -p /tmp/kaido/$containerName
wget "https://github.com/johman10/flood-for-transmission/releases/download/latest/flood-for-transmission.zip" -O "/tmp/kaido/$containerName/$themeFileName"
sudo unzip "/tmp/kaido/$containerName/$themeFileName" -d "$dstConfigPath"
rm "/tmp/kaido/$containerName/$themeFileName"
fi
# install
echo "Creating new container"
podman create \
--name $containerName \
--secret $secret_user,type=env,target=USER \
--secret $secret_pass,type=env,target=PASS \
-p $externalPort:9091/tcp \
-p $torrentPort:51413/tcp \
-p $torrentPort:51413/udp \
-v $dstConfigPath:/config \
-v $dstDownloadPath:/downloads \
-v $dstWatchPath:/watch \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=$timezone \
-e TRANSMISSION_WEB_HOME=$themePath \
$imageName
# systemd
create_systemd_services $containerName
systemctl --user enable --now $containerName