diff --git a/manager/models.py b/manager/models.py index f7f239c..a55cb67 100644 --- a/manager/models.py +++ b/manager/models.py @@ -13,12 +13,13 @@ class Organization(models.Model): return self.name class Network(models.Model): + commonname = models.CharField("Common Name", max_length=64, default="Network") extip = models.CharField("External/Public IP", max_length=15) intip = models.CharField("Internal/Private IP", max_length=15) organizations = models.ManyToManyField(Organization) def __str__(self): - return "%s (%s)" % (self.intip, self.extip) + return "%s (%s)" % (self.intip, self.commonname) class Model(models.Model): name = models.CharField("Model Name", max_length=100, unique=True) diff --git a/manager/views.py b/manager/views.py index 8d78c66..b4b5fe5 100644 --- a/manager/views.py +++ b/manager/views.py @@ -49,18 +49,20 @@ if /usr/bin/wget -O/tmp/wireless.in https://admin360.kumi.host/wireless --post-d then while read p 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 break fi echo $p >>/tmp/wireless.og done >/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 /bin/rm /tmp/wireless.* fi """ + device.lastbeat = timezone.now() elif device.reboot: code = "/sbin/reboot" @@ -77,18 +79,18 @@ fi return HttpResponse(code) def makewificonfig(device): - output = "\n# VPN360 WiFi Configuration\n" - + output = "" + i = 1 for wifi in device.wifi.all(): - output += """ -config wifi-iface - option network 'wwan' + output += """config wifi-iface + option network 'wwan%i' option ssid '%s' option encryption 'psk2' option device 'radio1' option mode 'sta' option key '%s' -""" % (wifi.ssid, wifi.key) +""" % (i, wifi.ssid, wifi.key) + i += 1 return output @@ -236,7 +238,7 @@ def ping(request, device_id): ajax += ',\n "network": {' 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 }' except: @@ -430,7 +432,7 @@ def makewifi(request): serial = wifi_serial, ssid = wifi_ssid, key = wifi_key, - organization = wifi_organization + organization = Organization.objects.filter(id=wifi_organization)[0] ) return redirect("/") diff --git a/static/js/devices.js b/static/js/devices.js index 7a5c256..04e92ca 100644 --- a/static/js/devices.js +++ b/static/js/devices.js @@ -29,7 +29,7 @@ function styleStatus(msg, device) { }; 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")) {