async everything?
Signed-off-by: Xe Iaso <me@christine.website>
This commit is contained in:
parent
b32c936041
commit
5aa1f61f1d
9
main.py
9
main.py
|
@ -12,11 +12,11 @@ class Plugin:
|
||||||
async def whoami(self, *args):
|
async def whoami(self, *args):
|
||||||
return os.getuid()
|
return os.getuid()
|
||||||
|
|
||||||
def _systemd_status(self, service = "tailscaled.service"):
|
async 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].strip()
|
return result.stdout.decode("utf-8").split(": ")[1].strip()
|
||||||
|
|
||||||
def _install_state(self):
|
async def _install_state(self):
|
||||||
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.loads(sysext.stdout.decode("utf-8"))
|
sysexts = json.loads(sysext.stdout.decode("utf-8"))
|
||||||
|
|
||||||
|
@ -27,13 +27,12 @@ class Plugin:
|
||||||
if ext["name"] != "tailscale":
|
if ext["name"] != "tailscale":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return self._systemd_status()
|
return await self._systemd_status()
|
||||||
|
|
||||||
return "impossible state"
|
return "impossible state"
|
||||||
|
|
||||||
async def install_state(self, *args):
|
async def install_state(self, *args):
|
||||||
await self.log("fetching state")
|
result = await self._install_state()
|
||||||
result = self.install_state()
|
|
||||||
await self.log("status: " + result)
|
await self.log("status: " + result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue