<?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/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>DK101.net &#187; compile</title>
	<atom:link href="http://blog.dk101.net/tag/compile/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dk101.net</link>
	<description>Nominated for best adaptation of a boring life</description>
	<lastBuildDate>Tue, 31 Aug 2010 12:12:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<!-- podcast_generator="podPress/8.8" - maintenance_release="8.8.4" -->
		<copyright>Copyright &amp;#xA9; TurnKey Linux 2010 </copyright>
		<managingEditor>vultuk@me.com (DK101.net)</managingEditor>
		<webMaster>vultuk@me.com (DK101.net)</webMaster>
		<category>posts</category>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle></itunes:subtitle>
		<itunes:summary>Just another WordPress weblog</itunes:summary>
		<itunes:author>DK101.net</itunes:author>
		<itunes:category text="Society &amp; Culture"/>
		<itunes:owner>
			<itunes:name>DK101.net</itunes:name>
			<itunes:email>vultuk@me.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://109.123.80.171/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://109.123.80.171/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>DK101.net</title>
			<link>http://blog.dk101.net</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>Making a php page to do an SVN Update</title>
		<link>http://blog.dk101.net/2009/07/15/making-a-php-page-to-do-an-svn-update/</link>
		<comments>http://blog.dk101.net/2009/07/15/making-a-php-page-to-do-an-svn-update/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 09:39:19 +0000</pubDate>
		<dc:creator>vultuk</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[exec]]></category>
		<category><![CDATA[include]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[run]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[suphp]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://blog.dk101.net/?p=483</guid>
		<description><![CDATA[Having just acquired two new web servers for work today I started to set them up this evening. One thing that I needed to do was make them as user friendly for everyone as possible and one of the main tools I needed for this was SVN. Server 1 is the main web server and [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-25" title="svn" src="http://cdn.dk101.net/blog/wp-content/uploads/2009/02/svn.png" alt="svn" width="524" height="140" /></p>
<p>Having just acquired two new web servers for work today I started to set them up this evening. One thing that I needed to do was make them as user friendly for everyone as possible and one of the main tools I needed for this was SVN. Server 1 is the main web server and Server 2 is purely an SVN Server. All this setup went fine and I went ahead converting all the current sites into SVN to get them ready. However, the need for this to be simple was high so I installed an auto update script to the dev server. This meant that every time a Commit was sent the Dev server automagically did an SVN update meaning it was the latest version.</p>
<p>Now, I could also have done this for the live server but for obvious reasons this wouldn't be acceptable. So, it came down to having to SVN update from command line though SSH. This works however giving command line details, passwords and trust to everyone that would need to update each website could be dangerous, if not through people pressing the wrong buttons but also by people writing down passwords and leaving them lying around. Not good, not good at all.</p>
<p><span id="more-483"></span>I tried making a standard php page to run</p>
<blockquote><p><span style="color: #3366ff;">&lt;?php<br />
exec("svn update");<br />
?&gt;</span></p></blockquote>
<p>However this did nothing and didn't even return anything. I googled for a while and only discovered people having the same problem and no one actually finding a solution. After a few hours the solution I came up with was... Firstly, recompile Apache and include mod_suPHP. This makes all php scripts on the server run under the user account that owns it, I then compiled a short c program that calls an SVN update with the username and password first used to checkout the site. The script looks like the following...</p>
<blockquote><p><code> <span style="color: #3366ff;">#include &amp;lt;stddef.h&amp;gt;<br />
#include &amp;lt;stdlib.h&amp;gt;<br />
#include &amp;lt;unistd.h&amp;gt;</span></code></p>
<p><span style="color: #3366ff;"><code>int main(void) {</code></span></p>
<p><span style="color: #3366ff;"><code>execl("/usr/bin/svn", "svn", "update", "--username", "USERNAME", "--password", "PASSWORD", "./", (const char *) NULL);<br />
return(EXIT_FAILURE);</code></span></p>
<p><span style="color: #3366ff;"><code> }</code></span></p></blockquote>
<p>You compile this using</p>
<blockquote><p><span style="color: #3366ff;">gcc -o svn_update svn_update.c</span></p></blockquote>
<p>Chmod the svn_update file as 755 then we simply use the normal php exec function to call this script.</p>
<blockquote><p><span style="color: #3366ff;">&lt;?php<br />
exec("svn_update");<br />
?&gt;</span></p></blockquote>
<p>Then everytime you run the php script it will update the requested file from the latest svn revision. Problem solved. It is then up to you to include any security to stop random users from updating your svn <img src='http://cdn.dk101.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Hope this helps some other people who had the same problem as me! <img src='http://cdn.dk101.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dk101.net/2009/07/15/making-a-php-page-to-do-an-svn-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
