Systemd service needs EnvironmentFile - but not found

Hello,

I am having trouble connecting to my university’s VPN. I am using the Cisco anyconnect client. The client creates the following vpnagentd.service which fails on system startup:

[Unit] 
Description=Cisco AnyConnect Secure Mobility Client Agent 

[Service] 
Type=simple
Restart=on-failure
ExecStartPre=/opt/cisco/anyconnect/bin/load_tun.sh
ExecStart=/opt/cisco/anyconnect/bin/vpnagentd -execv_instance
ExecReload=/bin/kill -HUP $MAINPID 
PIDFile=/var/run/vpnagentd.pid
KillMode=process
EnvironmentFile=/etc/environment

[Install] 
WantedBy=multi-user.target

I found in the logs that the service does not find the file /etc/environment.

After a little research I came across a reddit post that says the file was removed after a December update. The question now is, where did the file go or how else can I pass the environment file to the service?

P.S.: before the December update the client was working. Therefore I suspect that the EnvironmentFile line is causing the problem.

@Tmax Hi and welcome to the forum :smile:
That would be around /usr merge, you need to use /usr/etc/environment.

Nowhere. This file is still used if it exists. You just cannot and never could assume that it exists, so this unit should have used EnvironmentFile=-/etc/environment to ignore missing file.

What exactly “use” means here? You should not use this file to define your own variables because this file will be unconditionally overwritten on update. And adding your settings to /etc/environment.d will not work with this unit anyway.

I do not know what environment variables are used here, but if it is just for setting a couple of anyconnect specific variables, using unit-sepecific file would be much better.

Thanks for your fast reply. Changing the line to EnvironmentFile=/usr/etc/environment fixed the problem! The client is working again!

I better not count the time I spent solving the problem. :slightly_smiling_face:

@Tmax see what @arvidjaar indicated, does it use it? If going to adjust a service file, then also better to copy into /etc/systemd/system so it won’t be overwritten on an update as well.

Me neither. The service file was created by the Cisco installer (third party closed source software). I didn’t touch this file or add anything to it. I only noticed that the service failed because of the missing /etc/environment file.

I don’t know if the service needs any variables at all, and if so, which ones. My /usr/etc/environment file is empty, so I assume that the service does not need any variables.

Since it is not an openSUSE service, it should not be overwritten during a system update. The Unit file is already in /etc/systemd/system.

Thanks for your help.