继上次收到了 V 友们的帮助,已经成功在树莓派上部署 kcptun,路由器上跑 ss-redir,还有一点开机启动的小问题

2017-02-25 14:52:30 +08:00
 henryshen233
在树莓派上我在 /etc/rc.local 里加进去了 kcptun 的启动语句,但是却不能运行,而 source /etc/etc/rc.local 是能够使 kcptun 跑起来的,并且我确定 /etc/rc.local 是能够开机加载的。另外我新建了一个 systemctl 服务,还是只能够 systemctl start XXX ,当我设置了 systemctl enable XXX 后还是不能开机自动启动,求解,谢谢帮助🙏
4568 次点击
所在节点    Linux
7 条回复
henryshen233
2017-02-25 14:55:23 +08:00
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
/home/pi/kcptun/client_linux_arm7 -c /home/pi/kcptun/kcptunclient.json &
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
/client_linux_arm7 -c /kcptunclient.json &
exit 0
henryshen233
2017-02-25 14:55:43 +08:00
一楼是 /etc/rc.local
hmsea
2017-02-25 15:48:41 +08:00
pi@raspberrypi /etc/systemd/system $ cat kcptun.service
[Unit]
Description=Kcptun Client Service
After=network.target

[Service]
Type=simple
User=nobody
ExecStart=/usr/local/kcptun/kcptun-arm7 -c /usr/local/kcptun/bandwagon.json
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
liyvhg
2017-02-25 15:51:14 +08:00
@henryshen233 kcptun 是放在根目录吗?是否是路径设置错了
henryshen233
2017-02-25 15:54:02 +08:00
@hmsea have a try...
henryshen233
2017-02-25 15:55:44 +08:00
@liyvhg /etc/rc.local 倒数第二行请忽略,是多余的,路径没错的哈哈
henryshen233
2017-02-25 15:58:46 +08:00
@hmsea 谢谢兄弟啊啊啊,太感谢了,成功了,太感谢!!!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/343094

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX