OwnCloud is server application that provides Dropbox or Skydrive-like capabilities, using your own hardware. It’s completely free, if you host it yourself.
As it turns out, the WD My Book Live isn’t a terrible platform to host it on.
First, the obvious bits
- your.warranty=NULL;
- You will be working with the command line and root access. If you are not careful, you will brick your box, and bricks are terrible servers. Unbrickify here: Unbrickification
- Make sure you are on the most recent firmware
First, you need to enable SSH. Do this from the settings menu in the MBL UI. Or http://mybooklive/UI/ssh
Log in as root via SSH (Use PuTTy or similar). The default password is welc0me
Here is a script for running the first series of commands automatically.
#! /bin/bash
#check that requirements are fullfilled
if [“$(id -u)” != “0”]; then
echo -e “this script must be run as root.\n”
exit 1
fi
echo
echo -n “Removing WD-NAS Package References…”
rm -f /var/lib/dpkg/info/wd-nas.*
echo “done!”
echo “When prompted to install packages or unverified packages, answer Y to both prompts.”
echo “When prompted to overwrite files, choose NOT to overwrite them.”
echo “Overwriting the files may cause your system to bleep. So dont.”
read -p "Do you understand and wish to continue? [y/N] " -n 1
if ! [[$REPLY =~ [1]$ ]]; then
echo -e “\nUSER ABORT\n”
exit 1;
fi
apt-get update
apt-get install php5 php5-gd php-xml-parser php5-intl zlib1g
clear
echo -ne “Packages Installed. Installing Owncloud”
cd /var/www/
wget https://download.owncloud.com/download/community/setup-owncloud.php
–no-check-certificate
chmod 755 setup-owncloud.php
chgrp www-data /var/www
chmod g+w /var/www
The first step is to prepare the system for new software. This is a step that I have not seen mentioned anywhere except a single WD support page. When using apt-get to install new packages, it will throw a TON of errors, due to conflicts. Fix this by running this command:
rm -f /var/lib/dpkg/info/wd-nas.*
This removes the package references to the firmware.
EDIT: <NEW_STEP>
We need to configure the package repository source list. With your favorite text editor, (nano vim, in my case) open /etc/apt/sources.list
Edit your file so that the only active sources are the squeeze sources. Or, just edit it to look like this:
deb http://ftp.us.debian.org/debian/ squeeze main
deb-src http://ftp.us.debian.org/debian/ squeeze main
#deb http://ftp.us.debian.org/debian/ wheezy main
#deb-src http://ftp.us.debian.org/debian/ wheezy main
#deb http://ftp.us.debian.org/debian/ sid main
(The lines starting with the hash are not required - they are commented out. The first two lines are the important ones.)
EDIT: </NEW_STEP>
Then run
apt-get update
Next, we install the pre-requisite packages for OwnCloud. This includes an updated PHP5, in addition to a few libraries and modules.
apt-get install php5 php5-gd php-xml-parser php5-intl zlib1g
Answer Y to the installation prompts. It may ask if you want to install “unverified” files. Choose ‘Y’. This happens because the signature keys for the Debian repositories are not present. (If you like, you can add them) At a couple points, it will ask if you want to overwrite a file (a couple ini files). The default option is to keep the current version. That is what you want to do; accept the default suggestion. Do not overwrite the existing files.
After the packages have been installed, it is time to install owncloud. This part is easy.
From the SSH session, cd to the web root and download the setup file:
cd /var/www/wget https://download.owncloud.com/download/community/setup-owncloud.php --no-check-certificatechmod 755 setup-owncloud.php
We now need to make sure it has write permission to the directory (temporarily)
chgrp www-data /var/www
chmod g+w /var/www
In your web browser, navigate to http://mybooklive/setup-owncloud.php and follow the instructions. I had it install to the subdirectory owncloud. I recommend you do the same. It may not be necessary, but it helps with security a bit, at least.
You will likely recieve a warning about your data being available to the internet. Don’t worry, we’re going to fix that.
Once you have OwnCloud set up, it’s time to finalize the backend stuff.
We need to edit the apache configuration. With your favorite text editor (I use nano [recent vim convert]) or winSCP, edit /etc/apache2/sites-enabled/000-wdnas AND /etc/apache2/sites-enabled/000-wdnas-ssl There is one configuration each for normal http and SSL https.
Add these lines with the other <Directory… > lines
<Directory /var/www/owncloud/>
AllowOverride All
Options +FollowSymLinks
</Directory>
<Directory /var/www/owncloud/data>
Order deny,allow
Deny from all
</Directory>
Script for the rest of the code
#!/bin/bash#check that requirements are fullfilled
if [“$(id -u)” != “0”]; then
echo -e “this script must be run as root.\n”
exit 1
fi
/etc/init.d/apache2 restart
chmod g-w /var/www
/etc/init.d/apache2 stop
mv /var/www/owncloud/data /DataVolume/owncloud_data
chgrp www-data /DataVolume/owncloud_data
chmod 770 /DataVolume/owncloud_data
ln -s /DataVolume/owncloud_data /var/www/owncloud/data
/etc/init.d/apache2 start
Restart Apache and remove the web root write permissions
/etc/init.d/apache2 restartchmod g-w /var/www
The data is stored on the OS partition, currently. We need to move it to the larger Data partition. To do this, we need to make a folder, accessible to OwnCloud, move all the data to it, then create a symbolic link. (After stopping Apache)
/etc/init.d/apache2 stop
mv /var/www/owncloud/data /DataVolume/owncloud_datachgrp www-data /DataVolume/owncloud_datachmod 770 /DataVolume/owncloud_data
ln -s /DataVolume/owncloud_data /var/www/owncloud/data/etc/init.d/apache2 start
EDIT: Updated line 4 of above code: chmod 776 → chmod 770. Thanks to nfodiz!
EDIT: Simplified the code and script a bit, based on @tekati’s suggestions. Thanks!
Original code, just in case:
/etc/init.d/apache2 stop
mkdir /DataVolume/owncloud_data
chgrp www-data /DataVolume/owncloud_data
chmod 770 /DataVolume/owncloud_data
mv /var/www/owncloud/data/* /DataVolume/owncloud_data
rmdir /var/www/owncloud/data
ln -s /DataVolume/owncloud_data /var/www/owncloud/data
/etc/init.d/apache2 start
And… Done.
Access owncloud by going to http://mybooklive/owncloud
To make it accessable from the outside world, you will need to forward ports 80 and 443 on your router to your MBL. BE FREAKING CAREFUL WITH THIS. I CANNOT STRESS THIS ENOUGH. This will open up your MBL UI to the outside world as well. You know the risks and have been warned. If there is enough interest, I may go into securing the UI in another guide.
Edit: By default (to my mild surprise) they have restricted access from WAN (internet) addresses to the UI. It only allows connections from the 192.168.0.0/16 block. So, not as much of a risk, but still a risk.
Hope this helps someone! Figuring this out was quite an adventure. I think this thing has a lot of potential. I wouldn’t hate ideas for other uses.
~Chris
EDIT: I’m in the process of install SubSonic for media streaming, which has a ton of dependencies. I have to admit, I’m astonished at just how much of the Debian Repo supports the PPC architecture. That really illustrates the power of community-driven projects.
Also, I’m concluding that, if you know enough about linux internals, and are very careful, there’s a loooooooooooot that you can make this little box do. NAS, Cloud, Media Streaming, PPC Dev Box (Ok, maybe nobody else will use it for this), Web Server, Torrent box, proxy box, relay, file sync… yeah.
WD, you’re sitting on a fortune. Re-market them as real cloud boxes! Just put my name on it somewhere
-
Yy ↩︎