0

It is weird that the /usr/lib/systemd/system/openvpn@.service is a simple task:

[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

However, when I tried to make a self-start openvpn script like autoinit.service with ExecStart=/bin/bash /root/setvpn.sh

Where as /root/setvpn.sh:

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

Then this indirect start encounters a mistake:

# 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

Actually if I run systemctl daemon-reload before start this autoinit service, it will halt and cannot start at all. Of course /root/setvpn.sh has no problem of execution, why is that systemctl cannot run it?

George Y
  • 528
  • 6
  • 16

0 Answers0