vdrover 62 Posted May 7, 2023 Posted May 7, 2023 (edited) I have set up Emby using docker compose. I've configured the environment variables to run Emby as my Ubuntu user: environment: - PUID=1000 - PGID=1000 Since all my files are owned by UID 1000, managing media and using Emby works as expected. And the logs show clearly that Emby is running as UID 1000 (see attached). Today I began to experiment with post processing scripts. I created a simple bash script with the following content: #!/bin/bash touch "test2_$(date +"%F %T")" Running this script from the CLI creates a new file with the current timestamp in the same directory as the script. This works as expected, and does not require sudo. Here are the file permissions: -rwxrw-r--+ 1 username username 45 May 7 06:04 postprocessing.sh So far, so good. Next I configured the live recording to run this script in the `post processing` settings. After a recording is complete, the expected file is NOT created, and the logs show this: touch: cannot touch 'test2_2023-05-07 06:04:44': Permission denied If Emby is running as UID 1000, and the script runs normally outside Emby when logged in as user 1000, why is the permission denied? notably: $ id username uid=1000(username) gid=1000(username) Also, the parent directory of the bash script has the correct permissions to run as script works normally outside of Emby. It seems like the post-processing event does not respect the PUID/PGID environment variables set in docker. Am I missing something? Edited May 7, 2023 by vdrover
Q-Droid 989 Posted May 7, 2023 Posted May 7, 2023 Context, as in the location where the post processing script is being executed. The UID/GID 1000 might not have permissions in that directory. Add echo `pwd` or echo `/usr/bin/pwd` to the script to see where it's running and might have to redirect the output if it doesn't show in the log. It would be a good practice to define a working directory for all of the post processing actions and/or make use of the {path} argument to derive that location.
vdrover 62 Posted May 7, 2023 Author Posted May 7, 2023 `pwd` was excellent advice, and explains the issue. The script was trying to `touch` in a system folder, and not in the postprocessing folder that had the permissions for uid/gid 1000: /run/s6-rc:s6-rc-init:ImjAIL/servicedirs/svc-emby I took your advice and modified my script: #!/bin/bash touch /home/username/docker/appdata/emby/postprocessing/file.txt As above, this works as expected when I run it from the terminal. When it is run by Emby post processing, I get this error: `touch: cannot touch '/home/username/docker/appdata/emby/postprocessing/file.txt': No such file or directory` So the pwd command works, but not touch. Any thoughts?
Solution Q-Droid 989 Posted May 7, 2023 Solution Posted May 7, 2023 You have to reference the docker container paths, not the host side. In your case that might be /config/postprocessing?
vdrover 62 Posted May 7, 2023 Author Posted May 7, 2023 Just came to the same conclusion myself. Thanks for helping me work through it!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now