Getting Jellyfin and NextCloud on the same page

My YunoHost server

Hardware: Dell R720
YunoHost version: Powered by YunoHost 4.0.6.1 (stable).
I have access to my server : SSH, webadmin, direct access
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : not really. I have a RAID server.

Description of my issue

  • I have all of my media at /var/Multimedia/Picture (or Video, or eBook, etc)

This is because these are 2TB large and mountpoint is at /var. Yunohost is on / which is much smaller

  • Jellyfin can read the media on /var/Multimedia just fine, as can other apps
  • I want to use nextcloud to ease adding/removing files to /var/Multimedia
  • I’ve tried creating a nextcloud instance and then creating symbolic links like

ln -s /home/USER/yunohost.multimedia/Picture /var/Multimedia/Picture
or in /home/USER/share/Multimedia/Picture

In both cases nextcloud doesn’t read the files.

I also notice these in NC logs:

Following symlinks is not allowed ('/home/USER/Multimedia' -> '/home/yunohost.multimedia/USER/' not inside '/home/USER/')	

Following symlinks is not allowed ('/home/yunohost.multimedia/USER/Picture/Picture' -> '/var/Multimedia/Picture/' not inside '/home/yunohost.multimedia/USER/')	

Initlally when I installed NC I got an error about not having permission to create files so I tried following this YNH guide to permanently set NC to /var/Multimedia (preferred option) but eventually when I ran

sudo -u nextcloud php occ files:scan --all

I got the error that "you don’t have permission to run as www-data, this can be solved by giving access to webserver to config. I tried scrwing acround with chown and chgrp a dozen times but to no avail.

I might have borked this NC install, which is fine, and I can delete it and reinstall it but I’ve done this a few times now so I thought I’d ask for help :frowning:

But what’s your initial issue ? (you just jumped right into technical details without explaining what’s your issue / what you’re trying to achieve …)

I want to use Nextcloud to upload files to /var/Multimedia

I can’t get Nextcloud to read or show those folders

Here is what I did for a similar issue (between Syncthing, Nextcloud, and direct root mounts). Add jellyfin and nextcloud to each other’s group:

sudo usermod jellyfin -a -G nextcloud
sudo usermod nextcloud -a -G jellyfin

Then it depends on how you have mounted /var/Multimedia. The idea is to give the same permissions to both users.

  • If it’s a ext4 or equivalent partition, you need to chmod:
find /var/Multimedia -type d -exec chmod 0775 {} \;
find /var/Multimedia -type f -exec chmod 0664 {} \;
  • If its user, groups, and permissions are set as /etc/fstab options, I guess they are already set accordingly. If not, report back here, we will need to tune the uid, gid, fmask, and dmask options.

You may need to restart Jellyfin’s, NGINX, and PHP-FPM services.

Then you can add /var/Multimedia to Nextcloud external mounts (as a local directory, in its admin panel).

1 Like

they’re mounted through /etc/fstab I know!

it seems like I did something when fucking around with permissions and now jellyfin can’t access /var/Multimedia anymore either. so I’ll have a go at the commands you list here.

If I installed Ampache would I do a similar thing as you list here:

sudo usermod jellyfin -a -G Ampache ?

Please share your /etc/fstab and the result of ls -la /var/Multimedia (remove any confidential information, obviously), so that we can all be on the same page. :wink:

I would guess so, yes. Do not forget to do the same for ampache user.

/etc/fstab:


# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda3 during installation
UUID=BLABLA14d460438bee /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=BLABLA-E8D0  /boot/efi       vfat    umask=0077      0       1
# /var was on /dev/sdb during installation
UUID=BLABLA-3e3e80b219e3 /var            ext4    defaults        0       2
# swap was on /dev/sda2 during installation
UUID=BLABLA-83f9ea24bb0f none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0
/swap_seafile swap swap defaults 0 0 #Swap added by seafile

