From 6c8288945ba5a8227af68691f49985f558b58f29 Mon Sep 17 00:00:00 2001 From: Christopher Teutsch Date: Tue, 28 Apr 2020 16:30:57 +0200 Subject: [PATCH] wip --- main.py | 24 ++++++++++++++++++++++++ requirements.txt | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 main.py create mode 100644 requirements.txt diff --git a/main.py b/main.py new file mode 100644 index 0000000..2913254 --- /dev/null +++ b/main.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# A script to automatically add mail hosts with dynamic DNS to Mailcow. +# Please add it to the crontab of a user on your *Mailcow* server. +# Environment variables: +# MAILCOW_AWL_HOSTS: the DNS hosts you want to add, comma-separated +# MAILCOW_AWL_NOTIFY: the e-mail you want to receive notifications at. This is mandatory +# MAILCOW_AWL_NOTIFY: +import requests +import json +import dns.query +import os +from typing import List +import smtplib + +class Config(object): + hosts: List[str] + notify_email: str + api_key: str + def __init__(self): + hosts = os.getenv('MAILCOW_AWL_HOSTS') + if hosts: + self.hosts = hosts.split(',') + self.hosts = os.getenv('MAILCOW_AWL_HOSTS').split(',') + self.notify_email = os.environ('MAILCOW_AWL_NOTIFY') \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4f91610 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +dnspython +requests \ No newline at end of file