weidner/archives/2011/12/30/

Mit grep zum Kern der Sache kommen

Heute schon einen Blick in die Konfigurationsdatei von dovecot geworfen? Oder von samba oder irgendeine andere Konfigurationsdatei, die bei den meisten Linux-Distributionen mitgeliefert werden?

## Dovecot configuration file

# If you're in a hurry, see
# http://wiki.dovecot.org/QuickConfiguration

# "dovecot -n" command gives a clean output of the changed settings. Use it
# instead of copy&pasting this file when posting to the Dovecot
# mailing list.

# '#' character and everything after it is treated as comments. Extra spaces
# and tabs are ignored. If you want to use either of these explicitly, put the
# value inside quotes, eg.: key = "# char and trailing whitespace  "

# Default values are shown for each setting, it's not required to uncomment
# any of the lines. Exception to this are paths, they're just examples with
# the real defaults being based on configure options. The paths listed here
# are for configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
# --with-ssldir=/etc/ssl

# Base directory where to store runtime data.
#base_dir = /var/run/dovecot/

# Protocols we want to be serving: imap imaps pop3 pop3s managesieve
# If you only want to use dovecot-auth, you can set this to "none".
#protocols = imap imaps
protocols = imap imaps
...

Und das ist erst der Anfang. Andere Konfigurationsdateien sehen ähnlich aus. Jede Menge Kommentare und irgendwann dann eine Konfigurationsanweisung. Wenn ich dann mal schnell nachschauen will, was ich wirklich konfiguriert habe, oder jemand dazu befragen will, stehe ich erstmal im Wald.

Dann helfen mir die Filtermöglichkeiten, die mir grep bietet:

$ grep -Ev '^\s*(|#.*)$' /etc/dovecot/dovecot.conf

Die Option -E besagt, dass grep mein Muster als regulären Ausdruck auswerten soll, -v besagt, das ich genau das, was passt, nicht sehen will. Und der reguläre Ausdruck trifft auf Zeilen zu, die

Aus der oben angeführten Datei wird damit das folgende:

protocols = imap imaps
disable_plaintext_auth = yes
log_path = /var/log/dovecot.log
log_timestamp = "%Y-%m-%d %H:%M:%S "
ssl_cert_file = /etc/ssl/certs/dovecot.pem
ssl_key_file = /etc/ssl/private/dovecot.pem
mail_location = maildir:~/Maildir
mail_privileged_group = mail
mail_debug = yes
first_valid_uid = 106
last_valid_uid = 106
protocol imap {
}
protocol pop3 {
  pop3_uidl_format = %08Xu%08Xv
}
protocol managesieve {
  sieve=~/.dovecot.sieve
  sieve_storage=~/sieve
}
...

Der Unterschied ist offensichtlich. In Zahlen lässt er sich auch ausdrücken:

$ wc -l /etc/dovecot/dovecot.conf
1137 /etc/dovecot/dovecot.conf
$ grep -Ev '^\s*(|#.*)$' /etc/dovecot/dovecot.conf|wc -l
51

Das kann ich ausdrucken und im Notfallordner abheften.

Posted 2011-12-30
Tags: