communicate install status to the plugin

Signed-off-by: Xe Iaso <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-05-09 17:57:08 +00:00
parent d871074d29
commit 5ff618eee8
2 changed files with 6 additions and 11 deletions

View File

@ -9,17 +9,18 @@ class Plugin:
def _systemd_status(self, service = "tailscaled.service"): def _systemd_status(self, service = "tailscaled.service"):
result = subprocess.run(["/bin/sh", "-c", "systemctl status tailscaled.service | grep active"], stdout=subprocess.PIPE) result = subprocess.run(["/bin/sh", "-c", "systemctl status tailscaled.service | grep active"], stdout=subprocess.PIPE)
return result.stdout.decode("utf-8").split(": ")[1] return result.stdout.decode("utf-8").split(": ")[1].strip()
async def install_state(self, *args): async def install_state(self, *args):
print("got here")
sysext = subprocess.run(["/usr/bin/systemd-sysext", "list", "--json=short"], stdout=subprocess.PIPE) sysext = subprocess.run(["/usr/bin/systemd-sysext", "list", "--json=short"], stdout=subprocess.PIPE)
sysexts = json.load(sysext.stdout.decode("utf-8")) sysexts = json.loads(sysext.stdout.decode("utf-8"))
if sysexts.len() == 0: if len(sysexts) == 0:
return "not installed" return "not installed"
for ext in sysexts: for ext in sysexts:
if ext.name != "tailscale": if ext["name"] != "tailscale":
continue continue
return self._systemd_status() return self._systemd_status()

View File

@ -14,11 +14,6 @@
} }
async function onReady() { async function onReady() {
let heading = document.getElementById("heading");
let id = await getUID();
heading.innerText = `Hello ${id}`;
let status = document.getElementById("status"); let status = document.getElementById("status");
let install_status = await getInstallState(); let install_status = await getInstallState();
@ -27,7 +22,6 @@
</script> </script>
</head> </head>
<body onload="onReady()"> <body onload="onReady()">
<h2 id="heading">Hello World</h2> <h3>Status: <span id="status">loading</span></h3>
<h3 id="status">Status: loading</h3>
</body> </body>
</html> </html>