<?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>Biodegradable Geek &#187; Linux</title>
	<atom:link href="http://biodegradablegeek.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://biodegradablegeek.com</link>
	<description></description>
	<lastBuildDate>Tue, 22 Jun 2010 21:52:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bash Tips for Power Users</title>
		<link>http://biodegradablegeek.com/2009/06/bash-tips-for-power-users/</link>
		<comments>http://biodegradablegeek.com/2009/06/bash-tips-for-power-users/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 19:22:14 +0000</pubDate>
		<dc:creator>Isam</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[getting things done]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://biodegradablegeek.com/?p=105</guid>
		<description><![CDATA[Every Geek site needs an obligatory Bash Tips post
Copy Files Securely Between Two Machines
I used to always forget the syntax for this, until I realized that the syntax is exactly like the standard cp command. In fact, you can copy files like you normally would using scp, on your local machine. The following are equivalent:

$ [...]]]></description>
			<content:encoded><![CDATA[<p>Every Geek site needs an obligatory Bash Tips post</p>
<h2><strong>Copy Files Securely Between Two Machines</strong></h2>
<p>I used to always forget the syntax for this, until I realized that the syntax is exactly like the standard <strong>cp</strong> command. In fact, you can copy files like you normally would using scp, on your local machine. The following are equivalent:</p>
<pre class="brush: bash;">
$ cp file file.orig
$ scp file file.orig
</pre>
<p>Where they differ is, <strong>scp</strong> lets you copy files over a network, through SSH. Here&#8217;s an example:</p>
<pre class="brush: bash;">
$ scp contents.txt silver@ssh.domain.com:/tmp
</pre>
<p>This will copy local file contents.txt to /tmp on the remote machine ssh.domain.com, as user silver. Here are some more examples:</p>
<pre class="brush: bash;">
$ scp draft.pdf ssh.domain.com:
</pre>
<p>(copy draft.pdf to my home dir on remote machine. username is implied to be the same locally and remotely.)</p>
<pre class="brush: bash;">
$ scp swine.jpg rex@ssh.domain.com
</pre>
<p>(<strong>read</strong>: This will copy swine.jpg to local machine as a file named rex@ssh.domain.com. To make it go remote, append a : to the address, like above)<strong> </strong></p>
<p><strong>scp</strong> supports, among other things, compression (-C) and recursive copying of directories (-r).<br />
<strong> </strong></p>
<pre class="brush: bash;">
$ scp -rC code/ ssh.domain.com:/archive/code_02032009
</pre>
<p><strong></strong></p>
<p>Trying to copy to a directory you don&#8217;t have permission to (/usr etc) will fail.</p>
<h2>Don&#8217;t Get Lost Jumping To and Fro Between Directories</h2>
<p>You can use <strong>cd -</strong> to jump to the previous (NOT parent) dir. For example:</p>
<pre class="brush: bash;">
kiwi@localhost: ~ $ cd /usr/local/share
kiwi@localhost: /usr/local/share $ cd -
/home/kiwi
kiwi@localhost: ~ $ cd -
/usr/local/share
kiwi@localhost: /usr/local/share $
</pre>
<p>Another way is using <strong>pushd/popd</strong> &#8211; A Last In First Out (LIFO) stack of dirs.</p>
<pre class="brush: bash;">
kiwi@localhost: ~ $ pushd /usr/local/share/
/usr/local/share ~
</pre>
<p><strong>pushd</strong> is like cd but keeps note of the current dir before cd&#8217;ing into a new one. The stack of dirs is listed every time you invoke <strong>pushd</strong> <em>(the &#8220;/usr/local/share ~&#8221; output you see above.)</em></p>
<pre class="brush: bash;">
kiwi@localhost: /usr/local/share $ pushd /
/ /usr/local/share ~
</pre>
<p>Stack is ordered left to right, latest push first. If we pop the first dir off:</p>
<pre class="brush: bash;">
kiwi@localhost: / $ popd
/usr/local/share /tmp ~
kiwi@localhost: /usr/local/share $
</pre>
<p>We&#8217;re back in the share dir. We can keep popping until there&#8217;s nothing left (throws an error):</p>
<pre class="brush: bash;">
kiwi@localhost: /usr/local/share $ popd
/tmp ~
kiwi@localhost: /tmp $ pushd /lib
/lib /tmp ~
kiwi@localhost: /lib $ popd
/tmp ~
kiwi@localhost: /tmp $ popd
~
kiwi@localhost: ~ $ popd
bash: popd: directory stack empty
</pre>
<h2>Working with Long Lines</h2>
<p>No need for more Bash shortcut <a href="http://cheat.errtheblog.com/s/bash/" target="_blank">cheat sheets</a>, but here are some useful ones to help you work with long lines.</p>
<p>You can jump to the <strong>start &amp; end</strong> of a line using <strong>CTRL+a &amp; CTRL+e</strong> respectively. Example (* is the cursor):</p>
<pre class="brush: bash;">
kiwi@localhost: ~ $ echo al the ducks are swimming in the w*
</pre>
<p>and you want to fix the first word. You can hop to the beginning of the line with <strong>CTRL+a</strong>:</p>
<pre class="brush: bash;">
kiwi@localhost: ~ $ *echo al the ducks are swimming in the w
</pre>
<p>and now you can jump to the end of the misspelled word &#8220;al&#8221; using <strong>CTRL+Right</strong> twice to correct it:</p>
<pre class="brush: bash;">
kiwi@localhost: ~ $ echo all*the ducks are swimming in the w
</pre>
<p>Now ctrl+e to jump to the end of line:</p>
<pre class="brush: bash;">
kiwi@localhost: ~ $ echo all the ducks are swimming in the w*
</pre>
<p>Instead of backspacing every character, use <strong>ALT+Backspace</strong> to backspace entire words. You can also delete <strong>all</strong> or part of a line using <strong>CTRL+u</strong> combo. It deletes everything before the cursor. Likewise, <strong>CTRL+k</strong> wipes out everything after the cursor. I&#8217;ve developed a habit of using CTRL+e CTRL+k to delete lines.</p>
<p>Bash has a lot of <strong>ALT</strong> commands that let you move and manipulate words. <strong>ALT+l</strong> and <strong>ALT+u</strong> will make a word in front of the cursor lowercase or uppercase, for example. A neat one I don&#8217;t think I ever used is ALT+\ It pulls everything after the cursor left to the first non-whitespace character. Here&#8217;s an example, * is the cursor:</p>
<p><strong>BEFORE:</strong></p>
<pre class="brush: bash;">
$ my     spacebar is    *sticky
</pre>
<p><strong>AFTER (ALT+\):</strong></p>
<pre class="brush: bash;">
$ my     spacebar issticky
</pre>
<h2>Avoid Retyping Commands &amp; Arguments</h2>
<p><strong>ESC + .</strong> is <span style="text-decoration: underline;">very</span> useful. Escape followed by a period will output the argument you sent to your last Bash command. Command calls themselves are outputted if they were invoked without any arguments <em>(popd, ls, etc).</em></p>
<p>Example, unzipping a file and moving the archive to /tmp:</p>
<pre class="brush: bash;">
$ unzip archive-with-a-long-ambiguous-name-03092009-5960-1.2.5.zip
$ mv archive-with-a-long-ambiguous-name-03092009-5960-1.2.5.zip /tmp
</pre>
<p>In the mv command, the archive name was outputted by pressing <strong>ESC+.</strong> (full command being mv (ESC+.) /tmp) There was no need to type the long archive name twice.</p>
<p>The argument is taken from your bash history. You can keep invoking ESC+. to cycle back through all your recent command arguments. (history -c to clear)</p>
<p>Try not to forget this; You&#8217;ll naturally find plenty of uses for it.</p>
<p>Another way to avoid re-typing commands is <strong>CTRL+R</strong>. It will initiate a search of your command history. Begin typing, and watch Bash try to complete your command from previous ones you entered.</p>
<h2>Command Getting Too Big? Send it to your Editor</h2>
<p>Sometimes you begin writing what you think will be a simple command, only to realize that it has grown too complex for the command line, and you wish you were in your text editor.</p>
<p>First make sure your default editor is set. This is either in $EDITOR (export EDITOR=/usr/local/bin/vim) or elsewhere depending on the distro.</p>
<p>Use &#8220;fc&#8221; to open the last executed command in your editor:</p>
<pre class="brush: bash;">
ls -paul --sort=size
... ls output ...
fc
</pre>
<p>Now the <em>ls</em> line will be open in your editor. But what if you hadn&#8217;t executed the command yet? No problem. You&#8217;re sending off an email, but quickly realize that the command line isn&#8217;t ideal for everything:</p>
<pre class="brush: bash;">
echo -e &quot;Dear Santa, \n\n\tIt has become evident that your fat ass is contributing to Global Warming, primarily due to the large quantity of coal you distribute annually. We hereby
</pre>
<p>No matter where you are on the line, hit <strong>CTRL+x, CTRL+e</strong> to invoke your editor, which now contains what you were typing on the cmd line.</p>
<p>I always find myself wanting to finish a command in vim, but unwilling to type the first few lines over, especially when I&#8217;m trying to write a for loop or any ugly multiline Bash code.</p>
<p><strong>IMPORTANT: Whatever you type in your editor is executed automatically after you quit the editor.</strong><br />
<span id="more-105"></span></p>
<h2>Multiple Commands on a Single Line</h2>
<p>There are a number of ways to piece together commands (||, pipes, etc), depending on your need, but sometimes, you just commands executed consecutively. You can use ; or &amp;&amp;.</p>
<p><strong>semicolon (;) vs AND (&amp;&amp;)</strong>: The semicolon will run through each command consecutively, whereas &amp;&amp; is a little smarter, and will not continue if a command does not end successfully (return 0 &#8211; you can check the return value of the last app ran with <strong>echo $?</strong>).</p>
<p>&amp;&amp; is generally safer. i.e., ./configure &amp;&amp; make (&amp;&amp; sudo make install)</p>
<p>AND</p>
<pre class="brush: bash;">
$ cp bogus &amp;amp;&amp;amp; echo &quot;** copied&quot;
cp: missing destination file operand after `bogus'
Try `cp --help' for more information.
</pre>
<p>SEMICOLON;</p>
<pre class="brush: bash;">
cp bogus; echo &quot;** copied... or did I? tun tun tunnn!&quot;
cp: missing destination file operand after `bogus'
Try `cp --help' for more information.
** copied... or did I? tun tun tunnn!
</pre>
<h2>Convert between DOS and UNIX ASCII files</h2>
<p>Sometimes you get a text file that has weird ^M characters in it. These are due to a difference in how Unix and Windows systems end lines. You can convert between these formats using <strong>unix2dos</strong> or <strong>todos</strong> and <strong>dos2unix</strong> or <strong>fromdos</strong>.</p>
<pre class="brush: bash;">
$ mkdir /tmp/rcfl
$ cd /tmp/rcfl
$ echo -e &quot;Justa Lonely\nASCII File&quot; &gt; out
$ file out
out: ASCII text
$ todos out
$ file out
out: ASCII text, with CRLF line terminators
$ vim out # notice [dos] flag in status bar, quit :q!
$ fromdos out
$ file out
out: ASCII text
</pre>
<h2>Background Processes</h2>
<p>Have a little more control over your apps.</p>
<p><strong>Stop Right Thurr</strong><br />
When a program is running in the foreground, you no longer have access to the command line. An example is &#8216;tail -f&#8217; or &#8216;ruby script/server&#8217;</p>
<p>You can have a running process pause for a sec with <strong>CTRL+z</strong>.<br />
Do your dirty work and then bring the app back to the foreground with <strong>fg</strong>.<br />
To list the processes you have paused, use <strong>jobs</strong></p>
<pre class="brush: bash;">
$ tail -f useful.log
00:00:50 User did something that was log-worthy
00:00:56 User did something that was log-worthy
00:00:57 User did something that was log-worthy

# (press CTRL+z)
[1]+  Stopped                 tail -f useful.log

$ echo &quot;look ma, I can type&quot;
look ma, I can type

$ fg
tail -f useful.log

# (press CTRL+z)
[1]+  Stopped                 tail -f useful.log

$ tail -f blah.tmp

# (press CTRL+z)
[2]+  Stopped                 tail -f blah.tmp

$ jobs
[1]-  Stopped                 tail -f useful.log
[2]+  Stopped                 tail -f blah.tmp
$ fg 1
(process [2] continues)
</pre>
<p><strong>In the Background</strong></p>
<p>You can have a process start in the background by appending to it a <strong>&amp;</strong>.<br />
and bring this to the foreground using <strong>fg [#]</strong>.<br />
As before, jobs will list background processes, but with status <em>Running</em> instead of <em>Stopped</em>.</p>
<p>Programs running in the background will still output to stdout, which means they&#8217;ll make the shell ugly. So if you plan on using them, think about redirecting the output.</p>
<h2>Bash Redirection</h2>
<p>Some things are mentioned on nearly every &#8216;bash tips&#8217; page &#8212; like redirecting output. Here are the basics. We&#8217;re concerned with 2 I/O streams: STDOUT and STDERR. STDOUT has a value of 1, and it is the screen. If a program writes to stdout, that text is shown in the console. Errors are sent through a different stream, stderr, which has a value of 2. Value 0 is stdin, used for user input. The technical details aren&#8217;t important. Just remember that 1 is screen and 2 is error.</p>
<p>There&#8217;s a number of ways to redirect output:</p>
<pre class="brush: bash;">
$ echo &quot;asdfasdf&quot; 1&gt; /tmp/asdf.txt # overwrite existing file
$ echo &quot;asdfasdf&quot; &gt; /tmp/asdf.txt # (same, 1 is default, optional)
$
$ echo &quot;32452345&quot; &gt;&gt; /tmp/asdf.txt # append to end of existing file*
$ echo &quot;wash the dishes&quot; &gt; /dev/null # just ignore output
$ echo &quot;wash the dishes&quot; 2&gt; /dev/null # just ignore errors
$
$ more 1&gt; /dev/null # error still shown
$ more 2&gt; /dev/null # nothing shown
$ more &amp;&gt; /dev/null # nothing shown
$
$ more 2&gt;| /dev/null # silence errors
$ more &gt;| /tmp/more.txt # save output to file
$
$ more 1&gt; /tmp/more.txt 2&gt;&amp;1 # redirect stdout to file and redirect stderr to stdout (same file)
$ more 2&gt; /tmp/more.txt 1&gt;&amp;2 # have stdout follow stderr to file
</pre>
<p>To redirect output to a file &amp; screen, use <strong>tee</strong></p>
<pre class="brush: bash;">
$ echo &quot;dont forget the milk&quot; | tee /tmp/toforget.txt
</pre>
<p>More a more extensive guide on redirection, see <a href="http://tldp.org/LDP/abs/html/io-redirection.html" target="_blank">Bash IO Redirection</a> or some of the External Links below.</p>
<h2>Art of teh Alias</h2>
<p>I use a lot of aliases. Here are a few:</p>
<pre class="brush: bash;">
# I use these a lot. Can also have aptupdate, aptremove etc...
alias aptinstall='sudo apt-get install'
alias aptsearch='apt-cache search'
alias suvim='sudo vim'

# Aliasing command names. To use original commands, you'd need to specify absolute path.
alias a2restart='sudo apache2ctl restart'
alias gem='sudo gem'
alias checkinstall='sudo checkinstall'

# I used these to workaround the infamous FF memory leak (ugly)
# alias swapoff='sudo swapoff'
# alias swapon='sudo swapon'

# Going places. This + ssh keypair
alias macbookshell='ssh 192.168.1.17'
alias workshell='ssh meh@ssh.domain.com'

# Pretty output. (--group-directories-first might not work on your system).
alias lsf='ls -hAlF --group-directories-first --color=always --time-style=+&quot; %m/%d/%y %I:%M %p &quot;'

# List only directories
alias lsd='ls -d */'

# I'm a measly human!
alias free=&quot;free -m&quot;

# 'gimme x' is equivalent to 'sudo chown me.me x'
# alias gimme=&quot;ME6=`whoami` &amp;amp;&amp;amp; sudo \&quot;chown $ME6.$ME6\&quot;&quot;

# Usage: nullminate bloated-file.log
alias nullminate=&quot;cat /dev/null &gt; &quot;

# Search contents of an entire dir. Usage: scan &quot;PESKY_VARIABLE ?=&quot; project-123/
alias scan=&quot;grep -Rin --color&quot;
</pre>
<p>These should go in a ~/.bash_aliases file and invoked from within your user conf (.bashrc?)</p>
<p><!--<br />
screen<br />
public keys<br />
sub sections (shortcuts, history, redirection)<br />
--></p>
<p><strong>External links (related): </strong></p>
<ul>
<li><a href="http://www.caliban.org/bash/" target="_blank">Working more productively with bash 2.x/3.x</a></li>
<li><a href="http://www.hypexr.org/bash_tutorial.php" target="_blank">Getting Started with BASH</a></li>
<li><a href="http://www.wains.be/index.php/2007/11/26/bash-tips-and-tricks/" target="_blank">Bash Tips &amp; Tricks</a></li>
<li><a href="http://hacktux.com/bash/script/efficient" target="_blank">10 Tips for Writing Efficient Bash Scripts</a></li>
<li><a href="http://www.linuxtutorialblog.com/post/tutorial-the-best-tips-tricks-for-bash" target="_blank">Best Tips &amp; Trips for Bash</a></li>
<li><a href="http://linuxhelp.blogspot.com/2005/08/bash-shell-shortcuts.html" target="_blank">Bash Shell Shortcuts</a></li>
<li><a href="http://bashish.sourceforge.net/" target="_blank">Bashish</a></li>
<li><a href="http://www.davidpashley.com/articles/writing-robust-shell-scripts.html" target="_blank">Writing Robust Shell Scripts</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://biodegradablegeek.com/2009/06/bash-tips-for-power-users/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Block AIM&#8217;s Annoying &#8216;AOL System Msg&#8217; in Pidgin</title>
		<link>http://biodegradablegeek.com/2009/05/how-to-block-aims-annoying-aol-system-msg-in-pidgin/</link>
		<comments>http://biodegradablegeek.com/2009/05/how-to-block-aims-annoying-aol-system-msg-in-pidgin/#comments</comments>
		<pubDate>Sat, 02 May 2009 04:44:12 +0000</pubDate>
		<dc:creator>Isam</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Workarounds]]></category>
		<category><![CDATA[annoying]]></category>
		<category><![CDATA[chat]]></category>
		<category><![CDATA[pidgin]]></category>

		<guid isPermaLink="false">http://biodegradablegeek.com/?p=426</guid>
		<description><![CDATA[The following plugin for Pidgin will block the incredibly annoying and useless notifications from AOLSystemMsg on AIM.
&#8220;AOL System Msg: Your screen name (mrEman) is now signed into AOL(R) Instant Messenger (TM) in 2 locations. Click here for more information.&#8221;
To use, paste code in file, save file as blockaolsystemmsg.pl in ~/.purple/plugins/ and then open (or re-open) [...]]]></description>
			<content:encoded><![CDATA[<p>The following plugin for <a href="http://www.pidgin.im/">Pidgin</a> will block the incredibly annoying and useless notifications from AOLSystemMsg on AIM.</p>
<blockquote><p>&#8220;AOL System Msg: Your screen name (mrEman) is now signed into AOL(R) Instant Messenger (TM) in 2 locations. Click here for more information.&#8221;</p></blockquote>
<p>To use, paste code in file, save file as <strong>blockaolsystemmsg.pl</strong> in <strong>~/.purple/plugins/</strong> and then open (or re-open) Pidgin and go to Tools -&gt; Plugins (or press CTRL+U), and enable &#8220;Block AOLSystemMsg.&#8221; That should be it!</p>
<p><em>If you&#8217;re having any trouble, try going to Help -> Debug to open up Pidgin&#8217;s debug console. </em></p>
<pre class="brush: perl;">
#!/usr/bin/perl
# BlockAOLSystemMsg plugin tested on Pidgin 2.5.5. Put in ~/.purple/plugins/ and enable
use Purple;
our $target = 'AOL System Msg'; # case-insensitive
our $plugin_name = 'Block AOLSystemMsg'; 

%PLUGIN_INFO = (
  perl_api_version =&gt; 2,
  name =&gt; $plugin_name,
  version =&gt; &quot;0.1&quot;,
  summary =&gt; &quot;Blocks the screen name 'AOL System Msg'&quot;,
  description =&gt; &quot;Ignore annoying 'your SN has signed on at 2 locations' AIM message&quot;,
  author =&gt; &quot;Isam &quot;,
  url =&gt; &quot;http://biodegradablegeek.com&quot;,
  load =&gt; &quot;plugin_load&quot;,
  unload =&gt; &quot;plugin_unload&quot;
);

sub loginfo { Purple::Debug::info($plugin_name, &quot; @_\n&quot;); }
sub minimize {
  my $r = lc($_[0]);
  $r =~ s/ //g;
  return $r;
}

sub plugin_init { return %PLUGIN_INFO; }

sub plugin_load {
  my $plugin = shift;
  $target = minimize($target);
  loginfo(&quot;Sight set on '$target'&quot;);
  Purple::Signal::connect(Purple::Conversations::get_handle(),
                          'receiving-im-msg', $plugin, \&amp;callback, '');
}

sub plugin_unload {
  my $plugin = shift;
  loginfo('Block AOLSystemMsg Unloaded.');
}

sub callback {
  my ($acc, $sender, $msg, $flags) = @_;
  if (minimize($sender) eq $target) {
    loginfo(&quot;(BLOCKED) &lt;$sender&gt; $msg&quot;);
    return 1
  };
}
</pre>
<p>update: Fixed the botched code. Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://biodegradablegeek.com/2009/05/how-to-block-aims-annoying-aol-system-msg-in-pidgin/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>I Can&#8217;t Live Without My vim Config</title>
		<link>http://biodegradablegeek.com/2009/04/i-cant-live-without-my-vim-config/</link>
		<comments>http://biodegradablegeek.com/2009/04/i-cant-live-without-my-vim-config/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 17:43:18 +0000</pubDate>
		<dc:creator>Isam</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[editors]]></category>
		<category><![CDATA[gvim]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://biodegradablegeek.com/?p=384</guid>
		<description><![CDATA[I have updated the vim page with my vimrc/gvimrc configs. Instead of repeating myself, I will quote some parts of the page ..
More details and the vim config itself here
I recommend turning backups on if you have them off. I personally hate having the ~ files all over my OS, so I keep them along [...]]]></description>
			<content:encoded><![CDATA[<p>I have updated the <a href="/vim">vim</a> page with my vimrc/gvimrc configs. Instead of repeating myself, I will quote some parts of the page ..</p>
<p><strong><a href="/vim">More details and the vim config itself here</a></strong></p>
<p>I recommend turning backups on if you have them off. I personally hate having the ~ files all over my OS, so I keep them along with the .swp files in 1 backup dir in ~/.vim/</p>
<p>The programming language skeleton stuff will detect what files you are editing and change options in vim by inheriting the specified files which I put in ~/.vim/skeletons and ~/.vim/inherit.</p>
<p>The skeletons are automatically inserted in new files that vim is aware of. For example, in my own config, I have ~/.vim/inherit/c which has all the usual includes and int main() code. When I make a new C file (&#8220;gvim hello.c&#8221;), the new file begins with the skeleton code already present. Neat huh?</p>
<p>The inherit files can be used to set specific options for each language. This can mean different bindings, whitespace options, themes, etc depending on what language you&#8217;re working with, automatically.</p>
<p><a href="/vim">See the vim page</a></p>
<p><strong>What options have helped you the most?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://biodegradablegeek.com/2009/04/i-cant-live-without-my-vim-config/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Maintain Static Sites with Git &amp; Jekyll</title>
		<link>http://biodegradablegeek.com/2009/03/how-to-maintain-static-sites-with-git-jekyll/</link>
		<comments>http://biodegradablegeek.com/2009/03/how-to-maintain-static-sites-with-git-jekyll/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 04:10:00 +0000</pubDate>
		<dc:creator>Isam</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://biodegradablegeek.com/?p=371</guid>
		<description><![CDATA[Static sites in this context just means non-database driven sites. Your static site can be an elaborate PHP script or just a few markup and image files. For this I am using Jekyll &#8211; A neat Ruby gem that makes your static sites dynamic. It lets you create layouts and embed custom variables in your [...]]]></description>
			<content:encoded><![CDATA[<p>Static sites in this context just means non-database driven sites. Your static site can be an elaborate PHP script or just a few markup and image files. For this I am using <strong><a href="http://github.com/mojombo/jekyll/tree/master">Jekyll</a> &#8211; A neat Ruby gem that makes your static sites dynamic.</strong> It lets you create layouts and embed custom variables in your HTML (this is a &#8220;prototype&#8221; of the site). </p>
<p>Jekyll tackles all the nuisances involved in creating static pages (I used to add just enough PHP to make a layout). It works by running your prototype through some parsers and outputs plain static HTML/XML (RSS feeds) etc. It&#8217;s perfect for lightweight sites that would be impractical on Wordpress, like a few static pages of information, landing pages, portfolio/resume pages, and parked domains. </p>
<p>Git takes care of keeping your development (local) and production (remote) environments synced. Git might be a little confusing if you&#8217;re learning it with the mindset that it works like Subversion. </p>
<p><strong>I&#8217;ll update this post when the guide is done. For now, the following will assume you&#8217;re familiar with Jekyll (or at least have an empty file in the prototype directory) and git. This Bash script simplifies creating the remote git repository:</strong></p>
<p>** please read through the code and make sure you know what this does, and what you&#8217;re doing. As of now, this is bias towards my own Apache/vhost setup. It&#8217;s trivial to edit for your specific needs. <strong>You&#8217;re using this at your own risk</strong>.</p>
<p>(<a href="http://code.biodegradablegeek.com/repogen.sh" target="_blank">direct link &#8211; repogen.sh</a>)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># </span>
<span style="color: #666666; font-style: italic;"># 04/01/2009 | http://biodegradablegeek.com | GPL </span>
<span style="color: #666666; font-style: italic;"># </span>
<span style="color: #666666; font-style: italic;"># You should be in site (NOT public) root (be in same dir as public/ log/ etc)</span>
<span style="color: #666666; font-style: italic;"># proto/ is created and will house the jekyll prototype</span>
<span style="color: #666666; font-style: italic;"># public/ will be the generated static site</span>
<span style="color: #666666; font-style: italic;"># the public/ folder will be REMOVED and regenerated on every push</span>
<span style="color: #666666; font-style: italic;"># </span>
&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: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: ./repogen.sh domain.comn&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># optional. will make it easier to copy/paste cmd to clone repo </span>
<span style="color: #007800;">SSHURL</span>=<span style="color: #ff0000;">&quot;ssh.domain.com&quot;</span>
<span style="color: #007800;">URL</span>=<span style="color: #ff0000;">&quot;$1&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;** creating tmp repo&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> proto
<span style="color: #7a0874; font-weight: bold;">cd</span> proto
git init 
<span style="color: #c20cb9; font-weight: bold;">touch</span> INITIAL
git add INITIAL
git commit <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Initial Commit&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;** creating bare repo&quot;</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
git clone <span style="color: #660033;">--bare</span> proto proto.git
<span style="color: #c20cb9; font-weight: bold;">mv</span> proto proto.old
git clone proto.git
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> proto.old
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;** generating hook&quot;</span>
<span style="color: #007800;">HOOK</span>=proto.git<span style="color: #000000; font-weight: bold;">/</span>hooks<span style="color: #000000; font-weight: bold;">/</span>post-update
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$HOOK</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'#!/bin/sh'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'# To enable this hook, make this file executable by &quot;chmod +x post-update&quot;.'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'#exec git-update-server-info'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'URL='</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$URL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'PROTO=&quot;/home/$USER/www/$URL/proto&quot;'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'PUBLIC=&quot;/home/$USER/www/$URL/public&quot;'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>  <span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'export GIT_DIR=&quot;$PROTO/.git&quot;'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'pushd $PROTO &gt; /dev/null'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'git pull'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'popd &gt; /dev/null'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;echo -----------------------------&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;echo '** Pushing changes to '<span style="color: #007800;">$URL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;echo '** Moving current public to /tmp'&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'mv &quot;$PUBLIC&quot; &quot;/tmp/'</span><span style="color: #007800;">$URL</span><span style="color: #ff0000;">'public-`date '</span>+<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #ff0000;">'`&quot;'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'echo &quot;** Generating new public&quot;'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'jekyll &quot;$PROTO&quot; &quot;$PUBLIC&quot;'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HOOK</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;** enabling hook&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> a+x <span style="color: #007800;">$HOOK</span> 
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;** clone repo on local machina. example:&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;git clone ssh://<span style="color: #007800;">$USER</span>@<span style="color: #007800;">$SSHURL</span>/~<span style="color: #007800;">$USER</span>/www/<span style="color: #007800;">$SSHURL</span>/proto.git&quot;</span></pre></div></div>

<p><strong>Usage</strong></p>
<p>Your site structure might be different. <strong>repogen.sh</strong> is made by pasting the above code in a new file, and then chmod a+x to make it executable. This should be done on the remote server.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> www<span style="color: #000000; font-weight: bold;">/</span>domain.com<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">ls</span>
public<span style="color: #000000; font-weight: bold;">/</span> private<span style="color: #000000; font-weight: bold;">/</span> log<span style="color: #000000; font-weight: bold;">/</span> cgi-bin<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
.<span style="color: #000000; font-weight: bold;">/</span>repogen.sh domain.com</pre></div></div>

<p>Now on your local machine, clone the new repo, move your files in, and push:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git clone <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>username<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">@</span>ssh.domain.com<span style="color: #000000; font-weight: bold;">/</span>~<span style="color: #7a0874; font-weight: bold;">&#91;</span>username<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>domain.com<span style="color: #000000; font-weight: bold;">/</span>proto.git
<span style="color: #7a0874; font-weight: bold;">cd</span> proto<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #ff0000;">&quot;hello, world&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> index.htm
git add index.htm
git commit <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'first local commit'</span>
git push</pre></div></div>

<p>After you push your changes, the post-update hook will delete the public/ directory (the root of the site). This dir and its contents are automatically generated and will get wiped out on EVERY push. Keep this in mind. All your changes and content should reside in proto/. </p>
<p>The proto/ repo will pull in the new changes, and then Jekyll will be invoked to generate the updated site in public/ from the prototype.</p>
<p>Should you need to edit it, the <strong>post-update hook</strong> is in the bare git repo (proto.git/hooks/)</p>
<p>Thanks to the authors in the posts below for sharing ideas. I first read this git method on dmiessler&#8217;s site. </p>
<p><strong>Resources:</strong><br />
<a href="http://dmiessler.com/blog/using-git-to-maintain-your-website">dmiessler.com &#8211; using git to maintain static pages</a><br />
<a href="http://toroid.org/ams/git-website-howto">toroid.org &#8211; using git to manage a web site</a><br />
<a href="http://github.com/mojombo/jekyll/tree/master">Jekyll @ GitHub</a><br />
<a href="http://media.pragprog.com/titles/tsgit/chap-005-extract.html">git info</a><br />
<a href="http://www.nardol.org/2009/2/19/git-basics-reversing-the-git-sucks-effect">more git info</a></p>
]]></content:encoded>
			<wfw:commentRss>http://biodegradablegeek.com/2009/03/how-to-maintain-static-sites-with-git-jekyll/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Burning Xbox 360 Games on Linux (Stealth!)</title>
		<link>http://biodegradablegeek.com/2009/03/burning-xbox-360-games-on-linux-stealth/</link>
		<comments>http://biodegradablegeek.com/2009/03/burning-xbox-360-games-on-linux-stealth/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 05:20:02 +0000</pubDate>
		<dc:creator>Isam</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Workarounds]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[piracy]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://biodegradablegeek.com/?p=361</guid>
		<description><![CDATA[
You could run ImgBurn in Wine, or probably burn the games in VirtualBox running Windows, but that&#8217;s no solution&#8230; you&#8217;re reading this because you want to burn Xbox 360 games on Linux using native tools. It&#8217;s surprisingly easy!
The games are usually an ISO file, along with a little DVD (.dvd) file that tells the burner [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://biodegradablegeek.com/wp-content/uploads/2009/03/xbox360-bg.jpg" alt="xbox360 bg Burning Xbox 360 Games on Linux (Stealth!)" title="xbox360-bg" width="300" height="290" class="alignright plainimg size-full wp-image-367" /><br />
You could run ImgBurn in Wine, or probably burn the games in VirtualBox running Windows, but that&#8217;s no solution&#8230; you&#8217;re reading this because <strong>you want to burn Xbox 360 games on Linux using native tools</strong>. It&#8217;s surprisingly easy!</p>
<p>The games are usually an ISO file, along with a little DVD (.dvd) file that tells the burner to use a layer break value of 1913760. This file is not necessary in Linux (or Windows) as we will be telling the app to use that break value explicitly.</p>
<p><strong>I will go into detail on how to setup what you need. If you&#8217;re impatient, you might wanna skip the setup and jump straight to the <a href="#quickie">quick recap</a>.</strong></p>
<p><strong>Extract the ISO</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>games<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">360</span><span style="color: #000000; font-weight: bold;">/</span>GameX
rar  x kfc-gamex.part01.rar</pre></div></div>

<p>If you don&#8217;t have rar (&#8220;winrar&#8221;) installed, lookie:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">The program 'unrar' can be found in the following packages:
 * unrar-free
 * unrar
Try: sudo apt-get install &lt;selected package&gt;</pre></div></div>

<p>you can also DL it from <a href="http://rarlabs.com">rarlabs.com</a>.</p>
<p>Now we need to see if the game is stealth/valid. This is done using an app that runs natively on Linux (and OS X) called <strong>abgx360</strong>. </p>
<h2>Install abgx360</h2>
<p><img src="http://biodegradablegeek.com/wp-content/uploads/2009/03/abgx360-linux.png" alt="abgx360 linux Burning Xbox 360 Games on Linux (Stealth!)" title="abgx360-linux" width="695" height="112" class="size-full wp-image-365" /></p>
<p>Download the tar.gz files from <a href="http://abgx360.net/download.html">http://abgx360.net/download.html</a>. The TUI is nice. Don&#8217;t bother getting the GUI for abgx360.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zxvf</span> abgx360-1.0.0.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> abgx360-1.0.0<span style="color: #000000; font-weight: bold;">/</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> checkinstall <span style="color: #660033;">-D</span></pre></div></div>

<p>(You may use &#8216;make install&#8217; but this is not recommended on Debian/Ubuntu. checkinstall keeps your shit organized.)</p>
<p><em>If ./configure fails with an error about wx-config/wxWidgets, make sure wxWidgets is installed..</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-cache</span> search wxgtk2</pre></div></div>

<p><em>and make sure wx-config is in your PATH. On Ubuntu Intrepid, it wasn&#8217;t. Find it and make a symlink to something in your path.. i.e., </em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">locate</span> wx-config <span style="color: #666666; font-style: italic;"># (finds it in /etc/alternatives/wx-config)</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>alternatives<span style="color: #000000; font-weight: bold;">/</span>wx-config <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>wx-config</pre></div></div>

<p><em>Rerun ./configure/make/checkinstall</em></p>
<p>If you downloaded the local database (abgx360-data) from the site above, install it now; Just extract and move the .abgx360/ dir into your ~/ </p>
<h2>Checking ISO CRC/SS &#8211; Is the game stealth?</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">abgx360 <span style="color: #660033;">-af3</span> kfc-gamex.iso</pre></div></div>

<p>the af3 flag will automagically fix/patch the ISO should it encounter any problems.<br />
What abgx360 will do is check the ISO&#8217;s CRC against an online (or offline, ~/.abgx360/) database. It might begin by updating its database. If this is a problem (no net connection), pass it -localonly</p>
<p>When that&#8217;s done&#8230;</p>
<h2>Burning the ISO Using growisofs</h2>
<p>Making sure the dual layer DVD is in your drive, run the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760  -dvd-compat -speed=4 -Z /dev/burner=kfc-gamex.iso</span></pre></div></div>

<p>I commented it out so you don&#8217;t execute it trying to paste it. Let&#8217;s look closer at this command&#8230;</p>
<p>The <strong>break:1913760</strong> is the layer break, which you&#8217;ll find in the .dvd file. If for whatever reason you can&#8217;t check the .dvd file, just use this value. </p>
<p>Set your speed to something low. Some say 2.5x but I have no problems burning at 4X (my max is 8X). You don&#8217;t need to know the lowest speed your burner can go. Just set it to 2-4 and you&#8217;ll be fine.</p>
<p><strong>Set /dev/burner to your own device.</strong> It&#8217;s probably /dev/scd0, /dev/scd1, or may already have a symlink like /dev/dvd6 /dev/dvd etc..</p>
<h3>Try grepping dmesg to find your device. i.e., </h3>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">dmesg</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;LITE&quot;</span></pre></div></div>

<h3>This might give you some information but probably nothing too helpful: </h3>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> dvdrecord <span style="color: #660033;">-scanbus</span></pre></div></div>

<h3>To see if you have the right device, try ejecting it. </h3>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">eject <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>dvd6</pre></div></div>

<p>Set the kfc-gamex.iso to whatever the name/path of your ISO is (case sensitive of course). </p>
<p>Now I usually begin with a dry run. By passing <em>-dry-run</em> to growisofs, it will proceed as normal but quit before writing anything to disk. Actually, it kind of just spits out a command and dies. Awful design! i.e.,</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ growisofs <span style="color: #660033;">-dry-run</span> <span style="color: #660033;">-use-the-force-luke</span>=dao <span style="color: #660033;">-use-the-force-luke</span>=<span style="color: #7a0874; font-weight: bold;">break</span>:<span style="color: #000000;">1913760</span>  <span style="color: #660033;">-dvd-compat</span> <span style="color: #660033;">-speed</span>=<span style="color: #000000;">4</span> <span style="color: #660033;">-Z</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">burner</span>=kfc-gamex.iso
Executing <span style="color: #ff0000;">'builtin_dd if=kfc-bh5.iso of=/dev/dvd6 obs=32k seek=0'</span>
$</pre></div></div>

<p>So the above is good. Now remove the -dry-run flag to proceed with the actual burn.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760  -dvd-compat -speed=4 -Z /dev/burner=kfc-gamex.iso</pre></div></div>

<p>Find something to do, or just stare at the screen. After about 20 minutes (at 4X), you&#8217;ll see the burn end successfully with output like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"> 7798128640/7835492352 (99.5%) @3.8x, remaining 0:06 RBU 100.0% UBU  99.8%
 7815495680/7835492352 (99.7%) @3.8x, remaining 0:03 RBU  59.7% UBU  99.8%
 7832862720/7835492352 (100.0%) @3.8x, remaining 0:00 RBU   7.9% UBU  99.8%
builtin_dd: 3825936*2KB out @ average 3.9x1352KBps
/dev/burner: flushing cache
/dev/burner: closing track
/dev/burner: closing disc</pre></div></div>

<p>You&#8217;re done! </p>
<p><a name="quickie"><br />
<h2>Quick Recap</h2>
<p></a><br />
Assuming you installed all the dependencies above, here&#8217;s a quick recap of what needs to be done to burn a game.<br />
It really takes about 1 minute to begin the process. Write a shell script if you like.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> GameX_REGION_FREE_XBOX360_KFC<span style="color: #000000; font-weight: bold;">/</span>
rar x kfc-gamex.part01.rar <span style="color: #666666; font-style: italic;"># Extract game ISO </span>
abgx360 <span style="color: #660033;">-af3</span> kfc-gamex.iso <span style="color: #666666; font-style: italic;"># Checks if rip is valid/stealth/ss patched</span>
growisofs <span style="color: #660033;">-use-the-force-luke</span>=dao <span style="color: #660033;">-use-the-force-luke</span>=<span style="color: #7a0874; font-weight: bold;">break</span>:<span style="color: #000000;">1913760</span>  <span style="color: #660033;">-dvd-compat</span> <span style="color: #660033;">-speed</span>=<span style="color: #000000;">4</span> <span style="color: #660033;">-Z</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">burner</span>=kfc-gamex.iso
eject <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>burner <span style="color: #666666; font-style: italic;"># When burn is done, eject &amp; play.</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://biodegradablegeek.com/2009/03/burning-xbox-360-games-on-linux-stealth/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Gentoo Sucks, Ubuntu Doesn&#8217;t.</title>
		<link>http://biodegradablegeek.com/2008/12/gentoo-sucks-ubuntu-doesnt/</link>
		<comments>http://biodegradablegeek.com/2008/12/gentoo-sucks-ubuntu-doesnt/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 03:31:32 +0000</pubDate>
		<dc:creator>Isam</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[linux distros]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://biodegradablegeek.com/?p=302</guid>
		<description><![CDATA[I used Gentoo for a few years, and at first I loved it. Mainly because of portage, but the only distro I had experience with before Gentoo was Slackware, and I used to install packages and dependencies manually, so you can see why Gentoo would was so appealing to me.
When I first began my new [...]]]></description>
			<content:encoded><![CDATA[<p>I used Gentoo for a few years, and at first I loved it. Mainly because of portage, but the only distro I had experience with before Gentoo was Slackware, and I used to install packages and dependencies manually, so you can see why Gentoo would was so appealing to me.</p>
<p>When I first began my new job, the only distro available was Ubuntu, which deep down I hated without any real reason. I guess I saw Ubuntu as being &#8220;too user-friendly&#8221; and Mandrake-ish: Bloated and sluggish. But 10 minutes into using it, I made the decision that as soon as I get home, I&#8217;m wiping out Gentoo and installing Ubuntu.</p>
<h2>You Learn From Compiling Apps Yourself</h2>
<p>This is somewhat true, but I don&#8217;t believe it applies to Gentoo/portage. There&#8217;s nothing educational about watching shit scroll across the screen. None. If you want a real learning experience, try Slackware or Arch. You&#8217;ll learn if you&#8217;re forced to figure out what an app depends on, and what the most efficient compile flags are for your system. With Gentoo, the app is being compiled from scratch, but you aren&#8217;t doing any work, or research, for that matter. Running 1 command and then grabbing a bite while you wait for portage to do all the work for you isn&#8217;t going to teach you more than installing an RPM.</p>
<p>Gentoo&#8217;s installation isn&#8217;t going to teach you much of anything either, except maybe that patience is a virtue. The Gentoo docs are great, but each step is spoon fed to you. You&#8217;re basically copying and pasting commands so you can compile all the necessary files to get you started. After installation, Gentoo is as user-friendly as Ubuntu, even if it doesn&#8217;t seem like it at first.</p>
<h2>Compiled Apps Are More Efficient Than Packages</h2>
<p>Maybe. Prebuilt packages are usually compiled independently for each arch, and are already optimized, probably by people way more experienced in the field than you. Compiling your own apps can be slower if you don&#8217;t know what you&#8217;re doing, but even if you optimize your portage compile flags, the peformance difference between a prebuilt package for the specific arch vs an app compiled on that arch is minimal. There are too many drawbacks to compiling every app from scratch to make this tiny performance boost (which is just theoretical) worth it.<span id="more-302"></span></p>
<p>Compiling takes time. Not only does the app need to be compiled, but so does each of its dependencies. Compiling Xorg, OpenOffice, Gnome, or any big app will require that you leave the computer for a few hours, as the high load when you&#8217;re compiling something makes it unusable. System updates also take a long time, which means that&#8230;</p>
<p>You&#8217;re more likely to avoid updating. If you&#8217;re busy, the last thing you wanna do is drop what you&#8217;re doing for an hour just so you can update ABC app from version 2.3.0 to 2.3.1. Even security updates can be ignored if the app is big enough. I just installed about 15 new apps on Ubuntu, only took around 5 minutes in total, and 80% of that time was spent downloading the packages.</p>
<h2>Gentoo Uses Less RAM Than Distro X, Y, or Z</h2>
<p>By default, Gentoo is usually leaner than most distros, but that doesn&#8217;t mean you can&#8217;t easily tweak Ubuntu or any other distro to only run the apps and modules you want. Most distros use up a lot of memory because they offer a lot of functionality. Sure, you can disable nearly everything you &#8220;don&#8217;t need&#8221; and you&#8217;ll get a speedy system that runs on a stick of 256 megs of RAM, but why sacrifice functionality and aesthetics?</p>
<p>I&#8217;m also lazy and I hate closing programs, so I like to just keep my most used apps open. This means keeping Gimp, Mono+Tomboy Notes, Firefox with 50+ tabs (uses up 600 megs of RAM, at least), numerous gvim windows, terminals and SSH connections, numerous servers and services, Pidgin, Rythmbox, Compiz (which increases productivity, mind you), and misc apps like Agave, GColor2, MySQL query browser, etc&#8230;</p>
<p>I need the functionality, so I&#8217;m willing to put down money for more power instead of sacrificing my producitivity just to save a few bucks. Besides, RAM is damn cheap. I just picked up 8 GB of OZ DDR2800 (4 sticks total) for $20, brand new.</p>
<h2>Ubuntu Has Excellent Support</h2>
<p>This doesn&#8217;t apply to Ubuntu exclusively, but to any distro (or OS) that has an active community and great hardware support. Somewhere down the line you wake up and realize that you just want to get shit done and you want your computer to Just Work. Eventually you get tired of spending half of your time tweaking and hacking away and would like to devote as much time as possible to actual projects and work. I was shocked that my wifi worked out of the box with Ubuntu, as did everything else.</p>
<p><em>You can say that Ubuntu is to other distros what Rails or CakePHP are to CGI programming.</em></p>
<p>Ubuntu really demonstrates how far Linux has come. There&#8217;s a reason it&#8217;s so popular: <strong>It pwnz</strong>. If you want a &#8220;lean Ubuntu&#8221;, you can try Debian, which Ubuntu is based on. I use Debian for most of my servers and old boxes.</p>
]]></content:encoded>
			<wfw:commentRss>http://biodegradablegeek.com/2008/12/gentoo-sucks-ubuntu-doesnt/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Quick BASH Script to Dump &amp; Compress a MySQL Database</title>
		<link>http://biodegradablegeek.com/2008/12/quick-bash-script-to-dump-compress-a-mysql-database/</link>
		<comments>http://biodegradablegeek.com/2008/12/quick-bash-script-to-dump-compress-a-mysql-database/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 18:01:19 +0000</pubDate>
		<dc:creator>Isam</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://biodegradablegeek.com/?p=299</guid>
		<description><![CDATA[A quick script I whipped up to dump my MySQL database.
Usage: sh backthatsqlup.sh
(be warned that it dumps ALL databases. This can get huge uncompressed)

#!/bin/sh
# Isam (Biodegradablegeek.com) public domain 12/28/2008
# Basic BASH script to dump and compress a MySQL dump
&#160;
out=sequel_`date +'%m%d%Y_%M%S'`.sql
dest=/bx/
&#160;
function e &#123;
  echo -e &#34;n** $1&#34;
&#125;
&#160;
e &#34;Dumping SQL file ($out). May take awhile...&#34;
#echo &#34;oh [...]]]></description>
			<content:encoded><![CDATA[<p>A quick script I whipped up to dump my MySQL database.<br />
<strong>Usage: sh backthatsqlup.sh</strong></p>
<p><em>(be warned that it dumps ALL databases. This can get huge uncompressed)</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># Isam (Biodegradablegeek.com) public domain 12/28/2008</span>
<span style="color: #666666; font-style: italic;"># Basic BASH script to dump and compress a MySQL dump</span>
&nbsp;
<span style="color: #007800;">out</span>=sequel_<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">'%m%d%Y_%M%S'</span><span style="color: #000000; font-weight: bold;">`</span>.sql
<span style="color: #007800;">dest</span>=<span style="color: #000000; font-weight: bold;">/</span>bx<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> e <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;n** $1&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
e <span style="color: #ff0000;">&quot;Dumping SQL file (<span style="color: #007800;">$out</span>). May take awhile...&quot;</span>
<span style="color: #666666; font-style: italic;">#echo &quot;oh snap&quot; &amp;gt; $out</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> mysqldump <span style="color: #660033;">-u</span> root <span style="color: #660033;">-p</span> <span style="color: #660033;">--all-databases</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$out</span>
<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>
  e <span style="color: #ff0000;">&quot;MySQL dump failed. Check that server is up and your username/pass&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">7</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
e <span style="color: #ff0000;">&quot;Uncompressed SQL file size&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-hs</span> <span style="color: #007800;">$out</span>
&nbsp;
e <span style="color: #ff0000;">&quot;Compressing SQL file&quot;</span>
<span style="color: #007800;">gz</span>=<span style="color: #007800;">$out</span>.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-zvvcf</span> <span style="color: #007800;">$gz</span> <span style="color: #007800;">$out</span>
<span style="color: #007800;">rt</span>=<span style="color: #007800;">$?</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$rt</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>
  e <span style="color: #ff0000;">&quot;tar failed (error=<span style="color: #007800;">$rt</span>). Will NOT remove uncompressed SQL file&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
  e <span style="color: #ff0000;">&quot;Removing uncompressed SQL file&quot;</span>
  <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$out</span>
  <span style="color: #007800;">out</span>=<span style="color: #007800;">$gz</span>
&nbsp;
  e <span style="color: #ff0000;">&quot;Compressed SQL file size&quot;</span>
  <span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-hs</span> <span style="color: #007800;">$out</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
e <span style="color: #ff0000;">&quot;Moving shit to '<span style="color: #007800;">$dest</span>'&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$out</span> <span style="color: #007800;">$dest</span></pre></div></div>

<p><a href="http://code.biodegradablegeek.com/backthatsqlup.sh">BackThatSqlUp.sh</a></p>
]]></content:encoded>
			<wfw:commentRss>http://biodegradablegeek.com/2008/12/quick-bash-script-to-dump-compress-a-mysql-database/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RescueTime&#8217;s 22 Gigabyte notifier.debuglog Log File</title>
		<link>http://biodegradablegeek.com/2008/11/rescuetimes-22-gigabyte-notifierdebuglog-log-file/</link>
		<comments>http://biodegradablegeek.com/2008/11/rescuetimes-22-gigabyte-notifierdebuglog-log-file/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 08:25:46 +0000</pubDate>
		<dc:creator>Isam</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[nuisance]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[registry cleaner]]></category>
		<category><![CDATA[rescuetime]]></category>
		<category><![CDATA[spyware]]></category>

		<guid isPermaLink="false">http://biodegradablegeek.com/?p=285</guid>
		<description><![CDATA[I did find it weird that I kept running out of disk space recently. That hasn&#8217;t happened in years, and most of my big files go on another HD. On top of that, this box has been sluggish lately, even taking into account the fact that it&#8217;s ~4 years old and I always have 5-6 [...]]]></description>
			<content:encoded><![CDATA[<p>I did find it weird that I kept running out of disk space recently. That hasn&#8217;t happened in years, and most of my big files go on another HD. On top of that, this box has been sluggish lately, even taking into account the fact that it&#8217;s ~4 years old and I always have 5-6 desktops filled to the brim.</p>
<p>I finally found the culprit. <a href="http://rescuetime.com" target="_blank">RescueTime</a>&#8217;s (unofficial) Linux client keeps a log of <strong>every single window that has gotten focus, EVER.</strong> I figured this would be cleared when the notifications were sent out, but apparently it wasn&#8217;t. My <strong>failed/</strong> dir is nearly empty, so I know the notifications are getting sent out. The file is named ~/.rescuetime/tmp/notifier.debuglog</p>
<p>It might be that the client only clears the log when the app is closed? That sucks, because I don&#8217;t shutdown or reboot (or log out of X for that matter). Aside from the handful of kernel-update reboots (yeah yeah I could just init level down to preserve my uptime), I literally haven&#8217;t kept my PC off since 2006.</p>
<p>I don&#8217;t mind the disk space, but how the hell are you opening, seeking and writing to a 22gig+ file literally every single time focus is switched? I swear to the Gods I was one CC digit away from ordering a Mac.</p>
<p style="text-align: center;"><img class="size-full wp-image-286 aligncenter" title="notifier debug log rescue time picture" src="http://biodegradablegeek.com/wp-content/uploads/2008/11/notifierdebuglog.png" alt="notifier debug log rescue time picture" width="500" height="243" /></p>
<p>RescueTime is a great service/app, but I&#8217;ll keep the client off until this is fixed or they release an official client. No offense to the guys working on the Linux client (&lt;3), especially considering it&#8217;s probably their pet project, and I&#8217;ve had no other problems with it thus far. Hell, maybe the debug log could of easily been turned off.</p>
<p>I&#8217;m using version 90 (newest release as of 11/16). This may have already been fixed in trunk. I&#8217;ll check/submit a bug report&#8230; eventually.</p>
<p>https://launchpad.net/rescuetime-linux-uploader</p>
]]></content:encoded>
			<wfw:commentRss>http://biodegradablegeek.com/2008/11/rescuetimes-22-gigabyte-notifierdebuglog-log-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mephisto for the Masses &#8211; Installation HOWTO</title>
		<link>http://biodegradablegeek.com/2008/10/mephisto-for-the-masses-installation-howto/</link>
		<comments>http://biodegradablegeek.com/2008/10/mephisto-for-the-masses-installation-howto/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 02:14:00 +0000</pubDate>
		<dc:creator>Isam</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Workarounds]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[deploying]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[installing]]></category>
		<category><![CDATA[logs]]></category>
		<category><![CDATA[mefisto]]></category>
		<category><![CDATA[mephisot]]></category>
		<category><![CDATA[mephisto]]></category>
		<category><![CDATA[mephsto]]></category>
		<category><![CDATA[mod_rails]]></category>
		<category><![CDATA[phusion passanger]]></category>
		<category><![CDATA[redcloth-3.0.4]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://biodegradablegeek.com/?p=257</guid>
		<description><![CDATA[I&#8217;ve recently taken a fancy to Mephisto, a blogging-platform written in Rails. I have nothing against Wordpress, but being in Ruby and using Liquid for themes, Mephisto is far easier (and more fun) to tweak and configure, especially when I want to migrate my sites away from the &#8220;blog look&#8221; and make them more dynamic. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently taken a fancy to Mephisto, a blogging-platform written in Rails. I have nothing against Wordpress, but being in Ruby and using Liquid for themes, Mephisto is far easier (and more fun) to tweak and configure, especially when I want to migrate my sites away from the &#8220;blog look&#8221; and make them more dynamic. </p>
<p>It&#8217;s unfortunate development isn&#8217;t as active as say, Typo (also a Rails app, but I haven&#8217;t tried it), but I find that Mephisto at its current level makes a simple and <strong>fast</strong> starting point for most of my projects. </p>
<p>The point of this post is to address numerous problems with the installation. These are present in the tarball release of 0.8 Drax, and in trunk (as of 10/21). </p>
<h3>Git The Code</h3>
<p>Get the files, either the <a href="http://github.com/technoweenie/mephisto/tree/master">compressed archive</a> or from edge (recommended).</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">git clone git://github.com/technoweenie/mephisto.git</pre></div></div>

<h3>Pre-installation</h3>
<p>You&#8217;ll need to freeze rails 2.0.2, and have the latest tzinfo gem installed:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">gem install tzinfo 
cd mephisto/ 
rake rails:freeze:edge RELEASE=2.0.2</pre></div></div>

<p>The file it downloads should be named rails_2.0.2.zip and NOT rails_edge.zip. </p>
<p>Copy the &#8220;new&#8221; boot.rb into the config/ folder, overwriting the existing one:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">cp vendor/rails/railties/environments/boot.rb config/boot.rb</pre></div></div>

<p>Now rename the database sample file in config/ to database.yml and edit it to fit your own DB settings. You&#8217;ll probably only be using production.</p>
<h3>Bootstrapping</h3>
<p>Now bootstrap:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">rake db:bootstrap RAILS_ENV=production</pre></div></div>

<p>If it works, GREAT. But you&#8217;ll probably get an error or two. If you&#8217;re getting the following error:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Error message:
  undefined method `initialize_schema_information' for module  
  `ActiveRecord::ConnectionAdapters::SchemaStatements'
Exception class:
  NameError</pre></div></div>

<p>You forgot to copy over boot.rb from vendor/rails/ &#8211; scroll up. If you&#8217;re getting an error that redcloth is missing (<em>no such file to load—RedCloth-3.0.4/lib/redcloth</em>), even though it&#8217;s in vendor/, it&#8217;s because the path to RedCloth is relative in <strong>config/environment.rb</strong>. Change it from:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'../vendor/RedCloth-3.0.4/lib/redcloth'</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#CC00FF; font-weight:bold;">Object</span>.<span style="color:#9900CC;">const_defined</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:RedCloth</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>to</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#996600;">'../vendor/RedCloth-3.0.4/lib/redcloth'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#CC00FF; font-weight:bold;">Object</span>.<span style="color:#9900CC;">const_defined</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:RedCloth</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<h3>Running</h3>
<p>After the bootstrap, you may either start the server (ruby script/server, thin, mongrel, etc), or go with <a href="http://www.modrails.com/">mod_rails (Phusion Passanger)</a>. I recommend the latter &#8211; Passenger is amazing, and the error screen is pretty. </p>
<p>Just point your Apache2 vhost to Mephisto&#8217;s PUBLIC/ dir. Here&#8217;s an example:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&lt;VirtualHost *:80&gt;
   ServerAdmin mrEman@domain.com
   ServerName domain.com
   ServerAlias www.domain.com
&nbsp;
   # DocumentRoot must be rails_app/public/
   DocumentRoot /home/kiwi/www/domain.com/public/public
   Railsenv production
&nbsp;
   DirectoryIndex index.html index.htm index.php
   ErrorLog /home/blue/www/domain.com/log/error.log
   CustomLog /home/blue/www/domain.com/log/access.log combined
&lt;/VirtualHost&gt;</pre></div></div>

<p>Restart Apache2, and you&#8217;re done. The site should work right away. If you get the following error:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">No such file or directory - /tmp/mysql.sock</pre></div></div>

<p>It&#8217;s because the socket file resides somewhere else on your (host&#8217;s) distro. Just find (man find, locate, etc) and add a symlink to it. Here&#8217;s an example (Debian):</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ln -s /var/run/mysqld/mysqld.sock mysql.sock</pre></div></div>

<p>If you&#8217;re getting an error that gems you know you have aren&#8217;t found, like:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">no such file to load -- tzinfo (MissingSourceFile)</pre></div></div>

<p>it is due to the fact that Gems are not located anywhere Ruby checks. You&#8217;ll have to explicity pass Ruby -rubygems or require &#8216;rubygems&#8217; &#8212; what a nuisance. Open config/environment.rb and add the latter line:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"># requires vendor-loaded redcloth
require 'rubygems'</pre></div></div>

<p>This will be global. Now either restart the server you ran (i.e., thin), or tell mod_rails to restart the app. To do so, just create a file named &#8220;restart.txt&#8221; in the tmp/ folder of the RAILS app:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">cd mephisto_root/
touch tmp/restart.txt</pre></div></div>

<p>and refresh the page. Passenger will restart the app and restart.txt will vanish. </p>
<p>The default login for the /admin page is <strong>admin/test</strong>. <em>Wasn&#8217;t that a blast? </em></p>
]]></content:encoded>
			<wfw:commentRss>http://biodegradablegeek.com/2008/10/mephisto-for-the-masses-installation-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script to Quickly Setup WebApp Environment and Domain</title>
		<link>http://biodegradablegeek.com/2008/10/script-to-quickly-setup-webapp-environment-and-domain/</link>
		<comments>http://biodegradablegeek.com/2008/10/script-to-quickly-setup-webapp-environment-and-domain/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 04:10:32 +0000</pubDate>
		<dc:creator>Isam</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[phpmotion]]></category>
		<category><![CDATA[rio]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[warez]]></category>

		<guid isPermaLink="false">http://biodegradablegeek.com/?p=240</guid>
		<description><![CDATA[Just sharing a script I wrote to quickly deploy Wordpress (and eventually a few other webapps) sites, which somebody might find useful. This uses Linode&#8217;s API* to add the domain name to the DNS server along with some subdomains. If you&#8217;re using another server, (Slicehost, your own, etc), you can alter the dns class to [...]]]></description>
			<content:encoded><![CDATA[<p>Just sharing a script I wrote to quickly deploy Wordpress (and eventually a few other webapps) sites, which somebody might find useful. This uses <a href="http://linode.com">Linode</a>&#8217;s API* to add the domain name to the DNS server along with some subdomains. If you&#8217;re using another server, (Slicehost, your own, etc), you can alter the dns class to use that API, or just ignore the DNS stuff completely; Its optional.</p>
<p>This will be updated periodically as I refactor and add support for more apps (notably Joomla and Clipshare &#8211; though this would violate their terms unless you have the unlimited license). This was written primarily because I couldn&#8217;t stand setting up another vhost and Wordpress installation. There are plenty of existing deployers but I plan on adding very specific features and tweaking this for in-house work. I also wanted to try Rio (Ruby-IO). GPL license. Go nuts.</p>
<p><em>* As of 10/11, the apicore.rb file on the site has some syntactic errors in the domainResourceSave method. I sent an email out to the author about it. Problems aren&#8217;t major. You can get <a href="http://biodegradablegeek.com/wp-content/uploads/2008/10/apicore.rb" target="_new">my apicore.rb here</a>.</em></p>
<p>This won&#8217;t run unless you create the appropriate folder structure in /etc/mksite/. I&#8217;ll get going on this in a bit. See the code below:</p>
<p><span id="more-240"></span></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby </span>
&nbsp;
<span style="color:#008000; font-style:italic;">########################################################</span>
<span style="color:#008000; font-style:italic;"># Isam M. </span>
<span style="color:#008000; font-style:italic;"># http://biodegradablegeek.com</span>
<span style="color:#008000; font-style:italic;"># MKSITE.RB (0.2) Last updated Oct 19th, 2008</span>
<span style="color:#008000; font-style:italic;">#</span>
<span style="color:#008000; font-style:italic;"># mksite makes it quicker to setup sites and web</span>
<span style="color:#008000; font-style:italic;"># apps by doing most of the tedious work.</span>
<span style="color:#008000; font-style:italic;">#</span>
<span style="color:#008000; font-style:italic;">#</span>
<span style="color:#008000; font-style:italic;">#                     UNSTABLE</span>
<span style="color:#008000; font-style:italic;">#           Run it in your imagination,</span>
<span style="color:#008000; font-style:italic;">#              not on your system!</span>
<span style="color:#008000; font-style:italic;">#</span>
<span style="color:#008000; font-style:italic;">#</span>
<span style="color:#008000; font-style:italic;">######################################################## </span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rio'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'yaml'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'mysql'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'highline/import'</span>
HighLine.<span style="color:#9900CC;">track_eof</span> = <span style="color:#0000FF; font-weight:bold;">false</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">begin</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'apicore'</span>
<span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">LoadError</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;NOTICE: Unable to load apicore.rb - domains will not be added automatically&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
Apache_sites = <span style="color:#996600;">'/etc/apache2/sites-available/'</span>
Subdomains = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">''</span>, <span style="color:#996600;">'www'</span>, <span style="color:#996600;">'mail'</span>, <span style="color:#996600;">'blog'</span>, <span style="color:#996600;">&quot;dev#{(rand*10).floor}&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
Testing = <span style="color:#0000FF; font-weight:bold;">false</span>
Homedir = ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'HOME'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
Username = ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'USER'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
Applications = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Skeleton</span>, <span style="color:#ff3333; font-weight:bold;">:Clipshare</span>, <span style="color:#ff3333; font-weight:bold;">:Joomla</span>, <span style="color:#ff3333; font-weight:bold;">:PHPMotion</span>, <span style="color:#996600;">'PmWiki (N/A)'</span>, <span style="color:#ff3333; font-weight:bold;">:Wordpress</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#ff6633; font-weight:bold;">$config</span> = <span style="color:#0000FF; font-weight:bold;">nil</span>
<span style="color:#ff6633; font-weight:bold;">$log</span> = <span style="color:#0000FF; font-weight:bold;">nil</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> say<span style="color:#006600; font-weight:bold;">&#40;</span>txt<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">super</span> txt
<span style="color:#008000; font-style:italic;">#  $log &amp;lt;&amp;lt; txt if $log</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># flash('message', :notice || :error) to output msg</span>
<span style="color:#9966CC; font-weight:bold;">def</span> flash<span style="color:#006600; font-weight:bold;">&#40;</span>msg, message_type = <span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#41;</span>
 <span style="color:#9966CC; font-weight:bold;">if</span> message_type.<span style="color:#9900CC;">eql</span>? <span style="color:#ff3333; font-weight:bold;">:notice</span>
    say<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;INFORMATION: #{msg}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">elsif</span> message_type.<span style="color:#9900CC;">eql</span>? <span style="color:#ff3333; font-weight:bold;">:emphasize</span>
    say<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;***************************************************&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    say<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;NOTICE: #{msg}n&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    say<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;***************************************************&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">elsif</span> message_type.<span style="color:#9900CC;">eql</span>? <span style="color:#ff3333; font-weight:bold;">:error</span>
    STDERR.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;FATAL ERROR: #{msg}n&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># DZone 2111</span>
<span style="color:#9966CC; font-weight:bold;">def</span> genAlpha<span style="color:#006600; font-weight:bold;">&#40;</span>size=<span style="color:#006666;">64</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  s=<span style="color:#996600;">''</span>
  size.<span style="color:#9900CC;">times</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
    s <span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#006600; font-weight:bold;">&#40;</span>i = <span style="color:#CC00FF; font-weight:bold;">Kernel</span>.<span style="color:#CC0066; font-weight:bold;">rand</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">62</span><span style="color:#006600; font-weight:bold;">&#41;</span>; i <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>i <span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#006666;">48</span> : <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>i <span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#006666;">36</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#006666;">55</span> : <span style="color:#006666;">61</span> <span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">chr</span>
  <span style="color:#006600; font-weight:bold;">&#125;</span>
  s
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#9966CC; font-weight:bold;">defined</span>? ApiCore
  <span style="color:#9966CC; font-weight:bold;">class</span> DNSAPI <span style="color:#006600; font-weight:bold;">&amp;</span>lt; ApiCore
    <span style="color:#008000; font-style:italic;"># This depends on the Linode API Ruby bindings (apicore.rb)</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>key, debug=<span style="color:#0000FF; font-weight:bold;">false</span>, batching=<span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">super</span>
      <span style="color:#0066ff; font-weight:bold;">@batching</span>=<span style="color:#0000FF; font-weight:bold;">false</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># Add domain. Return ID on success, nil on failure</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> addDomain domain
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">nil</span> <span style="color:#9966CC; font-weight:bold;">if</span> !domain
      params = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
      params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:DomainID</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006666;">0</span>
      params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Domain</span><span style="color:#006600; font-weight:bold;">&#93;</span> = domain
      params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Type</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'master'</span>
      params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Status</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006666;">1</span>
      params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:SOA_Email</span><span style="color:#006600; font-weight:bold;">&#93;</span> = getVal<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'email'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> ask<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Enter SOA email for the domain: &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      domainSave params
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> addDomainResource<span style="color:#006600; font-weight:bold;">&#40;</span>domain, resource, target, record_type = <span style="color:#996600;">'A'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">nil</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>did = getDomainIdByName domain<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?
      params = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
      params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:ResourceID</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006666;">0</span>
      params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:DomainID</span><span style="color:#006600; font-weight:bold;">&#93;</span> = did
      params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Name</span><span style="color:#006600; font-weight:bold;">&#93;</span> = resource
      params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Type</span><span style="color:#006600; font-weight:bold;">&#93;</span> = record_type
      params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:Target</span><span style="color:#006600; font-weight:bold;">&#93;</span> = target
      domainResourceSave params
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> getDomainIdByName domain
      domainList.<span style="color:#9900CC;">find</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>dom<span style="color:#006600; font-weight:bold;">|</span>
        <span style="color:#0000FF; font-weight:bold;">return</span> dom<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;DOMAINID&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> dom<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;DOMAIN&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">downcase</span> == domain.<span style="color:#9900CC;">downcase</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">else</span>
  flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'ApiCore not loaded. Skipping DNS stuff'</span>, <span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> App
  <span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#0000FF; font-weight:bold;">self</span>; attr_reader <span style="color:#ff3333; font-weight:bold;">:message</span>, <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:version</span>, <span style="color:#ff3333; font-weight:bold;">:description</span>, <span style="color:#ff3333; font-weight:bold;">:vhost</span>; <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#0066ff; font-weight:bold;">@message</span> = <span style="color:#0000FF; font-weight:bold;">nil</span>
  <span style="color:#0066ff; font-weight:bold;">@name</span> = <span style="color:#0000FF; font-weight:bold;">nil</span>
  <span style="color:#0066ff; font-weight:bold;">@version</span> = <span style="color:#0000FF; font-weight:bold;">nil</span>
  <span style="color:#0066ff; font-weight:bold;">@description</span> = <span style="color:#996600;">'Just Another Web App'</span>
  <span style="color:#0066ff; font-weight:bold;">@vhost</span> = <span style="color:#996600;">'generic'</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>rootdir, domain, db<span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Initializing application (dir=#{rootdir}, domain=#{domain})&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@rootdir</span> = <span style="color:#006600; font-weight:bold;">&#40;</span>rootdir<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">chr</span>.<span style="color:#9900CC;">eql</span>? <span style="color:#996600;">'/'</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? rootdir.<span style="color:#CC0066; font-weight:bold;">chop</span> : rootdir
    <span style="color:#0066ff; font-weight:bold;">@domain</span> = domain
    <span style="color:#0066ff; font-weight:bold;">@db</span> = db <span style="color:#008000; font-style:italic;"># hash of database info </span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># System stuff</span>
    <span style="color:#008000; font-style:italic;">#if Testing</span>
      <span style="color:#008000; font-style:italic;">#@templates = '/home/kiwi/Code/mksite/templates'</span>
      <span style="color:#008000; font-style:italic;">#@configs = '/home/kiwi/Code/mksite/configs'</span>
      <span style="color:#008000; font-style:italic;">#@vhosts = '/home/kiwi/Code/mksite/vhosts'</span>
    <span style="color:#008000; font-style:italic;">#else</span>
      <span style="color:#0066ff; font-weight:bold;">@templates</span> = <span style="color:#996600;">'/etc/mksite/templates'</span>
      <span style="color:#0066ff; font-weight:bold;">@configs</span> = <span style="color:#996600;">'/etc/mksite/configs'</span>
      <span style="color:#0066ff; font-weight:bold;">@vhosts</span> = <span style="color:#996600;">'/etc/mksite/vhosts'</span>
    <span style="color:#008000; font-style:italic;">#end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># This generally does not need to be overriden.</span>
  <span style="color:#008000; font-style:italic;"># It does 'generic shit' like creating the rootdir</span>
  <span style="color:#008000; font-style:italic;"># and setting permissions</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> envSetup
    <span style="color:#9966CC; font-weight:bold;">if</span> !rio<span style="color:#006600; font-weight:bold;">&#40;</span>@rootdir<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">exist</span>?
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Creating directory #{@rootdir}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span>@rootdir<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">mkpath</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    rio<span style="color:#006600; font-weight:bold;">&#40;</span>@rootdir<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">chdir</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>root<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#008000; font-style:italic;"># Copy the generic public/private/log apache</span>
      <span style="color:#008000; font-style:italic;"># structure to rootdir</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Changing working dir to #{@rootdir}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Working inside '#{root.to_s}'&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span>@templates,<span style="color:#996600;">'skeleton.www'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>df<span style="color:#006600; font-weight:bold;">|</span>
        <span style="color:#008000; font-style:italic;"># Overwrite existing files? .. yes.</span>
        <span style="color:#008000; font-style:italic;">#while rio(root, df).exist? do</span>
        df <span style="color:#006600; font-weight:bold;">&amp;</span>gt; root
        <span style="color:#008000; font-style:italic;">#flash(&quot;Copied #{df.to_s} to #{root.to_s}&quot;)</span>
      <span style="color:#006600; font-weight:bold;">&#125;</span> 
&nbsp;
      <span style="color:#008000; font-style:italic;"># Set permissions (a+w on logs, etc)</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Setting permissions...'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'666 ./log/*.log'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'./log/access.log'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">chmod</span><span style="color:#006600; font-weight:bold;">&#40;</span>00666<span style="color:#006600; font-weight:bold;">&#41;</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'./log/error.log'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">chmod</span><span style="color:#006600; font-weight:bold;">&#40;</span>00666<span style="color:#006600; font-weight:bold;">&#41;</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'700 ./private'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'./private/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">chmod</span><span style="color:#006600; font-weight:bold;">&#40;</span>00700<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> setup
    <span style="color:#008000; font-style:italic;"># envSetup()</span>
    <span style="color:#008000; font-style:italic;"># databaseSetup()</span>
    <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">'OVERRIDE ME'</span>
    <span style="color:#008000; font-style:italic;">#flash(&quot;setup() template function invoked. 'OVERRIDE ME'&quot;, :log)</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> databaseSetup
    <span style="color:#008000; font-style:italic;"># Create database if it doesn't already exist</span>
    <span style="color:#008000; font-style:italic;"># This usually doesn't need to be overriden</span>
    <span style="color:#008000; font-style:italic;">#Mysql.server_connect(@db['name'])</span>
    <span style="color:#008000; font-style:italic;">#  flash('Checking database connection... ')</span>
    <span style="color:#9966CC; font-weight:bold;">begin</span>
      dbo = Mysql.<span style="color:#9900CC;">real_connect</span><span style="color:#006600; font-weight:bold;">&#40;</span>@db<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'host'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#0066ff; font-weight:bold;">@db</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'user'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <span style="color:#0066ff; font-weight:bold;">@db</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'pass'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Creating database '#{@db['name']}'&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;
      res = dbo.<span style="color:#9900CC;">query</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;CREATE DATABASE IF NOT EXISTS #{@db['name']};&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Database server returned #{res}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> res
    <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#6666ff; font-weight:bold;">Mysql::Error</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; err
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Unable to connect to access/create database'</span>, <span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Error returned (#{err.errno}) = '#{err.error}'&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#006666;">1</span>
    <span style="color:#9966CC; font-weight:bold;">ensure</span>
      dbo.<span style="color:#9900CC;">close</span> <span style="color:#9966CC; font-weight:bold;">if</span> dbo
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> dnsSetup
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#9966CC; font-weight:bold;">if</span> !<span style="color:#9966CC; font-weight:bold;">defined</span>? ApiCore
&nbsp;
    <span style="color:#008000; font-style:italic;"># Setup DNS - currently uses Linode API</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Setting up DNS for '#{@domain}'&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;This requires a Linode API keynLogin to linode.com and find it under 'My Profile'&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:emphasize</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    dns = <span style="color:#0000FF; font-weight:bold;">nil</span>
    api_key = getVal<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'apikey'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">loop</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      api_key = ask<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Paste your Linode API key (or '</span>skip<span style="color:#996600;">'): '</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> api_key.<span style="color:#0000FF; font-weight:bold;">nil</span>? <span style="color:#006600; font-weight:bold;">||</span> api_key.<span style="color:#9900CC;">empty</span>?
      <span style="color:#9966CC; font-weight:bold;">break</span> <span style="color:#9966CC; font-weight:bold;">if</span> api_key.<span style="color:#9900CC;">downcase</span>.<span style="color:#9900CC;">eql</span>? <span style="color:#996600;">'skip'</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># Check API key</span>
      <span style="color:#9966CC; font-weight:bold;">begin</span>
        dns = DNSAPI.<span style="color:#9900CC;">new</span> api_key
        dns.<span style="color:#9900CC;">domainList</span>
        <span style="color:#9966CC; font-weight:bold;">break</span>
      <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">RuntimeError</span>
        flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;API key invalid (or service down?). Learn to paste and try again.n&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        api_key = <span style="color:#0000FF; font-weight:bold;">nil</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">unless</span> api_key.<span style="color:#0000FF; font-weight:bold;">nil</span>? <span style="color:#9966CC; font-weight:bold;">or</span> api_key.<span style="color:#9900CC;">downcase</span>.<span style="color:#9900CC;">eql</span>? <span style="color:#996600;">'skip'</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Adding master domain '#{@domain}'&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">begin</span>
        <span style="color:#9966CC; font-weight:bold;">begin</span>
          dns.<span style="color:#9900CC;">addDomain</span><span style="color:#006600; font-weight:bold;">&#40;</span>@domain<span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">RuntimeError</span>
          flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Unable to add domain (exists already?). Attempting to add subdomains...'</span>, <span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
        server = getVal<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'server'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span>
                   ask<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Enter IP subdomains should point to (or 'skip'): &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>q<span style="color:#006600; font-weight:bold;">|</span> q.<span style="color:#9900CC;">default</span> = <span style="color:#996600;">'skip'</span> <span style="color:#006600; font-weight:bold;">&#125;</span> 
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">unless</span> server.<span style="color:#9900CC;">downcase</span>.<span style="color:#9900CC;">eql</span>? <span style="color:#996600;">'skip'</span>
          Subdomains.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>sub<span style="color:#006600; font-weight:bold;">|</span>
            flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Adding subdomain '#{sub}.#{@domain}' (points to #{server})&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
            flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Could not add subdomain'</span>, <span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> !dns.<span style="color:#9900CC;">addDomainResource</span><span style="color:#006600; font-weight:bold;">&#40;</span>@domain, <span style="color:#CC0066; font-weight:bold;">sub</span>, server<span style="color:#006600; font-weight:bold;">&#41;</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
     <span style="color:#9966CC; font-weight:bold;">rescue</span>
       <span style="color:#CC0066; font-weight:bold;">raise</span>
       flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Unable to add domain/subdomain. Skipping&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#41;</span>
     <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> serverSetup
    <span style="color:#008000; font-style:italic;"># Set Apache vhost</span>
    vhost_file = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#9966CC; font-weight:bold;">defined</span>? <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">vhost</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9966CC; font-weight:bold;">class</span>.<span style="color:#9900CC;">vhost</span> : <span style="color:#996600;">'generic'</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Generating vhost file (#{@vhosts}/#{vhost_file}) for Apache 2.x&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    vhost = <span style="color:#996600;">''</span>
    email = getVal<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'email'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> ask<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Enter a valid email for tech support: &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    rio<span style="color:#006600; font-weight:bold;">&#40;</span>@vhosts, vhost_file<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;</span>gt; vhost
    vhost.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'_MKS_DOMAIN_'</span>, <span style="color:#0066ff; font-weight:bold;">@domain</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    vhost.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'_MKS_EMAIL_'</span>, email<span style="color:#006600; font-weight:bold;">&#41;</span>
    vhost.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'_MKS_ROOT_'</span>, <span style="color:#996600;">&quot;#{@rootdir}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    vhost.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'_MKS_PUBLIC_'</span>, <span style="color:#996600;">&quot;#{@rootdir}/public&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#008000; font-style:italic;">#rio(Testing ? '/tmp/' : Apache_sites, @domain).puts(vhost)</span>
    rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'/tmp/'</span>, <span style="color:#0066ff; font-weight:bold;">@domain</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>vhost<span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
    <span style="color:#008000; font-style:italic;"># Your enemies should not read this</span>
    rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'/tmp/'</span>, <span style="color:#0066ff; font-weight:bold;">@domain</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">chmod</span><span style="color:#006600; font-weight:bold;">&#40;</span>00600<span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;vhost file has been generated as /tmp/#{@domain}n
          It is YOUR responsibility to move this to #{Apache_sites}n
          Site will not work until you 'a2ensite &amp;amp;&amp;amp; apache2ctl restart'&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:emphasize</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> postInstall<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Finished!&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:emphasize</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Skeleton <span style="color:#006600; font-weight:bold;">&amp;</span>lt; App
  <span style="color:#0066ff; font-weight:bold;">@name</span> = <span style="color:#996600;">'Skeleton'</span>
  <span style="color:#0066ff; font-weight:bold;">@description</span> = <span style="color:#996600;">'Generic WWW directory structure'</span>
  <span style="color:#0066ff; font-weight:bold;">@message</span> = <span style="color:#996600;">''</span>
  <span style="color:#0066ff; font-weight:bold;">@vhost</span> = <span style="color:#996600;">'generic'</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> setup
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">envSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">dnsSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">serverSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Wordpress <span style="color:#006600; font-weight:bold;">&amp;</span>lt; App
  <span style="color:#0066ff; font-weight:bold;">@name</span> = <span style="color:#996600;">'Wordpress'</span>
  <span style="color:#0066ff; font-weight:bold;">@version</span> = <span style="color:#996600;">'2.6.2'</span>
  <span style="color:#0066ff; font-weight:bold;">@description</span> = <span style="color:#996600;">'A popular blogging platform'</span>
  <span style="color:#0066ff; font-weight:bold;">@message</span> = <span style="color:#996600;">'Trying to make monies on the Internets?'</span>
  <span style="color:#0066ff; font-weight:bold;">@vhost</span> = <span style="color:#996600;">'generic'</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> setup
    <span style="color:#008000; font-style:italic;"># This sets up the initial environment / permissions</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">envSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
    <span style="color:#008000; font-style:italic;"># Copy the wordpress skeleton directory to the new dir</span>
    wproot = rio<span style="color:#006600; font-weight:bold;">&#40;</span>@rootdir,<span style="color:#996600;">'public'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Wordpress root will be #{wproot}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Copying Wordpress data over... (may take awhile)'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    rio<span style="color:#006600; font-weight:bold;">&#40;</span>@templates,<span style="color:#996600;">'wordpress'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>df<span style="color:#006600; font-weight:bold;">|</span> df <span style="color:#006600; font-weight:bold;">&amp;</span>gt; wproot <span style="color:#006600; font-weight:bold;">&#125;</span> 
&nbsp;
    rio<span style="color:#006600; font-weight:bold;">&#40;</span>wproot<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">chdir</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'wp-config-sample.php'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">rm</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#008000; font-style:italic;"># Generate and output wp config</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Generating wp-config.php based on your DB settings...'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      wpcfg = rio<span style="color:#006600; font-weight:bold;">&#40;</span>@configs, <span style="color:#996600;">'wordpress.cfg'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> !wpcfg.<span style="color:#9900CC;">exist</span>? <span style="color:#006600; font-weight:bold;">||</span> !wpcfg.<span style="color:#9900CC;">readable</span>?
        flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Wordpress config template missing or unreadable, quitting&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#006666;">2</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># Copy the config into a string, do things with it and then write it to disk</span>
      config = <span style="color:#996600;">''</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span>@configs, <span style="color:#996600;">'wordpress.cfg'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;</span>gt; config
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Warning: config file '#{@configs}/wordpress.cfg' is empty&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> config.<span style="color:#9900CC;">empty</span>?
      config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'_MKS_DB_HOST_'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@db</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'host'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'_MKS_DB_USER_'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@db</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'user'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'_MKS_DB_PASS_'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@db</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'pass'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'_MKS_DB_NAME_'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@db</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'name'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      config.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'_MKS_SECRET_'</span>, genAlpha<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Writing #{wpcfg} data&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'wp-config.php'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">w</span>!.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>config<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># Setup the database</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">databaseSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
    <span style="color:#008000; font-style:italic;"># Add DNS info</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">dnsSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
    <span style="color:#008000; font-style:italic;"># Setup the server/vhost</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">serverSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Clipshare <span style="color:#006600; font-weight:bold;">&amp;</span>lt; App
  <span style="color:#9966CC; font-weight:bold;">def</span> setup
    <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">'Clipshare support is currently not available. sowwie'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Joomla <span style="color:#006600; font-weight:bold;">&amp;</span>lt; App
  <span style="color:#0066ff; font-weight:bold;">@name</span> = <span style="color:#996600;">'Joomla'</span>
  <span style="color:#0066ff; font-weight:bold;">@version</span> = <span style="color:#996600;">'1.5.7'</span>
  <span style="color:#0066ff; font-weight:bold;">@description</span> = <span style="color:#996600;">'A widely used Content Management System'</span>
  <span style="color:#0066ff; font-weight:bold;">@message</span> = <span style="color:#996600;">''</span>
  <span style="color:#0066ff; font-weight:bold;">@vhost</span> = <span style="color:#996600;">'generic'</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> setup
    <span style="color:#008000; font-style:italic;"># This sets up the initial environment / permissions</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">envSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
    <span style="color:#008000; font-style:italic;"># Copy the wordpress skeleton directory to the new dir</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Copying Joomla data over... (may take awhile)'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    jooroot = rio<span style="color:#006600; font-weight:bold;">&#40;</span>@rootdir,<span style="color:#996600;">'public'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Joomla root will be #{jooroot}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    rio<span style="color:#006600; font-weight:bold;">&#40;</span>@templates,<span style="color:#996600;">'joomla-1.5.7'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>df<span style="color:#006600; font-weight:bold;">|</span> df <span style="color:#006600; font-weight:bold;">&amp;</span>gt; jooroot <span style="color:#006600; font-weight:bold;">&#125;</span> 
&nbsp;
    rio<span style="color:#006600; font-weight:bold;">&#40;</span>jooroot<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">chdir</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Removing stock Joomla config...'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'configuration.php-dist'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">rm</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># Generate and output joomla config</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Generating configuration.php based on provided settings...'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      joocfg = rio<span style="color:#006600; font-weight:bold;">&#40;</span>@configs, <span style="color:#996600;">'joomla.cfg'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> !joocfg.<span style="color:#9900CC;">exist</span>? <span style="color:#006600; font-weight:bold;">||</span> !joocfg.<span style="color:#9900CC;">readable</span>?
        flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Joomla config template missing or unreadable, quitting&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#006666;">2</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># Copy the config into a string, do things with it and then write it to disk</span>
      config = <span style="color:#996600;">''</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span>@configs, <span style="color:#996600;">'joomla.cfg'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&amp;</span>gt; config
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Warning: config file '#{@configs}/joomla.cfg' is empty&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> config.<span style="color:#9900CC;">empty</span>?
      config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'_MKS_DB_HOST_'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@db</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'host'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'_MKS_DB_USER_'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@db</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'user'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'_MKS_DB_PASS_'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@db</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'pass'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      config<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'_MKS_DB_NAME_'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@db</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'name'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      config.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'_MKS_DOMAIN_'</span>, <span style="color:#0066ff; font-weight:bold;">@domain</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      config.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'_MKS_SECRET_'</span>, genAlpha<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Writing ./configuration.php&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'configuration.php'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">w</span>!.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>config<span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Making configuration.php world writable (0666)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'configuration.php'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">chmod</span><span style="color:#006600; font-weight:bold;">&#40;</span>0666<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># Setup the database</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">databaseSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
    <span style="color:#008000; font-style:italic;"># Add DNS info</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">dnsSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
    <span style="color:#008000; font-style:italic;"># Setup the server/vhost</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">serverSetup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> postInstall<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Joomla is ready to be setup using the web interface'</span>, <span style="color:#ff3333; font-weight:bold;">:emphasize</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Go to #{@domain} where the Joomla! web based installer will
           guide you through the rest of the installation&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Here's the database information:n
           USERNAME: #{@db['user']}n
           DB HOST : #{@db['host']}n
           DB NAME : #{@db['name']}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
&nbsp;
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;nAdmin panel is located @ #{@domain}/administrator &quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;You can log into Admin using the username 'admin' along with the
    password that was generated or you chose during the web based install.&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">super</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> PHPMotion <span style="color:#006600; font-weight:bold;">&amp;</span>lt; App
  <span style="color:#9966CC; font-weight:bold;">def</span> setup
    <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">'PHPMotion support is currently not available. sowwie'</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Log
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>filename=<span style="color:#996600;">&quot;/tmp/#{Username}_mksite.log&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@log</span> = rio<span style="color:#006600; font-weight:bold;">&#40;</span>filename<span style="color:#006600; font-weight:bold;">&#41;</span>
    n=<span style="color:#006666;">0</span>; <span style="color:#0066ff; font-weight:bold;">@log</span> = rio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{filename}.#{n+=1}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">while</span> <span style="color:#0066ff; font-weight:bold;">@log</span>.<span style="color:#9900CC;">exist</span>?
    <span style="color:#0066ff; font-weight:bold;">@log</span>.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;# GENERATED BY MKS - BEGAN @ #{Time.now.to_i}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@log</span>.<span style="color:#9900CC;">chmod</span><span style="color:#006600; font-weight:bold;">&#40;</span>00600<span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Log file generated (important): #{@log.to_s} (no worries, set to 600)&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:emphasize</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0066ff; font-weight:bold;">@log</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># append to log</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&#40;</span>data<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#008000; font-style:italic;">#super &amp;lt;&amp;lt;(data)</span>
    <span style="color:#0066ff; font-weight:bold;">@log</span>.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>data<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@log</span>.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;n&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#008000; font-style:italic;">#@log &amp;lt;&amp;lt; data &amp;lt;&amp;lt; &quot;n&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> loadConfig<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  cfgpath = <span style="color:#996600;">&quot;#{ENV['HOME']}/.mksite&quot;</span>
  <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#CC00FF; font-weight:bold;">YAML</span>.<span style="color:#CC0066; font-weight:bold;">load</span><span style="color:#006600; font-weight:bold;">&#40;</span>rio<span style="color:#006600; font-weight:bold;">&#40;</span>cfgpath<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> rio<span style="color:#006600; font-weight:bold;">&#40;</span>cfgpath<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">exist</span>?
  <span style="color:#0000FF; font-weight:bold;">nil</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> getVal<span style="color:#006600; font-weight:bold;">&#40;</span>key, default=<span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#ff6633; font-weight:bold;">$config</span><span style="color:#006600; font-weight:bold;">&#91;</span>key<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#ff6633; font-weight:bold;">$config</span> <span style="color:#9966CC; font-weight:bold;">and</span> <span style="color:#9966CC; font-weight:bold;">defined</span>? <span style="color:#ff6633; font-weight:bold;">$config</span><span style="color:#006600; font-weight:bold;">&#91;</span>key<span style="color:#006600; font-weight:bold;">&#93;</span>
  default
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> main
  <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#006666;">1</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#996600;">'root'</span>==ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'USER'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>$config = loadConfig<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'~/.mksite config loaded'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'~/.mksite not found. It'</span>s fine, I<span style="color:#996600;">'ll annoy you with questions.'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#ff6633; font-weight:bold;">$config</span>.<span style="color:#9900CC;">inspect</span> <span style="color:#9966CC; font-weight:bold;">if</span> Testing
  flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Press ^C (CTRL+C) at any time quit'</span>, <span style="color:#ff3333; font-weight:bold;">:emphasize</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#008000; font-style:italic;"># Let's ask neutral questions about the new site.</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> Testing
    rootdir = <span style="color:#996600;">'/tmp/sandbox9/'</span>
    domain = <span style="color:#996600;">'domain.cxm'</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    domain = ask<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Enter site'</span>s domain name <span style="color:#006600; font-weight:bold;">&#40;</span>no http:<span style="color:#006600; font-weight:bold;">//</span> <span style="color:#9966CC; font-weight:bold;">or</span> www<span style="color:#006600; font-weight:bold;">&#41;</span>: <span style="color:#996600;">') #{ |d| d.validate = !! /^www.|^http:/// }
    rootdir = ask('</span>Root site directory <span style="color:#006600; font-weight:bold;">&#40;</span>leave blank <span style="color:#9966CC; font-weight:bold;">for</span> default<span style="color:#006600; font-weight:bold;">&#41;</span>: <span style="color:#996600;">') { |q|
      q.default = &quot;/home/#{Username}/www/#{domain}/&quot;
      q.validate = /^/home/#{Username}//
    }
  end
&nbsp;
  flash(&quot;Domain has been set to &quot;#{domain}&quot;&quot;)
  #$log = Log.new(&quot;/tmp/mks_#{domain}.log&quot;) 
&nbsp;
  flash(&quot;Site will reside in &quot;#{rootdir}&quot;, and the index/script&quot;)
  flash(&quot; files (index.php, .htaccess etc) will go in &quot;#{rootdir}/public/&quot;nn&quot;)
&nbsp;
  # Ask the user what app she wants to install and specific questions about that app
  app = nil
  choose do |menu|
    menu.prompt = '</span>Choose the software <span style="color:#9966CC; font-weight:bold;">for</span> your new site: <span style="color:#996600;">'
    Applications.each do |app|
      menu.choice app do |a|
        app = a
      end
    end
  end
&nbsp;
  flash(&quot;You chose #{app}. #{Kernel.const_get(app).message}n&quot;) 
&nbsp;
  # Fetch DB info if this app needs a database
  # XXX Should just have a db flag in the App'</span>s <span style="color:#9966CC; font-weight:bold;">class</span>
  db = <span style="color:#0000FF; font-weight:bold;">nil</span>
  <span style="color:#9966CC; font-weight:bold;">unless</span> app.<span style="color:#9900CC;">eql</span>? <span style="color:#ff3333; font-weight:bold;">:Skeleton</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'This app requires a database (only MySQL supported)'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'It will be created if it doesn'</span>t exist<span style="color:#996600;">')
&nbsp;
    db = {}
    db['</span>host<span style="color:#996600;">'] = '</span>localhost<span style="color:#996600;">'
    loop do
      if Testing
        db['</span>user<span style="color:#996600;">'] = '</span>kiwi<span style="color:#996600;">'
        db['</span>pass<span style="color:#996600;">'] = '</span><span style="color:#996600;">'
        db['</span>name<span style="color:#996600;">'] = '</span>kiwi_sandbox9<span style="color:#996600;">'
      else
        db['</span>user<span style="color:#996600;">'] = getVal('</span>db_user<span style="color:#996600;">') || ask('</span>Enter MySQL username: <span style="color:#996600;">')
        db['</span>pass<span style="color:#996600;">'] = getVal('</span>db_pass<span style="color:#996600;">') || ask('</span>Enter MySQL password: <span style="color:#996600;">') { |q| q.echo = '</span><span style="color:#006600; font-weight:bold;">*</span><span style="color:#996600;">'}
        db['</span>name<span style="color:#996600;">'] = ask('</span>Enter database name <span style="color:#006600; font-weight:bold;">&#40;</span>should <span style="color:#9966CC; font-weight:bold;">begin</span> w<span style="color:#006600; font-weight:bold;">/</span> your <span style="color:#996600;">'username_'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#996600;">') { |dbn| dbn.validate = /^#{Username}_/}
        puts db.inspect
      end
      flash(&quot;Please double check: mysql://#{db['</span>user<span style="color:#996600;">']}:#{'</span><span style="color:#006600; font-weight:bold;">*</span><span style="color:#996600;">' * (db['</span>pass<span style="color:#996600;">']).size}@#{db['</span>host<span style="color:#996600;">']}/#{db['</span>name<span style="color:#996600;">']}&quot;)
      break if Testing || agree('</span>Is this correct?<span style="color:#996600;">')
      flash(&quot;Please re-enter database infon&quot;)
    end
  end
&nbsp;
  # Check permissions and database login
  flash('</span>Doing a preliminary check<span style="color:#996600;">', :emphasize)
  flash('</span>Checking installation environment<span style="color:#996600;">')
  # Quit if the directory exists and the user does not want to go ahead
  unless Testing
    exit 1 if rio(rootdir).exist? &amp;amp;&amp;amp; !agree(&quot;Directory '</span><span style="color:#008000; font-style:italic;">#{rootdir}' exists! Continue? (Y/N)&quot;)</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Is the parent directory available and writable?</span>
  parentdir = rio<span style="color:#006600; font-weight:bold;">&#40;</span>rootdir<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">dirname</span>
  <span style="color:#9966CC; font-weight:bold;">unless</span> parentdir.<span style="color:#9900CC;">exist</span>? <span style="color:#006600; font-weight:bold;">&amp;</span>amp;<span style="color:#006600; font-weight:bold;">&amp;</span>amp; parentdir.<span style="color:#9900CC;">writable</span>?
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Directory '#{parentdir.to_s}' either doesn't exist or is not writable. Check permissions&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#006666;">1</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">unless</span> db.<span style="color:#0000FF; font-weight:bold;">nil</span>? <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#0000FF; font-weight:bold;">false</span>==getVal<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'db_confirm'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#008000; font-style:italic;"># Check DB connection - but this does not check if user has any privileges</span>
    flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Checking database connection'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">begin</span>
      dbo = Mysql.<span style="color:#9900CC;">real_connect</span><span style="color:#006600; font-weight:bold;">&#40;</span>db<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'host'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, db<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'user'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, db<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'pass'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Successfully connected to '#{dbo.get_server_info}'&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#6666ff; font-weight:bold;">Mysql::Error</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; err
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Unable to connect to database server'</span>, <span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Error returned (#{err.errno}) = '#{err.error}'&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:error</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#006666;">1</span>
    <span style="color:#9966CC; font-weight:bold;">ensure</span>
      dbo.<span style="color:#9900CC;">close</span> <span style="color:#9966CC; font-weight:bold;">if</span> dbo
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Begin installation</span>
  flash<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Word on the server racks is... you're good to go&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:emphasize</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  klass = <span style="color:#CC00FF; font-weight:bold;">Kernel</span>.<span style="color:#9900CC;">const_get</span><span style="color:#006600; font-weight:bold;">&#40;</span>app<span style="color:#006600; font-weight:bold;">&#41;</span>
  webapp = klass.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>rootdir, domain, db<span style="color:#006600; font-weight:bold;">&#41;</span>
  webapp.<span style="color:#9900CC;">setup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  webapp.<span style="color:#9900CC;">postInstall</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
main<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p><a href="http://biodegradablegeek.com/wp-content/uploads/2008/10/mksite.rb" target="_new"><strong>Download</strong> the ASCII mksite.rb file here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://biodegradablegeek.com/2008/10/script-to-quickly-setup-webapp-environment-and-domain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
