softether server的安装配置(ubuntu、debian)

7.3.8 Registering a Startup Script

After installing vpnserver to the /usr/local/vpnserver/ directory using the method described above, you can configure your system to operate the vpnserver program as a service mode program by registering the /usr/local/vpnserver/vpnserverprogram as a daemon process that continues to run in the background while Linux is starting.

To register vpnserver to Linux as a daemon process, create a startup script, as shown below, with the name /etc/init.d/vpnserver. (The following startup script is a description example, and you may have to rewrite part of the script for it to work properly on your system.)

#!/bin/sh
# chkconfig: 2345 99 01
# description: SoftEther VPN Server
DAEMON=/usr/local/vpnserver/vpnserver
LOCK=/var/lock/subsys/vpnserver
test -x $DAEMON || exit 0
case "$1" in
start)
$DAEMON start
touch $LOCK
;;
stop)
$DAEMON stop
rm $LOCK
;;
restart)
$DAEMON stop
sleep 3
$DAEMON start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0

You can use a text editor or the cat command to write the above script to /etc/init.d/vpnserver as a text file. To use the cat command to create the script, press Ctrl + D after the line break in the final line, as shown below.

[root@machine vpnserver]# cat > /etc/init.d/vpnserver
#!/bin/sh
# chkconfig: 2345 99 01
# description: SoftEther VPN Server
DAEMON=/usr/local/vpnserver/vpnserver
LOCK=/var/lock/subsys/vpnserver
test -x $DAEMON || exit 0
case "$1" in
start)
$DAEMON start
touch $LOCK
;;
stop)
$DAEMON stop
rm $LOCK
;;
restart)
$DAEMON stop
sleep 3
$DAEMON start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0

After creating the /etc/init.d/vpnserver startup script, change the permissions for this script so that the script cannot be rewritten by a user without permissions.

[root@machine vpnserver]# chmod 755 /etc/init.d/vpnserver

Lastly, use the chkconfig command to allow the above startup script to start automatically in the background when the Linux kernel starts.

[root@machine vpnserver]# /sbin/chkconfig --add vpnserver

VPN Server is now prepared to run as a service mode program.

 

7.3.9 Starting and Stopping Service

VPN Server registered as a service mode program automatically starts when Linux starts and automatically stops when Linux shuts down. You can manually stop or restart the VPN Server service if you need to do so for management reasons.

To start or stop VPN Server registered as a service mode program, type the command below.

Starting the VPN Server Service

With the VPN Server service not running and with root permissions, type the following to start the VPN Server service.

[root@machine vpnserver]# /etc/init.d/vpnserver start

Stopping the VPN Server Service

With the VPN Server service running and with root permissions, type the following to stop the VPN Server service.

[root@machine vpnserver]# /etc/init.d/vpnserver stop

Cases in Which You Must Stop the VPN Server Service

The VPN Server service must be manually stopped in the following cases.

  • When manually editing or replacing the configuration file

  • When updating the vpnserver program and other files after the release of a new version of VPN Server (To replace the vpnserver, vpncmd and hamcore.se2 files, be sure to stop the service in advance.)

  • When you want to restart the service due to erratic behavior of the operating VPN Server

Forcibly Terminating the vpnserver Process

It is unlikely that VPN Server would malfunction due to a problem with the physical memory of the computer or a software bug. If this should occur and the VPN Server service does not respond when you try to stop the service using the method above, you can stop the service by forcibly terminating the vpnserver process. For the detailed method for forcibly terminating the vpnserver process, please refer to the method of using the kill command described in 3.2 Operating Modes.

7.3.10 Limitations when Starting with General User Rights

The Linux version of VPN Server can also be started with general user rights. When starting VPN Server as a user mode program with general user rights, the program cannot be registered as a system service, but when a general user starts the VPN Server program in the background by typing [./vpnserver start], unlike the Windows version, the Linux version of the vpnserver process can continue to run even after that user logs out. SoftEther VPN Project does not recommend actually operating VPN Server in user mode for the following reasons.


Powered By Z-BlogPHP 1.5.2 Zero

175.es

. theme by Plat together