<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>*.hosting &#187; Kevin</title>
	<atom:link href="http://blog.stardothosting.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stardothosting.com</link>
	<description>Star Dot Hosting : Technology, Security, Virtualization and Cloud Computing</description>
	<lastBuildDate>Mon, 30 Aug 2010 19:16:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Foundry Load Balancers HTTP sticky sessions</title>
		<link>http://blog.stardothosting.com/2010/08/30/foundry-load-balancers-http-sticky-sessions/</link>
		<comments>http://blog.stardothosting.com/2010/08/30/foundry-load-balancers-http-sticky-sessions/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 19:15:06 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Load Balancing]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=401</guid>
		<description><![CDATA[This post is intended to be a general guide for configuring &#8220;stickied&#8221; load balanced HTTP servers. Whether it&#8217;s F5 load balancers, foundry load balancers or open source based load balancers (keepalived/lvs), the concepts are the same and can be migrated across said platforms. If you have a paid of foundry&#8217;s and are looking to configure [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F30%2Ffoundry-load-balancers-http-sticky-sessions%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F30%2Ffoundry-load-balancers-http-sticky-sessions%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>This post is intended to be a general guide for configuring &#8220;stickied&#8221; load balanced HTTP servers. Whether it&#8217;s F5 load balancers, foundry load balancers or open source based load balancers (keepalived/lvs), the concepts are the same and can be migrated across said platforms.</p>
<p>If you have a paid of foundry&#8217;s and are looking to configure stickied load balanced HTTP servers, hopefully this guide will provide some assistance.</p>
<ul>
<strong>Logging into the load balancer</strong></ul>
<p>Telnet to the box and &#8216;enable&#8217; to allow admin access. The first thing you want to do is show the current configuration to view the existing setup for other working boxes :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&gt; telnet 192.x.x.x<br />
Trying 192.x.x.x...<br />
Connected to 10.x.x.x.<br />
Escape character is '^]'.<br />
<br />
User Access Verification<br />
<br />
Please Enter Login Name: admin<br />
Please Enter Password: <br />
<br />
User login successful.<br />
<br />
SLB-telnet@XXXX&gt;enable<br />
Enable Password:<br />
Error - Incorrect username or password.<br />
SLB-telnet@XXXX&gt;enable<br />
Enable Password:<br />
SLB-telnet@XXXX#</div></div>
<ul>
<strong>Real servers : defining the multiple load balanced boxes</strong></ul>
<p>Show the existing configuration on the foundary :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sh config</div></div>
<p>Take a look at the configuration of two &#8220;real&#8221; servers, which are the two servers that are behind the load balancer that will have balanced sticky connections :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">server real serverposapp01-tomcat01 192.168.1.141<br />
&nbsp;port default disable<br />
&nbsp;port 8001<br />
! &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
!<br />
server real serverposapp03-tomcat01 192.168.1.143<br />
&nbsp;port default disable<br />
&nbsp;port 8001</div></div>
<p>The above example is balancing TCP 8001 traffic, which is for TOMCAT. Here are entries for two servers doing simple HTTP traffic :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">server real serverapp01-vhost01 192.168.1.195<br />
&nbsp;port default disable &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;port http<br />
&nbsp;port http keepalive<br />
&nbsp;port http url &quot;HEAD /&quot;<br />
!<br />
server real serverapp02-vhost01 192.168.1.196<br />
&nbsp;port default disable<br />
&nbsp;port http<br />
&nbsp;port http keepalive<br />
&nbsp;port http url &quot;HEAD /&quot;</div></div>
<p>This example is similar to the tomcat example, except you have several options. &#8220;port default disable&#8221; disables all other ports. &#8220;port http keepalive&#8221; and &#8220;port http url &#8220;HEAD /&#8221;" define the http checks that take place to ensure apache is running on that box. If not , it will fail over to the second box and stop sending traffic to it.</p>
<ul>
<strong>SSL Connections</strong></ul>
<p>SSL incoming connections are handled by the load balancer initially, then passed off to the actual server as regular http / port 80 traffic. The internal box configuration would be similar to the above configuration examples :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">server virtual portal 192.168.1.104<br />
&nbsp;port default disable<br />
&nbsp;port ssl sticky<br />
&nbsp;port ssl ssl-terminate portal<br />
&nbsp;bind ssl serverapp01-portal01 http<br />
<br />
Notice how instead of &quot;port http sticky&quot; , its &quot;port ssl sticky&quot;. First of all, the sticky option is only set on the &quot;virtual&quot; configuration directives. Secondly, the SSL traffic is bound to the real servers via http in the last line of this example. Its pretty self explanatory.<br />
[edit] Regular HTTP Sticky Connections<br />
<br />
If no SSL Is being used on the site at all, then all you need is to set an HTTP virtual configuration :<br />
<br />
&lt;code&gt;<br />
server virtual serverapp-vhost01 192.168.1.106<br />
&nbsp;port default disable<br />
&nbsp;port http sticky &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;bind http serverapp02-vhost01 http</div></div>
<ul>
<strong>Configuring the external IP to NAT to the internal virtual</strong></ul>
<p>Typically, you will have a firewall in front of the load balancer that actaully holds the external ip addresses. The traffic is filtered initially by the firewall, then NAT&#8217;d to the virtual ip (VIP) of the load balancer, which then handles balancing the traffic.</p>
<p>You will need to either establish a new external ip , or use an existing one (for instance, if you are moving from 1 web server to 2 web servers , and want to balance the traffic using the load balancer). You need to setup the external IP address, and NAT it to the internal VIP.</p>
<ul>
<strong>Verifying the configuration works</strong></ul>
<p>Once everything is setup properly, and the external IP is being NAT&#8217;d to the load balancer, it is time to ensure the load balancer is seeing the connections. You could do this before doing the switchover on the firewall as well, just to ensure everything looks right before actually doing the switchover.</p>
<p>To see the active connections being load balanced, issue the following command (replacing the servername for whichever one you want to check) :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sh server real serverapp02-vhost01</div></div>
<p>That should display information similar to this :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Real Servers Info<br />
========================<br />
State(St) - ACT:active, ENB:enabled, FAL:failed, TST:test, DIS:disabled,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UNK:unknown, UNB:unbind, AWU:await-unbind, AWD:await-delete<br />
<br />
Name: serverapp02-vhost01 &nbsp; &nbsp; State: Active &nbsp; &nbsp; &nbsp; Cost: 0 &nbsp;IP:192.168.1.196: &nbsp; 1<br />
Mac: 0012.7990.d06a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Weight: 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MaxConn: 2000000<br />
SrcNAT: not-cfg, not-op &nbsp; &nbsp; &nbsp;DstNAT: not-cfg, not-op &nbsp; &nbsp;Serv-Rsts: 0<br />
tcp conn rate:udp conn rate = 1:0, max tcp conn rate:max udp conn rate = 8:0<br />
BP max local conn configured No: 0 0 0 0 0 0 <br />
BP max conn percentage configured No: 0 0 0 0 0 0 <br />
Use local conn : No<br />
<br />
Port &nbsp; &nbsp;St &nbsp;Ms ServerConn TotConn &nbsp; &nbsp;Rx-pkts &nbsp; Tx-pkts &nbsp; Rx-octet &nbsp; Tx-octet &nbsp; Reas<br />
---- &nbsp; &nbsp;-- &nbsp;-- ------- ------- &nbsp; &nbsp;------- &nbsp; ------- &nbsp; -------- &nbsp; -------- &nbsp; ----<br />
default DIS 0 &nbsp;0 &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp;<br />
http &nbsp; &nbsp;ACT 0 &nbsp;104 &nbsp; &nbsp; 13094 &nbsp; &nbsp; &nbsp;181671 &nbsp; &nbsp;150813 &nbsp; &nbsp;162364862 &nbsp;20325115 &nbsp; 0 &nbsp;<br />
<br />
Server &nbsp;Total &nbsp;104 &nbsp; &nbsp; 13094 &nbsp; &nbsp; &nbsp;181671 &nbsp; &nbsp;150813 &nbsp; &nbsp;162364862 &nbsp;20325115 &nbsp; 0</div></div>
<p>The above is displaying the specific connection details for a single real server. To check the VIP / Virtual server :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sh server virtual tomcat</div></div>
<p>Which will display the following :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Virtual Servers Info<br />
<br />
Name: tomcat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; State: Enabled &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IP:192.168.1.101: &nbsp; 1<br />
Pred: least-conn &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ACL-Id: 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TotalConn: 149959<br />
<br />
Port &nbsp; &nbsp;State &nbsp; &nbsp; Sticky &nbsp;Concur &nbsp;Proxy &nbsp;DSR &nbsp; ServerConn &nbsp;TotConn &nbsp;PeakConn &nbsp;<br />
---- &nbsp; &nbsp;----- &nbsp; &nbsp; ------ &nbsp;------ &nbsp;----- &nbsp;--- &nbsp; ------- &nbsp;------- &nbsp;-------- &nbsp;<br />
<br />
default disabled &nbsp;NO &nbsp; &nbsp; &nbsp;NO &nbsp; &nbsp; &nbsp;NO &nbsp; &nbsp; NO &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; &nbsp; <br />
ssl &nbsp; &nbsp; enabled &nbsp; YES &nbsp; &nbsp; NO &nbsp; &nbsp; &nbsp;NO &nbsp; &nbsp; NO &nbsp; &nbsp;46 &nbsp; &nbsp; &nbsp; 149959 &nbsp; 443</div></div>
<p>You can see that &#8220;ServerConn&#8221; is displaying 46 connections. Thats it! </p>
<p><a href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F30%2Ffoundry-load-balancers-http-sticky-sessions%2F&amp;linkname=Foundry%20Load%20Balancers%20HTTP%20sticky%20sessions" title="Digg" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a> <a href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F30%2Ffoundry-load-balancers-http-sticky-sessions%2F&amp;linkname=Foundry%20Load%20Balancers%20HTTP%20sticky%20sessions" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a> <a href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F30%2Ffoundry-load-balancers-http-sticky-sessions%2F&amp;linkname=Foundry%20Load%20Balancers%20HTTP%20sticky%20sessions" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a> <a href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F30%2Ffoundry-load-balancers-http-sticky-sessions%2F&amp;linkname=Foundry%20Load%20Balancers%20HTTP%20sticky%20sessions" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.stardothosting.com/2010/08/30/foundry-load-balancers-http-sticky-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Xen template</title>
		<link>http://blog.stardothosting.com/2010/08/03/creating-a-xen-template/</link>
		<comments>http://blog.stardothosting.com/2010/08/03/creating-a-xen-template/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 20:33:47 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=387</guid>
		<description><![CDATA[One way to increase the efficiencies of Xen based systems is to utilize templates. VMware talks about this in their whitepaper for ESX2 best practices. With Xen, you have to create your own. Here is a straight forward guide for how to do it. 1. Bootstrap a DomU named -tpl (e.g. centos4-tpl). I recommend using [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F03%2Fcreating-a-xen-template%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F03%2Fcreating-a-xen-template%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>One way to increase the efficiencies of Xen based systems is to utilize templates. VMware talks about this in their whitepaper for ESX2 best practices.</p>
<p>With Xen, you have to create your own. Here is a straight forward guide for how to do it.</p>
<p><big><b><u>1. Bootstrap a DomU named <distname>-tpl (e.g. centos4-tpl).</big></b></u></p>
<p>I recommend using a file-backed VBD, but partition or LVM volume will work fine as well. Here is an example /etc/xen/centos4-tpl</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">kernel = &quot;/boot/vmlinuz-2.6.12.6-xenU&quot;<br />
memory = 256<br />
name = &quot;centos4-tpl&quot; <br />
disk = [ &nbsp;'file:/opt/xen/domains/centos4-tpl/diskimage,sdb1,w','file:/opt/xen/domains/centos4-tpl/swapimage,sdb2,w' &nbsp;]<br />
root = &quot;/dev/sdb1 ro&quot;<br />
dhcp=&quot;dhcp</div></div>
<p>This is just a normal system (DomU) install &#8211; see Centos-4 on Xen for an example. Un-customize files</p>
<p><big><b><u>2.Inside the VM, edit the following files</big></u></b></p>
<p><b>/etc/hosts</b><br />
remove any address lines other than localhost</p>
<p><b>/etc/sysconfig/network</b><br />
use a generic hostname which will be unique to each deployment</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">NETWORKING=yes<br />
HOSTNAME=centos4-tpl-changeme.example.com</div></div>
<p><b>/etc/sysconfig/network-scripts/ifcfg-eth0</b><br />
should look like this:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DEVICE=eth0<br />
ONBOOT=yes<br />
BOOTPROTO=dhcp</div></div>
<p>also important &#8211; remove any line starting with HWADDR, e.g.:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">HWADDR=00:10:5A:XX:YY:ZZ</div></div>
<p>Other configuration files to consider tweaking include /etc/dhclient.conf &#038; /etc/hosts</p>
<p><big><b><u>3. Files to remove:</b></big></u></p>
<p>- SSH Host key files (auto-created at boot time)</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rm -f /etc/ssh/*host*</div></div>
<p><big><b><u>4. Shutdown the template VM</big></b></u></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xm shutdown centos4-tpl</div></div>
<p>You might normally link your VMs into /etc/xen/auto. I recommend against this as the template VM can be left shutdown until/unless you want to update it, saving valuable RAM and CPU cycles.</p>
<p>Clone the virtual disk Now we can deploy from the template by cloning the data into a clean diskimage (or partition or LVM volume). Create the diskimage using an appropriate size (must be larger than the template). Oh -the nice thing here is that there is flexibility. For instance, you can have a file-based diskimage and clone the data onto LVM volumes. As long as you can mount the (virtual) disks, you can clone templatized systems.</p>
<p>Here we use /mnt/disk to mount the new system disk, and /mnt/image to mount the template disk.</p>
<p>First, mount the template disk.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mount -o loop /opt/xen/domains/centos4-tpl/diskimage /mnt/image</div></div>
<p>Next, create and mount the new system (DomU) disk space &#038; swap space.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mkdir -p /opt/xen/domains/cloned<br />
cd /opt/xen/domains/cloned<br />
dd if=/dev/zero of=diskimage bs=1024k count=2048<br />
dd if=/dev/zero of=swapimage bs=1024k count=256<br />
mkfs.ext3 diskimage<br />
mkswap swapimage<br />
mkdir -p /mnt/disk<br />
mount -o loop /opt/xen/domains/cloned/diskimage /mnt/disk</div></div>
<p>Create the exclude file in /tmp/XenCloneExclude</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">proc/*<br />
users/*<br />
tmp/*<br />
lost+found/<br />
etc/mtab</div></div>
<p>Copy the data across</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rsync -av -SHWD --exclude-from=&quot;/tmp/XenCloneExclude&quot; /mnt/image/ /mnt/disk</div></div>
<p>Chroot into the newly copied template and fixup certain files</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">chroot /mnt/disk /bin/bash</div></div>
<p>Fix the hostname, etc in the files we &#8220;un-customized&#8221; in the template.</p>
<p>Exit, unmount both the template image and volume</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">umount /mnt/disk<br />
umount /mnt/image</div></div>
<p>Setup your Xen config and be on your way!</p>
<p>cd /etc/xen<br />
cp centos4-tpl cloned<br />
(edit cloned to change name and paths to disk and swap)<br />
xm create -c cloned</p>
<p><a href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F03%2Fcreating-a-xen-template%2F&amp;linkname=Creating%20a%20Xen%20template" title="Digg" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a> <a href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F03%2Fcreating-a-xen-template%2F&amp;linkname=Creating%20a%20Xen%20template" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a> <a href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F03%2Fcreating-a-xen-template%2F&amp;linkname=Creating%20a%20Xen%20template" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a> <a href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F08%2F03%2Fcreating-a-xen-template%2F&amp;linkname=Creating%20a%20Xen%20template" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.stardothosting.com/2010/08/03/creating-a-xen-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hosting Coupon : 60% off the first month for ANY plan!</title>
		<link>http://blog.stardothosting.com/2010/07/15/hosting-coupon-60-off-the-first-month-for-any-plan/</link>
		<comments>http://blog.stardothosting.com/2010/07/15/hosting-coupon-60-off-the-first-month-for-any-plan/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 17:02:16 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Company Announcements]]></category>
		<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=380</guid>
		<description><![CDATA[Hello there, Just thought I&#8217;d share an exclusive coupon / discount for all of our shared / vps hosting plans that allows for 60% off the first month of hosting fee&#8217;s : COUPON CODE : SDHTWT2010 Take a look at our main site for plan details. This coupon expires and there is only a limited [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F15%2Fhosting-coupon-60-off-the-first-month-for-any-plan%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F15%2Fhosting-coupon-60-off-the-first-month-for-any-plan%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello there,</p>
<p>Just thought I&#8217;d share an exclusive coupon / discount for all of our shared / vps hosting plans that allows for 60% off the first month of hosting fee&#8217;s :</p>
<p><big><b>COUPON CODE : SDHTWT2010</big></b></p>
<p>Take a look at our <a href="http://www.stardothosting.com" target="_new">main site</a> for plan details. This coupon expires and there is only a limited number of them available!</p>
<p>Don&#8217;t say we never gave you nothin&#8217; <img src='http://blog.stardothosting.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><a href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F15%2Fhosting-coupon-60-off-the-first-month-for-any-plan%2F&amp;linkname=Hosting%20Coupon%20%3A%2060%25%20off%20the%20first%20month%20for%20ANY%20plan%21" title="Digg" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a> <a href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F15%2Fhosting-coupon-60-off-the-first-month-for-any-plan%2F&amp;linkname=Hosting%20Coupon%20%3A%2060%25%20off%20the%20first%20month%20for%20ANY%20plan%21" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a> <a href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F15%2Fhosting-coupon-60-off-the-first-month-for-any-plan%2F&amp;linkname=Hosting%20Coupon%20%3A%2060%25%20off%20the%20first%20month%20for%20ANY%20plan%21" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a> <a href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F15%2Fhosting-coupon-60-off-the-first-month-for-any-plan%2F&amp;linkname=Hosting%20Coupon%20%3A%2060%25%20off%20the%20first%20month%20for%20ANY%20plan%21" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.stardothosting.com/2010/07/15/hosting-coupon-60-off-the-first-month-for-any-plan/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Company site re-design</title>
		<link>http://blog.stardothosting.com/2010/07/14/company-site-re-design/</link>
		<comments>http://blog.stardothosting.com/2010/07/14/company-site-re-design/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 18:04:27 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Company Announcements]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=377</guid>
		<description><![CDATA[Greetings! I thought it would be prudent to let you all know that we have recently re-designed our front facing company website. You&#8217;ll also notice that our core prices for shared and VPS hosting have been significantly lowered, with resources allocated for each plan increased significantly (!). Take a look at our site, if you [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F14%2Fcompany-site-re-design%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F14%2Fcompany-site-re-design%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Greetings!</p>
<p>I thought it would be prudent to let you all know that we have recently re-designed our front facing company website.</p>
<p>You&#8217;ll also notice that our core prices for shared and VPS hosting have been significantly lowered, with resources allocated for each plan increased significantly (!).</p>
<p>Take a look at our site, if you haven&#8217;t already : <a href="http://www.stardothosting.com" target="_new"><big><b>www.stardothosting.com</a></big></b></p>
<p><a href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F14%2Fcompany-site-re-design%2F&amp;linkname=Company%20site%20re-design" title="Digg" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a> <a href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F14%2Fcompany-site-re-design%2F&amp;linkname=Company%20site%20re-design" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a> <a href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F14%2Fcompany-site-re-design%2F&amp;linkname=Company%20site%20re-design" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a> <a href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F14%2Fcompany-site-re-design%2F&amp;linkname=Company%20site%20re-design" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.stardothosting.com/2010/07/14/company-site-re-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Query Log &#8211; diagnosing and debugging mysql</title>
		<link>http://blog.stardothosting.com/2010/07/12/mysql-query-log-diagnosing-and-debugging-mysql/</link>
		<comments>http://blog.stardothosting.com/2010/07/12/mysql-query-log-diagnosing-and-debugging-mysql/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 18:13:53 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=373</guid>
		<description><![CDATA[The general query log is a general record of what mysqld is doing. The server writes information to this log when clients connect or disconnect, and it logs each SQL statement received from clients. The general query log can be very useful when you suspect an error in a client and want to know exactly [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F12%2Fmysql-query-log-diagnosing-and-debugging-mysql%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F12%2Fmysql-query-log-diagnosing-and-debugging-mysql%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>The general query log is a general record of what mysqld is doing. The server writes information to this log when clients connect or disconnect, and it logs each SQL statement received from clients. The general query log can be very useful when you suspect an error in a client and want to know exactly what the client sent to mysqld.</p>
<p>mysqld writes statements to the query log in the order that it receives them, which might differ from the order in which they are executed. This logging order contrasts to the binary log, for which statements are written after they are executed but before any locks are released. (Also, the query log contains all statements, whereas the binary log does not contain statements that only select data.)</p>
<p>To enable the general query log, start mysqld with the &#8211;log[=file_name] or -l [file_name] option.</p>
<p>If no file_name value is given for &#8211;log or -l, the default name is host_name.log in the data directory.</p>
<p>Server restarts and log flushing do not cause a new general query log file to be generated (although flushing closes and reopens it). On Unix, you can rename the file and create a new one by using the following commands:</p>
<pre>
shell> mv host_name.log host_name-old.log
shell> mysqladmin flush-logs
shell> cp host_name-old.log backup-directory
shell> rm host_name-old.log
</pre>
<p>Before 5.0.17, you cannot rename a log file on Windows while the server has it open. You must stop the server and rename the file, and then restart the server to create a new log file. As of 5.0.17, this applies only to the error log. However, a stop and restart can be avoided by using FLUSH LOGS, which causes the server to rename the error log with an -old suffix and open a new error log. </p>
<p><a href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F12%2Fmysql-query-log-diagnosing-and-debugging-mysql%2F&amp;linkname=MySQL%20Query%20Log%20%26%238211%3B%20diagnosing%20and%20debugging%20mysql" title="Digg" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a> <a href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F12%2Fmysql-query-log-diagnosing-and-debugging-mysql%2F&amp;linkname=MySQL%20Query%20Log%20%26%238211%3B%20diagnosing%20and%20debugging%20mysql" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a> <a href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F12%2Fmysql-query-log-diagnosing-and-debugging-mysql%2F&amp;linkname=MySQL%20Query%20Log%20%26%238211%3B%20diagnosing%20and%20debugging%20mysql" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a> <a href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F12%2Fmysql-query-log-diagnosing-and-debugging-mysql%2F&amp;linkname=MySQL%20Query%20Log%20%26%238211%3B%20diagnosing%20and%20debugging%20mysql" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.stardothosting.com/2010/07/12/mysql-query-log-diagnosing-and-debugging-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove mail headers in Postfix outgoing mail</title>
		<link>http://blog.stardothosting.com/2010/07/08/remove-mail-headers-in-postfix-outgoing-mail/</link>
		<comments>http://blog.stardothosting.com/2010/07/08/remove-mail-headers-in-postfix-outgoing-mail/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 19:04:07 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Mail]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=369</guid>
		<description><![CDATA[This post is intended for people who want to set up Postfix to remove specific headers within emails that pass through their systems. The most common use for this is to set up a relaying server that will remove any reference of where source emails originated and relevant information about the sender&#8217;s computer. Another useful [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F08%2Fremove-mail-headers-in-postfix-outgoing-mail%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F08%2Fremove-mail-headers-in-postfix-outgoing-mail%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>This post is intended for people who want to set up Postfix to remove specific headers within emails that pass through their systems. The most common use for this is to set up a relaying server that will remove any reference of where source emails originated and relevant information about the sender&#8217;s computer. Another useful application for this type of header_checks is to remove details about additional functions of your mail server that you do not want made available to the world.</p>
<p>This guide focuses on postfix&#8217;s header_checks capabilities, and although there are other ways to do so, we&#8217;ve found that this is by far the simplest.</p>
<p><big><u><b>IMPORTANT NOTES</b></u></big></p>
<p>Use these instructions at your own risk. Never test things out in a production environment!</p>
<p>In order for this to work, your main.cf file will have to have a reference to the header_checks file as follows: </p>
<pre>header_checks = regexp:/etc/postfix/maps/header_checks</pre>
<p>It is recomended that you keep all of your postfix map files in one directory along with any checks files. In this case, these will be kept in /etc/postfix/maps.</p>
<p><big><b><u>HEADER_CHECKS DETAILS</u></b></big></p>
<p>In addition to any spam filters (see our header_checks file for more information), the below lines should be added to your header_checks file to preserve privacy and remove headers for the internal operations of your mail server:</p>
<pre>
    # Sample For Dropping Headers:
    #/^Header: IfContains/ 	IGNORE
    /^Received: from 127.0.0.1/ 	IGNORE
    /^User-Agent:/ 	IGNORE
    /^X-Mailer:/ 	IGNORE
    /^X-Originating-IP:/ 	IGNORE
</pre>
<p>Each line above will search for headers tha have the content between the /^ and the / and will remove each line within the email headers that matches. As an example, the line &#8220;/^Received: from 127.0.0.1 .*/ IGNORE&#8221; will erase any lines from the email headers that list previous handoffs from an internal mail process to another. This is most commonly used for antivirus or antispam functions on a mail server.</p>
<p>The following lines are related to Anomy Sanitizer and SpamAssassin &#8211; two very useful products. These three lines will remove references from the headers for the two software packages, making sure that the users of the system will not easily identify the software that is running on the back end.</p>
<pre>
    # Sample For Dropping Headers:
    #/^Header: IfContains/ 	IGNORE
    /^Received: from 127.0.0.1/ 	IGNORE
    /^X-Sanitizer:/ 	IGNORE
    /^X-Spam-Status:/ 	IGNORE
    /^X-Spam-Level:/ 	IGNORE
</pre>
<p>If one were to want to remove all headers relevant to personal information and previous hosts on which the email has passed, the following would be a possible configuration. Note that by removing all of this information, some mail servers will automatically identify emails passing through this system as spam. You will also be removing useful information for troubleshooting any problems that may arise with the mail server.</p>
<pre>
    # Sample For Dropping Headers:
    #/^Header: IfContains/ 	IGNORE
    /^Received:/ 	IGNORE
    /^User-Agent:/ 	IGNORE
    /^Message-ID:/ 	IGNORE
    /^X-Mailer:/ 	IGNORE
    /^X-MimeOLE:/ 	IGNORE
    /^X-MSMail-Priority:/ 	IGNORE
    /^X-Spam-Status:/ 	IGNORE
    /^X-Spam-Level:/ 	IGNORE
    /^X-Sanitizer:/ 	IGNORE
    /^X-Originating-IP:/ 	IGNORE
</pre>
<p>Hopefully this will help you clean your mail headers up! <img src='http://blog.stardothosting.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F08%2Fremove-mail-headers-in-postfix-outgoing-mail%2F&amp;linkname=Remove%20mail%20headers%20in%20Postfix%20outgoing%20mail" title="Digg" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a> <a href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F08%2Fremove-mail-headers-in-postfix-outgoing-mail%2F&amp;linkname=Remove%20mail%20headers%20in%20Postfix%20outgoing%20mail" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a> <a href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F08%2Fremove-mail-headers-in-postfix-outgoing-mail%2F&amp;linkname=Remove%20mail%20headers%20in%20Postfix%20outgoing%20mail" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a> <a href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F07%2F08%2Fremove-mail-headers-in-postfix-outgoing-mail%2F&amp;linkname=Remove%20mail%20headers%20in%20Postfix%20outgoing%20mail" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.stardothosting.com/2010/07/08/remove-mail-headers-in-postfix-outgoing-mail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically Deploy Debian Load Balancers with bash scripting</title>
		<link>http://blog.stardothosting.com/2010/06/14/automatically-deploy-debian-load-balancers-with-bash-scripting/</link>
		<comments>http://blog.stardothosting.com/2010/06/14/automatically-deploy-debian-load-balancers-with-bash-scripting/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 19:58:46 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Scripting]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=361</guid>
		<description><![CDATA[In yet another post in our automation series, we will share a bash script that automates the deployment of debian based load balancers (specifically with LVS / Linux Virtual Server project). Even though the environments and systems you deploy may start to get more complicated such as with load balancers, there will always be a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F14%2Fautomatically-deploy-debian-load-balancers-with-bash-scripting%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F14%2Fautomatically-deploy-debian-load-balancers-with-bash-scripting%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In yet another post in our automation series, we will share a bash script that automates the deployment of debian based load balancers (specifically with LVS / <a href="http://www.linuxvirtualserver.org/" target="_new">Linux Virtual Server project</a>).</p>
<p>Even though the environments and systems you deploy may start to get more complicated such as with load balancers, there will always be a baseline level with which these systems can be brought to before further configuration and customization needs to be done. </p>
<p>There are many things that can be automated with this process, as you will see in the script below. In most round-robin load balancing scenarios, there wouldn&#8217;t be much more that needs to be done as far as configuration beyond what this script can do.</p>
<p>Obviously you will likely need to modify the script to suit your needs and requirements for the organization and standards therein.</p>
<p>Hopefully this will help you roll out many debian load balancers! May the load be split evenly between all your systems <img src='http://blog.stardothosting.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<span style="color: #666666; font-style: italic;"># Debian LVS deployer script</span><br />
<span style="color: #666666; font-style: italic;"># Version 1.0</span><br />
<br />
<span style="color: #007800;">PROGNAME</span>=<span style="color: #ff0000;">&quot;$0&quot;</span><br />
<span style="color: #007800;">VERSION</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># working directory for deployer process.</span><br />
<span style="color: #007800;">WORKDIR</span>=<span style="color: #ff0000;">&quot;/root&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># tasks left (this is updated every step to accommodate recovery during</span><br />
<span style="color: #666666; font-style: italic;"># the deployer &nbsp;process)</span><br />
<span style="color: #007800;">TASKS</span>=<span style="color: #ff0000;">&quot;./deploy-lvs.tasks&quot;</span><br />
<br />
init_tasks<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># This function will write a new tasks file.</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># it's called from the main body of the script if a tasks file does not exist.</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$TASKS</span><span style="color: #000000; font-weight: bold;">&lt;&lt;</span>EOS <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
nopasswd_ssh<br />
add_pkgs<br />
get_lvs<br />
configure_lvs<br />
set_hostname<br />
EOS<br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
installer_splash<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] &nbsp;LVS deployer script starting...&quot;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot; &nbsp; &nbsp;Version: <span style="color: #007800;">$VERSION</span>&quot;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
nopasswd_ssh<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># disable passwd auth on SSH</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Disabling password authentication for SSH... &quot;</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-pi</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/^PasswordAuthentication yes/PasswordAuthentication no/g'</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>sshd_config<br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-pi</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/^#PermitRootLogin yes/PermitRootLogin without-password/g'</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>sshd_config<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> restart<br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
add_pkgs<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #007800;">PKGS</span>=<span style="color: #ff0000;">&quot;libssl0.9.7 exim4 iproute ethtool tcpdump snmpd pciutils less python&quot;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Installing packages: <span style="color: #007800;">$PKGS</span>... &quot;</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #007800;">$PKGS</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
get_lvs<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Downloading &nbsp;packages... &quot;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># download the latest version of the &nbsp;Client firewall package.</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">--no-check-certificate</span> http:<span style="color: #000000; font-weight: bold;">//</span>your.domain.com<span style="color: #000000; font-weight: bold;">/</span>lvs.tgz <span style="color: #660033;">-O</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>firewall.tgz <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># unpack firewall scripts</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--no-same-owner</span> <span style="color: #660033;">--no-same-permissions</span> <span style="color: #660033;">--directory</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-zxvf</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>firewall.tgz <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>firewall.tgz <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
configure_lvs<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># time to configure the &nbsp;FW</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">KAD</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>keepalived<span style="color: #000000; font-weight: bold;">/</span>keepalived.conf<br />
&nbsp; &nbsp; <span style="color: #007800;">FW</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>firewall<br />
&nbsp; &nbsp; <span style="color: #007800;">COMMIT</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>lvs-commit.sh<br />
&nbsp; &nbsp; <span style="color: #007800;">HOSTS</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts<br />
&nbsp; &nbsp; <span style="color: #007800;">INTERFACES</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>interfaces<br />
&nbsp; &nbsp; <span style="color: #007800;">NRPE</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nagios<span style="color: #000000; font-weight: bold;">/</span>nrpe_local.cfg<br />
&nbsp; &nbsp; <span style="color: #007800;">EXIM</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>exim4<span style="color: #000000; font-weight: bold;">/</span>update-exim4.conf.conf<br />
&nbsp; &nbsp; <span style="color: #007800;">CONFIGURE_LVS</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>configure-lvs.pl<br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Configuring LVS...&quot;</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #007800;">$CONFIGURE_LVS</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[!] ERROR: Configuring LVS script failed!&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Moving files into place...&quot;</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #800000;">${KAD}</span><span style="color: #660033;">-template</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #800000;">${FW}</span><span style="color: #660033;">-template</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #800000;">${COMMIT}</span><span style="color: #660033;">-template</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #800000;">${CONFIGURE_LVS}</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #800000;">${HOSTS}</span>.new <span style="color: #800000;">${HOSTS}</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #800000;">${INTERFACES}</span>.new <span style="color: #800000;">${INTERFACES}</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #800000;">${NRPE}</span>.new <span style="color: #800000;">${NRPE}</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #800000;">${EXIM}</span>.new <span style="color: #800000;">${EXIM}</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">700</span> <span style="color: #800000;">${FW}</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">700</span> <span style="color: #800000;">${COMMIT}</span><br />
&nbsp; &nbsp; update-rc.d keepalived defaults <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; update-exim4.conf <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># for compatibility</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Generating RSA Keys&quot;</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa <span style="color: #660033;">-f</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa <span style="color: #660033;">-P</span> <span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span><br />
<br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
clean_up_and_reboot<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># remove:</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># -- temp task file</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$TASKS</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># remove self from .bashrc</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>.bashrc.orig <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>.bashrc.orig <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>.bashrc<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>.bashrc <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>.bashrc<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># delete self</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$0</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># and reboot.</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Please reboot system.&quot;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">#reboot -n</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
debug_quit<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># hard exit the script in appropriately referenced files </span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># so that no reboot happens.</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;debug_quit seen in tasks file, exiting.&quot;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
set_hostname<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Setting LVS hostname... &quot;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mailname<br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
usage<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Usage: <span style="color: #007800;">$PROGNAME</span>&quot;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">0</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">###############################</span><br />
<span style="color: #666666; font-style: italic;">### MAIN SCRIPT STARTS HERE ###</span><br />
<span style="color: #666666; font-style: italic;">###############################</span><br />
<br />
<span style="color: #666666; font-style: italic;"># installer_splash</span><br />
installer_splash<br />
<br />
<span style="color: #666666; font-style: italic;"># fix working dir.</span><br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$WORKDIR</span><br />
<br />
<span style="color: #666666; font-style: italic;"># does our installer file exist? if not, initalize it.</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$TASKS</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] No task file found, installation will start from beginning.&quot;</span><br />
&nbsp; &nbsp; init_tasks<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$?</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[!] ERROR: Cannot create tasks file. Installation will not continue.&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #000000; font-weight: bold;">else</span> <br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Tasks file located - starting where you left off.&quot;</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #666666; font-style: italic;"># start popping off tasks from the task list and running them.</span><br />
<span style="color: #666666; font-style: italic;"># pop first step off of the list</span><br />
<span style="color: #007800;">STEP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1</span> <span style="color: #007800;">$TASKS</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$STEP</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># execute the function.</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>###################################&quot;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Running step: <span style="color: #007800;">$STEP</span>&quot;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;###################################<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><br />
&nbsp; &nbsp; <span style="color: #007800;">$STEP</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$?</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># command failed.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[!] ERROR: Step <span style="color: #007800;">$STEP</span> failed!&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot; &nbsp; &nbsp;Installation will now abort - you can pick it up after fixing the problem&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># throw up a newline just so things don't look so crowded</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># remove function from function list.</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-pi</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/<span style="color: #007800;">$STEP</span><span style="color: #000099; font-weight: bold;">\n</span>?//&quot;</span> <span style="color: #007800;">$TASKS</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #007800;">STEP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1</span> <span style="color: #007800;">$TASKS</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #666666; font-style: italic;"># clean_up_and_reboot</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[+] Installation finished - cleaning up.&quot;</span><br />
clean_up_and_reboot<br />
<br />
<span style="color: #666666; font-style: italic;"># script is done now - termination should happen with clean_up_and_reboot.</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[!] Should not be here!&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span></div></div>
<p><a href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F14%2Fautomatically-deploy-debian-load-balancers-with-bash-scripting%2F&amp;linkname=Automatically%20Deploy%20Debian%20Load%20Balancers%20with%20bash%20scripting" title="Digg" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a> <a href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F14%2Fautomatically-deploy-debian-load-balancers-with-bash-scripting%2F&amp;linkname=Automatically%20Deploy%20Debian%20Load%20Balancers%20with%20bash%20scripting" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a> <a href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F14%2Fautomatically-deploy-debian-load-balancers-with-bash-scripting%2F&amp;linkname=Automatically%20Deploy%20Debian%20Load%20Balancers%20with%20bash%20scripting" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a> <a href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F14%2Fautomatically-deploy-debian-load-balancers-with-bash-scripting%2F&amp;linkname=Automatically%20Deploy%20Debian%20Load%20Balancers%20with%20bash%20scripting" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.stardothosting.com/2010/06/14/automatically-deploy-debian-load-balancers-with-bash-scripting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatically Deploy Debian Firewalls with bash scripting</title>
		<link>http://blog.stardothosting.com/2010/06/02/automatically-deploy-debian-firewalls-with-bash-scripting/</link>
		<comments>http://blog.stardothosting.com/2010/06/02/automatically-deploy-debian-firewalls-with-bash-scripting/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 19:47:25 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Scripting]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=342</guid>
		<description><![CDATA[Automation is as necessary as any other aspect of systems administration in any critical or production environment where growth and scalability are moving at a significant pace. Growth in any organization is obviously a good thing. In the systems administrator&#8217;s perspective, however, growth can mean more time spent deploying systems and less time spent focusing [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F02%2Fautomatically-deploy-debian-firewalls-with-bash-scripting%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F02%2Fautomatically-deploy-debian-firewalls-with-bash-scripting%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Automation is as necessary as any other aspect of systems administration in any critical or production environment where growth and scalability are moving at a significant pace.</p>
<p>Growth in any organization is obviously a good thing. In the systems administrator&#8217;s perspective, however, growth can mean more time spent deploying systems and less time spent focusing on other duties.</p>
<p>Automating the server deployment process is the natural next step when your organization has grown to a point where time efficiency becomes more relevant and noticeable to your business owners.</p>
<p>This is the first in a series of posts here where we will explain and share shell scripts that automate the deployment process of several key debian linux based systems. These scripts automate the patching, configuration and implementation of said systems.</p>
<p>They will certainly have to be modified to fit your organization&#8217;s needs and standards obviously, but hopefully it will give you a starting point to base your automation / roll-out policies.</p>
<p>Making your life easier and more automated is always a good thing! <img src='http://blog.stardothosting.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<p><small><b></p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#!/bin/sh<br />
# Debian FW deployer script<br />
# Version 1.0<br />
<br />
PROGNAME=&quot;$0&quot;<br />
VERSION=&quot;1.0&quot;<br />
<br />
# working directory for deployer process.<br />
WORKDIR=&quot;/root&quot;<br />
<br />
# tasks left (this is updated every step to accommodate recovery during<br />
# the deployer &nbsp;process)<br />
TASKS=&quot;./deploy-fw.tasks&quot;<br />
<br />
init_tasks() {<br />
&nbsp; &nbsp; # This function will write a new tasks file.<br />
&nbsp; &nbsp; # it's called from the main body of the script if a tasks file does not exist.<br />
&nbsp; &nbsp; cat &gt; $TASKS&lt;&lt;EOS || return 1<br />
nopasswd_ssh<br />
add_pkgs<br />
get__fw<br />
configure_fw<br />
set_hostname<br />
EOS<br />
&nbsp; &nbsp; return 0<br />
}<br />
<br />
installer_splash() {<br />
&nbsp; &nbsp; echo &quot;[+] Firewall deployer script starting...&quot;<br />
&nbsp; &nbsp; echo &quot; &nbsp; &nbsp;Version: $VERSION&quot;<br />
&nbsp; &nbsp; echo<br />
&nbsp; &nbsp; return 0<br />
}<br />
<br />
nopasswd_ssh() {<br />
&nbsp; &nbsp; # disable passwd auth on SSH<br />
&nbsp; &nbsp; echo &quot;[+] Disabling password authentication for SSH... &quot;<br />
&nbsp; &nbsp; perl -pi -e 's/^PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config<br />
&nbsp; &nbsp; perl -pi -e 's/^#PermitRootLogin yes/PermitRootLogin without-password/g' /etc/ssh/sshd_config<br />
&nbsp; &nbsp; /etc/init.d/ssh restart<br />
&nbsp; &nbsp; return 0<br />
}<br />
<br />
add_pkgs() {<br />
&nbsp; &nbsp; PKGS=&quot;libssl0.9.7 exim4 iproute ethtool tcpdump snmpd pciutils less python&quot;<br />
&nbsp; &nbsp; echo &quot;[+] Installing packages: $PKGS... &quot;<br />
&nbsp; &nbsp; apt-get -y install $PKGS || return 1<br />
&nbsp; &nbsp; return 0<br />
}<br />
<br />
get__fw() {<br />
&nbsp; &nbsp; echo &quot;[+] Downloading &nbsp;packages... &quot;<br />
&nbsp; &nbsp; # download the latest version of the &nbsp;Client firewall package.<br />
&nbsp; &nbsp; wget --no-check-certificate http://www.yoursite.com/fw.tgz -O /tmp/firewall.tgz || return 1<br />
&nbsp; &nbsp; # get the latest firewall.trusted file<br />
&nbsp; &nbsp; wget --no-check-certificate http://www.yoursite.com/firewall.trusted -O /tmp/firewall.trusted || return 1<br />
&nbsp; &nbsp; # unpack firewall scripts<br />
&nbsp; &nbsp; tar --no-same-owner --no-same-permissions --directory / -zxvf /tmp/firewall.tgz || return 1<br />
&nbsp; &nbsp; mv /tmp/firewall.trusted /etc/network/firewall.trusted || return 1<br />
&nbsp; &nbsp; chmod +x /etc/network/firewall.trusted || return 1<br />
&nbsp; &nbsp; rm /tmp/firewall.tgz || return 1<br />
&nbsp; &nbsp; echo &quot;done.&quot;<br />
&nbsp; &nbsp; return 0<br />
}<br />
<br />
configure_fw() {<br />
&nbsp; &nbsp; # time to configure the &nbsp;FW<br />
&nbsp; &nbsp; &nbsp; &nbsp; KAD=/etc/keepalived/keepalived.conf<br />
&nbsp; &nbsp; FW=/etc/network/firewall<br />
&nbsp; &nbsp; RELOAD=/etc/network/reload.sh<br />
&nbsp; &nbsp; HOSTS=/etc/hosts<br />
&nbsp; &nbsp; INTERFACES=/etc/network/interfaces<br />
&nbsp; &nbsp; NRPE=/etc/nagios/nrpe_local.cfg<br />
&nbsp; &nbsp; EXIM=/etc/exim4/update-exim4.conf.conf<br />
&nbsp; &nbsp; CONFIGURE_FW=/etc/network/configure-fw.pl<br />
&nbsp; &nbsp; echo &quot;[+] Configuring Firewall...&quot;<br />
&nbsp; &nbsp; perl $CONFIGURE_FW<br />
&nbsp; &nbsp; if [ $? -ne 0 ]; then<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &quot;[!] ERROR: Configuring firewall script failed!&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 1<br />
&nbsp; &nbsp; fi<br />
&nbsp; &nbsp; echo &quot;[+] Moving files into place...&quot;<br />
&nbsp; &nbsp; rm ${KAD}-template || return 1<br />
&nbsp; &nbsp; rm ${FW}-template || return 1<br />
&nbsp; &nbsp; rm ${RELOAD}-template || return 1<br />
&nbsp; &nbsp; rm ${CONFIGURE_FW}<br />
&nbsp; &nbsp; mv ${HOSTS}.new ${HOSTS} || return 1<br />
&nbsp; &nbsp; mv ${INTERFACES}.new ${INTERFACES} || return 1<br />
&nbsp; &nbsp; mv ${NRPE}.new ${NRPE} || return 1<br />
&nbsp; &nbsp; mv ${EXIM}.new ${EXIM} || return 1<br />
&nbsp; &nbsp; chmod 700 ${FW}<br />
&nbsp; &nbsp; chmod 700 ${RELOAD}<br />
&nbsp; &nbsp; update-rc.d keepalived defaults || return 1<br />
&nbsp; &nbsp; update-exim4.conf || return 1<br />
&nbsp; &nbsp; # for compatibility<br />
&nbsp; &nbsp; echo &quot;[+] Generating RSA Keys&quot;<br />
&nbsp; &nbsp; ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' || return 1<br />
<br />
&nbsp; &nbsp; return 0<br />
}<br />
clean_up_and_reboot() {<br />
&nbsp; &nbsp; # remove:<br />
&nbsp; &nbsp; # -- temp task file<br />
&nbsp; &nbsp; rm $TASKS<br />
&nbsp; &nbsp; # remove self from .bashrc<br />
&nbsp; &nbsp; if [ -f /root/.bashrc.orig ]; then<br />
&nbsp; &nbsp; &nbsp; &nbsp; mv /root/.bashrc.orig /root/.bashrc<br />
&nbsp; &nbsp; fi<br />
&nbsp; &nbsp; if [ -z /root/.bashrc ]<br />
&nbsp; &nbsp; then<br />
&nbsp; &nbsp; &nbsp; &nbsp; rm /root/.bashrc<br />
&nbsp; &nbsp; fi<br />
&nbsp; &nbsp; # delete self<br />
&nbsp; &nbsp; rm $0<br />
&nbsp; &nbsp; # and reboot.<br />
&nbsp; &nbsp; echo &quot;[+] Please reboot system.&quot;<br />
&nbsp; &nbsp; #reboot -n<br />
&nbsp; &nbsp; exit 0<br />
}<br />
<br />
debug_quit() {<br />
&nbsp; &nbsp; # hard exit the script in appropriately referenced files <br />
&nbsp; &nbsp; # so that no reboot happens.<br />
&nbsp; &nbsp; echo &quot;debug_quit seen in tasks file, exiting.&quot;<br />
&nbsp; &nbsp; exit 0<br />
}<br />
<br />
set_hostname() {<br />
&nbsp; &nbsp; echo &quot;[+] Setting FW hostname... &quot;<br />
&nbsp; &nbsp; echo `hostname` &gt; /etc/hostname<br />
&nbsp; &nbsp; echo `hostname` &gt; /etc/mailname<br />
&nbsp; &nbsp; echo &quot;done.&quot;<br />
&nbsp; &nbsp; return 0<br />
}<br />
<br />
usage() {<br />
&nbsp; &nbsp; echo &quot;[+] Usage: $PROGNAME&quot;<br />
&nbsp; &nbsp; echo<br />
&nbsp; &nbsp; return 0<br />
}<br />
<br />
###############################<br />
### MAIN SCRIPT STARTS HERE ###<br />
###############################<br />
<br />
# installer_splash<br />
installer_splash<br />
<br />
# fix working dir.<br />
cd $WORKDIR<br />
<br />
# does our installer file exist? if not, initalize it.<br />
if [ ! -f $TASKS ]<br />
then<br />
&nbsp; &nbsp; echo &quot;[+] No task file found, installation will start from beginning.&quot;<br />
&nbsp; &nbsp; init_tasks<br />
&nbsp; &nbsp; if (($? != 0))<br />
&nbsp; &nbsp; then<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &quot;[!] ERROR: Cannot create tasks file. Installation will not continue.&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit 1<br />
&nbsp; &nbsp; fi<br />
else <br />
&nbsp; &nbsp; echo &quot;[+] Tasks file located - starting where you left off.&quot;<br />
fi<br />
<br />
# start popping off tasks from the task list and running them.<br />
# pop first step off of the list<br />
STEP=`head -n 1 $TASKS`<br />
while [ ! -z $STEP ]<br />
do<br />
&nbsp; &nbsp; # execute the function.<br />
&nbsp; &nbsp; echo -e &quot;\n\n###################################&quot;<br />
&nbsp; &nbsp; echo &quot;[+] Running step: $STEP&quot;<br />
&nbsp; &nbsp; echo -e &quot;###################################\n\n&quot;<br />
&nbsp; &nbsp; $STEP<br />
&nbsp; &nbsp; if (($? != 0))<br />
&nbsp; &nbsp; then<br />
&nbsp; &nbsp; &nbsp; &nbsp; # command failed.<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &quot;[!] ERROR: Step $STEP failed!&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo &quot; &nbsp; &nbsp;Installation will now abort - you can pick it up after fixing the problem&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; echo<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit 1<br />
&nbsp; &nbsp; fi<br />
&nbsp; &nbsp; # throw up a newline just so things don't look so crowded<br />
&nbsp; &nbsp; echo<br />
&nbsp; &nbsp; # remove function from function list.<br />
&nbsp; &nbsp; perl -pi -e &quot;s/$STEP\n?//&quot; $TASKS || exit 1<br />
&nbsp; &nbsp; STEP=`head -n 1 $TASKS`<br />
done<br />
<br />
# clean_up_and_reboot<br />
echo &quot;[+] Installation finished - cleaning up.&quot;<br />
clean_up_and_reboot<br />
<br />
# script is done now - termination should happen with clean_up_and_reboot.<br />
echo &quot;[!] Should not be here!&quot;<br />
exit 1</div></div>
<p></small></b></p>
<p><a href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F02%2Fautomatically-deploy-debian-firewalls-with-bash-scripting%2F&amp;linkname=Automatically%20Deploy%20Debian%20Firewalls%20with%20bash%20scripting" title="Digg" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a> <a href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F02%2Fautomatically-deploy-debian-firewalls-with-bash-scripting%2F&amp;linkname=Automatically%20Deploy%20Debian%20Firewalls%20with%20bash%20scripting" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a> <a href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F02%2Fautomatically-deploy-debian-firewalls-with-bash-scripting%2F&amp;linkname=Automatically%20Deploy%20Debian%20Firewalls%20with%20bash%20scripting" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a> <a href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F06%2F02%2Fautomatically-deploy-debian-firewalls-with-bash-scripting%2F&amp;linkname=Automatically%20Deploy%20Debian%20Firewalls%20with%20bash%20scripting" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.stardothosting.com/2010/06/02/automatically-deploy-debian-firewalls-with-bash-scripting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Relay Exim mail to google mail in Debian Linux</title>
		<link>http://blog.stardothosting.com/2010/05/25/relay-exim-mail-to-google-mail-in-debian-linux/</link>
		<comments>http://blog.stardothosting.com/2010/05/25/relay-exim-mail-to-google-mail-in-debian-linux/#comments</comments>
		<pubDate>Tue, 25 May 2010 20:23:28 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=332</guid>
		<description><![CDATA[Sometimes its necessary to relay your mail through a third party provider. If your server environment has a dedicated sendmail server (most do), then this scenario is applicable to you. It is ideal to centralize your outgoing mail to one server so that changes, policies and configuration is located in a single place. In this [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F05%2F25%2Frelay-exim-mail-to-google-mail-in-debian-linux%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F05%2F25%2Frelay-exim-mail-to-google-mail-in-debian-linux%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Sometimes its necessary to relay your mail through a third party provider. If your server environment has a dedicated sendmail server (most do), then this scenario is applicable to you. It is ideal to centralize your outgoing mail to one server so that changes, policies and configuration is located in a single place.</p>
<p>In this scenario, outgoing mail is relayed to google&#8217;s domain mail in an Exim mail environment. These steps are fairly straightforward and will hopefully help you to utilize google&#8217;s free mail service to send your mail. </p>
<p>Note that google has queuing and mass mail restrictions so if you plan on sending alot of mail this way, you will just get blocked.</p>
<p><strong>
<ul>
<big>Step 1</ul>
<p></strong></big></p>
<p>Run dpkg-reconfigure exim4-config</p>
<p>1. Choose mail sent by smarthost; received via SMTP or fetchmail</p>
<p>2. Type System Mail Name: e.g. company.com</p>
<p>3. Type IP Adresses to listen on for incoming SMTP connections: 127.0.0.1</p>
<p>4. Leave Other destinations for which mail is accepted blank</p>
<p>5. Leave Machines to relay mail for: blank</p>
<p>6. Type Machine handling outgoing mail for this host (smarthost): smtp.gmail.com::587</p>
<p>7. Choose NO, don’t hide local mail name in outgoing mail.</p>
<p>8. Chose NO, don’t keep number of DNS-queries minimal (Dial-on-Demand).</p>
<p>9. Choose mbox</p>
<p>10. Choose NO, split configuration into small files</p>
<p>11. Mail for postmaster. Leaving blank will not cause any problems though it is not recommended</p>
<ul>
<strong><big>Step 2</big></strong></ul>
<p>1. Open the file /etc/exim4/exim4.conf.template<br />
2. Find the line .ifdef DCconfig_smarthost DCconfig_satellite and add the following in that section</p>
<pre>
 send_via_gmail:
 driver = manualroute
 domains = ! +local_domains
 transport = gmail_smtp
 route_list = * smtp.gmail.com
</pre>
<p>If you have any other smarthost defined with “domains = ! +local_domains” remove that smarthost.</p>
<p>3. Find the “begin authenticators”. In that section add the following</p>
<pre>
 gmail_login:
 driver = plaintext
 public_name = LOGIN
 client_send = : yourname@gmail.com : YourGmailPassword
</pre>
<p>Make sure you have no other authenticators with the same public_name (LOGIN). Comment them out if needed (Thanks Jakub for reminding me) </p>
<p>4. Find the comment  “transport/30_exim4-config_remote_smtp_smarthost”. In that section add</p>
<pre>
 gmail_smtp:
 driver = smtp
 port = 587
 hosts_require_auth = $host_address
 hosts_require_tls = $host_address
</pre>
<ul>
<strong><big>Step 3</big></strong></ul>
<p>1. Run update-exim4.conf</p>
<p>2. Do /etc/init.d/exim4 restart</p>
<p>That should be it. You can test by using the command line mail client.</p>
<p>Test :</p>
<pre>
 echo "test" | mail -s "subject" test@email-to-send-to.com
</pre>
<p><a href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F05%2F25%2Frelay-exim-mail-to-google-mail-in-debian-linux%2F&amp;linkname=Relay%20Exim%20mail%20to%20google%20mail%20in%20Debian%20Linux" title="Digg" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a> <a href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F05%2F25%2Frelay-exim-mail-to-google-mail-in-debian-linux%2F&amp;linkname=Relay%20Exim%20mail%20to%20google%20mail%20in%20Debian%20Linux" title="Twitter" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a> <a href="http://www.addtoany.com/add_to/reddit?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F05%2F25%2Frelay-exim-mail-to-google-mail-in-debian-linux%2F&amp;linkname=Relay%20Exim%20mail%20to%20google%20mail%20in%20Debian%20Linux" title="Reddit" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/reddit.png" width="16" height="16" alt="Reddit"/></a> <a href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F05%2F25%2Frelay-exim-mail-to-google-mail-in-debian-linux%2F&amp;linkname=Relay%20Exim%20mail%20to%20google%20mail%20in%20Debian%20Linux" title="Delicious" rel="nofollow" target="_blank"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.stardothosting.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.stardothosting.com/2010/05/25/relay-exim-mail-to-google-mail-in-debian-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Integrate your custom IPTables script with Linux</title>
		<link>http://blog.stardothosting.com/2010/05/11/integrate-your-custom-iptables-script-with-linux/</link>
		<comments>http://blog.stardothosting.com/2010/05/11/integrate-your-custom-iptables-script-with-linux/#comments</comments>
		<pubDate>Tue, 11 May 2010 20:25:15 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://blog.stardothosting.com/?p=330</guid>
		<description><![CDATA[A custom iptables script is sometimes necessary to work around the limitations of the Red Hat Enterprise Linux firewall configuration tool.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F05%2F11%2Fintegrate-your-custom-iptables-script-with-linux%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.stardothosting.com%2F2010%2F05%2F11%2Fintegrate-your-custom-iptables-script-with-linux%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>How do I integrate my custom iptables script with Red Hat Enterprise Linux?</p>
<p>A custom iptables script is sometimes necessary to work around the limitations of the Red Hat Enterprise Linux firewall configuration tool. The procedure is as follows:</p>
<p>1. Make sure that the default iptables initialization script is not running:</p>
<pre>service iptables stop</pre>
<p>2. Execute the custom iptables script:</p>
<pre>sh [custom iptables script]</pre>
<p>3. Save the newly created iptables rules:</p>
<pre>service iptables save</pre>
<p>4. Restart the iptables service:</p>
<pre>service iptables restart</pre>
<p>5. Verify that the custom iptables ruleset have taken effect:</p>
<pre>service iptables status</pre>
<p>6. Enable automatic start up of the iptables service on boot up:</p>
<pre>chkconfig iptables on</pre>
<p>The custom iptables script should now be integrated into the operating system. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stardothosting.com/2010/05/11/integrate-your-custom-iptables-script-with-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
