Systemctl 无法在 openvpn 上运行脚本命令

Systemctl 无法在 openvpn 上运行脚本命令

奇怪的是 /usr/lib/systemd/system/[电子邮件保护]是一个简单的任务:

[Unit]
Description=OpenVPN Robust And Highly Flexible Tunneling Application On %I
After=network.target

[Service]
Type=notify
PrivateTmp=true
ExecStart=/usr/sbin/openvpn --cd /etc/openvpn/ --config %i.conf

[Install]
WantedBy=multi-user.target

然而,当我尝试制作一个自启动的 openvpn 脚本autoinit.serviceExecStart=/bin/bash /root/setvpn.sh

然而/root/setvpn.sh

#!/bin/bash
/usr/sbin/openvpn --config /etc/openvpn/tun0.conf

那么这次间接启动就遇到错误了:

# systemctl start autoinit
Warning: autoinit.service changed on disk. Run 'systemctl daemon-reload' to reload units.
# systemctl status autoinit
● autoinit.service - Sets up OpenVPN servers
   Loaded: loaded (/usr/lib/systemd/system/autoinit.service; enabled; vendor preset: disabled)
   Active: deactivating (stop-sigterm) since Fri 2020-05-15 18:54:50 CST; 12s ago
  Process: 10692 ExecStart=/root/setvpn.sh (code=exited, status=0/SUCCESS)
 Main PID: 10692 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/autoinit.service
           └─10694 /usr/sbin/openvpn --config /etc/openvpn/tun0.conf

其实如果我systemctl daemon-reload在启动这个 autoinit 服务之前运行它,它就会停止,根本无法启动。当然/root/setvpn.sh执行没有问题,为什么 systemctl 无法运行它呢?

相关内容