<?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>I can has weblog? &#187; How-To</title>
	<atom:link href="http://justin-hopkins.com/blog/category/how-to/feed" rel="self" type="application/rss+xml" />
	<link>http://justin-hopkins.com/blog</link>
	<description>The thoughts and works of Justin Hopkins.</description>
	<lastBuildDate>Wed, 23 Jun 2010 15:32:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>MySQL Shutdown Problem During Upgrade to Ubuntu 9.10 (Karmic Koala)</title>
		<link>http://justin-hopkins.com/blog/2009/11/02/mysql-shutdown-problem-during-upgrade-to-ubuntu-9-10-karmic-koala</link>
		<comments>http://justin-hopkins.com/blog/2009/11/02/mysql-shutdown-problem-during-upgrade-to-ubuntu-9-10-karmic-koala#comments</comments>
		<pubDate>Mon, 02 Nov 2009 15:49:14 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://justin-hopkins.com/blog/2009/11/02/mysql-shutdown-problem-during-upgrade-to-ubuntu-9-10-karmic-koala</guid>
		<description><![CDATA[Immediately following the download of new packages for the upgrade to Karmic Koala, I noticed it had hung up while attempting to turn off services which were going to be upgraded. mysql stopping... It happened that MySQL was the hold up, and because killing the upgrade process seemed like a risky operation &#8211; I needed [...]]]></description>
			<content:encoded><![CDATA[<p>Immediately following the download of new packages for the upgrade to Karmic Koala, I noticed it had hung up while attempting to turn off services which were going to be upgraded.</p>

<code>


<pre>
mysql stopping...
</pre>


</code>

<p>It happened that MySQL was the hold up, and because killing the upgrade process seemed like a risky operation &#8211; I needed to find a way to move it along.</p>

<p>I wasn&#8217;t able to turn up any other posts from the community about this issue &#8211; so I decided to take the usual approach: <strong>Start killing process with fingers crossed and blog the outcome!</strong></p>

<p>Just so happens I nailed it on the first try:<br />
<code>


<pre>
$ ps aux | grep mysql
&lt;snip /&gt;
root      3624  0.0  0.0   5452  1744 pts/7    S+   09:05   0:00 /usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf shutdown

$ sudo kill -9 3624 #your pid would be different...
</pre>


</code></p>

<p>The upgrader picked up and moved right along at that point. Hurray!</p>]]></content:encoded>
			<wfw:commentRss>http://justin-hopkins.com/blog/2009/11/02/mysql-shutdown-problem-during-upgrade-to-ubuntu-9-10-karmic-koala/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To: Export and Import of .csv data out of and into MySQL</title>
		<link>http://justin-hopkins.com/blog/2009/08/04/how-to-export-and-import-of-csv-data-out-of-and-into-mysql</link>
		<comments>http://justin-hopkins.com/blog/2009/08/04/how-to-export-and-import-of-csv-data-out-of-and-into-mysql#comments</comments>
		<pubDate>Tue, 04 Aug 2009 17:08:09 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://justin-hopkins.com/blog/?p=197</guid>
		<description><![CDATA[I keep having to do this, and have just got tired of Googling every time for it. Here is the method I use for pulling a table out of MySQL then putting it back later. It may not work for versions of MySQL other than 5, but hey, it works for me. Why do this? [...]]]></description>
			<content:encoded><![CDATA[<p>I keep having to do this, and have just got tired of Googling every time for it. Here is the method I use for pulling a table out of MySQL then putting it back later. It may not work for versions of MySQL other than 5, but hey, it works for me. <strong>Why do this?</strong> Because it&#8217;s a great way to schlep off work to others who don&#8217;t know MySQL. Rather than having folks submit changes to me, I like to just dump it out to a .csv, have them open it in Excel, make their changes, re-save as .csv, then I can import it at my leisure. I sometimes like to throw flour on my face (like in the old rice crispies commercial) and come out of my cube saying &#8216;Whew, that took forever! Next time tell them it&#8217;s going to take a couple weeks&#8230;&#8217;</p>

<h3>Exporting the MySQL data into a comma delimited (.csv) file</h3>

<p><code>SELECT * INTO OUTFILE '/var/tmp/data.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '&quot;' LINES TERMINATED BY '\n' FROM tblWhatever;</code></p>

<p>This will dump your table into a file with each row from the database being on it&#8217;s own line, columns separated by commas, and if there are any spaces or funny business going on with the data in a field, the data will be enclosed in double quotes. You can make changes to this if you like by, for instance, substituting &#8216;,&#8217; with &#8216;\t&#8217; would result in a tab delmited file.</p>

<p><strong>some things:</strong> The reason I put the file into /var/tmp is because you need to put the file in a place that MySQL can write to. Put it wherever you want though. Also, your system may not use /var/tmp but /tmp or who knows what else. If you are using shared hosting, and are working with sensitive data &#8211; don&#8217;t do anything dumb like export credit card numbers to /tmp and then leave them there ;)</p>

<h3>Importing the comma delimited (.csv) file back into MySQL</h3>

<p>First thing, you&#8217;ll need to clear out your old table (otherwise the keys would collide):</p>

<p><code>DELETE FROM tblWhatever;</code></p>

<p>Then you can proceed with the import:</p>

<p><code>LOAD DATA INFILE '/home/youruser/data.csv' INTO TABLE tblWhatever FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '&quot;' LINES TERMINATED BY '\n';</code></p>

<p><strong>some things:</strong> Naturally the file will need to be readable by MySQL, but it can be anywhere. Older versions of MySQL used &#8216;LOAD <span class="caps">DATA LOCAL INFILE&#8217; </span>but MySQL5 uses just &#8216;LOAD <span class="caps">DATA INFILE&#8217; </span>and only accepts local files (a pretty good thing). So yeah you&#8217;ll have to scp your file to and fro.</p>]]></content:encoded>
			<wfw:commentRss>http://justin-hopkins.com/blog/2009/08/04/how-to-export-and-import-of-csv-data-out-of-and-into-mysql/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get a .csv of subscribers on all your Mailman lists</title>
		<link>http://justin-hopkins.com/blog/2009/05/16/how-to-get-a-csv-of-subscribers-on-all-your-mailman-lists</link>
		<comments>http://justin-hopkins.com/blog/2009/05/16/how-to-get-a-csv-of-subscribers-on-all-your-mailman-lists#comments</comments>
		<pubDate>Sat, 16 May 2009 17:16:33 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Mailman]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://justin-hopkins.com/blog/?p=185</guid>
		<description><![CDATA[The boss asked me to create a list of everyone subscribed to every discussion list we have. Ended up being like 3000 lines&#8230;luckly there is a python script that polls the mailman admin web interface. The below script makes it quite a bit easier to perform on all the lists. First thing, you need a [...]]]></description>
			<content:encoded><![CDATA[<p>The boss asked me to create a list of everyone subscribed to every discussion list we have. Ended up being like 3000 lines&#8230;luckly there is a python script that polls the mailman admin web interface. The below script makes it quite a bit easier to perform on all the lists.</p>

<p>First thing, you need a file with all of your list names &#8211; this works:</p>


<pre>
ls /usr/local/mailman/lists | cat &gt; lists.txt ## This is where mailman is located on FreeBSD
</pre>



<p>Next, download <a href="http://www.msapiro.net/mailman-subscribers.py" title="Mailman Subscribers Script">mailman-subscribers.py</a> to your home directory.</p>

<p>Finally, you need to create a shell script (i.e. getallsubscribers.sh) and paste the following (substitute the [[bracketed text]] with the info for your system):</p>


<pre>
while read line
do
 echo $line | cat &gt;&gt; listsAndMembers.csv
  ~/mailman-subscribers.py -c [[your.mailman.host]] $line [[listAdminPassword]] | cat &gt;&gt; listsAndMembers.csv
  echo | cat &gt;&gt; listsAndMembers.csv
  echo | cat &gt;&gt; listsAndMembers.csv
done &lt; lists.txt
</pre>



Now make the file executable and run it:<br />
</pre>

<pre>
chmod +x getallsubscribers.sh
./getallsubscribers.sh
</pre>



<p>That's it. You should have a single file with all of your lists and their subscribers.</p>

<p><strong>edit:</strong> It came up later that it would be nice to get a list of who from each domain was subscribed. This regex will turn up the listname and name/email for each subscriber in the .csv</p>


<pre>
(?:.*(?:gmail\.com)&quot;|^[^&quot;].*$)
</pre>]]></content:encoded>
			<wfw:commentRss>http://justin-hopkins.com/blog/2009/05/16/how-to-get-a-csv-of-subscribers-on-all-your-mailman-lists/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Friends, don&#8217;t give away your passwords!</title>
		<link>http://justin-hopkins.com/blog/2009/03/04/friends-dont-give-away-your-passwords</link>
		<comments>http://justin-hopkins.com/blog/2009/03/04/friends-dont-give-away-your-passwords#comments</comments>
		<pubDate>Thu, 05 Mar 2009 02:11:15 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[How-To]]></category>

		<guid isPermaLink="false">http://justin-hopkins.com/blog/2009/03/04/friends-dont-give-away-your-passwords</guid>
		<description><![CDATA[So, despite having logged into my blog just now without doing this &#8211; I&#8217;m going to share with you the easy way that probably 90% of you can protect your passwords while using the public wifi: Step 1: ssh -D 9999 -C somebox.youcan.sshto Step 2 Go get something like FoxyProxy for Firefox and MM3 for [...]]]></description>
			<content:encoded><![CDATA[<p>So, despite having logged into my blog just now without doing this &#8211; I&#8217;m going to share with you the easy way that probably 90% of you can protect your passwords while using the public wifi:</p>

<h3>Step 1:</h3>

<code>


<pre>
ssh -D 9999 -C somebox.youcan.sshto
</pre>


</code>

<h3>Step 2</h3>

<p>Go get something like FoxyProxy for Firefox and <span class="caps">MM3 </span>for Thunderbird (especially if you are using any version of Thunderbird 3 &#8211; nothing else is compatible). </p>

<p>For Firefox, set up a <span class="caps">SOCKS5 </span>proxy (Prefs &gt; Advanced &gt; Network &gt; Settings) on localhost port 9999. Start using the proxy. Stop using the proxy when you kill your ssh connection and make sure you open the connection if you are using the proxy.</p>

<p>For thunderbird it&#8217;s basically the same if you are using FoxyProxy &#8211; but if you are using <span class="caps">MM3 </span>like me, you need to create (click edit, oh btw you will probably have to add the button to the toolbar first) a proxy with this config:</p>

<code>


<pre>
[Arbitrary_name
  socks=127.0.0.1:9999
]
</pre>


</code>

<p>That&#8217;s it. Now I can&#8217;t steal your passwordsss! If you want to encrypt <span class="caps">DNS </span>requests you can set network.proxy.socks_remote_dns to true in about:config</p>]]></content:encoded>
			<wfw:commentRss>http://justin-hopkins.com/blog/2009/03/04/friends-dont-give-away-your-passwords/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Convert mbox to mailman archives using procmail</title>
		<link>http://justin-hopkins.com/blog/2008/12/10/how-to-convert-mbox-to-mailman-archives-using-procmail</link>
		<comments>http://justin-hopkins.com/blog/2008/12/10/how-to-convert-mbox-to-mailman-archives-using-procmail#comments</comments>
		<pubDate>Wed, 10 Dec 2008 16:55:23 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://justin-hopkins.com/blog/?p=139</guid>
		<description><![CDATA[Update: NATURALLY, after doing all of this I learned that I was given the wrong information. Turns out Mailman is more than happy to take a huge mbox file as input for the arch script. I did learn that running clean_arch on the mbox first is a good idea&#8230; Are you like me? Do you [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> <em><span class="caps">NATURALLY, </span>after doing all of this I learned that I was given the wrong information. Turns out Mailman is more than happy to take a huge mbox file as input for the arch script. I did learn that running clean_arch on the mbox first is a good idea&#8230;</em></p>

<p><a href="http://justin-hopkins.com/blog/wp-content/uploads/2008/12/mailman.jpg"><img src="http://justin-hopkins.com/blog/wp-content/uploads/2008/12/mailman-240x300.jpg" alt="mailman" title="mailman" width="240" height="300" class="alignright size-medium wp-image-138" /></a>
Are you like me? Do you get upset when you have to deal with an almost decade old problem that you had nothing to do with? Well then I&#8217;ve got a story for you&#8230;</p>

<h2>So we&#8217;ve got these archives&#8230;</h2>

<p>Our organization was using Lyris ListServ for about the past 10 years to handle all of our discussion list. Like most <acronym title="Mailing List Managers">MLM</acronym>&#8216;s, ListServ does have the ability to keep list archives&#8230;but naturally we opted to not use them for all of our lists. Big mistake.</p>

<p>Instead of list archives we have a user on our webserver called &#8216;archive&#8217;. Archive is subscribed to each and every list and gets copies of all the messages. When the messages come in, Archive processes them with a procmail script and separates them into mbox mailboxes for each of the lists.</p>

<p>Each of the mails are then piped to a program called mhonarc which converts them into html and provides an index, etc &#8211; which can be displayed on our current(old) website. But now we&#8217;ve got a new website coming up&#8230;</p>

<h2>Enter <span class="caps">GNU</span> Mailman</h2>

<p>Me:</p>

<blockquote><p>Thank you for coming Mailman. I&#8217;m really glad to have you because you do a really good job, not to mention you&#8217;re free and uber-powerful&#8230; One thing though&#8230; We&#8217;ve got these uh, <strong>gulp</strong> &#8220;archives&#8221;. We, uh, need to keep them and everything but you know, they&#8217;re like, not in the greatest shape. See, there actually in mbox format&#8230; </p></blockquote>

<p>Mailman:</p>

<blockquote><p>Oh yeah, that&#8217;s not a problem at all. I&#8217;ve got a built in script to to do that. Just take all of the monthly mailbox files for each of your lists and drop them in my folder &#8211; I&#8217;ll knock them out in no time!</p></blockquote>

<p>Me:</p>

<blockquote><p><span class="caps">SWEET</span>! But what did you say about monthly whatevers?</p></blockquote>

<p>Mailman:</p>

<blockquote><p>The mailbox files that you create every month for each list&#8230; You are using your procmail script to start a new mailbox file every month aren&#8217;t you? Putting 10 years worth of emails into a single monolithic file would be retarded&#8230;</p></blockquote>

<p>Me:</p>

<blockquote><p>Oh yeah yeah&#8230; Of course we did that. I thought you were talking about something else. Silly me. Anyway, so uh, yeah, I&#8217;ll get those file to you real soon.</p></blockquote>

<h2>Breaking up the monolith</h2>

<p>So clearly I needed to edit the procmail script a little bit and reprocess all the mail &#8211; but <span class="caps">WTH</span>? </p>

<p>Last month I had a help desk ticket come my way about a list which was not appearing on the website, and hadn&#8217;t been for a number of months. After digging around, I realized that someone (almost certainly me) had made a mistake in the .procmailrc file which had kept it from processing mail for that list. This was embarrasing, but I discovered <a href="http://www.professional.org/procmail/sandbox.html">how to reprocess mail with formail</a>.</p>

<p>I knew I could probably reprocess all of the mail (many thousands) but had absolutely no clue how to do it. I had only this one clue from my procmail recipe:</p>

<code>

<pre>
LOGFILE=$PMDIR/list_archive-`date +%Y-%m`.log
</pre>

</code>

<p>They had written it to rotate the logs, but not the mailbox names! Uncool! But at least I had my answer &#8211; `date +%Y-%m` can get the date into the names&#8230;But wait!</p>

<p>When I rewrote my procmail file like so:</p>

<code>

<pre>
#this is just one of many
:0 E
     * ^Sender:.*LIST-L
     {
       :0 c
       LIST-L.`date +%Y%m` #to match mailmans archive format...
     }
</pre>

</code>

<p><strong>Totally not working!</strong> It created only one file, and the date was this month and this year. </p>

<p>I&#8217;ll fast-forward for the benefit of the reader at this point and just share an insight with you: <strong>date is a *nix command and has nothing to do with procmail and cannot get any data out of the emails themselves &#8211; like dates!</strong> Yes that&#8217;s right, you can put anything you want in between those little ticks, but because the date command only returns the system date, we&#8217;ve got to do two things:</p>


<ol>
<li>Get the date the email was sent out of the email header (Magic)</li>
<li>Process the date field to have only the 4 digit year and 2 digit month (More Magic)</li>
</ol>



<p>It gets easier from here&#8230;</p>

<h2>Getting the date field</h2>

<p>The first thing we need to do is nab the Date: header from the emails. This part is fairly straight forward. Procmail uses a variable $MATCH to hold the matched string for the rule that it&#8217;s matching on. We can use this to hold our Date header and then just pipe it to a script for processing.</p>

<p>Here&#8217;s the <del>recipe</del> magic!</p>

<code>

<pre>
# NOTE: I later found that this rule only seems to work
# when used as an ELSE rule (:0 E). I'm not sure why, but
# it was only matching the 'Date:' portion, and not the entire
# line. If you can help me understand why, please leave a comment.
# ANOTHER NOTE: The ticks in `echo $MATCH.... are ticks(the
# un-shifted tilde) and not single quotes.

:0 E
     * ^Sender:.*LIST-L
     {
       :0 c
       * ^\/Date:.*
       LIST-L.`echo $MATCH | php /path/to/dateconvert.php`
     }
</pre>

</code>

<h2>Transforming the date into Mailman&#8217;s monthly format</h2>

<p>Here&#8217;s <del>the php code</del> more magic to get your date cut down and switched around to a format Mailman will love. It uses <del>php&#8217;s built in functions</del> fairy dust to put the Date header into an array, and drop the empty elements. It was also necessary to create an array that maps the three letter month names used in the email header to their numerical equivalents. </p>

<code>

<pre>
&lt; ?php
 $date = trim(fgets(STDIN));
 
 $datearray = array_values(array_filter(explode(&quot; &quot;, $date)));
 
 $month = $datearray[3];
 $year = $datearray[4];
 
 $montharray = array(
 &quot;Jan&quot; =&gt; &quot;01&quot;,
 &quot;Feb&quot; =&gt; &quot;02&quot;,
 &quot;Mar&quot; =&gt; &quot;03&quot;,
 &quot;Apr&quot; =&gt; &quot;04&quot;,
 &quot;May&quot; =&gt; &quot;05&quot;,
 &quot;Jun&quot; =&gt; &quot;06&quot;,
 &quot;Jul&quot; =&gt; &quot;07&quot;,
 &quot;Aug&quot; =&gt; &quot;08&quot;,
 &quot;Sep&quot; =&gt; &quot;09&quot;,
 &quot;Oct&quot; =&gt; &quot;10&quot;,
 &quot;Nov&quot; =&gt; &quot;11&quot;,
 &quot;Dec&quot; =&gt; &quot;12&quot;
 );
 
 echo $year . $montharray[$datearray[3]];
?&gt;
</pre>

</code>

<p>At this point you&#8217;re probably thinking one of two things:</p>


<ol>
<li>&#8220;ZOMG you&#8217;re such a hack. You could have done that with so much less code! You have no style!&#8221;</li>
<li>&#8220;ZOMG you can totally do that with a sed/awk one liner!&#8221;</li>
</ol>



<p>Sorry for wasting everyone&#8217;s time yet again. </p>

<p>After you&#8217;ve got the recipe in place and the php file all ready to go, just give it one of these:</p>

<code>

formail -s procmail -m /path/to/yourprocmailfile &lt; /path/to/LIST-L

</code>

<h3>Final product</h3>

<p>Anyway, you should, after a few hours or days end up with a grip of mailbox files like this:</p>

<p></code><code>

<pre>
               LIST-L.200306  LIST-L.200502  LIST-L.200701
 	        LIST-L.200307  LIST-L.200503  LIST-L.200702
LIST-L.200112  LIST-L.200308  LIST-L.200504  LIST-L.200703
LIST-L.200201  LIST-L.200309  LIST-L.200505  LIST-L.200704
LIST-L.200202  LIST-L.200310  LIST-L.200506  LIST-L.200705
LIST-L.200203  LIST-L.200311  LIST-L.200507  LIST-L.200707
LIST-L.200204  LIST-L.200312  LIST-L.200509  LIST-L.200708
LIST-L.200205  LIST-L.200401  LIST-L.200511  LIST-L.200709
LIST-L.200206  LIST-L.200402  LIST-L.200512  LIST-L.200710
LIST-L.200207  LIST-L.200403  LIST-L.200601  LIST-L.200711
LIST-L.200208  LIST-L.200404  LIST-L.200602  LIST-L.200712
LIST-L.200209  LIST-L.200405  LIST-L.200603  LIST-L.200801
LIST-L.200210  LIST-L.200406  LIST-L.200604  LIST-L.200802
LIST-L.200211  LIST-L.200407  LIST-L.200605  LIST-L.200803
LIST-L.200212  LIST-L.200408  LIST-L.200606  LIST-L.200804
LIST-L.200301  LIST-L.200409  LIST-L.200607  LIST-L.200805
LIST-L.200302  LIST-L.200410  LIST-L.200608  LIST-L.200806
LIST-L.200303  LIST-L.200411  LIST-L.200610  LIST-L.200807
LIST-L.200304  LIST-L.200412  LIST-L.200611
LIST-L.200305  LIST-L.200501  LIST-L.200612
</pre>

</code></p>

<p>So there ya go. Now make with the comments.</p>]]></content:encoded>
			<wfw:commentRss>http://justin-hopkins.com/blog/2008/12/10/how-to-convert-mbox-to-mailman-archives-using-procmail/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Setting Up Drupal File Framework On Ubuntu 8.10</title>
		<link>http://justin-hopkins.com/blog/2008/12/02/how-to-setting-up-drupal-file-framework-on-ubuntu-810</link>
		<comments>http://justin-hopkins.com/blog/2008/12/02/how-to-setting-up-drupal-file-framework-on-ubuntu-810#comments</comments>
		<pubDate>Tue, 02 Dec 2008 21:00:02 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://justin-hopkins.com/blog/?p=101</guid>
		<description><![CDATA[This document is continually changing! One of the ways it gets changed is by people communicating with me using comments. In the future, I will host a wiki for this purpose &#8211; but for the time being please help me out by posting your suggested changes/improvements as comments! *2010/05/17: New users will want to read [...]]]></description>
			<content:encoded><![CDATA[<p><strong>This document is continually changing! One of the ways it gets changed is by people communicating with me using comments. In the future, I will host a wiki for this purpose &#8211; but for the time being please help me out by posting your suggested changes/improvements as comments!</strong></p>

<p>*2010/05/17: New users will want to read down through all of the comments, as this post has become out of date in quite a few ways. Especially have a look at <a href="http://justin-hopkins.com/blog/2008/12/02/how-to-setting-up-drupal-file-framework-on-ubuntu-810#comment-172">this comment from Wouter</a>.*</p>

<p><a href="http://justin-hopkins.com/blog/wp-content/uploads/2008/11/logo2.png"><img src="http://justin-hopkins.com/blog/wp-content/uploads/2008/11/logo2.png" alt="Drupal Logo" title="Drupal Logo" width="49" height="57" class="alignright size-full wp-image-111" /></a>
In my <a href="http://justin-hopkins.com/blog/2008/11/26/document-management-woes">previous post</a> I described the troubles I had with standalone document management softwares. Many of the issues I had were related to a lack of flexibility and lack of integration with my <span class="caps">CMS </span>of choice: Drupal.</p>

<p>At first glance(and even after looking quite hard), Drupal seems to be weak when it comes to document management. But just like any Drupal solution, a careful examination of the available modules might turn up <strong>the ingredients for the perfect recipe!</strong></p>

<p>In this article, I&#8217;m going to describe the steps required to get off the ground with a Drupal based document management solution that will provide:</p>


<ul>
<li>Organization of documents</li>
<li>Revision control</li>
<li>WebDav access</li>
<li>Rich metadata</li>
<li>Indexing for search</li>
<li>In-browser display of documents</li>
<li>Document conversion services</li>
<li>All the goodness you get from building it inside Drupal
<ul>
<li>Free authentication</li>
<li>Free administration interface</li>
<li>Integration with other Drupal modules (Views anyone?)</li>
<li>Awesome community of developers</li>
</ul>
</li>
</ul>



<h2>Getting started</h2>

<p>I&#8217;d recommend testing this out on a fresh install of Drupal6.6 &#8211; should you encounter difficulty, the number of modules on an established site could make troubleshooting a bit more difficult. After you&#8217;ve got it down, you can move on to your active development site.</p>

<p>Thanks to <a href="http://drupal.org/user/26089">Arto Bendiken</a>, <a href="http://drupal.org/user/18741">Miglius Alaburda</a>, <a href="http://drupal.org/user/51124">Justin Miller</a>, <a href="http://drupal.org/user/186547">Ben Lavender</a>, <a href="http://drupal.org/user/43670">Frank Febbraro</a>, and of course <a href="http://drupal.org/user/23">Moshe Weitzman</a>. </p>

<p>This article is based on <a href="http://bhuga.net/2008/07/setting-your-system-file-conversions-with-file-framework">Setting up your system for file conversions with File Framework</a>. Ben gives a very helpful and accurate rundown of what it takes to get going under CentOS. Since I was trying it out under Ubuntu, I thought I&#8217;d spend the time documenting my troubles &#8211; and include instructions to add some extra bells and whistles.</p>

<h2>System stuff</h2>

<p>First things first, lets go ahead and get all the packages we need:</p>

<code>


<pre>
sudo apt-get install php5 php5-dev php-pear make php-getid3 libmagic-dev clamav swftools unrtf poppler-utils catdoc ghostscript tzdata tzdata-java alsa-tools alsa-utils libx11-6 libxext6 libxi6 libxtst6 asoundconf-gtk libfreetype6 libpng12-0 libjpeg62 giflib-tools libsm6 openjdk-6-jdk openoffice.org openoffice.org-headless code2html pstotext
sudo pecl install Fileinfo
sudo pear install http://download.pear.php.net/package/HTTP_WebDAV_Server-1.0.0RC4.tgz
sudo pear install http://download.pear.php.net/package/HTTP_WebDAV_Client-1.0.0.tgz
</pre>


</code>

<p>If you have trouble with the install of the pear modules, probably the version has changed &#8211; you should visit the <a href="http://pear.php.net/packages.php?catpid=11&amp;catname=HTTP"><span class="caps">HTTP </span>packages page</a>.</p>

<h3><span class="caps">JODC</span>onverter</h3>

<p>We also need to get the <span class="caps">JOD</span> Converter. It&#8217;s a few .jar files that we&#8217;ll stick in a directory in /opt. <span class="caps">JODC</span>onverter is the piece that actually manages the conversion process through openoffice.</p>

<code>
cd /opt &amp;&amp; wget http://internap.dl.sourceforge.net/sourceforge/jodconverter/jodconverter-2.2.1.zip &amp;&amp; unzip jodconverter-2.2.1.zip &amp;&amp; mv jodconverter-2.2.1 jodconverter
</code>

<h3>Run OpenOffice as a service</h3>

<p>Long story short, use a version later than 2.3 to avoid problems running it &#8216;headless&#8217;. This is essential for the file conversion process.</p>

<p><em><strong>edit</strong></em>: I realized that the OpenOffice service really needs to be running as www-data, so using an init script like this one is really necessary.</p>

<code>

<pre>
#!/bin/bash
#
# description: Open Office Service
#

export WEBUSER=www-data
export PATH=$PATH
export LANG=en_US.UTF-8

start() {
echo -n &quot;Starting OpenOffice service: &quot;
sudo -u $WEBUSER /opt/openoffice.org3/program/soffice -headless -accept=&quot;socket,host=127.0.0.1,port=8100;urp&quot; -nofirststartwizard &amp; 
echo &quot;OpenOffice Started&quot;
}

stop() {
echo -n &quot;Stopping soffice: &quot;
pkill soffice
echo &quot;OpenOffice Stopped&quot;
}

case &quot;$1&quot; in
start)
start
;;
stop)
stop
;;
status)
status soffice
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $&quot;Usage: $0 {start|stop|restart|reload|status}&quot;
exit 1
esac

exit 0
</pre>

</code>

<p>If you want OpenOffice3 like I&#8217;m using, you might want to remove the 2.4 packages with apt-get remove and go to openoffice.org and download the .deb packages. I installed by extracting the archive, cd&#8217;ing into the folder and using </p>

<pre>sudo dpkg -i *.deb</pre>

<p> and doing the same in the desktop integration folder. I can&#8217;t really <em>recommend</em> using OOo3 because the Ubuntu folks don&#8217;t have it in the repos&#8230;and the <span class="caps">GUI </span>is very crash happy.</p>

<h2>Drupal stuff</h2>

<h3>Clean <span class="caps">URL</span>s</h3>

<p>Pop over to <a href="http://drupal.org/node/134439">the Drupal.org page</a> describing how to set up clean urls if you don&#8217;t have that going already. Clean urls aren&#8217;t necessary, but due to a bug currently in bitcaching &#8211; <strong>it is</strong>.</p>

<h3>Install Drush</h3>

<p>If you aren&#8217;t using the <a href="http://drupal.org/project/drush">Drush module</a>, I <strong>highly</strong> recommend it. Although not related to or necessary for this project, since I discovered it <strong>one day ago</strong>, it&#8217;s become one of my favorite modules. It provides a familiar way to install and update your packages &#8211; and has a number of modules that extend it&#8217;s functionality.</p>


<ul>
<li>Install the Drush module by downloading the tarball to your modules directory (sites/all/modules) and extract it.</li>
<li>Go into your modules page in Drupal and enable the Drush and associated modules. You won&#8217;t be able to turn on the simpletest runner module, that&#8217;s fine. Also &#8211; I wasn&#8217;t able to use the <span class="caps">CVS </span>support, so I have that disabled as well.</li>
</ul>



<p>One last thing &#8211; you need to add a softlink to drush.php somewhere in your path. For me, I just echoed the path variable and picked the place that looked the best&#8230; Make sure you change any paths to whatever works.</p>

<code>

<pre>
% echo $PATH
/home/hopkinsju/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

% ln -s /var/www/drupal/sites/all/modules/drush/drush.php /home/hopkinsju/bin/drush
</pre>

</code>

<p>Now you should be able to type &#8216;drush&#8217; and the computer will know what you&#8217;re talking about.</p>

<h3>Add required modules with Drush</h3>

<p>Now we just do this to get all the modules we need:</p>

<code>
drush pm install bitcache cck dav fileframework rdf views fileserver #FTW!
</code>

<p>Drush will go out and grab the latest version of each module and extract it in your &#8216;sites/all/modules&#8217; directory. </p>

<p><strong><em>note: As of this writing bitcache-alpha3 had a bug in it. Using alpha3 will result in the error &#8220;Fatal error: Unsupported operand types in serverpath/includes/common.inc on line 1546&#8243;. To resolve this, you can use either the <a href="http://drupal.org/node/192590/release">alpha2 or dev versions</a> of the bitcache module</em></strong></p>

<h3>A few other bits</h3>

<p>The File Framework can get metadata for and play flash and mp3 files. You need only add a couple things to the vendor folder of fileframeworks:</p>

<p><strong><em>edit</em></strong>: Using the commands below should get you going without a problem, but I wanted to clarify: You <span class="caps">MUST </span>use the &#8216;slim&#8217; version of the xspf player. Also, the path to getid3 should be /vendor/getid3 &#8211; there should also be a directory /vendor/getid3/getid3 containing the different modules. </p>

<p><strong><em>update</em></strong>: new versions of getID3 and flowplayer as of Mar 18, 2009 &#8211; also you need to make folders for them&#8230;I&#8217;ll update the lines in a bit.<br />
<code>

<pre>
cd /path/to/drupal/sites/all/modules/fileframework/vendor
wget http://voxel.dl.sourceforge.net/sourceforge/getid3/getid3-1.7.9.zip
unzip getid3-1.7.9.zip

wget http://flowplayer.org/releases/flowplayer/flowplayer-3.0.7.zip
unzip flowplayer-3.0.7.zip

wget http://voxel.dl.sourceforge.net/sourceforge/musicplayer/xspf_player_slim-correct-0.2.3.zip
unzip xspf_player_slim-correct-0.2.3.zip
</pre>

</code></p>

<h3>Enable the modules</h3>

<p>Visit your modules page and enable the modules you need. When I first attempted this, I did run into an error where I had enabled one module or another without first enabling the modules it required(I think it was the <span class="caps">RDF API </span>module that needed to be enabled before the File formats). You&#8217;ll want to actually look at what you&#8217;re installing rather that just checking all the boxes of course. But basically &#8211; check all the boxes ;)</p>

<h3>Drupal admin area things</h3>


<ul>
<li>Visit admin/settings/dav/dav_fs and save the page to create the dav directory</li>
<li>Enable <span class="caps">DAV</span> Server in admin/settings/dav</li>
<li>If you want html highlighting for text files admin/settings/file/format/text</li>
<li>Enable antivirus scanning (I chose to run it as a program) admin/settings/file/antivirus</li>
<li>Enable file formats admin/settings/file/format</li>
<li>Go tell the Fileserver that you want it to use the &#8216;Files&#8217; vocab. Doing this will enable automatic creation of file nodes when items are added to that folder via WebDAV.</li>
</ul>



<p><strong>Please post your comments if you can improve on what I&#8217;ve done!</strong> </p>

<p>Happy document managing!</p>]]></content:encoded>
			<wfw:commentRss>http://justin-hopkins.com/blog/2008/12/02/how-to-setting-up-drupal-file-framework-on-ubuntu-810/feed</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
	</channel>
</rss>
