Getting the Device UUID from a local unix user account (Non root)

I’m running a service on my raspberry PI that is not allowed to be “root”, so in my docker file I create a local user “acme”, group “acme”, and with systemctl it gets started up correctly with the correct permissions and ownership.

As the acme user, I want to get access to my device’s uuid so that I can use it to to uniquely identify my device when connecting to api services etc etc. However, the problem is that the local user doesn’t get access to the environment variables created within the resin system. The root account is fine:

[root shell] export |grep RESIN
declare -x RESIN="1"
declare -x RESIN_API_KEY="aaaabbbbccccdddd"
declare -x RESIN_APP_ID="12345"
declare -x RESIN_APP_NAME="MyCoolApplication"
declare -x RESIN_APP_RELEASE="asd65utausdtfuatsdfaudst3"
declare -x RESIN_DEVICE_NAME_AT_INIT="my-device-name"
declare -x RESIN_DEVICE_TYPE="raspberrypi3"
declare -x RESIN_DEVICE_UUID="cd30b2b12c29dffee398ef4a21c74f6c"
declare -x RESIN_HOST_OS_VERSION="Resin OS 2.7.8+rev1"
declare -x RESIN_SUPERVISOR_API_KEY="e273f0e426a54b87d19d8a43cbe4398adeff55gga5ddcf905edd0a197b"
declare -x RESIN_SUPERVISOR_PORT="48484"

But not in my newly created account “acme”:

[local shell] export |grep RESIN

If I had access to the device UUID in the Dockerfile.template, I could easy ensure that the value gets injected into the acme’s .profile or .bashrc acc, but it looks like resin doesn’t support that yet?

Am I missing something? Is there an easy way in which I can get this value? Or any environment value from a non root account?

The environment vars for root are stored in /proc/1/environ, but the security is tight (Which is as it should be):

-r-------- 1 root root 0 Feb 15 10:53 /proc/1/environ

So my local user cannot get access.

Anyone have any ideas?



the UUID isn’t available in Dockerfile.template, as the Docker build is being run on the build server rather than the device itself. This causes the build environment not to be able to do device-specific stuff.

A common practice with is to use a startup-script, which is run when the application starts. This would allow you to save the required variables wherever you want. For an example about the usage of a startup-script you can take a look at the many example projects provided, such as resin-rpi-python-picamera.


Hi there

Thanks for the response, and the tip.

Instead of calling CMD [“systemctl”, “start”, “liquidsoap”], I can just wrap it in a, in which I can use my root account to get the UUID, and push it to the .bashrc file of my local user. Once done I can then call sytemctl start liquidsoap.

Appreciate the help.