Skip to main content

World Edition SVN

Posted by rah003 on April 16, 2008 at 1:09 PM PDT

Few months ago drive in my notebook stopped working and I lost some data which I was very sorry about. That's when I started to look into some backup solution. Then recently I found this little (physical size wise) disk - WD MyBook World Edition 2TB. Since memory of having lost my data is still fresh in my mind I configured this drive to run in RAID-1 mode even though it meant reducing size to 1TB only. "1TB only", indeed, reminds me of beginning of 90-ies when I got desktop with super king size HDD of 80MB.

Anyway, after discovering there was a linux running inside of box, and finding out how to enable ssh (Thank you Martin) it was just a matter of time, to try to install svn server on this neat box.

Installing svn was not as simple as I imagined originally, but was not too complex either, so if anyone gets box with same linux (should be any of the World Edition drives, no matter of what size) what's written below can save you stumbling across same problems I had and should help you to make installation smooth and simple.

If you don't know your Linux, you might screw up your World Edition Hard Drive big time. If you proceed it is at your own risk, so proceed with caution!

Get started - Apache2

Login to your box using ssh as whatever user you have created during installation of your box, then execute following to get your apache installed in default location (/usr/local/apache2):

wget http://www.apache.org/dist/httpd/httpd-2.2.8.tar.gz
tar
-xvzf httpd-2.2.8.tar.gz
./configure --enable-dav --enable-so --enable-maintainer-mode
make
sudo make install

Installation itself takes quite while so don't be nervous. I would be very happy if WD offered boxes with more powerful version of little ARM brain it uses, but true is that what they put inside is enough to do the job.

Be there a light - Neon

After successful installation of Apache2 you are ready to get started with subversion

wget http://subversion.tigris.org/downloads/subversion-1.4.6.tar.bz2
tar
-xvjf subversion-1.4.6.tar.bz2

You will also need subversion dependencies (goes into same installation folder as subversion itself

wget http://subversion.tigris.org/downloads/subversion-deps-1.4.6.tar.bz2
tar
-xvjf subversion-deps-1.4.6.tar.bz2

Now we need to get rid of apr since we will use one that came with apache2. This is important as using different versions would result in seq faults later

cd subversion-1.4.6
rm -rf apr
rm -rf apr-util

Build neon separately. Why? First it is recommended in Subversion installation guide and second I could not make it work when trying to build it together with subversion itself

cd neon
# provide configure with expat location under apache
LDFLAGS="-L/usr/local/apache2/lib" CPPFLAGS="-I/usr/local/apache2/include" ./configure --with-ssl
make
sudo make install
cd ..
rm -rf neon

Big Finale - Subversion

Now we have all mandatory prerequisites ready and can start building subversion itself

LDFLAGS="-L/usr/local/apache2/lib" CPPFLAGS="-I/usr/local/apache2/include" ./configure --with-ssl --with-apr=/usr/local/apache2 --with-apr-util=/usr/local/apache2 --with-apxs=/usr/local/apache2/bin/apxs --with-ssl
make

Before running make install you need to update ldconfig so create (or update if you have it already) /etc/ld.so.conf and add following lines

/usr/local/lib
/usr/local/apache2/lib

afterward update ld cache by executing

sudo ldconfig

and finally install subversion

sudo make install

Post Mortem

Now having successfuly installed apache and subversion all that's left is to configure it. Add following to the end of /usr/local/apache2/conf/httpd.conf

<Location /svn>                                        
    DAV svn                                                                   
    SVNParentPath /internal/shares/SVN   
    AuthType Basic                                                           
    AuthName "Subversion repository"                                    
    AuthUserFile /etc/svn/passwd                                      
    Require valid-user                    
</Location>

Another configuration steps you should perform are

  • change Listen from 80 to something else i.e. 78
  • change User from deamon to apache
  • change Group from deamon to apache

Now we have configured everything we need to make sure that the configuration is also valid. To do so execute:

sudo adduser apache
sudo svnadmin create /shares/internal/SVN
sudo chown -R apache:apache /shares/internal/SVN
sudo mkdir /etc/svn
sudo /usr/local/apache2/bin/htpasswd -c /etc/svn/passwd  your_svn_user_name

With all above done only remaining step is to start your apache

sudo /usr/local/apache2/bin/apachectl start

Now you can create as many svn repositories under /shares/internal/SVN as you want. To do so just


cd /shares/internal/SVN
sudo svnadmin create NewRepoName
sudo chown -R apache:apache NewRepoName

each of such the created repositories will be accessible on http://ip_of_your_box:78/svn/NewRepoName

Phenix - Come to life on restart

Optional part is to have svn to start automatically on restart of your box. To enable this just

cd /etc/init.d
sudo vi S98Apache

And add following contentto the file:

#!/bin/sh                                              
#                                                     
# Start apache                                       
#                                                     
                                                      
start() {                                             
        echo "Starting Apache"                       
        /usr/local/apache2/bin/apachectl start
        }                               
                                        
stop() {                                
        echo "Stopping Apache"               
        /usr/local/apache2/bin/apachectl -k stop
       }                        
restart() {                               
        /usr/local/apache2/bin/apachectl -k restart
     }                                          
                                           
case "$1" in                                               
    start)                                                   
      start                                                                 
      ;;     
    stop)                               
      stop                              
      ;;                                
    restart)                                  
      restart                                                   
      ;;                        
    cleanup)                              
      ;;                                   
    *)                                              
      echo $"Usage: $0 {start|stop|restart}"    
      exit 1                               
esac                                                       
                                                             
exit $?                                                                     
     

after saving the file, don't forget to make it executable by running

sudo chmod 755 S98Apache

That's it. It is that simple. It took me few hours to put the whole setup together and to make it work, so hopefully it will save time to someone else. I should also probably mention that installation was not done on a clean box, but I had already some software installed because of previous installation of Firefly described here. Notably I installed sqlite3 which I've noticed subversion picked up during configuration and installation, but you should be still OK even without it.

Good Luck!

Related Topics >>