Make heartbeats to the test environment possible

This commit is contained in:
Kumi 2019-02-07 16:11:45 +00:00
parent 3ea5c941d9
commit 723aeb1946
6 changed files with 13 additions and 8 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ __pycache__
*.pyc *.pyc
static/static_root static/static_root
images/ images/
manager/hostname.py

View file

@ -22,7 +22,7 @@ restartwifi(){
. /etc/vpnsecret . /etc/vpnsecret
/usr/bin/wget -O/etc/hosts https://admin360.kumi.host/hosts --post-data "secret=$SECRET" --no-check-certificate >/var/log/wget 2>&1 /usr/bin/wget -O/etc/hosts https://$HOSTNAME/hosts --post-data "secret=$SECRET" --no-check-certificate >/var/log/wget 2>&1
/sbin/uci set wireless.@wifi-iface[0].network="VPN360" /sbin/uci set wireless.@wifi-iface[0].network="VPN360"
/sbin/uci commit /sbin/uci commit
@ -40,7 +40,7 @@ if [ $(ipaddr) ]
sleep 10 sleep 10
if [ $(ipaddr) ] if [ $(ipaddr) ]
then then
/usr/bin/wget -O- https://admin360.kumi.host/heartbeat --post-data "secret=$SECRET&ip=$(ipaddr)" --no-check-certificate 2>/var/log/wget | /bin/ash /usr/bin/wget -O- https://$HOSTNAME/heartbeat --post-data "secret=$SECRET&ip=$(ipaddr)" --no-check-certificate 2>/var/log/wget | /bin/ash
fi fi
done done
else else
@ -53,7 +53,7 @@ if [ $(ipaddr) ]
while [ True ] while [ True ]
do do
sleep 10 sleep 10
/usr/bin/wget -O- https://admin360.kumi.host/heartbeat --post-data "secret=$SECRET" --no-check-certificate 2>/var/log/wget | /bin/ash /usr/bin/wget -O- https://$HOSTNAME/heartbeat --post-data "secret=$SECRET" --no-check-certificate 2>/var/log/wget | /bin/ash
done done
fi fi

View file

@ -62,7 +62,7 @@ counter=0
while [ $counter -lt 60 ] while [ $counter -lt 60 ]
do do
# Retrieve hosts file from server # Retrieve hosts file from server
if /usr/bin/wget -O/etc/hosts https://admin360.kumi.host/hosts --timeout=2 --post-data "secret=$SECRET" --no-check-certificate >/var/log/wget 2>&1 if /usr/bin/wget -O/etc/hosts https://$HOSTNAME/hosts --timeout=2 --post-data "secret=$SECRET" --no-check-certificate >/var/log/wget 2>&1
then then
if pgrep "openvpn" >/dev/null if pgrep "openvpn" >/dev/null
@ -87,7 +87,7 @@ while [ $counter -lt 60 ]
# We assume that users will reboot the device if it doesn't work for extended periods of time # We assume that users will reboot the device if it doesn't work for extended periods of time
if [ $(ipaddr) ] if [ $(ipaddr) ]
then then
/usr/bin/wget -O- https://admin360.kumi.host/heartbeat --post-data "secret=$SECRET&ip=$(ipaddr)" --no-check-certificate 2>/var/log/wget | /bin/ash /usr/bin/wget -O- https://$HOSTNAME/heartbeat --post-data "secret=$SECRET&ip=$(ipaddr)" --no-check-certificate 2>/var/log/wget | /bin/ash
fi fi
done done
@ -122,6 +122,6 @@ startwifi
while [ True ] while [ True ]
do do
sleep 10 sleep 10
/usr/bin/wget -O- https://admin360.kumi.host/heartbeat --post-data "secret=$SECRET" --no-check-certificate 2>/var/log/wget | /bin/ash /usr/bin/wget -O- https://$HOSTNAME/heartbeat --post-data "secret=$SECRET" --no-check-certificate 2>/var/log/wget | /bin/ash
done done

1
manager/hostname.dist.py Normal file
View file

@ -0,0 +1 @@
hostname="no.hostname.set"

View file

@ -2,6 +2,7 @@ from celery import shared_task
from distutils.dir_util import copy_tree from distutils.dir_util import copy_tree
from .views import makewificonfig from .views import makewificonfig
from .hostname import hostname
import os import os
import time import time
@ -38,7 +39,7 @@ def mkfirmware(device, path):
# Write secret # Write secret
with open(tempdir.name + "/etc/vpnsecret", "w") as secret: with open(tempdir.name + "/etc/vpnsecret", "w") as secret:
secret.write('SECRET="%s"' % device.secret) secret.write('SECRET="%s"\nHOSTNAME="%s"' % (device.secret, hostname)
# Write password # Write password

View file

@ -25,9 +25,11 @@ chmod +x misc/make_config
sudo cp misc/make_config misc/base.conf /etc/openvpn/client-configs sudo cp misc/make_config misc/base.conf /etc/openvpn/client-configs
openvpn --genkey --secret /etc/openvpn/ca/keys/ta.key openvpn --genkey --secret /etc/openvpn/ca/keys/ta.key
sudo chown vpn.vpn /etc/openvpn/client-configs -R sudo chown vpn.vpn /etc/openvpn/client-configs -R
cp manager/hostname.dist.py manager/hostname.py
sudo chown vpn.vpn . -R
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl enable vpnmanager sudo systemctl enable vpnmanager
sudo systemctl start vpnmanager sudo systemctl start vpnmanager
sudo systemctl enable celery sudo systemctl enable celery
sudo systemctl start celery sudo systemctl start celery
echo "This should be working so far. Now point your webserver to uwsgi.sock using its WSGI options. Be sure to include the static files at static/static_root/" echo "This should be working so far. Now point your webserver to uwsgi.sock using its WSGI options. Be sure to include the static files at static/static_root/ and don't forget to set the hostname in manager/hostname.py"