0

I have a GCP instance with Ubuntu 18.04, and I'm using GCP secret manager to pull down secrets at boot time with a script in /etc/profile.d, that way I can setup system-wide environment variables that are then used by my other services.

As I understood /etc/profile.d, these get source when a user logins, but my curiosity is that when I reboot the computer, without anyone log in, it seems the scripts were executed because the variables were populated (web server serves the pages just fine, which means the environment variables were set.

Can someone please shed some light on whether this is the right approach for this? And the reason why /etc/profile.d scripts are sourced without any user login?

Why are they executed at boot time?

Thank you!

TechOcean201
  • 101
  • 2
  • I didn't know that the contents of /etc/profile.d were executed on boot. But couldn't it be that your web server sources those scripts on starting? – Gerard H. Pille Apr 19 '20 at 12:47
  • Hi Gerard, they are not explicitly sourcing them; it's super curios that they are being sourced. Or maybe, GCP at boot is starting a session for root to do some sort of internal setup or check. I don't want to assume that they'll be executed after a boot because I might end up without those environment variables at one point.. Thanks! – TechOcean201 Apr 20 '20 at 01:54

1 Answers1

0

I confirmed with Google Cloud support that they indeed run a shell after login using root. Thus why those /etc/profile.d scripts were executing. Which in this case this is good enough for my situation. I hope this helps someone else in the future.

TechOcean201
  • 101
  • 2