<?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>Dirty Motherfucking Blog &#187; administration</title>
	<atom:link href="http://dirty-motherfucker.org/blog/category/administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://dirty-motherfucker.org/blog</link>
	<description>All kinds of shit</description>
	<lastBuildDate>Wed, 04 Jan 2012 15:38:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19620</generator>
		<item>
		<title>Integrate Progress Indicator in Console Output</title>
		<link>http://dirty-motherfucker.org/blog/2012/01/04/integrate-progress-indicator-in-console-output/</link>
		<comments>http://dirty-motherfucker.org/blog/2012/01/04/integrate-progress-indicator-in-console-output/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 15:38:39 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://dirty-motherfucker.org/blog/?p=355</guid>
		<description><![CDATA[I recently tried to use pv in a bash script so that it wouldn&#8217;t interfere with my concept of communicating overall progress to the user. When I usually like to do is to echo -n a description of the current task and then later echo either &#8220;Done.&#8221; or &#8220;Failed!&#8221; (or something similar). Obviously, that somewhat [...]]]></description>
			<content:encoded><![CDATA[<p>I recently tried to use <code>pv</code> in a bash script so that it wouldn&#8217;t interfere with my concept of communicating overall progress to the user.</p>
<p>When I usually like to do is to <code>echo -n</code> a description of the current task and then later <code>echo</code> either &#8220;Done.&#8221; or &#8220;Failed!&#8221; (or something similar).<br />
Obviously, that somewhat conflicts with <code>pv</code>. So here is the solution:</p>
<pre class="brush: bash; highlight: [11,12]; title: ; notranslate">
# Create backup archive
_statusMessage=&quot;Compressing installation...&quot;
echo -n $_statusMessage
if hash pv 2&gt;&amp;- &amp;&amp; hash gzip 2&gt;&amp;- &amp;&amp; hash du 2&gt;&amp;-; then
  echo
  _folderSize=`du --summarize --bytes $BASE | cut --fields 1`
  if ! tar --create --file - $BASE | pv --progress --rate --bytes --size $_folderSize | gzip --best &gt; $FILE; then
    echo &quot;Failed!&quot;
    exit 1
  fi
  # Clear pv output and position cursor after status message
  tput cuu 2 &amp;&amp; tput cuf ${#_statusMessage} &amp;&amp; tput ed
else
  if ! tar --create --gzip --file $FILE $BASE; then
    echo &quot;Failed!&quot;
    exit 1
  fi
fi

echo &quot;Done.&quot;
</pre>
<p>The snippet also shows how to conditionally use pv if it is available, which I really like.</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2012/01/04/integrate-progress-indicator-in-console-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check Write Permissions for Folder Hierachcy</title>
		<link>http://dirty-motherfucker.org/blog/2012/01/02/check-write-permissions-for-folder-hierachcy/</link>
		<comments>http://dirty-motherfucker.org/blog/2012/01/02/check-write-permissions-for-folder-hierachcy/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 15:21:54 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[find]]></category>

		<guid isPermaLink="false">http://dirty-motherfucker.org/blog/?p=344</guid>
		<description><![CDATA[While working on a bash script, I wanted to check if I could rm -rf a folder before actually attempting it and flushing the console with tons of write permission error messages. Upon failing to find what I wanted online, I constructed this beauty: find . \( -exec test -w {} \; -o \( -exec [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a bash script, I wanted to check if I could <code>rm -rf</code> a folder before actually attempting it and flushing the console with tons of write permission error messages.</p>
<p>Upon failing to find what I wanted online, I constructed this beauty:<br />
<code><br />
find . \( -exec test -w {} \; -o \( -exec echo {} \; -quit \) \) | xargs -I {} bash -c "if [ -n "{}" ]; then echo {} is not writeable\!; exit 1; fi"<br />
</code><br />
This will print the name of the item that is not writeable in addition to the non-zero return value needed when used in more complex scripts.</p>
<p>If you don&#8217;t want/need the output, you can go with the simpler version:<br />
<code><br />
find . \( -exec test -w {} \; -o \( -exec echo {} \; -quit \) \) | xargs -I {} test -z "{}"<br />
</code></p>
<p>If there is a more simple solution, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2012/01/02/check-write-permissions-for-folder-hierachcy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Self-updating Bash Script</title>
		<link>http://dirty-motherfucker.org/blog/2011/12/22/self-updating-bash-script/</link>
		<comments>http://dirty-motherfucker.org/blog/2011/12/22/self-updating-bash-script/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 11:59:58 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://dirty-motherfucker.org/blog/?p=338</guid>
		<description><![CDATA[While working on the typo3scripts project, I wanted to implement a self-updating feature into each of the scripts as that seemed most convenient for where these scripts would be used. My initial approach was OK but left me wondering. So, here is the revised approach for a bash script that has the ability to update [...]]]></description>
			<content:encoded><![CDATA[<p>While working on the <a href="http://code.google.com/p/typo3scripts/" title="typo3scripts">typo3scripts</a> project, I wanted to implement a self-updating feature into each of the scripts as that seemed most convenient for where these scripts would be used. My <a href="http://stackoverflow.com/questions/8595751/is-this-a-valid-self-update-approach-for-a-bash-script" title="Self-updating bash script at StackOverflow">initial approach</a> was OK but left me wondering.</p>
<p>So, here is the revised approach for a bash script that has the ability to update itself:</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash

set -o nounset
set -o errexit

SELF=$(basename $0)

# The base location from where to retrieve new versions of this script
UPDATE_BASE=http://typo3scripts.googlecode.com/svn/trunk

# Self-update
runSelfUpdate() {
  echo &quot;Performing self-update...&quot;

  # Download new version
  echo -n &quot;Downloading latest version...&quot;
  if ! wget --quiet --output-document=&quot;$0.tmp&quot; $UPDATE_BASE/$SELF ; then
    echo &quot;Failed: Error while trying to wget new version!&quot;
    echo &quot;File requested: $UPDATE_BASE/$SELF&quot;
    exit 1
  fi
  echo &quot;Done.&quot;

  # Copy over modes from old version
  OCTAL_MODE=$(stat -c '%a' $SELF)
  if ! chmod $OCTAL_MODE &quot;$0.tmp&quot; ; then
    echo &quot;Failed: Error while trying to set mode on $0.tmp.&quot;
    exit 1
  fi

  # Spawn update script
  cat &gt; updateScript.sh &lt;&lt; EOF
#!/bin/bash
# Overwrite old file with new
if mv &quot;$0.tmp&quot; &quot;$0&quot;; then
  echo &quot;Done. Update complete.&quot;
  rm \$0
else
  echo &quot;Failed!&quot;
fi
EOF

  echo -n &quot;Inserting update process...&quot;
  exec /bin/bash updateScript.sh
}

# Update check
SUM_LATEST=$(curl $UPDATE_BASE/versions 2&gt;&amp;1 | grep $SELF | awk '{print $1}')
SUM_SELF=$(md5sum $0 | awk '{print $1}')
if [[ &quot;$SUM_LATEST&quot; != &quot;$SUM_SELF&quot; ]]; then
  echo &quot;NOTE: New version available!&quot;
fi
</pre>
<p>It also includes the update check which wasn&#8217;t discussed over at StackOverflow. In case I revise the approach yet again, you&#8217;ll find the latest version over at the <a href="http://code.google.com/p/typo3scripts/" title="Typo3Scripts Project Page">typo3scripts project page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2011/12/22/self-updating-bash-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The mystery of the broken OpenVPN certificate</title>
		<link>http://dirty-motherfucker.org/blog/2011/01/07/the-mystery-of-the-broken-openvpn-certificate/</link>
		<comments>http://dirty-motherfucker.org/blog/2011/01/07/the-mystery-of-the-broken-openvpn-certificate/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 14:06:30 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[openvpn]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=326</guid>
		<description><![CDATA[Someone complained to me about the following error message when trying to use OpenVPN to connect to a VPN: All research regarding the matter pointed to a broken certificate. But even after re-exporting it and comparing the contents, we could not find any problem. I had the client repeat several parts of the certificate over [...]]]></description>
			<content:encoded><![CDATA[<p>Someone complained to me about the following error message when trying to use OpenVPN to connect to a VPN:</p>
<pre class="brush: plain; title: ; notranslate">
Cannot load certificate file error:0906D06C:
PEM routines:PEM_read_bio:no start line: error:140AD009:
SSL routines:SSL_CTX_use_certificate_file:PEM lib
</pre>
<p>All research regarding the matter pointed to a broken certificate. But even after re-exporting it and comparing the contents, we could not find any problem. I had the client repeat several parts of the certificate over the phone to my while comparing them to the one I had on the server. Everything matched exactly.</p>
<p>So I had the client send me the certificate and after a while I found the problem. The certificate the client had was saved as UTF8. If it was the BOM or the encoding of some characters, I have no idea. But after saving it as ANSI/ASCII the problem went away and the client was able to connect.</p>
<p>tl;dr: UTF8 is bad for OpenVPN certificates.</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2011/01/07/the-mystery-of-the-broken-openvpn-certificate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Increased Screen-Space for Ubuntu Server VM</title>
		<link>http://dirty-motherfucker.org/blog/2010/10/13/increased-screen-space-for-ubuntu-server-vm/</link>
		<comments>http://dirty-motherfucker.org/blog/2010/10/13/increased-screen-space-for-ubuntu-server-vm/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 09:49:37 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=320</guid>
		<description><![CDATA[I often run Ubuntu server installations in VirtualBox. Sadly, this only provides you with the default console window. So most of the time I would additionally connect with Putty into the same VM, so that I can make use of a larger console. But recently it pissed me off so badly that I went hunting [...]]]></description>
			<content:encoded><![CDATA[<p>I often run Ubuntu server installations in VirtualBox. Sadly, this only provides you with the default console window. So most of the time I would additionally connect with Putty into the same VM, so that I can make use of a larger console. But recently it pissed me off so badly that I went hunting for a solution. And I found it in <a href="http://joeamined.wordpress.com/2008/02/25/enabling-high-resolution-console-in-ubuntu/">this article</a>. It&#8217;s not quite up speed with the current environment, so I&#8217;ll duplicate the information here and update it as well.</p>
<p>So first thing we want to do is remove the vesa framebuffer module from the modprobe blacklist.</p>
<pre class="brush: plain; title: ; notranslate">sudo editor /etc/modprobe.d/blacklist-framebuffer</pre>
<p>Comment out or delete the following line:</p>
<pre class="brush: plain; title: ; notranslate">blacklist vesafb</pre>
<p>Now to enable the needed modules:</p>
<pre class="brush: plain; title: ; notranslate">sudo editor /etc/initramfs-tools/modules</pre>
<p>And add the following lines at the end:</p>
<pre class="brush: plain; title: ; notranslate">fbcon
vesafb</pre>
<p>Finally, update your initramfs images:</p>
<pre class="brush: plain; title: ; notranslate">sudo update-initramfs -u</pre>
<p>Now, we need to make Grub pass the required parameters to the kernel to enable the high-res console.<br />
In case of Ubuntu 8.04 (and 8.10 I guess) or any pre-Grub2 version:</p>
<pre class="brush: plain; title: ; notranslate">sudo editor /boot/grub/menu.lst</pre>
<p>For Grub2 installations:</p>
<pre class="brush: plain; title: ; notranslate">sudo editor /etc/default/grub</pre>
<p>There will be a line like this:</p>
<pre class="brush: plain; title: ; notranslate">GRUB_CMDLINE_LINUX_DEFAULT=&quot;quiet splash&quot;</pre>
<p>You&#8217;re gonna want to add the vga parameter to that:</p>
<pre class="brush: plain; title: ; notranslate">GRUB_CMDLINE_LINUX_DEFAULT=&quot;quiet splash vga=791&quot;</pre>
<p>Or as the original article suggests (and what I prefer as well):</p>
<pre class="brush: plain; title: ; notranslate">GRUB_CMDLINE_LINUX_DEFAULT=&quot;verbose vga=791&quot;</pre>
<p>But that only changes the amount of information you get during boot time.<br />
The number that is passed as an argument with vga signals the desired resolution and color depth. 791 is 1024&#215;768 with 64K colors. A full list can be found <a href="http://www.mjmwired.net/kernel/Documentation/fb/vesafb.txt">here</a>.<br />
Now, for Grub2 installations you&#8217;ll want to update Grub:</p>
<pre class="brush: plain; title: ; notranslate">sudo update-grub2</pre>
<p>And then, reboot!</p>
<pre class="brush: plain; title: ; notranslate">sudo reboot now</pre>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2010/10/13/increased-screen-space-for-ubuntu-server-vm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ICH9R Raid Recovery</title>
		<link>http://dirty-motherfucker.org/blog/2010/08/17/ich9r-raid-recovery/</link>
		<comments>http://dirty-motherfucker.org/blog/2010/08/17/ich9r-raid-recovery/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 18:19:53 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[ich9r]]></category>
		<category><![CDATA[raid]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=313</guid>
		<description><![CDATA[You know how everyone would tell you to not use RAID0 unless the data you store on it is worthless? And do you know how the same people would most likely tell you to never put your operating system on a RAID0 volume? Well, I ignored those people and did it anyway. And what did [...]]]></description>
			<content:encoded><![CDATA[<p>You know how everyone would tell you to not use RAID0 unless the data you store on it is worthless? And do you know how the same people would most likely tell you to never put your operating system on a RAID0 volume?</p>
<p>Well, I ignored those people and did it anyway. And what did I, shortly after, get in return? A failed RAID volume. Yay.</p>
<p>One day I simply shut off my computer for a little restructuring of my work area, and after I turned it on again, it told me it can&#8217;t boot, cause, well, yeah. In fact, it reported that one of the RAID disks was no longer a member of the array. So I rebooted multiple times, shut off the computer and power supply, booted back up. The volume remained failed.</p>
<p>So I booted into an Ubuntu Live CD and browsed the web for solutions. Cause I was certain no data could have actually been lost. The RAID controller was just stupid. The solutions I found were mostly along the lines of &#8220;re-create the volume and restore a backup&#8221;. Of course I had no backup.<br />
So I thought I would just back up the drives contents now and try to simply re-create the volume and write the data back.</p>
<p>Using dd, I did exactly that:</p>
<pre class="brush: plain; title: ; notranslate">
dd if=/dev/sda of=/media/backup/sda.dd bs=2MB
dd if=/dev/sdb of=/media/backup/sdb.dd bs=2MB
</pre>
<p>This took the whole night of course. So, the next day I rebooted to re-create the RAID volume. But I was very surprised to find that the RAID controller reported the volume to be in perfect health. And surely enough, seconds later my Windows was up and running again.<br />
I praised the gods, instantly made backups and went on with my life.</p>
<p>Until yesterday. When the same shit happened AGAIN. I was minding my own business, when suddenly my computer shut off (due to overheating I assume). When I started it back up again, it, again, reported the RAID volume as failed.<br />
Again, multiple reboots didn&#8217;t do anything. And, again, I went into a Live CD to back up the RAID member disks.<br />
And, AGAIN, today my volume comes up as healthy as ever.</p>
<p>I have no clue if there is any logic behind this or if this was just magic happening. I also have no idea if my actions actually had anything to do with this RAID recovery. But, sure as hell, when I come across a failed ICH9R RAID0 volume again, I&#8217;ll dd the disks and reboot the shit out of it.</p>
<p>And, also, I&#8217;ll be converting back to a non-RAID setup ASAP.</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2010/08/17/ich9r-raid-recovery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simulating TCP data from another device</title>
		<link>http://dirty-motherfucker.org/blog/2009/12/03/simulating-tcp-data-from-another-device/</link>
		<comments>http://dirty-motherfucker.org/blog/2009/12/03/simulating-tcp-data-from-another-device/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 22:11:22 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=293</guid>
		<description><![CDATA[This almost feels too simple to even mention it. But I guess it doesn&#8217;t hurt putting it our there. Someone might hit it in a desperate Google hunt. So this is the deal. You have a device on your network that controls another device by means of sending out simple TCP payloads. Now you want [...]]]></description>
			<content:encoded><![CDATA[<p>This almost feels too simple to even mention it. But I guess it doesn&#8217;t hurt putting it our there. Someone might hit it in a desperate Google hunt.<br />
So this is the deal. You have a device on your network that controls another device by means of sending out simple TCP payloads.<br />
Now you want to perform the same tasks with your program to get rid of the device. This is how you do it.</p>
<p>First, you wanna fire up your old friend <a href="http://www.wireshark.org/">Wireshark</a>. Now set up the device you want to emulate to send the data to the IP of your machine. Now you can start a Live Capture in Wireshark (Ctrl+E). Now you command your device to send the message by whatever means needed (like pressing the correct button on the device). Now stop the Live Capture in Wireshark (Ctrl+E) and add a filter to get the packet you need.</p>
<p>Let&#8217;s assume the devices IP address is 10.0.0.1 and your IP address is 10.0.0.2. Now the correct filter would be</p>
<pre class="brush: plain; title: ; notranslate">
ip.src == 10.0.0.1 &amp;&amp; ip.dst == 10.0.0.2
</pre>
<p>Now, hopefully you&#8217;ll see a single packet. In the center panel of Wireshark there should be a Data segment. This is what we want. Right-click it and select Copy -> Bytes (Hex Stream). You&#8217;ll get something like:</p>
<pre class="brush: plain; title: ; notranslate">
4e656574732c4b2c0100
</pre>
<p>(In case you&#8217;re interested, this is the payload when you press the first button on a <a href="http://neets.dk/products/control_system/307-0001/index.php">Neets Control EU Standard</a> device.)</p>
<p>Now let&#8217;s put this into code. The below example already has 2 payloads that would signal the target device to be turned on or off. For this 2 packets have been captured and can now be selected via the command line. The implementation is straight-forward.</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;

namespace Neets_Control {
  class Program {

    private static byte[] WORKLOAD_ON   = new byte[] { 0x4e, 0x65, 0x65, 0x74, 0x73, 0x2c, 0x4b, 0x2c, 0x01, 0x00 };
    private static byte[] WORKLOAD_OFF  = new byte[] { 0x4e, 0x65, 0x65, 0x74, 0x73, 0x2c, 0x4b, 0x2c, 0x02, 0x00 };

    private static string TARGET_HOST   = &quot;10.11.110.11&quot;;
    private static int    TARGET_PORT   = 5009;

    static void Main( string[] args ) {

      TcpClient sender = new TcpClient( TARGET_HOST, TARGET_PORT );
      NetworkStream stream = sender.GetStream();
      if( args[ 0 ] == &quot;on&quot; ) {
        Console.WriteLine( &quot;Switching on&quot; );
        stream.Write( WORKLOAD_ON, 0, WORKLOAD_ON.Length );

      } else if( args[ 0 ] == &quot;off&quot; ) {
        Console.WriteLine( &quot;Switching off&quot; );
        stream.Write( WORKLOAD_OFF, 0, WORKLOAD_OFF.Length );

      } else {
        Console.WriteLine( &quot;Missing parameter (on/off).&quot; );
      }

      stream.Close();
      sender.Close();

    }
  }
}
</pre>
<p>So, yeah, I can now just refer back to my introduction. Possibly this wasn&#8217;t event worth mentioning ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2009/12/03/simulating-tcp-data-from-another-device/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building PHP 5.3.0 on Ubuntu 8.04 Server</title>
		<link>http://dirty-motherfucker.org/blog/2009/08/06/building-php-5-3-0-on-ubuntu-8-04-server/</link>
		<comments>http://dirty-motherfucker.org/blog/2009/08/06/building-php-5-3-0-on-ubuntu-8-04-server/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 21:07:37 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=274</guid>
		<description><![CDATA[When I wanted to build the latest PHP for a server I found several guides online. Sadly none of them worked right away. So after finally getting it all to work like I wanted to, I decided to quickly write up this guide. I start with a clean Ubuntu 8.04 install. So, first things first: [...]]]></description>
			<content:encoded><![CDATA[<p>When I wanted to build the latest PHP for a server I found several guides online. Sadly none of them worked right away.<br />
So after finally getting it all to work like I wanted to, I decided to quickly write up this guide.</p>
<p>I start with a clean Ubuntu 8.04 install. So, first things first:</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get update
sudo apt-get dist-upgrade
sudo shutdown -r now
</pre>
<p>Now that we&#8217;re up-to-date, let&#8217;s begin:</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get build-dep php5
sudo apt-get install libmcrypt-dev libc-client-dev checkinstall
</pre>
<p>Now we have all the crap to build PHP with. Let&#8217;s get PHP itself:</p>
<pre class="brush: plain; title: ; notranslate">
cd /tmp/
wget http://us3.php.net/get/php-5.3.0.tar.gz/from/this/mirror
tar xvzf php-5.3.0.tar.gz
cd php-5.3.0/
</pre>
<p>Now all that is left is to build PHP&#8230;</p>
<pre class="brush: plain; title: ; notranslate">
./configure --prefix=/usr --with-apxs2=/usr/bin/apxs2 --with-config-file-path=/etc/php5/apache2 --with-config-file-scan-dir=/etc/php5/apache2/conf.d --mandir=/usr/share/man --disable-debug --with-regex=php --disable-rpath --disable-static --with-pic --with-layout=GNU --with-pear=/usr/share/php --enable-calendar --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-bcmath --with-bz2 --enable-ctype --with-db4 --without-gdbm --with-iconv --enable-exif --enable-ftp --with-gettext --enable-mbstring --with-pcre-regex=/usr --enable-shmop --enable-sockets --enable-wddx --with-libxml-dir=/usr --with-zlib --with-kerberos=/usr --with-openssl=/usr --enable-soap --enable-zip --with-exec-dir=/usr/lib/php5/libexec --without-mm --with-curl=shared,/usr --with-zlib-dir=/usr --with-gd=shared,/usr --enable-gd-native-ttf --with-gmp=shared,/usr --with-jpeg-dir=shared,/usr --with-xpm-dir=shared,/usr/X11R6 --with-png-dir=shared,/usr --with-freetype-dir=shared,/usr --with-t1lib=shared,/usr --with-ldap=shared,/usr --with-ldap-sasl=/usr --with-mhash=shared,/usr --with-mysql=shared,/usr --with-mysqli=/usr/bin/mysql_config --with-pspell=shared,/usr --with-unixODBC=shared,/usr --with-xsl=shared,/usr --with-snmp=shared,/usr --with-sqlite=shared,/usr --with-mssql=shared,/usr --with-tidy=shared,/usr --with-xmlrpc=shared --with-pgsql=shared,/usr --enable-gd-native-ttf --enable-dba=shared --with-openssl-dir=shared,/usr --enable-gd-jis-conv --enable-json --with-mcrypt=shared,/usr --enable-pcntl --with-pdo-mysql --with-pdo-odbc=unixODBC,/usr --with-pdo-pgsql=shared,/usr --with-pdo-sqlite --enable-xmlreader --with-tsrm-pthreads --with-imap --with-imap-ssl
</pre>
<p>I&#8217;m sure this doesn&#8217;t enable ALL features in PHP, but it works for me so far. If I&#8217;ll ever find I was missing something, I&#8217;ll be sure to update this post.</p>
<p>When building make sure to pass the correct number of CPUs to make with the -j parameter to safe some time.</p>
<pre class="brush: plain; title: ; notranslate">
make -j2
</pre>
<p>And now we wait&#8230;</p>
<p>Now we need to add these lines to our httpd.conf (which is empty in this case)</p>
<pre class="brush: plain; title: ; notranslate">
#LoadModule directive to aid module installations
#LoadModule dummy_module /usr/lib/apache2/modules/mod_dummy.so
</pre>
<p>Now we can build our .deb for PHP.</p>
<pre class="brush: plain; title: ; notranslate">
sudo checkinstall -D --install=no --fstrans=no --maintainer=your@email --reset-uids=yes --nodoc --pkgname=php5 --pkgversion=5.3 --pkgrelease=200908060830 --arch=amd64
</pre>
<p>And that&#8217;s it. Now you have a .deb which you can install on a different system or (as checkinstall told you) just put on this system with dpkg -i.</p>
<p>Have fun</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2009/08/06/building-php-5-3-0-on-ubuntu-8-04-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>gSteam &#8211; HLDS Frontend</title>
		<link>http://dirty-motherfucker.org/blog/2009/06/09/gsteam-hlds-frontend/</link>
		<comments>http://dirty-motherfucker.org/blog/2009/06/09/gsteam-hlds-frontend/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 21:24:49 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[hlds]]></category>
		<category><![CDATA[steam]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=271</guid>
		<description><![CDATA[This is a little introduction to the latest version of my steam and hlds frontend bash script. I will demonstrate it&#8217;s use by setting up a new Team Fortress 2 game server with it. This tutorial assumes an Ubuntu 8.04.2 x86 server system. I set up a VM for the sake of this tutorial. It [...]]]></description>
			<content:encoded><![CDATA[<p>This is a little introduction to the latest version of my steam and hlds frontend bash script.<br />
I will demonstrate it&#8217;s use by setting up a new Team Fortress 2 game server with it.<br />
This tutorial assumes an Ubuntu 8.04.2 x86 server system. I set up a VM for the sake of this tutorial.<br />
It has 2 CPUs, 512MB RAM and an 8GB harddrive. So if you want to do a dry run in a VM at first<br />
as well, this will do fine.<br />
Setting up the server OS is beyond the scope of this tutorial. I just assume you have a default<br />
install with an OpenSSH server and that you have fully updated your system after install.<br />
So, let&#8217;s get going.</p>
<p>The first thing we&#8217;ll need is the screen package.</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install screen
</pre>
<p>Now let&#8217;s create a user for steam and switch to it.</p>
<pre class="brush: plain; title: ; notranslate">
sudo adduser --disabled-login steam
sudo su - steam
</pre>
<p>Let&#8217;s download gSteam, my frontend, and set it executable for only steam.</p>
<pre class="brush: plain; title: ; notranslate">
wget http://www.dirty-motherfucker.org/steam/gSteam.sh
chmod 700 gSteam.sh
</pre>
<p>Now we can install the steam client.</p>
<pre class="brush: plain; title: ; notranslate">
./gSteam.sh install steam
</pre>
<p>As noted in my post regarding the L4D server, if the installation does not seem to properly start or<br />
hang, you can try to create a Steam.cfg file (in the homedir) with preferred content server ids.</p>
<p>http://www.dirty-motherfucker.org/blog/2008/12/26/running-a-source-dedicated-server-for-left-4-dead/</p>
<p>After you get the magic line &#8220;Steam Linux Client updated, please retry the command&#8221; you are ready to<br />
install some games. So let&#8217;s install Team Fortress 2.</p>
<pre class="brush: plain; title: ; notranslate">
./gSteam.sh install tf
</pre>
<p>The identifiers for the games can be obtained with:</p>
<pre class="brush: plain; title: ; notranslate">
./steam -command list
</pre>
<p>The &#8220;No installation record found at&#8230;&#8221; messages can be safely ignored.<br />
Now you will have to wait until the game is fully downloaded. This can take from &#8220;forever&#8221; to<br />
&#8220;until the fucking end of time&#8221; in some cases. The old Steam.cfg can help here as well, but<br />
I personally found that patience is the best tool.</p>
<p>Once the installation is completed a profile template for tf will be created. gSteam will try its<br />
best to determine some default parameters. You should edit it nevertheless to at least adjust<br />
the name of your server (and possibly the profile).</p>
<p>If everything worked fine you can now simply</p>
<pre class="brush: plain; title: ; notranslate">
./gSteam start tf2
</pre>
<p>and the thing should be running.</p>
<p>Installing other games is as simple as:</p>
<pre class="brush: plain; title: ; notranslate">
./gSteam install l4d_full
</pre>
<p>Let me just add that the script is far from fail-proof. Especially error-cases aren&#8217;t properly handled. But it saved me a lot of time so I thought I&#8217;d share it.<br />
Hope it helps someone else ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2009/06/09/gsteam-hlds-frontend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running a Source dedicated server (for Left 4 Dead)</title>
		<link>http://dirty-motherfucker.org/blog/2008/12/26/running-a-source-dedicated-server-for-left-4-dead/</link>
		<comments>http://dirty-motherfucker.org/blog/2008/12/26/running-a-source-dedicated-server-for-left-4-dead/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 21:18:31 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[left4dead]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[steam]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=212</guid>
		<description><![CDATA[For a while now I have been running some dedicated servers for Source games. Primarily Team Fortress 2. I lately switched those off in favor of Left 4 Dead servers. I was always looking for a way to improve my setup. At some point during my initial googleing I came across this article. I based [...]]]></description>
			<content:encoded><![CDATA[<p>For a while now I have been running some dedicated servers for Source games. Primarily <a href="http://orange.half-life2.com/tf2.html">Team Fortress 2</a>. I lately switched those off in favor of <a href="http://www.l4d.com/">Left 4 Dead</a> servers. I was always looking for a way to improve my setup. At some point during my initial googleing I came across <a href="http://www.m0interactive.com/archives/2008/09/13/steam_linux_server_init_script_in_chrooted_environment.html">this article</a>.<br />
I based my startup script on the one in that article. But we&#8217;ll come back to that later. Let&#8217;s start with installation.<br />
The initial steps are laid out perfectly on <a href="http://www.srcds.com/">srcds.com</a>. But I&#8217;ll list everything important in here as well.</p>
<p>As all of my administration articles (so far) this one is for Ubuntu Server 8.04.1. </p>
<p>Let&#8217;s start by adding a new user that will run our servers.</p>
<pre class="brush: plain; title: ; notranslate">sudo adduser --disabled-login steam</pre>
<p>
Now to log in with the newly created user to install the servers. We need to switch the user as root as a normal user can not log into this account.</p>
<pre class="brush: plain; title: ; notranslate">sudo su - steam</pre>
<p>
No we can install the HLDSUpdateTool.</p>
<pre class="brush: plain; title: ; notranslate">wget http://www.steampowered.com/download/hldsupdatetool.bin
chmod +x hldsupdatetool.bin
./hldsupdatetool.bin
./steam</pre>
</p>
<p>In case it will hang at &#8220;Checking bootstrapper version&#8230;&#8221; you can try to set a set of preferred content servers. You do that by creating a file called &#8220;steam.cfg&#8221; and adding the following line to it:
<pre class="brush: plain; title: ; notranslate">PreferredContentServerIDs = &quot;id id id&quot;</pre>
<p>You can find the ids on <a href="http://store.steampowered.com/stats/content/">http://store.steampowered.com/stats/content/</a> under &#8220;Individual Server Statisistics&#8221;. Look for Valve #NN servers and place the number of the servers you want to use inside the quotes. Then retry running steam.</p>
<p>Now we&#8217;ll install a game. Let&#8217;s start out with Left 4 Dead. If you want to see what games are available, run:</p>
<pre class="brush: plain; title: ; notranslate">./steam -command list</pre>
<p>This will also show you the correct game identifier for Left 4 Dead, which is l4d_full (left4dead was for the demo).</p>
<pre class="brush: plain; title: ; notranslate">./steam -command update -game l4d_full -dir /home/steam</pre>
</p>
<p>In case the installation process hangs you can also try setting the preferred content servers as mentioned above. Now, theoretically you&#8217;re good to go and you can start your server. But we&#8217;re gonna go a step further. I use a start script based on the article mentioned at the start of this article. Now let&#8217;s grab it.<br />
But wait, in case you realize that you really don&#8217;t want to use any of my shitty scripts and that you just want to get a clean server running, in that case it can stilll be helpful to get the script. You see when you use my script and you start a profile it will print out the command line it used. That way you can build up your desired configuration according to this guide, then run the script and get the correct command line to run your server. Thus I still highly recommend getting the script.</p>
<pre class="brush: plain; title: ; notranslate">wget http://www.dirty-motherfucker.org/blog/wp-content/uploads/2008/12/steamLauncher.sh
chmod +x steamLauncher.sh
</pre>
</p>
<p>The script allows to easily start and stop Source servers in the background. It also allows for several profiles for several games. So you can start all games through the same interface. I like it, if you don&#8217;t then maybe have a look at the original script.</p>
<p>So let&#8217;s create a profile for Left 4 Dead.</p>
<pre class="brush: plain; title: ; notranslate">mkdir profiles
editor profiles/l4d.conf
</pre>
<p>
Now, this is how a profile should look like:</p>
<pre class="brush: plain; title: ; notranslate">longName                = Left 4 Dead - 1 instance      ; The name of this profile/game
gameName                = left4dead                     ; The name given by steam to the game (equals the foldername ex. cstrike|tf2|left4dead)
daemon                  = /home/steam/l4d/srcds_run     ; Usually srcds_run
updater                 = /home/steam/steam             ; Where is the updater located? (steam binary)
basePath                = /home/steam/l4d               ; The base path of the steam installation (this folder contains tf2/cstrike/left4dead folders)
userName                = steam                         ; What user the server should run as

serverName              = My L4D Server                 ; The name that will appear in the server browser
serverIp                = 11.222.33.111                 ; The IP address to bind the server socket to
serverPort              = 27010                         ; The first port to use for listening (will be treated as base port with forked l4d servers)
serverMap               = l4d_hospital01_apartment      ; The first map to load
serverMaxPlayers        = 4                             ; Maximum number of players allowed on the server
serverPriority          = 0                             ; Renice to set for the server process (-20 is high, 0 is normal, +19 is low)
forkCount               = 0                             ; How many instances to fork
additionalParams        = -nohltv -steamport 27960+## +clientport 25030+## +exec server##.cfg +sv_lan 0 ; Additional params to run the server with
</pre>
<p>
Obviously in that profile you need to adjust at least the serverIp parameter. Now you can run that profile by typing.</p>
<pre class="brush: plain; title: ; notranslate">./steamLauncher start l4d</pre>
<p>
Keep in mind though, this is not a state that we want to be comfortable with just yet. Nevertheless start it up and check if there is any trouble. If it comes up, attach to the screen session as the script tells you to.<br />
In case you get an error saying &#8220;Cannot open terminal &#8216;/dev/pts/0&#8242;&#8221;, you can run &#8220;script /dev/null&#8221; and then attach to the session. There are other ways to resolve it. If you wanna find out about those they&#8217;re easy to find in Google ;)</p>
<p>Now, in the profile of Left 4 Dead in the additionParameters we also tell the server to execute a certain config file. Let&#8217;s create that one now.</p>
<pre class="brush: plain; title: ; notranslate">editor l4d/left4dead/cfg/server01.cfg</pre>
<p>In here we can now override the default map, difficulty and whatnot. For example:
<pre class="brush: plain; title: ; notranslate">hostname        My L4D Server - No Mercy - Normal Difficulty
map             l4d_hospital01_apartment
m_difficulty    normal
</pre>
<p>Setting the difficulty and map is almost pointless though as they can be changed by vote anyway. But I&#8217;m sure you can think of some other server variables that you might want to set. And this is the place to do it.</p>
<p>Now might be a good time to talk about forking with Left 4 Dead servers. Given that there are only 4 or 8 players on a Left 4 Dead server it&#8217;s almost a waste only running a single instance. That&#8217;s why you can fork multiple instances of servers. Let&#8217;s have a look at a Left 4 Dead profile modified to run 4 servers.</p>
<pre class="brush: plain; title: ; notranslate">longName                = Left 4 Dead - 4 instances     ; The name of this profile/game
gameName                = left4dead                     ; The name given by steam to the game (equals the foldername ex. cstrike|tf2|left4dead)
daemon                  = /home/steam/l4d/srcds_run     ; Usually srcds_run
updater                 = /home/steam/steam             ; Where is the updater located? (steam binary)
basePath                = /home/steam/l4d               ; The base path of the steam installation (this folder contains tf2/cstrike/left4dead folders)
userName                = steam                         ; What user the server should run as

serverName              = My L4D Server                 ; The name that will appear in the server browser
serverIp                = 11.222.33.111                 ; The IP address to bind the server socket to
serverPort              = 27010                         ; The first port to use for listening (will be treated as base port with forked l4d servers)
serverMap               = l4d_hospital01_apartment      ; The first map to load
serverMaxPlayers        = 4                             ; Maximum number of players allowed on the server
serverPriority          = 0                             ; Renice to set for the server process (-20 is high, 0 is normal, +19 is low)
forkCount               = 4                             ; How many instances to fork
additionalParams        = -nohltv -steamport 27960+## +clientport 25030+## +exec server##.cfg +sv_lan 0 ; Additional params to run the server with
</pre>
<p>
You can now also create server02.cfg, server03.cfg and server04.cfg in the l4d folder. This way you can start up each instance with a different map, difficulty, key, &#8230;<br />
It remains a mystery to me how to properly send commands to the console with forked instances though. Although from what I read there are ways, but I just never had any luck with those. I also never had any luck with rcon. So basically when I play on my own servers I can&#8217;t do shit when someone is getting on my nerves. And we sure don&#8217;t want that!<br />
So what do we do? We install SourceMod. It gives us a nice and easy way to kick players when they get on our balls. And we can be happy little server admins. During the installation of SourceMod it may be helpful to run only a single instance profile of Left 4 Dead so you can easily attach to the screen session and send of some commands to test your installation.<br />
So let&#8217;s get to it!</p>
<p>First of all we require MetaMod. A very straight-forward guide can be found on the <a href="http://wiki.alliedmods.net/Installing_Metamod:Source">MetaMod Wiki</a>. For completeness sake I&#8217;ll replicate the required information here though.</p>
<ol>
<li>Download MetaMod at <a href="http://www.metamodsource.net/">http://www.metamodsource.net/</a></li>
<li>Put it into the left4dead folder. (cd l4d/left4dead)</li>
<li>tar xvzf mmsource-1.7.0.tar.gz (Filename might differ)</li>
<li>In l4d/left4dead/addons create a file metamod.vdf and put the following into it:
<pre class="brush: plain; title: ; notranslate">&quot;Plugin&quot;
{
        &quot;file&quot;  &quot;../left4dead/addons/metamod/bin/server_i486.so&quot;
}
</pre>
</li>
<li>Go back into your home directory and restart your server (./steamLauncher restart l4d)</li>
<li>Attach to the screen session and type &#8220;meta version&#8221;. Everything other than &#8220;Unknown command&#8221; is a good sign.</li>
</ol>
<p>If the installation of MetaMod fails, refer to the MetaMod Wiki or bug me about it.</p>
<p>Now we&#8217;re gonna install SourceMod. Again a proper guide can be found at <a href="http://wiki.alliedmods.net/Installing_SourceMod">http://wiki.alliedmods.net/Installing_SourceMod</a>.</p>
<ol>
<li>Grab one of the latest snapshots of SourceMod from <a href="http://www.sourcemod.net/snapshots-1.2.php">http://www.sourcemod.net/snapshots-1.2.php</a></li>
<li>Just like we did with MetaMod, put it into the l4d/left4dead folder.</li>
<li>Extract it via tar xvzf sourcemod-1.2.0-hg2469.tar.gz (Filename may differ again)</li>
<li>Go back into your home directory and restart your server (./steamLauncher restart l4d)</li>
<li>Attach to the screen session and type &#8220;meta list&#8221;. You should see that SourceMod is loaded.</li>
</ol>
<p>Now last but not least we need to set ourself up as an admin in SourceMod. We do that by editing
<pre class="brush: plain; title: ; notranslate">l4d/left4dead/addons/sourcemod/configs/admins_simple.ini</pre>
<p>
Right at the bottom we will now put the following line:
<pre class="brush: plain; title: ; notranslate">&quot;STEAM_YOURID&quot; &quot;99:z&quot;</pre>
<p>
If you&#8217;re like me then you&#8217;ll have no clue what your Steam ID is. So open up steam and connect to any server in any game. Then open up the console and type &#8220;status&#8221;. In the list that appears there should be your nick somewhere. And close to it, you&#8217;ll find your Steam ID.</p>
<p>Now you should be an admin on your Left 4 Dead servers. You can join your own servers easily by invoking &#8220;openserverbrowser&#8221; in the Left 4 Dead console. To enjoy being an admin it helps to bind &#8220;sm_admin&#8221; to some key. Then you can open the admin menu and kick those pesky players who just can&#8217;t stop running ahead to get themselves killed.</p>
<p>In case this isn&#8217;t clear. You&#8217;ll have to forward some ports for your servers to work. Which can easily be accomplished by adding two lines to your /etc/ufw/after.rules file. Similar to these two:</p>
<pre class="brush: plain; title: ; notranslate"># Steam TF2 Server
-A ufw-after-input -d 11.222.33.111 -m udp -p udp --dport 26900:27040 -m conntrack --ctstate NEW,RELATED,ESTABLISHED -j ACCEPT
-A ufw-after-input -d 11.222.33.111 -m tcp -p tcp --dport 27000:27020 -m conntrack --ctstate NEW,RELATED,ESTABLISHED -j ACCEPT
</pre>
</p>
<p>I hope I haven&#8217;t left any open questions. In case I did, please let me know ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2008/12/26/running-a-source-dedicated-server-for-left-4-dead/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

