一、树莓派设置蒲公英进行外网访问
1.1 树莓派安装蒲公英客户端
PgyVPN_Raspbian_2.2.1_armhf_systemd.deb.txt
1.2 创建启动蒲公英服务脚本
#!/bin/sh
#/etc/init.d/pgyvpnservice.sh
### BEGIN INIT INFO
# Provides:testboot
# Required-Start:$remote_fs $syslog
# Required-Stop:$remote_fs $syslog
# Default-Start:2 3 4 5
# Default-Stop:0 1 6
# Short-Description: testboot
# Description: This service is used to start my applaction
### END INIT INFO
case "$1" in
start)
echo "启动蒲公英异地组网"
su root -c "pgyvpn" # 以root模式执行pgyvpn指令打开蒲公英
;;
stop)
echo "执行完毕"
;;
esac
五、其他
5.1 创建网络检测脚本
#!/bin/bash
#检测网络链接&&ftp上传数据
declare -i n=0 #创建变量n并声明为数值
while [ $n -ne 1 ] #判断n是否不等于1
do
ret_code=`curl -I -s --connect-timeout 5 baidu.com -w %{http_code} | tail -n1` #网络值
if [ "$ret_code" = "200" ]; then
nohup /home/pi/Desktop/pgyvpnservice.sh & #网络连接成功后需要启动的程序脚本,即pgyvpnservice.sh
n=1;
else
n=0; #失败等待
fi
done