ls -la /var/Multimedia (before running the commands above:

drwxrwx---   13 nextcloud nextcloud  4096 Sep  6 12:22 .
drwxr-xr-x   16 root      root       4096 Sep  3 05:43 ..
drwxr-xr-x    8 nextcloud nextcloud  4096 Sep  6 03:15 appdata_ocncx4d736vt
drwxr-xr-x    4 nextcloud nextcloud  4096 Sep  3 23:56 Bak
drwxr-xr-x    3 nextcloud nextcloud  4096 Sep  6 12:22 USER
drwxr-xr-x    2 nextcloud nextcloud 20480 Jul  5 20:08 Comic
drwxrwxr-x+   4 nextcloud nextcloud  4096 Sep  6 12:36 eBook
drwxr-xr-x    2 nextcloud nextcloud  4096 Sep  6 03:15 files_external
drwxr-xr-x    2 nextcloud nextcloud  4096 Sep  6 03:12 mediawiki_ldap
drwxrwxr-x+ 186 nextcloud nextcloud  4096 Sep  6 12:37 Music
-rw-r-----    1 nextcloud nextcloud  4077 Sep  6 03:15 nextcloud.log
-rw-r--r--    1 root      root          2 Sep  6 03:11 .ocdata
drwxrwxr-x+  15 nextcloud nextcloud  4096 Sep  6 12:37 Picture
drwxr-xr-x    2 nextcloud nextcloud  4096 Sep  6 03:12 svc_wikijs_ldap
drwxrwxr-x+   4 nextcloud nextcloud  4096 Sep  6 12:38 Video

You can see from the drwxrwxr-x+ and drwxrwxr-x that I’ve been tinkering quite a bit with everything :upside_down_face::grimacing: still learning!!

I used this to add the storage by the way: https://yunohost.org/#/external_storage

I see that you used the ACLs (+ at the end of the permissions). They seem quite powerful but I am not used to them.
I have also realized that giving Nextcloud access to all Jellyfin files and vice-versa is not really safe, so let’s use an intermediary group multimedia.
Let’s reset everything.

sudo su
# Let's remove the previous unsafe groups
deluser jellyfin nextcloud
deluser nextcloud jellyfin
# Let's create the group and add its users
groupadd multimedia
usermod jellyfin -a -G multimedia
usermod nextcloud -a -G multimedia
# Are you sure there is a upper case A in Ampache ?
usermod Ampache -a -G multimedia
# Set permissions
chown nextcloud:multimedia -R /var/Multimedia
find /var/Multimedia -type d -exec chmod 0775 {} \;
find /var/Multimedia -type f -exec chmod 0664 {} \;
# Set ACLs (I did some research :p)
# Users will get ownership of their own files,
# but the group will always be multimedia
# I left the r permission to other, but you can replace it with 0
# if you only want the apps listed above to access the files
setfacl -d -m u::rwX,g::rwX,o::r /var/Multimedia
# Restart services
systemctl restart nginx
systemctl restart php7.3-fpm
systemctl restart jellyfin

Then add the external mount /var/Multimedia into Nextcloud. Jellyfin should now have write access to the directory too.

2 Likes
  1. thank you so much for your help and clear descriptions!!
  2. I just want to complement you on how beautifully written these commands are! the setfacl -d -m u::rwX,g::rwX,o::r /var/Multimedia is so well done! thank you and I’m glad you learned something from it!
  3. No, Ampache is definitely ‘ampache’ but my phone wanted to initial cap it first.
  4. The files seem like they show up in nextcloud, but the storage all shows as “pending.” I am not sure if this is because I was using symbolic links beforehand on the /var/Multimedia (to link them from /home/USER/yunohost.multimedia folders or if it is because it just takes NC awhile to read everything. I will try to poke around and delete symbolic links
1 Like

Okay: NC has access to /home/USER/Multimedia and /home/yunohost.multimedia/share/ and shows them here as Multimedia and Shared Multimedia respectively:

image

jellyfin does not seem to have access to /var/Multimedia and Ampache does not list anything currently (but might need to play around with settings).

This is what ls -la for /var/Multimedia reports:

drwxrwxr-x+  12 nextcloud multimedia  4096 Sep  8 00:35 .
drwxr-xr-x   16 root      root        4096 Sep  3 05:43 ..
drwxrwxr-x    4 nextcloud multimedia  4096 Sep  3 23:56 Bak
drwxrwxr-x    3 nextcloud multimedia  4096 Sep  6 12:22 _NCUSER
drwxrwxr-x    2 nextcloud multimedia 20480 Jul  5 20:08 Comic
drwxrwxr-x+   4 nextcloud multimedia  4096 Sep  6 12:36 eBook
drwxrwxr-x    2 nextcloud multimedia  4096 Sep  6 03:15 files_external
drwxrwxr-x    2 nextcloud multimedia  4096 Sep  6 03:12 mediawiki_ldap
drwxrwxr-x+ 186 nextcloud multimedia  4096 Sep  6 12:37 Music
drwxrwxr-x+  15 nextcloud multimedia  4096 Sep  6 12:37 Picture
drwxrwxr-x    2 nextcloud multimedia  4096 Sep  6 03:12 svc_wikijs_ldap
drwxrwxr-x+   4 nextcloud multimedia  4096 Sep  6 12:38 Video

I think I can delete

drwxrwxr-x 3 nextcloud multimedia 4096 Sep 6 12:22 NC_USER as I deleted the other leftover NC items

Ah! I’m an idiot, they totally show up in Nextcloud after I take the step of adding them via “External Storage”

re: Jellyfin—I thought I would just delete and reinstall but the install failed (if you’re very curious here are the logs: https://paste.yunohost.org/raw/hatixexudu) but it seems to be a jellyfin issue not a permissions issue, so I’ll chase that down. Thanks for giving me a guide (more or less) on how to do things going forward!

I think this may have been created as a side effect of the non-handling of symlinks by Nextcloud. If there is no data belonging to you in it, you can delete it yes.

Do not hesitate to report back here when Jellyfin is fixed. Did you have any luck with Ampache, finally?

1 Like

Ampache works! I’m not really a big fan of the interface, but it’ll work while Jellyfin is still being transitioned to buster :slight_smile: