Allow splitting config, downloads and media paths via .env
Some checks failed
Check running / run (push) Has been cancelled
Some checks failed
Check running / run (push) Has been cancelled
Adds optional CONFIG_DIR, DOWNLOADS_DIR and MEDIA_DIR env variables so
users can spread configs, downloads and media across different drives
without restructuring ROOT_DIR. Each falls back to its ROOT_DIR-based
default when left empty, so existing setups keep working unchanged.
The -arr services (sonarr, radarr, lidarr, mylar3) now use a single
${DOWNLOADS_DIR}:/data parent bind with a ${MEDIA_DIR}:/data/media
overlay. This preserves TRaSH's single-/data-mount semantics inside
the container (hardlinks still work on one filesystem) while letting
the host-side media tree live wherever the user wants.
README documents the new variables, the generated folder structure,
recommended storage layouts, and the same-filesystem requirement for
hardlinks between downloads and media.
This commit is contained in:
63
setup.sh
63
setup.sh
@@ -5,10 +5,21 @@
|
||||
set -a
|
||||
source .env
|
||||
set +a
|
||||
# This is always going to complain about UID being a read-only variable.
|
||||
# This is always going to complain about UID being a read-only variable.
|
||||
# However that is not a problem and it's necessary for UID to be defined in the .env so that docker-compose.yml can take it.
|
||||
# Reminder to set the UID variable in .env if you haven't already. It needs to be the user you want to run docker as. Find what it should be by running "id -u" from that user's shell.
|
||||
|
||||
# Resolve location overrides. If the user didn't set CONFIG_DIR / DOWNLOADS_DIR / MEDIA_DIR in .env,
|
||||
# fall back to the ROOT_DIR-based defaults (which mirror what docker-compose.yml.sample uses).
|
||||
ROOT_DIR=${ROOT_DIR:-.}
|
||||
CONFIG_DIR=${CONFIG_DIR:-${ROOT_DIR}/config}
|
||||
DOWNLOADS_DIR=${DOWNLOADS_DIR:-${ROOT_DIR}/data}
|
||||
MEDIA_DIR=${MEDIA_DIR:-${ROOT_DIR}/data/media}
|
||||
|
||||
# NOTE on hardlinks: Sonarr/Radarr/etc. perform hardlinks and atomic moves from DOWNLOADS_DIR into
|
||||
# MEDIA_DIR. This only works if both paths sit on the SAME filesystem. If you've split them across
|
||||
# different drives or mounts, operations will silently fall back to copying.
|
||||
|
||||
# Make users and group
|
||||
sudo useradd sonarr -u $SONARR_UID
|
||||
sudo useradd radarr -u $RADARR_UID
|
||||
@@ -28,10 +39,10 @@ sudo groupadd mediacenter -g $MEDIACENTER_GID
|
||||
# Adds current user to the mediacenter group. This is recommended so that you can still have access to files inside the ezarr folder structure for manual control.
|
||||
# This is way better than just doing everything as root, especially on NFS shares. Also some services run as the default user anyway (Jellyfin, Tautulli).
|
||||
sudo usermod -a -G mediacenter $USER
|
||||
# When you add the user to the group the changes don't take effect immediately.
|
||||
# When you add the user to the group the changes don't take effect immediately.
|
||||
# You can force them by running "sudo newgrp mediacenter" but that won't always work and it's better to just reboot after the script finishes running.
|
||||
|
||||
# adds all the service users to the group
|
||||
# adds all the service users to the group
|
||||
sudo usermod -a -G mediacenter sonarr
|
||||
sudo usermod -a -G mediacenter radarr
|
||||
sudo usermod -a -G mediacenter lidarr
|
||||
@@ -47,29 +58,31 @@ sudo usermod -a -G mediacenter bazarr
|
||||
sudo usermod -a -G mediacenter audiobookshelf
|
||||
|
||||
# Make directories
|
||||
# ${ROOT_DIR:-.}/ means take the value from ROOT_DIR value, if failed or empty place it in the current folder
|
||||
sudo mkdir -pv ${ROOT_DIR:-.}/config/{sonarr,radarr,lidarr,mylar,prowlarr,qbittorrent,jackett,audiobookshelf,overseerr,plex,jellyfin,tautulli,sabnzbd,jellyseerr,bazarr}-config
|
||||
sudo mkdir -pv ${ROOT_DIR:-.}/data/{torrents,usenet,media}/{tv,movies,music,books,comics,audiobooks,podcasts,audiobookshelf-metadata}
|
||||
sudo mkdir -pv ${CONFIG_DIR}/{sonarr,radarr,lidarr,mylar,prowlarr,qbittorrent,jackett,audiobookshelf,overseerr,plex,jellyfin,tautulli,sabnzbd,jellyseerr,bazarr}-config
|
||||
sudo mkdir -pv ${DOWNLOADS_DIR}/{torrents,usenet}/{tv,movies,music,books,comics,audiobooks,podcasts}
|
||||
sudo mkdir -pv ${MEDIA_DIR}/{tv,movies,music,books,comics,audiobooks,podcasts,audiobookshelf-metadata}
|
||||
|
||||
# Set permissions
|
||||
sudo chmod -R 775 ${ROOT_DIR:-.}/data/
|
||||
sudo chmod -R 775 ${ROOT_DIR:-.}/config/
|
||||
sudo chown -R $UID:mediacenter ${ROOT_DIR:-.}/data/
|
||||
sudo chown -R $UID:mediacenter ${ROOT_DIR:-.}/config/
|
||||
sudo chown -R sonarr:mediacenter ${ROOT_DIR:-.}/config/sonarr-config
|
||||
sudo chown -R radarr:mediacenter ${ROOT_DIR:-.}/config/radarr-config
|
||||
sudo chown -R lidarr:mediacenter ${ROOT_DIR:-.}/config/lidarr-config
|
||||
sudo chown -R mylar:mediacenter ${ROOT_DIR:-.}/config/mylar-config
|
||||
sudo chown -R prowlarr:mediacenter ${ROOT_DIR:-.}/config/prowlarr-config
|
||||
sudo chown -R qbittorrent:mediacenter ${ROOT_DIR:-.}/config/qbittorrent-config
|
||||
sudo chown -R jackett:mediacenter ${ROOT_DIR:-.}/config/jackett-config
|
||||
sudo chown -R overseerr:mediacenter ${ROOT_DIR:-.}/config/overseerr-config
|
||||
sudo chown -R plex:mediacenter ${ROOT_DIR:-.}/config/plex-config
|
||||
sudo chown -R $UID:mediacenter ${ROOT_DIR:-.}/config/jellyfin-config
|
||||
sudo chown -R $UID:mediacenter ${ROOT_DIR:-.}/config/tautulli-config
|
||||
sudo chown -R sabnzbd:mediacenter ${ROOT_DIR:-.}/config/sabnzbd-config
|
||||
sudo chown -R jellyseerr:mediacenter ${ROOT_DIR:-.}/config/jellyseerr-config
|
||||
sudo chown -R bazarr:mediacenter ${ROOT_DIR:-.}/config/bazarr-config
|
||||
sudo chown -R audiobookshelf:mediacenter ${ROOT_DIR:-.}/config/audiobookshelf-config
|
||||
sudo chmod -R 775 ${DOWNLOADS_DIR}/
|
||||
sudo chmod -R 775 ${MEDIA_DIR}/
|
||||
sudo chmod -R 775 ${CONFIG_DIR}/
|
||||
sudo chown -R $UID:mediacenter ${DOWNLOADS_DIR}/
|
||||
sudo chown -R $UID:mediacenter ${MEDIA_DIR}/
|
||||
sudo chown -R $UID:mediacenter ${CONFIG_DIR}/
|
||||
sudo chown -R sonarr:mediacenter ${CONFIG_DIR}/sonarr-config
|
||||
sudo chown -R radarr:mediacenter ${CONFIG_DIR}/radarr-config
|
||||
sudo chown -R lidarr:mediacenter ${CONFIG_DIR}/lidarr-config
|
||||
sudo chown -R mylar:mediacenter ${CONFIG_DIR}/mylar-config
|
||||
sudo chown -R prowlarr:mediacenter ${CONFIG_DIR}/prowlarr-config
|
||||
sudo chown -R qbittorrent:mediacenter ${CONFIG_DIR}/qbittorrent-config
|
||||
sudo chown -R jackett:mediacenter ${CONFIG_DIR}/jackett-config
|
||||
sudo chown -R overseerr:mediacenter ${CONFIG_DIR}/overseerr-config
|
||||
sudo chown -R plex:mediacenter ${CONFIG_DIR}/plex-config
|
||||
sudo chown -R $UID:mediacenter ${CONFIG_DIR}/jellyfin-config
|
||||
sudo chown -R $UID:mediacenter ${CONFIG_DIR}/tautulli-config
|
||||
sudo chown -R sabnzbd:mediacenter ${CONFIG_DIR}/sabnzbd-config
|
||||
sudo chown -R jellyseerr:mediacenter ${CONFIG_DIR}/jellyseerr-config
|
||||
sudo chown -R bazarr:mediacenter ${CONFIG_DIR}/bazarr-config
|
||||
sudo chown -R audiobookshelf:mediacenter ${CONFIG_DIR}/audiobookshelf-config
|
||||
|
||||
echo "Done! It is recommended to reboot now."
|
||||
|
||||
Reference in New Issue
Block a user