Monday 30 July 2007

Processing Arguments in BASH

There are many ways to skin a cat, but in a bash script, this is probably the "most right" way to processes command line arguments:

#!/bin/bash

while getopts vf: opt ; do
case "$opt" in
v) echo "verbose set" ;;
f) echo "f: $OPTARG" ;;
\\?) echo "Error: unknown flag" >&2 ;;
esac
done

shift `expr $OPTIND - 1`


Basically, you run "getopts" giving it a "parameter string" and a variable name. The parameter string is a list of letters you want to pull arguments from and each one that takes an argument itself is followed by a colon (:).

Loop through the arguments as above, and then use "shift" and the "OPTIND" to shift off all the arguments that were processed, leaving only the "regular" arguments, e.g. take out all the "-v" and such but leave the list of file names.

Props: SHELLdorado

Tuesday 24 July 2007

Configuring Postfix to Relay to a Server with SMTP AUTH

If your system has a mail server installed and is not an actual mail server, it is preferable that your system relays through a host that is a regular mail server. In this example, we are configuring Postfix to relay to a host that requires SMTP and TLS.

Make these changes to your Postfix configuration, either by editing /etc/postfix/main.cf or using "postconf -e":
relayhost = [smtp.dl.nibble.bz]
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes


The given password map file will need to be created and it is in the format of:
mailserver.example.com username:password

The name of the mail server must match your "relayhost" above, and the username and password are the credentials of some user with permission to relay mail. You can use your own credentials or create an account on the server to specifically allow mail relaying.

Once you have created the password map file, run:
postmap /etc/postfix/sasl_passwd

This should create a corresponding "sasl_passwd.db" file. Since both these files contain the above password in plaintext, you should protect them as much as possible:
chmod 600 /etc/postfix/sasl_passwd
chmod 640 /etc/postfix/sasl_passwd.db
chgrp mail /etc/postfix/sasl_passwd.db


Once you have edited your Postfix configuration and created the password map, just restart or reload postfix (just run "postfix reload") and you're done!

Optionally, you can enable SSMTP (on port 465) in addition to TLS on the standard SMTP port (25) which is useful for users who are connecting from sites which block outbound SMTP. It's trivial, un-comment these lines in master.conf and do "postfix reload" again:

smtps inet n - - - - smtpd
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject


Props to the following resources:
http://www.postfix.org/postconf.5.html#smtp_use_tls
http://wiki.zimbra.com/index.php?title=Outgoing_SMTP_Authentication
http://ben.franske.com/blogs/bensbits.php/2005/09/06/postfix_smtp_auth_support_for_relayhost
http://dl.nibble.bz/~archangel/archive.php?news=219

Friday 13 July 2007

Connect to Nibble Jabber with iChat on a Mac

Connecting to Nibble Jabber with iChat on a Mac requires OS X 10.4 or above and it is super easy to setup. The screenshots below are for OS X 10.4 (Tiger). Note: If you are already using iChat for other types of instant messaging, scroll down to the end to see how to enable Jabber.

When iChat is first run, it will come up and tell you how great it is:
iChat First Run

Then it will ask you for your name, just check that it is correct, and your .Mac account info which is optional:
iChat Basic Settings

Then you can enable a Jabber account. Just check the box as show, and provide your Jabber ID:
iChat Jabber Account

Basically you're done at this point. You will get a couple screens asking you about enabling Bonjour (optional) and configuring your web-camera (if you have one), and then you're done:
iChat Done

When iChat connects, you will probably get this warning about security, choose "continue":
iChat Security Warning

And then you will be logged in and you should see your buddy list:
iChat Buddy List


On the other hand, if you are already using iChat, you just need to go in to "Preferences" to enable Jabber. Open the "Preferences" for iChat, and go to the "Accounts" tab as shown:
iChat Account Settings

Now just choose "Jabber" from the drop-down box and provide your Jabber ID:
iChat New Jabber Account

That's it! You should get the security warning and buddy list as shown above.

Monday 9 July 2007

The ReadyNAS Does Everything

Infrant, a subsidiary of NetGear, makes this NAS (a file-server in a box) called the "ReadyNAS NV+". If you need a network file server and are willing to look at ~$1,000 price range, this is the way to go, hands down.

Just let this Jesuit tell you how great it is:



No, really, he's serious. It does *everything*. One-touch external drive backup, expandable by attaching a USB drive, or many through a USB hub... It will fold your laundry and walk the dog!

Not to be a product whore or anything, but I want me one of these!

Sunday 8 July 2007

Connect to Nibble Jabber with Pidgin

To connect to Nibble Jabber with Pidgin, just add a new "XMPP" account. Give your Nibble login name as the "Screen name", and "dl.nibble.bz" as the "Domain". That's it! Just click "Save".

For example, in Windows, it looks like this:
Pidgin in Windows

Popular Posts