mirror of
https://github.com/getumbrel/umbrel-apps.git
synced 2024-11-11 16:09:18 +00:00
Migrate contents of Simple torrent downloads directory to Umbrel's shared downloads directory (#356)
Co-authored-by: Steven Briscoe <me@stevenbriscoe.com> Co-authored-by: Mayank Chhabra <mayankchhabra9@gmail.com>
This commit is contained in:
parent
e7d6ff64cd
commit
ff5dce7a48
|
@ -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
|
||||
|
|
61
simple-torrent/hooks/pre-start
Executable file
61
simple-torrent/hooks/pre-start
Executable file
|
@ -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"
|
|
@ -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
|
Loading…
Reference in New Issue
Block a user