<?xml version="1.0" encoding="ISO-8859-1"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xml:lang="en-US">
	<title>Samurai Penguin&#039;s Lair</title>
	<link rel="alternate" type="text/html" href="http://www.samurai-penguin.com/index.php" />
	<modified>2008-10-07T00:29:12Z</modified>
	<author>
		<name>James Ber</name>
	</author>
	<copyright>Copyright 2008, James Ber</copyright>
	<generator url="http://www.sourceforge.net/projects/sphpblog" version="0.5.1">SPHPBLOG</generator>
	<entry>
		<title>Sorry for the downtime...</title>
		<link rel="alternate" type="text/html" href="http://www.samurai-penguin.com/index.php?entry=entry080722-074906" />
		<content type="text/html" mode="escaped"><![CDATA[Sorry I haven&#039;t updated much recently, but I&#039;ve been extremely busy in my personal life.  Part two of the Ubuntu Mailserver tutorial should be forthcoming very soon, which will detail setting up SMTP Auth and some basic spam filtration techniques.  Keep checking back! ]]></content>
		<id>http://www.samurai-penguin.com/index.php?entry=entry080722-074906</id>
		<issued>2008-07-22T00:00:00Z</issued>
		<modified>2008-07-22T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Custom Bash Prompt</title>
		<link rel="alternate" type="text/html" href="http://www.samurai-penguin.com/index.php?entry=entry080512-070238" />
		<content type="text/html" mode="escaped"><![CDATA[All things have to start somewhere. Linux starts with the shell, and this blog embodies that spirit by hacking it up. This is my prompt on all my servers. It’s 3 lines, and includes all possible relevant information. Date/time, load, and memory use, and the normal user@host:path info. It’s also easily customizable. Here’s how it looks:<br /><br /><img src="http://www.samurai-penguin.com/static/prompt.png" width="186" height="50" border="0" alt="" /><br /><br />The comments pretty much cover how it works, with the memory working the same as the load average. It does require the ‘<a href="http://www.samurai-penguin.com/static/ansicolor.txt" >ansicolor</a>’ library, which I borrowed and improved from ubuntuforums. It’s quite useful for bash programming. This makes it trivial to customize the prompt. Set the colors you want at the top under the PROMPT_COLOR variables. I’ve included two variations(one commented) in the script, so I can tell which machine I’m on at a glance.<br /><br /><a href="http://www.samurai-penguin.com/static/prompt.txt" target="_blank" >Click here</a> to download the code]]></content>
		<id>http://www.samurai-penguin.com/index.php?entry=entry080512-070238</id>
		<issued>2008-05-12T00:00:00Z</issued>
		<modified>2008-05-12T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Deep Thoughts...</title>
		<link rel="alternate" type="text/html" href="http://www.samurai-penguin.com/index.php?entry=entry080512-065739" />
		<content type="text/html" mode="escaped"><![CDATA[<img src="http://www.samurai-penguin.com/static/mccain_cn.jpg" width="450" height="317" border="0" alt="" />]]></content>
		<id>http://www.samurai-penguin.com/index.php?entry=entry080512-065739</id>
		<issued>2008-05-12T00:00:00Z</issued>
		<modified>2008-05-12T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Ubuntu MailServer Part 1: Making Postfix and Dovecot play nice</title>
		<link rel="alternate" type="text/html" href="http://www.samurai-penguin.com/index.php?entry=entry080509-114157" />
		<content type="text/html" mode="escaped"><![CDATA[This is the first entry in a series on how to build out a stable, easy to manage, multiple-domain mailserver.  I personally use this to host mail for my clients, and can say that it works quite well with no problems.  Postfix is the SMTP server, handling remote deliver of mail, as well as accepting incoming mail and delivering it to user&#039;s mailboxes.  Dovecot is responsible for accepting POP and IMAP connections, and reads mailboxes and sends them out.  I&#039;ll explore a few different avenues and optional features you can add or remove.  The original inspiration for this article is from the <a href="https://help.ubuntu.com/community/PostfixVirtualMailBoxClamSmtpHowto" target="_blank" >Ubuntu Wiki</a>.<br /><br /><br /><h3>Installing Core Software</h3><br />First, we&#039;ll want to install the core programs that will be our mailserver.  To do this:<br /><br /><code>sudo aptitude install postfix mailx dovecot-common dovecot-imapd dovecot-pop3d whois</code><br /><br />This may take a few minutes to complete.<br /><br /><h3>Configuring postfix</h3><br />Now, we&#039;ll tell postfix how we want it to work.  First, we&#039;re going to tell it where to store mail, and how to figure out what mailbox belongs to what user.  Add the following lines to /etc/postfix/main.cf:<br /><br /><code>home_mailbox = Maildir/<br />virtual_mailbox_domains = /etc/postfix/vhosts<br />virtual_mailbox_base = /home/vmail<br />virtual_mailbox_maps = hash:/etc/postfix/vmaps<br />virtual_minimum_uid = 1000<br />virtual_uid_maps = static:5000<br />virtual_gid_maps = static:5000<br /></code><br /><br />The virtual lines all imply that we&#039;re not applying a specific domain, but that it needs to read various files to find the user/domain names that it accepts mail for.  Let&#039;s go ahead and create those files:<br /><br /><b>/etc/postfix/vhosts:</b> Here, insert a list of all the domains you&#039;re hosting, each on its own line.  For example:<br /><br /><code>example.com<br />example.net<br />samurai-penguin.com</code><br /><br />and so on.  <br /><br /><b>/etc/postfix/vmaps:</b> Now we specify both the email addresses we host, and the paths to them. You should always use the domain.com/user paths to keep things straight.  Example:<br /><br /><code>abuse@example.com   example.com/abuse/<br /><a href="mailto:postmaster@example.com" target="_blank" >postmaster@example.com</a>   example.com/postmaster/<br /><a href="mailto:you@example.net" target="_blank" >you@example.net</a>   example.net/you/</code><br /><br /><i>IMPORTANT:</i> Make sure to postmap the vmaps file every time you change it so that postfix can use it.  Run the following command to do this:<br /><br /><code>sudo postmap /etc/postfix/vmaps</code><br /><br />Finally, we need to setup the mailbox user/group so that both postfix and dovecot can read the mail directories.<br /><br /><code>sudo groupadd -g 5000 vmail<br />sudo useradd -m -u 5000 -g 5000 -s /bin/bash vmail</code><br /><br /><h3>Configuring Dovecot</h3><br />For the dovecot configuration, there are a LOT of changes, so it&#039;s easier to simply copy over the configuration file. Download this file, backup your old /etc/dovecot/dovecot.conf file, and write this one.<br /><br /><a href="http://www.samurai-penguin.com/static/dovecot.conf" >Dovecot.conf</a><br /><br />What this does, essentially, is make dovecot play by the same rules we just told postfix to play by as far as how to recieve mail, where to look, etc.  We also tell it where to find it&#039;s username/password information.<br /><br /><h3>Adding Users</h3><br />Now it&#039;s time to actually create some users.  This is a two step process(really 3).  The first step is to add the domain name to postfix&#039;s /etc/postfix/vhosts file.  If it&#039;s already there, then just skip that.  <br /><br />For sanity, take a look at the configuration formats for the dovecot users.  In reality, you&#039;ll never have to touch these because we&#039;re going to automate the whole process.<br /><br /><b>/etc/dovecot/users</b><br /><code>info@domain1.com::5000:5000::/home/vmail/domain1.com/:/bin/false::</code><br /><br /><b>/etc/dovecot/passwd:</b><br /><code>info@domain1.com:$1$G/FqlOG5$Vj0xmc9fKY.UVr8OWr/7C1</code><br /><br />As I mentioned, you can/should use this script to do it all for you.  It takes care of adding the user to postfix and postmapping the config file, as well as setting the password for the dovecot user. Note that it doesn&#039;t actually create folders -- postfix will do that for us.<br /><br /><a href="http://www.samurai-penguin.com/static/adddovecotuser" >adddovecotuser</a><br /><br />Copy this file to somewhere like /usr/local/bin, and make sure it&#039;s executable (chmod +x adddovecotuser).  You have to run this script as root/sudo.  To add a user:<br /><br /><code>sudo adddovecotuser <a href="mailto:user@domain.com" target="_blank" >user@domain.com</a></code><br /><br />So long as the domain is in /etc/postfix/vhosts, that&#039;s it!  You should now have a mailserver that can recieve mail for you.  That&#039;s great and all, but there are still a few limitations which will be covered in subsequent HOWTO articles:<br /><br /> - No Spam Filtration<br /> - No Blocklists<br /> - No way to send mail from outside<br /> - No Antivirus scanning<br /> - No Webmail<br />Good luck, and feel free to post comments if you have any questions!]]></content>
		<id>http://www.samurai-penguin.com/index.php?entry=entry080509-114157</id>
		<issued>2008-05-09T00:00:00Z</issued>
		<modified>2008-05-09T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Bash one-line script to find common referrers</title>
		<link rel="alternate" type="text/html" href="http://www.samurai-penguin.com/index.php?entry=entry080505-145544" />
		<content type="text/html" mode="escaped"><![CDATA[Recently, I had a need to find common referring URLS for a site NOW (which meant no time to install webalizer, which I highly recommend.)  This is a fairly standard bash one-liner, but it might be useful to someone in a pinch:<br /><br /><code>grep &quot;/page.html&quot; access.* | awk &#039;{print $11}&#039; | sort | uniq -c | sort -n</code><br /><br />Basically, this checks for all requests to page.html in all access logs.  It then spits out only the 11th column(referrer), then counts and sorts.<br /><br />Other useful columns (assuming that you&#039;re using the standard &quot;combined&quot; log format:<br />  - $1 - IP address<br />  - $12+ - user agent<br />  - $6 - request type(GET, POST, PUT, etc.)<br /><br />This can be useful in a number of different ways.  For example, trying to find abusive behaviors can be done by looking for a lot of POST and PUT requests from a specific IP:<br /><br /><code>grep &quot;POST\|PUT&quot; access.* | awk &#039;{print $1}&#039; | sort | uniq -c | sort -n</code><br /><br />Hopefully this is of use to someone!]]></content>
		<id>http://www.samurai-penguin.com/index.php?entry=entry080505-145544</id>
		<issued>2008-05-05T00:00:00Z</issued>
		<modified>2008-05-05T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Welcome...</title>
		<link rel="alternate" type="text/html" href="http://www.samurai-penguin.com/index.php?entry=entry080504-213114" />
		<content type="text/html" mode="escaped"><![CDATA[After a few moves, this blog should be at a permanent home.  I&#039;d like to thank slicehost for being so damn awesome, that after moving around between various VPS providers, and even a dedicated, I&#039;m right back with them, rolling a 512slice. I&#039;ll be documenting my own personal touches on setting up an Ubuntu slice, especially the mailserver side.  I&#039;ll also be reposting some of the old articles (like the live earth background and custom prompts.) Feel free to leave thoughts in comments.  ]]></content>
		<id>http://www.samurai-penguin.com/index.php?entry=entry080504-213114</id>
		<issued>2008-05-05T00:00:00Z</issued>
		<modified>2008-05-05T00:00:00Z</modified>
	</entry>
</feed>
