Git: Configuring native git commit emails

To start out, move the post-receive.sample script from your git hooks directory to just plain post-receive like so:

mv post-receive.sample post-receive

Then in your git config file add the below, below any existing configuration items. Note, you will need to change the URL and repository name (currently named “git-repository”) before this will work.

[hooks]
        mailinglist = email@example.com
        emailprefix = "git-repository: "
        showrev = "t=%s; printf 'https://example.com/secure/?p=git-repoistory;a=commitdiff;h=%%s' $t; echo;echo; git show -C $t; echo;"

And there you go, when you now push to the repository, you will receive an email send to “mailinglist” with the changes made in a nice diff and a link back to your main git repository site.

Advertisements

Git Commit eMail Notifications

Git’s Native eMail Notifier

From the repository you wish to send email on commits.

cd .git/hooks
mv post-receive post-receive.bkp
ln -s /usr/share/git-core/contrib/hooks/post-receive-email post-receive git config hooks.mailinglist "mailinglist@example.com"
git config hooks.emailprefix "[SUBJECT PREFIX] " # note the trailing space 

Git Commit Notifier

This ‘plugin’ will allow you to send an email every time a commit is committed to the repository. You may use this on the central repository to keep everyone following the project up to date.

To use this plugin, you first need to compile the script, then add the config information to each repository you wish to use it on.

To Install Git Commit Notifier

On Fedora 12 you first need to install Ruby and a few other dependences. After you download the needed dependences, you may compile the script.

yum install ruby rubygems hpricot rubygem-hpricott
gem install git-commit-notifier

To Configure Git Commit Notifier

In your repository’s .git/hooks folder or if it’s a “bare” repository, just the hooks folder. Create a file named
post-receive with the following content.

#!/bin/sh
git-commit-notifier ../git-commit-notifier.yml

Once you have saved the file, you need to make it executable.

chmod 775 post-receive

After you have made the hook executable, check up one directory to the repository’s .git directory. From here you need to create and modify your git-commit-notifier’s config file. Start out by creating a file named git-commit-notifier.yml, and copy the below config to it.

Git Commit Notifier Config File

# The recipient for the commit:
mailinglist: developers@example.com

# set to true if you want to ignore empty merge messages
ignore_merge: false

# Optional parameter for the subject-line of the mail
# emailprefix: GIT

# Decorate files with link to a webview. Possible values: none or gitweb link_files: none

# select the delivery method: smtp or sendmail
delivery_method: sendmail

# settings for the smtp server
smtp_server:
address: localhost
port: 25
domain: localhost
user_name: user@localhost
password: password
authentication: plain
enable_tls: false

# settings for sendmail
sendmail_options:
location: /usr/sbin/sendmail
arguments: -i -t

# If link_files is set to "gitweb", you need to configure the path to your gitweb
# instance and the project name.
gitweb:
path: <a href="http://developerserver/path_to_gitweb">http://developerserver/path_to_gitweb</a>
project: test.git

Dovecot v2.1+ Statistics

There are different “zoom levels” you may use to view the following statistics:

  • command: Per-IMAP command
  • session: Per IMAP/POP3 connection
  • user: Per user (all of user’s sessions summed up)
  • domain: Per domain (all of domain’s users summed up)
  • ip: Per IP address (all sessions from the IP summed up)

Basic Configuration

mail_plugins = $mail_plugins stats
protocol imap {
  mail_plugins = $mail_plugins imap_stats
}
plugin {
  # how often to session statistics
  stats_refresh = 30 secs
  # track per-IMAP command statistics
  stats_track_cmds = yes
}

You’ll also need to give enough permissions for mail processes to be able to write to stats-mail fifo. For example if you use a single “vmail” user for mail access:

service stats {
  fifo_listener stats-mail {
    user = vmail
    mode = 0600
  }
}

Statistics gathered

Statistics gathered using the getrusage() system call:

  • user_cpu: User CPU (seconds.microseconds)
  • sys_cpu: System CPU (seconds.microseconds)
  • min_faults: Minor page faults (page reclaims)
  • maj_faults: Major page faults
  • vol_cs: Voluntary context switches
  • invol_cs: Involuntary context switches
  • disk_input: Number of bytes read from disk
  • disk_output: Number of bytes written to disk

