#!/bin/python3

import os

transport_closed_file_path = "/etc/postfix/transport_closed"

if os.path.exists(transport_closed_file_path):
    lines = []
    needs_write = False

    with open(transport_closed_file_path, "r") as file:
        lines = file.readlines()
        for x in range(len(lines)):
            if ("admins@perfact.de" in lines[x]) or lines[x].isspace():
                lines[x] = ""
                needs_write = True

    if needs_write:
        with open(transport_closed_file_path, "w") as file:
            file.writelines(lines)
        os.system("postmap /etc/postfix/transport_closed")
