Systemd服务单元中的此构造无法正常工作
ExecStartPre = /usr/bin/bash -c "systemctl set-environment BOSH_EXPORTER_BOSH_PASSWORD=$$(echo $$BOSH_CLIENT_SECRET)"
启动服务单元后,在预期的环境中找不到变量BOSH_EXPORTER_BOSH_PASSWORD变量:
$ sudo systemctl daemon-reload
$ sudo systemctl start bosh-exporter
$ sudo systemctl show-environment
LANG=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
$
设置了环境变量BOSH_CLIENT_SECRET 。
感谢指针。