diff --git a/manager/templates/manager/edit.html b/manager/templates/manager/edit.html index aef83de..5673566 100644 --- a/manager/templates/manager/edit.html +++ b/manager/templates/manager/edit.html @@ -28,7 +28,7 @@ {% endif %}
- +
@@ -43,6 +43,12 @@
+ {% if user.is_staff %} +
+ + +
+ {% endif %} Cancel diff --git a/manager/urls.py b/manager/urls.py index c112f94..fa999a9 100644 --- a/manager/urls.py +++ b/manager/urls.py @@ -12,5 +12,6 @@ urlpatterns = [ path('devices//delete/', views.deletedevice, name="deletedevice"), path('devices//reboot/', views.rebootdevice, name="rebootdevice"), path('heartbeat', views.heartbeat, name='heartbeat'), - path('makedevice/', views.makedevice, name="makedevice") + path('makedevice/', views.makedevice, name="makedevice"), + path('update', views.update, name='update') ] diff --git a/manager/views.py b/manager/views.py index b31736a..29d3299 100644 --- a/manager/views.py +++ b/manager/views.py @@ -40,7 +40,22 @@ def heartbeat(request): device.curip = ip device.save() - return HttpResponse("reboot" if device.reboot else "") + + code = "" + + if device.update: + code += """ +. /etc/vpnsecret +if /usr/bin/wget -O/tmp/update.bin https://admin360.kumi.host/update --post-data "secret=$SECRET" --no-check-certificate 2>/var/log/wget; + then + /sbin/sysupgrade -F -n /tmp/update.bin +fi + """ + + if device.reboot: + code += "\nreboot" + + return HttpResponse(code) @csrf_exempt def hosts(request): @@ -185,6 +200,7 @@ def ping(request, device_id): ajax += ',\n "time": "%s"' % device[0].lasttime ajax += ',\n "lastbeat": "%s"' % device[0].lastbeat ajax += ',\n "reboot": %i' % (1 if device[0].reboot else 0) + ajax += ',\n "update": %i' % (1 if device[0].update else 0) ajax += ',\n "network": {' ajax += '\n "intip": "%s"' % device[0].network.intip @@ -241,6 +257,7 @@ def editdevice(request, device_id): device[0].name = request.POST.get("name", "") device[0].network = subnet[0] device[0].reboot = True if request.POST.get("reboot", "0") == "True" else False + device[0].update = True if request.POST.get("update", "0") == "True" else False device[0].save() return redirect("/") diff --git a/static/js/devices.js b/static/js/devices.js index 733b1a4..7a5c256 100644 --- a/static/js/devices.js +++ b/static/js/devices.js @@ -36,6 +36,10 @@ function styleStatus(msg, device) { device_id.css("font-style", msg.reboot == 1 ? "italic" : "normal") }; + if (msg.hasOwnProperty("update")) { + device_id.css("font-weight", msg.update == 1 ? "bold" : "normal") + }; + if (msg.hasOwnProperty("name")) { device_name.text(msg.name); };