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
static/static_root
images/
manager/hostname.py

View file

@ -22,7 +22,7 @@ restartwifi(){
. /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 commit
@ -40,7 +40,7 @@ if [ $(ipaddr) ]
sleep 10
if [ $(ipaddr) ]
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
done
else
@ -53,7 +53,7 @@ if [ $(ipaddr) ]
while [ True ]
do
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
fi

View file

@ -62,7 +62,7 @@ counter=0
while [ $counter -lt 60 ]
do
# 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
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
if [ $(ipaddr) ]
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
done
@ -122,6 +122,6 @@ startwifi
while [ True ]
do
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

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 .views import makewificonfig
from .hostname import hostname
import os
import time
@ -38,7 +39,7 @@ def mkfirmware(device, path):
# Write 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

View file

@ -25,9 +25,11 @@ chmod +x misc/make_config
sudo cp misc/make_config misc/base.conf /etc/openvpn/client-configs
openvpn --genkey --secret /etc/openvpn/ca/keys/ta.key
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 enable vpnmanager
sudo systemctl start vpnmanager
sudo systemctl enable 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"