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