Haftungsausschluss 644 0 0 2121 14532071327 11125 0 0 0 Haftungsausschluss: Ich erhebe keinen Anspruch darauf, dass diese Dokumentation oder die von mir geschriebenen und im Tar-File enthaltenden Shell-Scripte vollständig fehlerfrei sind und ich behaupte das auch nicht. Sowohl durch Programmierfehler in den Programmen ist Datenverlust möglich, wie auch durch den Anwender selber verursacht durch unsachgemäße oder fehlerhafte Einstellungen oder falsche Bedienung aller hier beschriebenen und verwendeten Programme. Deshalb schließe ich jede Haftung für Schäden an Software oder Hardware oder Vermögensschäden oder für Datenverlust aus, die durch die Benutzung der Shell-Scripte oder dieses Dokumentation entstehen. Die Benutzung dieser Dokumentation sowie aller im Tar-File enthaltenen Dateien erfolgt auf eigenes Risiko. Dieses Dokument sowie die im Tar-Archiv enthaltenen Dateien enstprechend den Beispielen in der eigentlichen Dokumention wird veröffentlicht unter: GNU General Public License 3 im Juli 2017 Aktualisiert: November 2017 Aktualisiert: Januar 2018 Aktualisiert: Oktober 2019 Aktualisiert: Juli 2022 Aktualisiert: November 2023 etc/ 755 0 0 0 14320330654 6000 5 0 0 etc/hosts 644 0 0 225 13551021424 7117 0 0 0 127.0.0.1 localhost raspi3 127.0.1.1 mail ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters etc/aliases 644 0 0 107 13550611106 7400 0 0 0 # See man 5 aliases for format mailer-daemon: root postmaster: root etc/mailname 644 0 0 5 13550611232 7477 0 0 0 mail etc/hostname 644 0 0 7 13123500410 7523 0 0 0 raspi3 etc/postfix/ 755 0 0 0 14532071005 7471 5 0 0 etc/postfix/main.cf 644 0 0 11256 14532071005 11034 0 0 0 # Version: 5.5 # Date: 18.09.2023 #=========================================================================== # mydomain = externer (www) domain-name des Mailservers (domain.tld) # myhostname = externer (www) hostname des Mailservers (host.domain.tld) # myorigin = interner (lan) hostname/domain-name des Mailservers # mydestination = erlaubte Domains für Annahme zu sendender Mails # mynetworks = vertrauenswürdige Netzwerke mydomain = mail myhostname = mail myorigin = mail mydestination = $myhostname, $myhostname.localdomain, localhost, localhost.localdomain mynetworks = 127.0.0.0/8 [::1]/128 10.0.1.0/24 10.0.8.0/23 #------------------------------------------------------------------------- # disable backwards compatibility compatibility_level = 3.6 biff = no append_dot_mydomain = no readme_directory = no mailbox_command =/usr/lib/dovecot/deliver mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = ipv4 disable_vrfy_command = yes #------------------------------------------------------------------------- # Redirect lokal adressierte Emails direkt zum Dovecot-Empfänger transport_maps = hash:/etc/postfix/check_local_transport_maps virtual_transport = lmtp:unix:private/dovecot-lmtp virtual_alias_maps = hash:/etc/postfix/check_local_alias_maps #------------------------------------------------------------------------- # Lokal SMTP-Daemon, TLS-Settings smtpd_tls_security_level = encrypt smtpd_tls_auth_only = yes smtpd_tls_ciphers = high smtpd_tls_protocols = TLSv1.3 TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3 smtpd_tls_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL smtpd_tls_mandatory_protocols = TLSv1.3 TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3 smtpd_tls_mandatory_ciphers = high smtpd_tls_mandatory_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtpd_tls_loglevel = 1 smtpd_tls_CApath = /etc/postfix/certs smtpd_tls_CAfile = /etc/postfix/certs/cacert.pem smtpd_tls_cert_file = /etc/postfix/certs/servercert.pem smtpd_tls_key_file = /etc/postfix/certs/serverkey.pem smtpd_tls_dh1024_param_file = /etc/postfix/certs/dh4096.pem smtpd_banner = $myhostname ESMTP $mail_name smtpd_helo_required=yes smtpd_sasl_security_options = noanonymous smtpd_sasl_auth_enable = yes smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth tls_random_source = dev:/dev/urandom #------------------------------------------------------------------------- # Extended Restrictions # 1. Black/Whitelist: Wer darf (nicht) senden? Default=reject! smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/check_sender_filter reject # 2. Black/Whitelist: Wer darf (nicht) extern via Relayhost senden? (hier deaktiviert, default=dunno) smtpd_relay_restrictions = # check_sender_access hash:/etc/postfix/check_sender_relayaccess permit_mynetworks reject_unauth_destination # 3. Standard-Prüfmethoden. Default=permit! smtpd_recipient_restrictions = permit_mynetworks reject_non_fqdn_sender reject_non_fqdn_recipient reject_unauth_destination permit #------------------------------------------------------------------------- # ISP SMTP, TLS-Settings smtp_tls_note_starttls_offer = no smtp_tls_security_level = encrypt smtp_tls_ciphers = high smtp_tls_protocols = TLSv1.3 TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3 smtp_tls_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL smtp_tls_mandatory_protocols = TLSv1.3 TLSv1.2, !TLSv1.1, !TLSv1, !SSLv2, !SSLv3 smtp_tls_mandatory_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL smtp_tls_mandatory_ciphers = high smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtp_sasl_auth_enable = yes smtp_sasl_security_options = noanonymous smtp_sasl_password_maps = hash:/etc/postfix/get_relayhost_passwd smtp_generic_maps = hash:/etc/postfix/check_generic_replace_from smtp_sender_dependent_authentication = yes sender_dependent_relayhost_maps = hash:/etc/postfix/get_sender_relayhost #------------------------------------------------------------------------- # Specifies which account sent mail to an alias alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases #------------------------------------------------------------------------- # Remove sensitive information from email-headers with postfix mime_header_checks = regexp:/etc/postfix/remove_header_sensitives header_checks = regexp:/etc/postfix/remove_header_sensitives #=========================================================================== # Ende etc/postfix/rules/ 755 0 0 0 14320330654 10626 5 0 0 etc/postfix/rules/check_local_transport_maps 644 0 0 317 13550564535 16210 0 0 0 # Lokal sender, local recipient - prevents transmission # over the Internet, processes only local Traffic #======================================================= mail lmtp:unix:private/dovecot-lmtp etc/postfix/rules/get_sender_relayhost 644 0 0 752 13550564277 15044 0 0 0 # Per-sender provider; see also /etc/postfix/get_relayhost_passwd #================================================================ root@mail smtp.toml.de thomas.addams_t@mail smtp.toml.de thomas.addams_g@mail mail.gmx.net tom.addams@mail smtp.gmail.com silvia.addams_t@mail smtp.toml.de silvia.addams_g@mail mail.gmx.net manuel.addams_t@mail smtp.toml.de manuel.addams_g@mail mail.gmx.net familie@mail smtp.toml.de etc/postfix/rules/get_relayhost_passwd 644 0 0 1357 13550564277 15107 0 0 0 # Per-sender authentication; see also /etc/postfix/get_sender_relayhost #====================================================================== root@.mail thomas.addams@toml.de:irgendeingeheimespwd thomas.addams_t@mail thomas.addams@toml.de:irgendeingeheimespwd thomas.addams_g@mail thomas.addams@gmx.de:irgendeinanderesgeheimespwd tom.addams@mail tom.addams@gmail.com:auchganzgeheim silvia.addams_t@mail silvia.addams@toml.de:eineigenespwd silvia.addams_g@mail silvia.addams@gmx.de:einandereseigenesgeheimespwd manuel.addams_t@mail manuel.addams@toml.de:manuelspwd manuel.addams_g@mail manuel.addams@gmx.de:manuels2pwd familie@mail thomas+silvia.addams@_toml.de:familypassword etc/postfix/rules/check_sender_relayaccess 644 0 0 327 13550642704 15614 0 0 0 # Authorized or forbidden senders to send via relayhost # default in main.cf = permit/dunno #====================================================== manuel.addams_t@mail reject manuel.addams_g@mail reject etc/postfix/rules/check_local_alias_maps 644 0 0 662 13551021117 15231 0 0 0 # Translates shortened local recipients to regular local recipients #================================================================== root thomas.addams_t@mail root@mail thomas.addams_t@mail postmaster thomas.addams_t@mail mailer-daemon thomas.addams_t@mail thomas@mail thomas.addams_t@mail silvia@mail silvia.addams_t@mail manuel@mail manuel.addams_t@mail manu@mail manuel.addams_t@mail etc/postfix/rules/check_generic_replace_from 644 0 0 1026 13550564277 16135 0 0 0 # Per-sender replacement of local "from" to Provider-"from" #========================================================== root@mail thomas.addams@toml.de thomas.addams_t@mail thomas.addams@toml.de thomas.addams_g@mail thomas.addams@gmx.de tom.addams@mail tom.addams@gmail.com silvia.addams_t@mail silvia.addams@toml.de silvia.addams_g@mail silvia.addams@gmx.de manuel.addams_t@mail manuel.addams@toml.de manuel.addams_g@mail manuel.addams@gmx.de familie@mail thomas+silvia.addams@_toml.de etc/postfix/rules/check_sender_filter 644 0 0 656 13550564277 14620 0 0 0 # Authorized or forbidden senders to send Email # default in main.cf = reject #=============================================== root@mail permit thomas.addams_t@mail permit thomas.addams_g@mail permit tom.addams@mail permit silvia.addams_t@mail permit silvia.addams_g@mail permit manuel.addams_t@mail permit manuel.addams_g@mail permit familie@mail permit etc/postfix/rules/refresh-rules 644 0 0 4531 14267453641 13436 0 0 0 #!/bin/bash # # Support-Script to recreate rules # Date : 09.10.2019 # Version: 2.2 #=================================================================== if [[ $EUID -ne 0 ]]; then echo -e "\nThis script must be run as root" exit 1 fi cd /etc/postfix/rules [ -f check_generic_replace_from ] && postmap check_generic_replace_from [ -f check_local_alias_maps ] && postmap check_local_alias_maps [ -f check_local_transport_maps ] && postmap check_local_transport_maps [ -f check_sender_filter ] && postmap check_sender_filter [ -f check_sender_relayaccess ] && postmap check_sender_relayaccess [ -f get_sender_relayhost ] && postmap get_sender_relayhost [ -f get_relayhost_passwd ] && postmap get_relayhost_passwd chown root:postfix /etc/postfix/rules/*.db chmod 640 /etc/postfix/rules/*.db [ -f check_generic_replace_from.db ] && mv -f check_generic_replace_from.db /etc/postfix [ -f check_local_alias_maps.db ] && mv -f check_local_alias_maps.db /etc/postfix [ -f check_local_transport_maps.db ] && mv -f check_local_transport_maps.db /etc/postfix [ -f check_sender_filter.db ] && mv -f check_sender_filter.db /etc/postfix [ -f check_sender_relayaccess.db ] && mv -f check_sender_relayaccess.db /etc/postfix [ -f get_sender_relayhost.db ] && mv -f get_sender_relayhost.db /etc/postfix [ -f get_relayhost_passwd.db ] && mv -f get_relayhost_passwd.db /etc/postfix cp remove_header_sensitives /etc/postfix chown root:postfix /etc/postfix/remove_header_sensitives chmod 644 /etc/postfix/remove_header_sensitives cd /etc newaliases echo -e "\nRestart Mailsystem! Continue? (y/n): " read CONFIRM && [ "$CONFIRM" = "n" ] && exit 0 clear echo -e "Stop Mailsystem:\n" [ -f /usr/sbin/dovecot ] && systemctl stop dovecot && systemctl status dovecot [ -f /usr/sbin/postfix ] && systemctl stop postfix && systemctl status postfix echo -e "\nMailsystem gestoppt!\nEinen kleinen Moment bitte!\n" sleep 3 clear echo -e "Start Mailsystem:\n" [ -f /usr/sbin/dovecot ] && systemctl start dovecot && systemctl status dovecot [ -f /usr/sbin/postfix ] && systemctl start postfix && systemctl status postfix echo -e "\nMailsystem started!\n" echo -e "\nCheck running Postfix-Configuration!" postfix check echo -e "Ready!\n" exit 0 #=================================================================== # Ende etc/postfix/rules/remove_header_sensitives 644 0 0 602 13550564277 15706 0 0 0 # Remove sensitive information from email headers with postfix #============================================================= /^Received:.*with ESMTPSA/ IGNORE /^X-Originating-IP:/ IGNORE /^X-Mailer:/ IGNORE /^Mime-Version:/ IGNORE /^From:.*(root)/ REPLACE From: etc/postfix/certs/ 755 0 0 0 14320330654 10614 5 0 0 etc/postfix/certs/servercert.pem 644 0 0 175 14267227061 13555 0 0 0 -----BEGIN CERTIFICATE----- inhalt gelöscht.... bitte gemäß Dokumentation neu anlegen -----END CERTIFICATE----- etc/postfix/certs/dh4096.pem 644 0 0 202 14267227017 12277 0 0 0 -----BEGIN DH PARAMETERS----- inhalt gelöscht.... bitte gemäß Dokumentation neu anlegen -----END DH PARAMETERS----- etc/postfix/certs/cacert.pem 644 0 0 175 14267227073 12635 0 0 0 -----BEGIN CERTIFICATE----- inhalt gelöscht.... bitte gemäß Dokumentation neu anlegen -----END CERTIFICATE----- etc/postfix/certs/serverkey.pem 644 0 0 175 13127206426 13404 0 0 0 -----BEGIN CERTIFICATE----- inhalt gelöscht.... bitte gemäß Dokumentation neu anlegen -----END CERTIFICATE----- etc/dovecot/ 755 0 0 0 14320330653 7442 5 0 0 etc/dovecot/passwd 644 0 0 4156 13550612026 10755 0 0 0 # Create PWD: # doveadm pw -s plain-md5 # # Description Fileformat # user:password : uid:gid : Comment User-Info : home:(shell) : extra_fields # # Username : It is used when user logs in. It should be between 1 and 32 characters in length. # Password : An x character indicates that encrypted password is stored in /etc/shadow file. # User ID (UID) : Overrides the global mail_uid setting. # Group ID (GID): Overrides the global mail_gid setting. # User ID Info : The comment field. It allow you to add extra information about the users such as user’s full # name, phone number etc. This field use by finger command. # Home directory: The absolute path to the directory the user will be in when they log in. If this directory does # not exists then users directory becomes /Command/shell # # (User ID Info and Home-Dir are unused by dovecot) #=================================================================================================================================================== # Postfächer: thomas.addams_t:{PLAIN-MD5}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:vmail:vmail: :::userdb_mail=maildir:/media/SSD/Mail/Imap/thomas/thomas.addams_t thomas.addams_g:{PLAIN-MD5}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:vmail:vmail: :::userdb_mail=maildir:/media/SSD/Mail/Imap/thomas/thomas.addams_g tom.addams:{PLAIN-MD5}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:vmail:vmail: :::userdb_mail=maildir:/media/SSD/Mail/Imap/thomas/tom.addams silvia.addams_t:{PLAIN-MD5}uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu:vmail:vmail: :::userdb_mail=maildir:/media/SSD/Mail/Imap/silvia/silvia.addams_t silvia.addams_g:{PLAIN-MD5}uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu:vmail:vmail: :::userdb_mail=maildir:/media/SSD/Mail/Imap/silvia/silvia.addams_g manuel.addams_t:{PLAIN-MD5}mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm:vmail:vmail: :::userdb_mail=maildir:/media/SSD/Mail/Imap/manuel/manuel.addams_t manuel.addams_g:{PLAIN-MD5}mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm:vmail:vmail: :::userdb_mail=maildir:/media/SSD/Mail/Imap/manuel/manuel.addams_g familie:{PLAIN-MD5}dddddddddddddddddddddddddddddddd:vmail:vmail: :::userdb_mail=maildir:/media/SSD/Mail/Imap/familie etc/dovecot/alias_maps 644 0 0 521 13222450773 11542 0 0 0 # Assigns virtual dovecot-user to a suitable linux-user #======================================================== thomas.addams_t thomas thomas.addams_g thomas tom.addams thomas silvia.addams_t silvia silvia.addams_g silvia manuel.addams_t manuel manuel.addams_g manuel familie familie etc/dovecot/dovecot.conf 644 0 0 15150 14267203623 12064 0 0 0 # Version: 4.3 # Date: 25.07.2022 #auth_verbose=yes # enables logging all failed authentication attempts. #auth_debug=yes # enables all authentication debug logging (also enables auth_verbose). Passwords are logged as . #auth_debug_passwords=yes # does everything that auth_debug=yes does, but it also removes password hiding (but only if you are not # using PAM, since PAM errors aren't written to Dovecot's own logs). #mail_debug=yes # enables all kinds of mail related debug logging, such as showing where Dovecot is looking for mails. #verbose_ssl=yes # enables logging SSL errors and warnings. Even without this setting if connection is closed because of an # SSL error, the error is logged as the disconnection reason. #auth_verbose_passwords=no|plain|sha1 # If authentication fails, this setting logs the used password. If you don't really need to know what the # password itself was, but are more interested in knowing if the user is simply trying to use the wrong # password every single time or if it's a brute force attack, you can set this to "sha1" and only the SHA1 # of the password is logged. That's enough to know if the password is same or different between login attempts. auth_verbose_passwords=sha1 disable_plaintext_auth = yes mail_privileged_group = vmail hostname = mail mail_location = maildir:/media/SSD/Mail/Imap:UTF-8 mail_home = /media/SSD/Mail/Sieve/%n # Nur User vmail UID=5000/GID=5000 ist erlaubt first_valid_uid = 5000 last_valid_uid = 5000 first_valid_gid = 5000 last_valid_gid = 5000 protocols = imap lmtp #------------------------------------------------------------------------------- # Bei Login eines Users in sein Dovecot-Postfach ein Script starten, dass # für dieses Email-Konto via Getmail die Emails vom ISP-Mail-Konto abruft. service imap { executable = imap imap-postlogin } service imap-postlogin { executable = script-login /usr/local/bin/getmail_eventhandler # user = $default_internal_user user = root unix_listener imap-postlogin { } } #------------------------------------------------------------------------------- # Zustellung lokaler EMails innerhalb des LAN abwickeln, ohne Beteiligung des # Internets. Erstellt einen Unix-Socket zur Interprozesskommunikation zwischen # Dovecot und Postfix. (siehe /etc/postfix/rules/check_local_transport_maps) service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp { group = postfix mode = 0600 user = postfix } } #------------------------------------------------------------------------------- # Dovecot User—Accountmanagement, Zugangsdaten sind in PWD-File hinterlegt passdb { driver = passwd-file args = scheme=plain-md5 username_format=%n /etc/dovecot/passwd } userdb { driver = passwd-file args = username_format=%n /etc/dovecot/passwd } #------------------------------------------------------------------------------- # Postfix smtp-auth. dovecot ist das authentication backend für Postfix # Zum Senden von Emails über Postfix werden das starttls-Kommando und die # Dovecot-Anmeldedaten verlangt. Unberechtigte Anwender können nicht senden. # Die Interprozesskommunikation zwischen Postfix und Dovecot findet über # diesen von Dovecot etablierten Socket statt. # (siehe postfix.conf -> smtpd_sasl_type = dovecot) service auth { unix_listener /var/spool/postfix/private/auth { mode = 0666 } } auth_mechanisms = plain login #------------------------------------------------------------------------------- # Getmail führt bei der Abholung der Emails eines Users ein SetUID auf den User # vmail durch und ermöglicht hiermit ein Linux-Schreibrecht auf die Mail- # Verzeichnisse des Users. # service auth erlaubt den Usern der Gruppe "mail" sich über den Socket # auth-userdb zu authentifizieren und die Zustellung in das eigene Postfach # via dovecot LDA durchzuführen. service auth { unix_listener auth-userdb { group = vmail mode = 0660 } } #------------------------------------------------------------------------------- # Socket-Permissions für Gruppe vmail setzen. Troubleshooting für # net_connect_unix(/var/run/dovecot/stats-writer) failed: Permission denied # ls /var/run/dovecot/stats* # srw-r----- 1 root vmail 0 2019-09-25 11:59 /var/run/dovecot/stats-reader # srw-rw---- 1 root vmail 0 2019-09-25 11:59 /var/run/dovecot/stats-writer service stats { unix_listener stats-reader { group = vmail mode = 0640 } unix_listener stats-writer { group = vmail mode = 0660 } } #------------------------------------------------------------------------------- # Prot. lda = führt die Sieve-Scripte für Getmail->Dovecot-Delivered Mails aus # Prot. lmtp = dto. für via Postfix lokal gesendete und empfangene Mails # Plugin beschreibt die Orte, an denen die Sieve-Scripte gespeichert sind protocol lda { mail_plugins = $mail_plugins sieve } protocol lmtp { mail_plugins = $mail_plugins sieve } plugin { sieve_dir = /media/SSD/Mail/Sieve/%n sieve = /media/SSD/Mail/Sieve/%n/.dovecot.sieve sieve_global_dir = /media/SSD/Mail/Sieve sieve_default = /media/SSD/Mail/Sieve/default.sieve } #------------------------------------------------------------------------------- # Mailbox-Defaults - autocreated mailboxes are created lazily to disk only # when accessed for the first time. namespace inbox { inbox = yes mailbox Trash { auto = subscribe special_use = \Trash } mailbox Drafts { auto = subscribe special_use = \Drafts } mailbox Sent { auto = subscribe special_use = \Sent } mailbox Spam { auto = subscribe special_use = \Junk } } #------------------------------------------------------------------------------- # Zertifikat und Key, verschlüsselt den Datenverkehr bzw. lässt # unverschlüsselten Datenverkehr nicht zu. # Mögliche Werte für die Protokoll-Festlegung sind: SSLv3,TLSv1, TLSv1.1, TLSv1.2 ssl = required ssl_min_protocol=TLSv1.2 ssl_prefer_server_ciphers = yes ssl_cipher_list = EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4 ssl_dh = /dev/null)" ]; then anyconffound=true fi fi if [ ! -f $GetmailConfDir/getmail-last-polling.log ]; then touch $GetmailConfDir/getmail-last-polling.log chown vmail:vmail $GetmailConfDir/getmail-last-polling.log fi if [ $anyconffound == true ]; then echo "$msg4 $(date +%d.%m.%Y) - $(date +%H:%M:%S)" >$GetmailConfDir/getmail-last-polling.log while read line do echo "processing getmail: started downloads for $line, setuid to user vmail (UID 5000) " | systemd-cat -t "thlu:$(basename $0)" -p "info" su vmail -m -p -c "getmail -v --getmaildir $GetmailConfDir --rcfile $line 2>&1 >>$GetmailConfDir/getmail-last-polling.log" done < <(ls $GetmailConfDir/*.conf) sleep 60 echo "$msg7 $LinuxUser" | systemd-cat -t "thlu:$(basename $0)" -p "info" rm "$LockFile" else echo "$msg5" | systemd-cat -t "thlu:$(basename $0)" -p "warning" fi return 0 } #============================================================================================ # Main VirtUser=$(echo "$USER" | sed 's/@mail//; s/^[ \t]*//; s/[ \t]*$//') LinuxUser=$(awk '$1 == "'$VirtUser'" {print $2;exit}' /etc/dovecot/alias_maps) if [ -z "$LinuxUser" ]; then echo "$msg0 Virtuser=$VirtUser" | systemd-cat -t "thlu:$(basename $0)" -p "err" else LinuxUser_UID=$(/usr/bin/id -r -u "$LinuxUser" 2>/dev/null) if [ -z "$LinuxUser_UID" ]; then echo "$msg2 VirtUser=$VirtUser LinuxUser=$LinuxUser" | systemd-cat -t "thlu:$(basename $0)" -p "err" else echo "started: VirtUser=$VirtUser LinuxUser=$LinuxUser UID=$LinuxUser_UID" | systemd-cat -t "thlu:$(basename $0)" -p "info" GetmailConfDir="/media/SSD/Mail/Getmail/$LinuxUser" LockFile="$GetmailConfDir/getmail.lock" find "$LockFile" -mmin +60 -exec rm "$LockFile" \; 2>/dev/null echo "$msg6 $VirtUser ($LinuxUser)" | systemd-cat -t "thlu:$(basename $0)" -p "info" echo "$VirtUser.$$" >>$LockFile line=$(head -n 1 $LockFile) if [ "$line" == "$VirtUser.$$" ]; then DoPollingByAccount & else echo "$msg3 $LinuxUser ($VirtUser)" | systemd-cat -t "thlu:$(basename $0)" -p "warning" fi fi fi exec "$@" exit 0 #============================================================================================ # Ende