Category Archives: Admin

How to Configure WGet to Work with Proxy Server

The Problem

I want to configure WGet to go through a proxy server without having to specify that on the command line

The Solutions

The first solution is easy: I can set a shell variable called http_proxy. Here is an example in bash:

$ http_proxy=http://proxy-server:8080
$ export http_proxy

Another solution is to place this information in a configuration file called ~/.wgetrc. Here is a sample:

http_proxy=http://proxy-server:8080

If you have administrative rights and want to configure the system-wide behavior, then place the above line into the file /etc/wgetrc.

Conclusion

This is a very simple configuration problem, but it took me a while to figure out because I assumed that my system came with proxy pre-configured, but it was not. If you use wget on your system and it took a long time to get some trivia file (for example http://google.com) and you are sure that your internet connection is working fine, then you might have a proxy problem. Normally, you only encounter proxy servers at work, school, or other organization, but not at home.

Advertisements

Automate Email Notifications for Subversion (SVN) Commits

The Problem

I want SVN to automatically send out notifications every time some one commits.

The Solution

I have used svn-mailer before and love its ability to configure the email contents as well as subject. This time I am interested in the DIY approach to learn more about SVN, so I did it without svn-mailer.

The first step is to go to my svn repository (/var/svn in this case) and create a script call post-commit in the hooks directory. Subversion looks for this file, so the name must be exact. The script must be executable. Here it the contents of /var/svn/hook/post-commit:

#!/bin/sh

REPOS="$1"
REV="$2"
AUTHOR=$(svnlook author -r $REV $REPOS)
DATE=$(svnlook date -r $REV $REPOS)

{
    echo "REPOSITORY:   $REPOS"
    echo "REVISION:     $REV"
    echo "COMMITTED BY: $AUTHOR"
    echo "DATE:         $DATE"

    echo ""
    echo "DESCRIPTION:"
    svnlook log -r $REV $REPOS

    echo ""
    echo "FILES:"
    svnlook changed -r $REV $REPOS

} | mail -s "PerfPortal Check In Rev $REV by $AUTHOR" email_alias...

Now, every time someone checks in, Subversion will invoke the post-commit script with the path to the repository as the first parameter and the revision number as the second.

Explanation

The script employs two tools to accomplish its objective: svnlook to retrieve various information regarding the committed revision and mail, the Unix command-line utility to send out email. I assume that your system is set up to allow sending email.

  • Line 3-4 identify the parameters Subversion passes to this script, namely the path to the repository and the revision number.
  • Line 5-6 determine the name of the person who committed the code and on which date
  • Line 9-20 display various information regarding the commitment. These information are piped into the mail command on line 22, thus become the body of the email.
  • Line 16 displays the comment the submitter entered when that person committed the code
  • Line 20 displays a list of files that are affected in this commitment.
  • Line 22 invokes the mail command to send out the notification. The -s flag specifies the subject. Replace email_alias with a list of email aliases separated by spaces.

Conclusion

Enabling Subversion commit notification is straight forward: all you have to do is to create a script which sends email with various information regarding the commitment. The script’s potentials do not limit to sending email, it can start unit tests modules, start build processes, update log files, and other tasks–use your imagination.

Another alternative to writing the script is to use tools such as svn-mailer. However, as with most of the tools, you do need to invest some initial time to learn about the tool to fully exploit its capacity