ep1cman / unifi-protect-backup

Python tool to backup unifi event clips in realtime
MIT License
580 stars 25 forks source link

Ability to set custom conf directory and not run as root #16

Closed roastlechon closed 2 years ago

roastlechon commented 2 years ago

Description

I have this running on k3s, but had to set some additional parameters to not run as root, set a specific user, etc.

Ideally would be nice to change which directory to mount the rclone.conf file from with appropriate permissions, and run unif-protect-backup and rclone as a specific user.

What I Did

Currently I am mounting volume at /.config since that was the first place it looks for configuration. I am also running the container as non-root as well.

ep1cman commented 2 years ago

Hi,

Just to be sure I am understanding what you are asking for:

1) The script does not need to be run as root to work, so I am assuming you are asking for the user inside the docker container to not be root? and more specifically to run them as a user of your choice?

2) Again because the directory that rclone looks for its config falls outside of the scope of what this script does, I assume you are asking about the ability to change where rclone looks for the config file inside the container? Rclone uses the env variable RCLONE_CONFIG, so setting that should suffice for this.

roastlechon commented 2 years ago
  1. That is correct, ideally follow pattern where could specify user/group https://docs.linuxserver.io/general/understanding-puid-and-pgid

  2. Ah okay, I didnt know that theres an env variable for where to look for the rclone.conf file.

ep1cman commented 2 years ago

Can you check the Dockerfile in the docker_user branch? The only problem I have with this is that it will be a breaking change for anyone who already setup the old container since the config file location has changed.

roastlechon commented 2 years ago

I believe the dockerfile changes you have would mean that you need to compile the docker image when you want to use a new puid or pguid.

See these as examples for how linuxserver images work https://github.com/linuxserver/docker-pyload-ng/blob/main/Dockerfile which uses https://github.com/linuxserver/docker-baseimage-alpine/blob/master/Dockerfile as a base image, which has init processes for adduser https://github.com/linuxserver/docker-baseimage-alpine/tree/master/root/etc/cont-init.d

In regards to backwards compatibility, I think having a separate version or migration steps can work, or you could default to the original rclone conf path as a default

ep1cman commented 2 years ago

You are totally right, looks like I will need to adopt a more complex container in order to implement such a feature

roastlechon commented 2 years ago

If you would like I can try and tackle the issue and submit a PR!

ep1cman commented 2 years ago

That would be awesome!

ep1cman commented 2 years ago

I've taken a crack at it moving to the S6 init system like the linuxserver containers. I also took the opportunity to add some default settings for rclone. Your feedback would be appreciated

roastlechon commented 2 years ago

i was going to suggest using their base image and building on top of it, that way you dont have to maintain those scripts

roastlechon commented 2 years ago

Check out my #23 PR and let me know what you think