Skip to main content
added 115 characters in body
Source Link
pkaramol
  • 3.1k
  • 9
  • 53
  • 84

I am trying to create a systemd service;

This service has a script that is supposed to use some environment variables;

So I created this:

cat /etc/systemd/system/atlantis-server.service [Service] ExecStart=/usr/local/bin/atlantis-server.sh 

Which points to this

pkara@atlantis-server:~$ cat /usr/local/bin/atlantis-server.sh #!/bin/bash source /etc/environment atlantis server --atlantis-url="$URL" --gitlab-user="$USERNAME" --gitlab-token="$TOKEN" --gitlab-webhook-secret="$SECRET" --gitlab-hostname="$HOSTNAME" --repo-whitelist="$REPO_WHITELIST" 

What I noticed (after some errors in my systemd logs) is that I had to explicitly source /etc/environment

(this is where the above vars are declared).

Why is this needed?

Aren't they globally visible?

edit: Adding this to the service definition did not solve the problem

Environment=/etc/environment 

I am trying to create a systemd service;

This service has a script that is supposed to use some environment variables;

So I created this:

cat /etc/systemd/system/atlantis-server.service [Service] ExecStart=/usr/local/bin/atlantis-server.sh 

Which points to this

pkara@atlantis-server:~$ cat /usr/local/bin/atlantis-server.sh #!/bin/bash source /etc/environment atlantis server --atlantis-url="$URL" --gitlab-user="$USERNAME" --gitlab-token="$TOKEN" --gitlab-webhook-secret="$SECRET" --gitlab-hostname="$HOSTNAME" --repo-whitelist="$REPO_WHITELIST" 

What I noticed (after some errors in my systemd logs) is that I had to explicitly source /etc/environment

(this is where the above vars are declared).

Why is this needed?

Aren't they globally visible?

I am trying to create a systemd service;

This service has a script that is supposed to use some environment variables;

So I created this:

cat /etc/systemd/system/atlantis-server.service [Service] ExecStart=/usr/local/bin/atlantis-server.sh 

Which points to this

pkara@atlantis-server:~$ cat /usr/local/bin/atlantis-server.sh #!/bin/bash source /etc/environment atlantis server --atlantis-url="$URL" --gitlab-user="$USERNAME" --gitlab-token="$TOKEN" --gitlab-webhook-secret="$SECRET" --gitlab-hostname="$HOSTNAME" --repo-whitelist="$REPO_WHITELIST" 

What I noticed (after some errors in my systemd logs) is that I had to explicitly source /etc/environment

(this is where the above vars are declared).

Why is this needed?

Aren't they globally visible?

edit: Adding this to the service definition did not solve the problem

Environment=/etc/environment 
Source Link
pkaramol
  • 3.1k
  • 9
  • 53
  • 84

Env vars in /etc/environment not globally visible?

I am trying to create a systemd service;

This service has a script that is supposed to use some environment variables;

So I created this:

cat /etc/systemd/system/atlantis-server.service [Service] ExecStart=/usr/local/bin/atlantis-server.sh 

Which points to this

pkara@atlantis-server:~$ cat /usr/local/bin/atlantis-server.sh #!/bin/bash source /etc/environment atlantis server --atlantis-url="$URL" --gitlab-user="$USERNAME" --gitlab-token="$TOKEN" --gitlab-webhook-secret="$SECRET" --gitlab-hostname="$HOSTNAME" --repo-whitelist="$REPO_WHITELIST" 

What I noticed (after some errors in my systemd logs) is that I had to explicitly source /etc/environment

(this is where the above vars are declared).

Why is this needed?

Aren't they globally visible?