Added common name to network, fix issue #1

This commit is contained in:
Julia Pfitzer 2019-01-03 18:29:49 +01:00
parent 120933aa33
commit aa75cfc0f7
3 changed files with 15 additions and 12 deletions

View file

@ -13,12 +13,13 @@ class Organization(models.Model):
return self.name return self.name
class Network(models.Model): class Network(models.Model):
commonname = models.CharField("Common Name", max_length=64, default="Network")
extip = models.CharField("External/Public IP", max_length=15) extip = models.CharField("External/Public IP", max_length=15)
intip = models.CharField("Internal/Private IP", max_length=15) intip = models.CharField("Internal/Private IP", max_length=15)
organizations = models.ManyToManyField(Organization) organizations = models.ManyToManyField(Organization)
def __str__(self): def __str__(self):
return "%s (%s)" % (self.intip, self.extip) return "%s (%s)" % (self.intip, self.commonname)
class Model(models.Model): class Model(models.Model):
name = models.CharField("Model Name", max_length=100, unique=True) name = models.CharField("Model Name", max_length=100, unique=True)

View file

@ -49,18 +49,20 @@ if /usr/bin/wget -O/tmp/wireless.in https://admin360.kumi.host/wireless --post-d
then then
while read p while read p
do do
if [[ $p == "# VPN360 WiFi Configuration" ]] echo $p >/tmp/wireless.line
if /bin/grep wifi-iface /tmp/wireless.line && ! /bin/grep radio /tmp/wireless.line;
then then
break break
fi fi
echo $p >>/tmp/wireless.og echo $p >>/tmp/wireless.og
done </etc/config/wireless done </etc/config/wireless
/bin/cat /tmp/wireless.in >>/tmp/wireless.og /bin/cat /tmp/wireless.in >>/tmp/wireless.og
/bin/mv /tmp/wireless.og /etc/config/wireless /bin/cp /tmp/wireless.og /etc/config/wireless
/sbin/uci commit /etc/config/wireless /sbin/uci commit /etc/config/wireless
/bin/rm /tmp/wireless.* /bin/rm /tmp/wireless.*
fi fi
""" """
device.lastbeat = timezone.now()
elif device.reboot: elif device.reboot:
code = "/sbin/reboot" code = "/sbin/reboot"
@ -77,18 +79,18 @@ fi
return HttpResponse(code) return HttpResponse(code)
def makewificonfig(device): def makewificonfig(device):
output = "\n# VPN360 WiFi Configuration\n" output = ""
i = 1
for wifi in device.wifi.all(): for wifi in device.wifi.all():
output += """ output += """config wifi-iface
config wifi-iface option network 'wwan%i'
option network 'wwan'
option ssid '%s' option ssid '%s'
option encryption 'psk2' option encryption 'psk2'
option device 'radio1' option device 'radio1'
option mode 'sta' option mode 'sta'
option key '%s' option key '%s'
""" % (wifi.ssid, wifi.key) """ % (i, wifi.ssid, wifi.key)
i += 1
return output return output
@ -236,7 +238,7 @@ def ping(request, device_id):
ajax += ',\n "network": {' ajax += ',\n "network": {'
ajax += '\n "intip": "%s"' % device[0].network.intip ajax += '\n "intip": "%s"' % device[0].network.intip
ajax += ',\n "extip": "%s"' % device[0].network.extip ajax += ',\n "commonname": "%s"' % device[0].network.commonname
ajax += '\n }' ajax += '\n }'
except: except:
@ -430,7 +432,7 @@ def makewifi(request):
serial = wifi_serial, serial = wifi_serial,
ssid = wifi_ssid, ssid = wifi_ssid,
key = wifi_key, key = wifi_key,
organization = wifi_organization organization = Organization.objects.filter(id=wifi_organization)[0]
) )
return redirect("/") return redirect("/")

View file

@ -29,7 +29,7 @@ function styleStatus(msg, device) {
}; };
if (msg.hasOwnProperty("network")) { if (msg.hasOwnProperty("network")) {
device_network.text(msg.network.intip + " (" + msg.network.extip + ")"); device_network.text(msg.network.intip + " (" + msg.network.commonname + ")");
}; };
if (msg.hasOwnProperty("reboot")) { if (msg.hasOwnProperty("reboot")) {