环境文件中的 systemd 用户和组
systemd user and group in environmentfile
我有一个看起来像这样的服务:
[Unit]
Description=someApplication
...
[Service]
EnvironmentFile=/path/to/environment.file
Type=simple
User=$APPLICATION_USER
Group=$APPLICATION_GROUP
ExecStart=/bin/bash -c "$APPLICATION_HOME/app.sh $APPLICATION_OPTS"
PIDFile=$APPLICATION_HOME/application.pid
...
在我的 environment.file 我有
APPLICATION_USER=test_user
APPLICATION_GROUP=test_group
APPLICATION_HOME=/opt/application
APPLICATION_OPTS= -d test
如果我尝试启动它,我会收到消息 "Unit application.service entered failed state." 如果我将用户和组的属性移动到它工作的服务中。
工作示例:
[Unit]
Description=someApplication
...
[Service]
EnvironmentFile=/path/to/environment.file
Type=simple
User=test_user
Group=test_group
ExecStart=/bin/bash -c "$APPLICATION_HOME/app.sh $APPLICATION_OPTS"
PIDFile=$APPLICATION_HOME/application.pid
有没有办法将用户和组移动到环境文件中?
Systemd 不支持 User 和 Group 选项的环境替换。参见 systemd.exec
您必须提供文字 string 或 id
我有一个看起来像这样的服务:
[Unit]
Description=someApplication
...
[Service]
EnvironmentFile=/path/to/environment.file
Type=simple
User=$APPLICATION_USER
Group=$APPLICATION_GROUP
ExecStart=/bin/bash -c "$APPLICATION_HOME/app.sh $APPLICATION_OPTS"
PIDFile=$APPLICATION_HOME/application.pid
...
在我的 environment.file 我有
APPLICATION_USER=test_user
APPLICATION_GROUP=test_group
APPLICATION_HOME=/opt/application
APPLICATION_OPTS= -d test
如果我尝试启动它,我会收到消息 "Unit application.service entered failed state." 如果我将用户和组的属性移动到它工作的服务中。
工作示例:
[Unit]
Description=someApplication
...
[Service]
EnvironmentFile=/path/to/environment.file
Type=simple
User=test_user
Group=test_group
ExecStart=/bin/bash -c "$APPLICATION_HOME/app.sh $APPLICATION_OPTS"
PIDFile=$APPLICATION_HOME/application.pid
有没有办法将用户和组移动到环境文件中?
Systemd 不支持 User 和 Group 选项的环境替换。参见 systemd.exec
您必须提供文字 string 或 id