summaryrefslogtreecommitdiff
path: root/jellyfin/setup-media-user.sh
diff options
context:
space:
mode:
authorTyler Hoang <tyler@tylerhoang.xyz>2026-07-09 21:49:56 -0700
committerTyler Hoang <tyler@tylerhoang.xyz>2026-07-09 21:49:56 -0700
commit1d043702ef136e8f2e516c5304a57be5718f1f6f (patch)
tree9b3ad070f11dad5994c58acd41a15db8043745aa /jellyfin/setup-media-user.sh
Initial commit: docker compose files for all self-hosted servicesHEADmaster
12 services: adguard, ampache, azuracast, flood, glance, glances, grafana, immich, invidious, jellyfin, openwebui, watchtower Each service includes a docker-compose.yml, README.md with setup instructions, and .env.example where applicable.
Diffstat (limited to 'jellyfin/setup-media-user.sh')
-rwxr-xr-xjellyfin/setup-media-user.sh75
1 files changed, 75 insertions, 0 deletions
diff --git a/jellyfin/setup-media-user.sh b/jellyfin/setup-media-user.sh
new file mode 100755
index 0000000..d470c16
--- /dev/null
+++ b/jellyfin/setup-media-user.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+set -e
+
+echo "=== Creating dedicated media user (UID 1001) and group (GID 1001) ==="
+
+# Create the media group
+sudo groupadd -g 1001 media
+
+# Create the media user (no home dir, no login shell)
+sudo useradd -u 1001 -g media -s /usr/sbin/nologin -M media
+
+# Add tyler to media group so tyler can access files created by the media user
+sudo usermod -aG media tyler
+
+# Add media user to video and render groups for hardware transcoding access
+sudo usermod -aG video,render media
+
+echo "=== Fixing Jellyfin config/cache ownership ==="
+sudo chown -R 1001:1001 /home/tyler/docker/jellyfin/config
+sudo chown -R 1001:1001 /home/tyler/docker/jellyfin/cache
+
+echo "=== Creating config directories for Sonarr and Radarr ==="
+sudo mkdir -p /home/tyler/docker/jellyfin/sonarr-config
+sudo mkdir -p /home/tyler/docker/jellyfin/radarr-config
+sudo chown -R 1001:1001 /home/tyler/docker/jellyfin/sonarr-config
+sudo chown -R 1001:1001 /home/tyler/docker/jellyfin/radarr-config
+
+echo "=== Setting media group ownership on /srv/ directories ==="
+# Change group to media on all media directories
+sudo chown -R :media /srv/vids /srv/mus /srv/books /srv/photos /srv/roms /srv/torrents
+
+echo "=== Clearing conflicting POSIX ACLs (if any) ==="
+# ACLs from NAS/Samba can override Unix group permissions.
+# Strip them so our chmod/chown rules actually take effect.
+if command -v setfacl &>/dev/null; then
+ sudo setfacl -R -b /srv/vids /srv/mus /srv/books /srv/photos /srv/roms /srv/torrents 2>/dev/null || true
+else
+ echo "Warning: setfacl not found. Install the 'acl' package if you have ACL issues."
+fi
+
+echo "=== Setting directory sticky bit (g+s) so new files inherit media group ==="
+sudo find /srv/vids /srv/mus /srv/books /srv/photos /srv/roms /srv/torrents -type d -exec chmod g+s {} +
+
+echo "=== Setting base permissions ==="
+# Group read+execute on all directories
+sudo find /srv/vids /srv/mus /srv/books /srv/photos /srv/roms /srv/torrents -type d -exec chmod g+rx {} +
+
+# Group read on all files
+sudo find /srv/vids /srv/mus /srv/books /srv/photos /srv/roms /srv/torrents -type f -exec chmod g+r {} +
+
+echo "=== Setting write permissions for Sonarr/Radarr managed directories ==="
+# Allow group write on top-level dirs and recursively within them
+sudo chmod g+w /srv/vids/movies /srv/vids/shows /srv/torrents
+sudo find /srv/vids/movies /srv/vids/shows /srv/torrents -type d -exec chmod g+w {} +
+sudo find /srv/vids/movies /srv/vids/shows /srv/torrents -type f -exec chmod g+w {} +
+
+echo "=== Done! ==="
+echo ""
+echo "You will need to log out and back in (or run 'newgrp media') for the"
+echo "group changes to take effect in your current shell."
+echo ""
+echo "Start the stack with: docker compose up -d"
+echo ""
+echo "=== Web UI Configuration ==="
+echo "Sonarr (http://<host>:8989):"
+echo " - Root folder: /data/vids/shows"
+echo " - Download client path: /data/torrents"
+echo ""
+echo "Radarr (http://<host>:7878):"
+echo " - Root folder: /data/vids/movies"
+echo " - Download client path: /data/torrents"
+echo ""
+echo "If you add a download client later, mount it with /srv:/data too"
+echo "and set its download directory to /data/torrents."
+echo "This ensures paths match and hard links / fast moves work correctly."