2024-07-10 18:12:45 +00:00
|
|
|
#!/usr/bin/env python
|
2024-05-30 21:51:51 +00:00
|
|
|
|
|
|
|
# Generate the status config based on the exozyme explore page
|
|
|
|
|
2024-07-10 18:12:45 +00:00
|
|
|
from re import search
|
|
|
|
from socket import getaddrinfo
|
|
|
|
from sys import argv
|
2024-05-30 21:51:51 +00:00
|
|
|
|
|
|
|
|
2024-07-10 18:12:45 +00:00
|
|
|
tld = "exozy.me"
|
|
|
|
ip = getaddrinfo(tld, 443)[0][4][0]
|
2024-05-30 21:51:51 +00:00
|
|
|
rules = {
|
2024-07-10 18:12:45 +00:00
|
|
|
"Status": None, # Make sure we don't include the status page itself!!
|
|
|
|
"PixivFE": "about",
|
|
|
|
"LiteXiv": "main.css",
|
|
|
|
"Priviblur": "priviblur/licences",
|
|
|
|
"Redlib": "info",
|
2024-05-30 21:51:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sites = []
|
2024-07-10 18:12:45 +00:00
|
|
|
with open("/srv/http/www/explore.html") as f:
|
2024-05-30 21:51:51 +00:00
|
|
|
for l in f.readlines():
|
2024-07-10 18:12:45 +00:00
|
|
|
m = search('<td><a href="https://(.*)">(.*)</a></td>', l)
|
|
|
|
if m is None:
|
|
|
|
continue
|
|
|
|
x = m.groups()
|
|
|
|
if not x[0].endswith(tld) and getaddrinfo(x[0], 443)[0][4][0] != ip:
|
|
|
|
continue
|
|
|
|
if x[1] in rules:
|
|
|
|
if rules[x[1]]:
|
|
|
|
sites.append((f"{x[0]}/{rules[x[1]]}", x[1]))
|
|
|
|
else:
|
|
|
|
sites.append(x)
|
2024-05-30 21:51:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
newconf = []
|
2024-07-10 18:12:45 +00:00
|
|
|
with open(argv[1]) as f:
|
2024-05-30 21:51:51 +00:00
|
|
|
for l in f.readlines():
|
2024-07-10 18:12:45 +00:00
|
|
|
if "description = " not in l:
|
2024-05-30 21:51:51 +00:00
|
|
|
newconf.append(l)
|
2024-07-10 18:12:45 +00:00
|
|
|
if l == "service = [\n":
|
|
|
|
newconf += list(
|
|
|
|
map(
|
|
|
|
lambda x: f' {{ description = "{x[1]}", url = "https://{x[0]}" }},\n',
|
|
|
|
sites,
|
|
|
|
)
|
|
|
|
)
|
2024-05-30 21:51:51 +00:00
|
|
|
|
|
|
|
|
2024-07-10 18:12:45 +00:00
|
|
|
with open(argv[1], "w") as f:
|
|
|
|
f.write("".join(newconf))
|