SensorsIot / IOTstack

Docker stack for getting started on IOT on the Raspberry PI
GNU General Public License v3.0
1.44k stars 307 forks source link

Remove assumption user ID is 1000 #553

Open ukkopahis opened 2 years ago

ukkopahis commented 2 years ago

DO NOT MERGE YET

On menu.sh start, store current UID and GID to .env, if they are missing. Use these to run services that support a custom user setting.

Lines added to .env by menu.sh are e.g.:

# Changing IOTSTACK_UID or IOTSTACK_GID after you have started the stack is not
# supported. File ownerships in the 'volumes'-folder won't automatically update
# to match, resulting in various problems.
IOTSTACK_UID=1000
IOTSTACK_GID=1000

And in templates and services:

services:
  wireguard:
     environment:
     - PUID=${IOTSTACK_UID:?IOTSTACK_UID must be defined in ~/IOTstack/.env}
     - PGID=${IOTSTACK_GID:?IOTSTACK_GID must be defined in ~/IOTstack/.env}

When dropping the ID=1000 assumption, there is only one chance to get this right:

Other small changes:

Resolves #542, Fixes #183

Paraphraser commented 2 years ago

Err - 100 ? Should that be 1000 ?

I think it's only the commit message above. I couldn't find any 100 in the changed files (but I do have ancient eyeballs).

ukkopahis commented 2 years ago

Err - 100 ? Should that be 1000 ?

I was trying to show what it does on a non-default install. Clarified.

ukkopahis commented 2 years ago

Alternate suggestion (NOT RECOMMENDED)

I think it's better to change this so a .env-file isn't needed nor generated.

Templates would still use the syntax allowing .env-use:

- PUID=${IOTSTACK_UID:?replace with your actual UID}

buildstackmenu.py would identify template environment variable values matching `^\${IOTSTACK[UG]ID:.*}$` and replace them with the actual UID/GID number of the user running the menu, resulting in a docker-compose.yml with e.g.

- PUID=1000

Resoning

Drawbacks