diff --git a/simple-torrent/docker-compose.yml b/simple-torrent/docker-compose.yml index 2cf4ab2..7e282f1 100644 --- a/simple-torrent/docker-compose.yml +++ b/simple-torrent/docker-compose.yml @@ -15,5 +15,5 @@ services: --config-path /config/simple-torrent.json volumes: - ${APP_DATA_DIR}/data/torrents:/torrents - - ${APP_DATA_DIR}/data/downloads:/downloads + - ${UMBREL_ROOT}/data/storage/downloads:/downloads - ${APP_DATA_DIR}/data/config:/config diff --git a/simple-torrent/hooks/pre-start b/simple-torrent/hooks/pre-start new file mode 100755 index 0000000..62c84db --- /dev/null +++ b/simple-torrent/hooks/pre-start @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +set -euo pipefail + +# The purpose of this pre-start hook is to migrate +# the local downloads folder for existing installations +# to Umbrel's shared downloads folder + +APP_DATA_DIR="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)" +UMBREL_ROOT="${APP_DATA_DIR}/../.." + +# We need to ensure Umbrel's shared download folder +# exists and is owned by the correct user +UMBREL_DATA_DIR="${UMBREL_ROOT}/data" +UMBREL_DATA_STORAGE_DIR="${UMBREL_DATA_DIR}/storage" +UMBREL_DATA_STORAGE_DOWNLOADS_DIR="${UMBREL_DATA_STORAGE_DIR}/downloads" +DESIRED_OWNER="1000:1000" + +if [[ ! -d "${UMBREL_DATA_STORAGE_DOWNLOADS_DIR}" ]]; then + mkdir -p "${UMBREL_DATA_STORAGE_DOWNLOADS_DIR}" +fi + +simpletorrent_correct_permission() { + local -r path="${1}" + + if [[ -d "${path}" ]]; then + owner=$(stat -c "%u:%g" "${path}") + + if [[ "${owner}" != "${DESIRED_OWNER}" ]]; then + chown "${DESIRED_OWNER}" "${path}" + fi + fi +} + +simpletorrent_correct_permission "${UMBREL_DATA_DIR}" +simpletorrent_correct_permission "${UMBREL_DATA_STORAGE_DIR}" +simpletorrent_correct_permission "${UMBREL_DATA_STORAGE_DOWNLOADS_DIR}" + +# Migrate existing installations to use the shared downloads directory +LOCAL_DOWNLOADS_DIR="${APP_DATA_DIR}/data/downloads" + +if [[ ! -d "${LOCAL_DOWNLOADS_DIR}" ]]; then + echo "No local downloads directory found. Skipping migration..." + exit +fi + +# Check if local downloads is not empty +if [[ "$(ls -l "${LOCAL_DOWNLOADS_DIR}" | wc -l)" -gt "1" ]]; then + # Move contents of local downloads folder to Umbrel's shared downloads folder + mv --verbose "${LOCAL_DOWNLOADS_DIR}/"* "${UMBREL_DATA_STORAGE_DOWNLOADS_DIR}" +fi + +# Check if the local downloads directory is now empty +if [[ "$(ls -l "${LOCAL_DOWNLOADS_DIR}" | wc -l)" -gt "1" ]]; then + echo "Failed to migrate local downloads directory: ${LOCAL_DOWNLOADS_DIR}" + echo "This directory still contains files/folders..." + exit +fi + +rm -rf "${LOCAL_DOWNLOADS_DIR}" + +echo "Local downloads directory successfully migrated" \ No newline at end of file diff --git a/simple-torrent/umbrel-app.yml b/simple-torrent/umbrel-app.yml index a897199..594d0f2 100644 --- a/simple-torrent/umbrel-app.yml +++ b/simple-torrent/umbrel-app.yml @@ -1,8 +1,8 @@ -manifestVersion: 1 +manifestVersion: 1.1 id: simple-torrent category: Networking name: SimpleTorrent -version: "1.3.9" +version: "1.3.9-hotfix-1" tagline: Download torrents with your Umbrel description: >- SimpleTorrent is a a self-hosted remote torrent client that starts @@ -28,6 +28,8 @@ description: >- - Protocol Handler to magnet: - Magnet RSS subscribing supported +releaseNotes: >- + - SimpleTorrent now utilizes the shared downloads folder that can be accessed by other apps on Umbrel, such as Jellyfin, File Browser, Transmission, Plex, and more. developer: Preston website: https://github.com/boypt dependencies: [] @@ -42,5 +44,7 @@ path: "" defaultUsername: "" defaultPassword: "" torOnly: false +permissions: + - STORAGE_DOWNLOADS submitter: Umbrel submission: https://github.com/getumbrel/umbrel/commit/b12c581ae14255c2087fc8e2f0e7014a351a363b \ No newline at end of file