<?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>Stoat - Where? &#187; FuseDAV</title>
	<atom:link href="http://jamietalbot.com/tag/fusedav/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamietalbot.com</link>
	<description>Adventures in Engrish</description>
	<lastBuildDate>Sat, 29 Oct 2011 05:14:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Automatically Mounting WebDAV in Ubuntu with a FuseDAV Init Script</title>
		<link>http://jamietalbot.com/2010/01/27/automatically-mounting-webdav-in-ubuntu-with-a-fusedav-init-script/</link>
		<comments>http://jamietalbot.com/2010/01/27/automatically-mounting-webdav-in-ubuntu-with-a-fusedav-init-script/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 09:18:12 +0000</pubDate>
		<dc:creator>Jamie Talbot</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[BingoDisk]]></category>
		<category><![CDATA[FuseDAV]]></category>
		<category><![CDATA[init.d]]></category>
		<category><![CDATA[LinkedIn]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[WebDAV]]></category>

		<guid isPermaLink="false">http://jamietalbot.com/?p=6</guid>
		<description><![CDATA[How to automatically mount a WebDAV share in Ubuntu using FuseDAV, an init script and a simple configuration file.]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://www.bingodisk.com/">BingoDisk</a> as a backup and remote storage solution and wanted to use it as the destination for my daily backup of this blog and my development environment.  BingoDisk is available via WebDAV which is nice and convenient, and there are 2 main options for Ubuntu, davfs2 and fusedav.</p>
<p>On the face of it, davfs2 is more convenient, as it allows you to automount quite easily using fstab.  However, despite a number of attempts, I couldn&#8217;t convince it to allow me to write files remotely, only folders.  It seems a number of people have had the same issue.</p>
<p>Fusedav, on the other hand, was much more reliable, writing files and folders without errors.  It also seemed noticeably faster.  Unfortunately, there didn&#8217;t seem to be any convenient way to mount the share automatically, and this would be important for my automated backup routine.  To solve this, I put together a quick solution using a simple mount description file and an init script that gives me better control over the process.  The idea and parts of the code are built on a solution I found by <a href="http://muzso.hu/2008/12/16/using-a-webdav-server-to-share-stuff-settings-preferences-between-multiple-environments">müzso</a>.  This goes one step further and enables it to run automatically at boot time.</p>
<p>Below are the steps I took, and the script I&#8217;m using.  The steps are for Ubuntu, but should be easily modifiable to any flavour of Linux.</p>
<p>First, install fusedav.</p>
<pre class="brush: bash; title: ; notranslate">sudo aptitude -y install fusedav</pre>
<p>Next, we do a quick test to check that fusedav will indeed connect to our WebDAV share.</p>
<pre class="brush: bash; title: ; notranslate">sudo /usr/bin/fusedav -u username -p password http://mydomain.bingodisk.com /mnt/bingo</pre>
<p>We&#8217;re running fusedav in the foreground because it will be easier to kill that way once we&#8217;ve finished testing, so open a new terminal and check that you can connect.</p>
<pre class="brush: bash; title: ; notranslate">
cd /mnt/bingo
ls -la
</pre>
<p>If all is well, the top level of your remote share should now be visible.  I don&#8217;t like that you have to specify the password on the command line, but there doesn&#8217;t seem to be too much you can do about that at the moment.</p>
<p>Close the second terminal, and kill the fusedav process in the first by pressing Ctrl+c.  Now, we&#8217;re going to create a directory and a simple mount description file that includes the URL, username and password.  I&#8217;m going to call the file <strong>bingo</strong>, and later on this means that the share will be mounted at <code>/mnt/bingo</code>.  The directory layout I went for is similar to how Apache and Nginx manage virtual hosts.</p>
<pre class="brush: bash; title: ; notranslate">
mkdir -p /etc/fusedav/mounts-available
</pre>
<p>Now edit <code>/etc/fusedav/mounts-available/bingo</code> as root using your favourite text editor and put the following in it.  The 3 segments are the URL to the WebDAV location, username and password, separated by a space.</p>
<pre class="brush: bash; title: ; notranslate">
http://mydomain.bingodisk.com username password
</pre>
<p>Because this file contains your password in plaintext, you should secure it so that only the owner (root) can read it.</p>
<pre class="brush: bash; title: ; notranslate">
sudo chmod 600 /etc/fusedav/mounts-available/bingo
</pre>
<p>Next, the init script, which you can download from here.  You need to make it executable.</p>
<pre class="brush: bash; title: ; notranslate">
cd /etc/init.d/
sudo wget http://jamietalbot.com/projects/fusedav/files/bingo
sudo chmod +x bingo
</pre>
<p>You can take a look at the file in its entirety.  It&#8217;s not especially complex but the highlights are:</p>
<pre class="brush: bash; title: ; notranslate">NAME=bingo</pre>
<p>You should alter <strong>bingo</strong> on this line to be the same as the name of the file you put in <code>/etc/fusedav/mounts-available</code>.  This is the only change you have to make (and you only have to make it if you called your mount something other than bingo).</p>
<pre class="brush: bash; title: ; notranslate">
MOUNT_FILE=/etc/fusedav/mounts-available/$NAME
MOUNT_POINT=/mnt/$NAME
</pre>
<p>These lines define where the mount description files are kept and where the share will be mounted.</p>
<pre class="brush: bash; title: ; notranslate">
set -- $(cat ${MOUNT_FILE})
URI=$1
USERNAME=$2
PASSWORD=$3

DAEMON_ARGS=&quot;-u $USERNAME -p $PASSWORD $URI $MOUNT_POINT&quot;
</pre>
<p>This section splits the mount description into usable variables and sets the parameters for fusedav.</p>
<p>The script automatically creates a PID file which should help avoid any issues if you start the daemon more than once.  It also starts fusedav as a background process, so it doesn&#8217;t interfere with your terminal.</p>
<p>Let&#8217;s check that the script works.</p>
<pre class="brush: bash; title: ; notranslate">
su -
/etc/init.d/bingo start
cd /mnt/bingo/
ls -la
</pre>
<p>Hopefully, at this point you should see the remote share, as before.</p>
<p>Finally, we can add the script to the default runlevel so that it starts when the server boots up.</p>
<pre class="brush: bash; title: ; notranslate">sudo /usr/sbin/update-rc.d -f bingo defaults</pre>
<p>And that should be that!  If you need to stop the daemon use the following.</p>
<pre class="brush: bash; title: ; notranslate">sudo /etc/init.d/bingo stop</pre>
<p>You can easily add further shares if necessary with the following steps as root (assuming the new share name of <strong>bongo</strong>).</p>
<pre class="brush: bash; title: ; notranslate">
cp /etc/init.d/bingo /etc/init.d/bongo
chmod +x /etc/init.d/bongo
vim /etc/init.d/bongo
:%s/bingo/bongo/g
:wq
cat 'http://bongo.remote.drive username password' &gt; /etc/fusedav/mounts-available/bongo
chmod 600 /etc/fusedav/mounts-available/bongo
/usr/sbin/update-rc.d -f bongo defaults
/etc/init.d/bongo start
</pre>
<p>At which point, <code>/mnt/bongo</code> should be ready and waiting.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamietalbot.com/2010/01/27/automatically-mounting-webdav-in-ubuntu-with-a-fusedav-init-script/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

