运行 natapp 客户端
1
| chmod a+x /usr/natapp/natapp
|
注意:在官网下载客户端,放在目录/usr/natapp 中运行上面命令。
创建配置文件
注意:根据官网提供的 authtoken 将配置写入 config.ini,放置在/usr/natapp 目录。
测试运行情况
注意:在/usr/natapp 目录执行上面命令,测试穿透应用,确保无误后关闭客户端。
服务运行脚本
将下面的代码保存名为 natapp 放在/etc/init.d 目录:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| #!/bin/sh -e ### BEGIN INIT INFO # Provides: natapp.cn # Required-Start: $network $remote_fs $local_fs # Required-Stop: $network $remote_fs $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: autostartup of natapp for RaspberryPi ### END INIT INFO
NAME=natapp DAEMON=/usr/natapp/$NAME PIDFILE=/var/run/$NAME.pid
[ -x "$DAEMON" ] || exit 0
case "$1" in start) if [ -f $PIDFILE ]; then echo -n "$NAME already running" echo "." else echo "Starting $NAME..." start-stop-daemon -S -x $DAEMON -p $PIDFILE -m -b -o -q || return 2 echo "." fi ;; stop) echo "Stoping $NAME..." start-stop-daemon -K -p $PIDFILE -s TERM -o -q || return 2 rm -rf $PIDFILE echo "." ;; restart) $0 stop && sleep 2 && $0 start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac exit 0
|
开启服务命令:
1
| /etc/init.d/natapp start
|
关闭服务命令:
重启服务命令:
1
| /etc/init.d/natapp restart
|
开机启动命令:
1
| /etc/init.d/update-rc.d natapp defaults 90
|
取消开机启动:
1
| /etc/init.d/update-rc.d -f natapp remove
|
本文链接:https://my.lmcjl.com/post/18895.html
4 评论