systemd 환경 파일에 변수가 허용됩니까?
[Unit]
Description=ServiceAuto
Requires=network-online.target
After=network-online.target
[Service]
EnvironmentFile=/etc/systemd/system/auto.service.d/env.conf
Type=simple
ExecStart="Script to execute"
IgnoreSIGPIPE=no
RestartSec=8
TimeoutStartSec=10
TimeoutStopSec=15
User=support
[Install]
WantedBy=multi-user.target
/etc/systemd/system/auto.service.d/env.conf에서 MAIN_HOME 변수를 사용할 수 있는지 알고 싶습니다. 예를 들어:
MAIN_HOME=/opt/prod
USER=support
PATH=/usr/java/jdk1.8.0_161/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/support/.local/bin:/home/support/bin
JAVA_HOME=/usr/java/jdk1.8.0_161
LD_LIBRARY_PATH=/$MAIN_HOME/bin:/usr/lib
답변1
systemd.exec(5)
매뉴얼 페이지 에서 :
EnvironmentFile= Similar to Environment= but reads the environment variables from a text file. [...]
...
Environment= [...] Variable expansion is not performed inside the strings, however, specifier expansion is possible. The $ character has no special meaning. [...]
그래서 아니야.