2018-12-15 11:35:37 +00:00
|
|
|
ipaddr(){
|
|
|
|
if="${1:-br-VPN360}"
|
|
|
|
result=$(/sbin/ip -o -4 addr show dev "${if}" 2&>/dev/null | /bin/sed 's/^.*inet // ; s/\/...*$//')
|
|
|
|
/usr/bin/printf %s "${result}"
|
|
|
|
}
|
|
|
|
|
|
|
|
stopwifi(){
|
|
|
|
/sbin/uci set wireless.radio1.disabled=1
|
|
|
|
/sbin/uci commit
|
|
|
|
}
|
|
|
|
|
|
|
|
startwifi(){
|
|
|
|
/sbin/uci set wireless.radio1.disabled=0
|
|
|
|
/sbin/uci commit
|
|
|
|
/sbin/wifi
|
|
|
|
}
|
|
|
|
|
|
|
|
restartwifi(){
|
|
|
|
stopwifi
|
|
|
|
startwifi
|
|
|
|
}
|
|
|
|
|
|
|
|
. /etc/vpnsecret
|
|
|
|
|
2019-02-07 20:23:02 +00:00
|
|
|
/bin/wget -O/etc/hosts https://$HOSTNAME/hosts --post-data "secret=$SECRET" --no-check-certificate >/var/log/wget 2>&1
|
2018-12-15 11:35:37 +00:00
|
|
|
|
|
|
|
/sbin/uci set wireless.@wifi-iface[0].network="VPN360"
|
|
|
|
/sbin/uci commit
|
|
|
|
stopwifi
|
|
|
|
|
|
|
|
/usr/sbin/openvpn /etc/openvpn/client.conf >/var/log/openvpn &
|
|
|
|
|
|
|
|
/bin/sleep 60
|
|
|
|
|
|
|
|
if [ $(ipaddr) ]
|
|
|
|
then
|
|
|
|
startwifi
|
|
|
|
while [ True ]
|
|
|
|
do
|
|
|
|
sleep 10
|
|
|
|
if [ $(ipaddr) ]
|
|
|
|
then
|
2019-02-07 20:23:02 +00:00
|
|
|
/bin/wget -O- https://$HOSTNAME/heartbeat --post-data "secret=$SECRET&ip=$(ipaddr)" --no-check-certificate 2>/var/log/wget | /bin/ash
|
2018-12-15 11:35:37 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
/sbin/uci set wireless.@wifi-iface[0].network="DHCP"
|
|
|
|
/sbin/uci commit
|
|
|
|
startwifi
|
|
|
|
/sbin/ip a add 192.168.36.1/24 dev br-DHCP
|
|
|
|
/sbin/ifconfig br-DHCP down
|
|
|
|
/sbin/ifconfig br-DHCP up
|
|
|
|
while [ True ]
|
|
|
|
do
|
|
|
|
sleep 10
|
2019-02-07 20:23:02 +00:00
|
|
|
/bin/wget -O- https://$HOSTNAME/heartbeat --post-data "secret=$SECRET" --no-check-certificate 2>/var/log/wget | /bin/ash
|
2018-12-15 11:35:37 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|