Solved how to create a service in freebsd15.0 ?

Dear all:
i have openvpnclient in freebsd15.0 ...
when i want to connected vpnserver , i need to use root running "openvpn xxxx_config.ovpn" , now the the client work normal. this console was Occupated by openvpn program..and i want to disconnect vpnconnection. i must input "ctl + c" . i want to create service to start vpn connection in background and we can stop it using service command as below ..

service openvpnxxx status -------show the vpn connect status
service openvpnxxx stop -------stop the vpn connection
service openvpnxxx start -------start vpn connection....


thanks.
 
DEar all:
i have got it . when we install openvpn , the tools will create a script in /usr/local/etc/rc.d/openvpn....now we just modify the one line as below
eval ": \${${name}_configfile:=\"/usr/local/etc/openvpn/xxxx_config.ovpn\"}"

thanks. close this topic..
 
Do not modify the rc script. You should be able to just put the following in /etc/rc.conf

Code:
openvpn_enable="yes"
openvpn_configfile="/path/to/config"
 
Indeed, never edit the rc(8) scripts. If/when openvpn is updated your changes will get removed and the original file is restored.

And to do what you want from the first post:
cp /usr/local/etc/rc.d/openvpn /usr/local/etc/rc.d/openvpnxxx
Then in rc.conf you can set this:
Code:
openvpnxxx_enable="YES"
openvpnxxx_configfile="/usr/local/etc/openvpn/xxxx_config.ovpn"

The openvpn rc(8) script is specifically set up to allow this, so you can have multiple instances running, each with its own configuration.
 
Indeed, never edit the rc(8) scripts. If/when openvpn is updated your changes will get removed and the original file is restored.

And to do what you want from the first post:
cp /usr/local/etc/rc.d/openvpn /usr/local/etc/rc.d/openvpnxxx
Then in rc.conf you can set this:
Code:
openvpnxxx_enable="YES"
openvpnxxx_configfile="/usr/local/etc/openvpn/xxxx_config.ovpn"

The openvpn rc(8) script is specifically set up to allow this, so you can have multiple instances running, each with its own configuration.
Dear all:
thanks for your advisement. your are professional.
 
Back
Top