The disk_input and disk_output attempt to count the actual read/write bytes to physical disk, so e.g. reads from OS’s cache aren’t counted. Note that not all operating systems and filesystem support this, instead they simply show these values always as 0.

Statistics gathered by Dovecot’s lib-storage internally:

  • lookup_path: Number of open() and stat() calls (i.e. “path lookups”)
  • lookup_attr: Number of stat() and fstat() calls
  • read_count: Number of read() calls for message data (e.g. index files not counted)
  • read_bytes: Number of message bytes read()
  • cache_hits: Number of cache hits from dovecot.index.cache file


RoundCube Regression Testing

With the release of RoundCube 0.3-stable and all the upgrades that will happen, It feels like a good time to talk about regression testing.  Regression testing is when you test the functions of a peace of software to make sure that your updates didn’t break any functions.  In RoundCube it takes me about 10 minuets to fully test a site.  Here’s my check list, yours my vary depending on the plugins your using.

Main Screen

  • Read a HTMLmessage from the preview panel
    • Confirm the “View Header” drop down window works with HTML messages
  • Read a Plain Textmessage from the preview panel
    • Confirm the “View Header” drop down window works with Plain Text messages
  • Read a HTMLmessage full screen
    • Confirm the “View Header” drop down window works with HTML messages
    • Confirm the “Read Source” button works with HTML messages
  • Read a Plain Textmessage full screen
    • Confirm the “View Header” drop down window works with Plain Text messages
    • Confirm the “Read Source” button works with Plain Text messages
  • Change Message pages
  • Select All, Unread, None from the bottom center
  • Is the quota meter displaying
  • Flag (star) a message
  • Search for a known message value
  • Move a message from Inbox to a folder
  • Move a message from a folder to the Inbox
  • Send a message to an internal account
  • Send a message to an external account
  • Add a message via the plus symbol when viewing a message
    • Dose it show up in Personal Settings / Spam / Address Rules

Address Book

  • Add an Address Book entry
    • Dose it show up in Personal Settings / Spam / Address Rules
  • Change an existing entry
  • Compose Mail To” button, top center
  • Export Contacts in vCard format” button, top center
  • “Import Contacts” button, top center
  • Delete a contact
    • Dose it delete from Personal Settings / Spam / Address Rules

Personal Settings / Folders

  • Subscribe to a folder
  • Unsubscribe from a folder
  • Add a folder
  • Delete a folder

Personal Settings / Identities

  • Add a new “Identity”
    • Send a message with this identity
  • Modify an existing “Identity”
    • Send a message with this identity
  • Delete an Identity
  • Change default Identity’s

Personal Settings / Spam

  • Add a new white list entry
  • Add a new black list entry
  • Delete a white list entry
  • Delete a black list entry

Postfix: Archiving Mail when sent from or to the outside world

The goal here is to send an BCC message for every email send to or from the outside world, for a group of internal addresses.

Use sender_bcc_maps or recipient_bcc_maps. Configure them so that the archive copy is made when the sender is remote OR the receiver is remote.

/etc/postfix/main.cf:

sender_bcc_maps = pcre:/etc/postfix/archive-check
recipient_bcc_maps = pcre:/etc/postfix/archive-check

/etc/postfix/archive-check:

!/@example.com$/        archive@example.com

This is a predicate transformation, from (NOT (local AND local)), what you asked for, into ((NOT local) OR (NOT local)), shown above.

Postfix: allow select users permission to send to a cretin address

So the idea here is to have an email address that you would only like a select few to have access to email to, for example, a everyone or all address. In this example we will be locking down the email address all@example.com and only allow the address abc@example.com to send to it.

In /etc/postfix/main.cf add the following:

smtpd_restrictions_classes =  restricted_recipient
  • note: This is in smtpd_SENDER_restrictions to avoid becoming an open relay because of the “OK” below.
smtpd_sender_restrictions =
  check_recipient_access hash:/etc/postfix/restricted_recipientrestricted_recipient =
  check_sender_access hash:/etc/postfix/privileged_sender
  reject

restricted_recipient:

all@example.com         restricted_recipient

privileged_sender:

abc@example.com         OK