
| Current Path : /var/spool/mail/etc/postfix/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/spool/mail/etc/postfix/restart_postfix.py~ |
import re,sys,os
uid=""
gid=""
for zeile in open("/etc/passwd").read().split("\n"):
m = re.search(r"^(.*?)\:(.*?)\:(.*?)\:(.*?)\:",zeile)
if m:
uid = uid + "/\\/" + m.group(1) + "\\//" + " " + m.group(3) + "\n"
gid = gid + "/\\/" + m.group(1) + "\\//" + " " + m.group(4) + "\n"
# uid = uid + "/" + m.group(1) + "/" + " " + m.group(3) + "\n"
# gid = gid + "/" + m.group(1) + "/" + " " + m.group(4) + "\n"
open("/etc/postfix/uid","w").write(uid)
open("/etc/postfix/gid","w").write(gid)
# for opendkim:
trustedhosts = '''
localhost
127.0.0.1
85.214.96.57
ift-intern.de
'''
keytable = ""
signingtable = ""
os.system("mkdir /etc/opendkim; mkdir /etc/opendkim/keys")
for zeile in (open("vdomains").read()).split("\n"):
m = re.search(r"^ *(\S+) +OK",zeile)
if not m:
continue
domain = m.group(1)
trustedhosts = trustedhosts + domain + "\n"
keytable = keytable + "default._domainkey." + (domain + " "*30)[0:30] + " " + domain + ":default:/etc/opendkim/keys/" + domain + "/default.private\n"
signingtable = signingtable + (domain + " "*30)[0:30] + " default._domainkey." + domain + "\n"
if not os.path.isfile("/etc/opendkim/keys/" + domain + "/default.private"):
os.system("chdir /etc/opendkim/keys; mkdir " + domain + "; chdir " + domain + "; opendkim-genkey -r -d " + domain)
open("/etc/opendkim/TrustedHosts","w").write(trustedhosts)
open("/etc/opendkim/KeyTable" ,"w").write(keytable)
open("/etc/opendkim/SigningTable","w").write(signingtable)
os.system("chown -R opendkim:opendkim /etc/opendkim")
os.system("chmod -R 0755 /etc/opendkim")
os.system("chmod -R 0600 /etc/opendkim/keys/*/*")
# ---
os.system("/etc/init.d/opendkim restart")
os.system("/etc/init.d/saslauthd restart")
os.system("/etc/init.d/postfix restart")
os.system("/etc/init.d/amavis restart")
os.system("/etc/init.d/clamav-daemon restart")
os.system("/etc/init.d/spamassassin restart")
os.system("/etc/init.d/dovecot restart")