Setting up a subversion repository

This is a bit old. From 2008 to be exact. But, I am putting it out there for reference anyway.

1. Install packages:
sudo apt-get install subversion libapache2-svn libapache-mod-dav apache2

 

Note: libapache-mod-dav is included in libapache2.2-common, so it may be unavailable or you do not need it.

 

2. Enable SSL:
sudo a2enmod ssl

 

check the ports.conf file, if ssl is already enabled we do not need to do the following:
sudo sh -c “echo ‘Listen 443’ >> /etc/apache2/ports.conf”

 

3. Generate Certificate:
Ubuntu < Feisty:
sudo apache2-ssl-certificate
Use the server name to be used for access the web server.

Ubuntu >= Feisty:
sudo apt-get install ssl-cert
sudo mkdir /etc/apache2/ssl
sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem

 

4. Create Virtual Host:
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/$SITENAME
sudo vim /etc/apache2/sites-available/$SITENAME
change:
NameVirtualHost *:443
<VirtualHost *:443>
add:
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM

 

5. Enable the site:
sudo a2ensite $SITENAME
sudo /etc/init.d/apache2 restart

A warning that complaints about failure of server name determination can be fixed by adding ServerName $SERVERNAME to the main Apache config /etc/apache2/apache2.conf

 


6. Adding repository(ies):
The following setup assumes we want to host multiple repositories.

$REPOS is “nbty” currently
sudo mkdir /var/svn/repositories
sudo svnadmin create /var/svn/repositories/$REPOS
sudo chown -R www-data:www-data /var/svn/repositories/$REPOS
sudo chmod -R g+ws /var/svn/$REPOS

 

7. Adding Basic Authentication:

$AUTH_USER is svn with password mypassword
sudo htpasswd -c -m /etc/apache2/dav_svn.passwd $AUTH_USER

 

8. Enable and configure WebDAV and SVN:
Add to /etc/apache2/mods-available/dav_svn.conf
DAV svn
SVNParentPath /var/svn/repositories
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
SSLRequireSSL

and for non-anonymous access comment out:
#<LimitExcept GET PROPFIND OPTIONS REPORT>
#</LimitExcept>

(optionally the same configuration can be set for particular virtual host only, i.e. /etc/apache2/sites-available/$SITENAME)

 

$SITENAME is svn (ssl on svn01 and svn02)

 

Add to $SITENAME in /etc/apache2/sites-available:

# Specially log any Subversion operations.

CustomLog /var/log/apache2/svn.log “%t %u %{SVN-ACTION}e” env=SVN-ACTION

 

<Location /svn/company>

DAV svn

SVNPath /var/svn/repositories/company

SVNReposName “Companies Main Subversion Repository”

</Location>

 


9. Finalization:
sudo /etc/init.d/apache2 restart

 

Testing:

$REPOS = company
Web access:
lynx https://svn01/svn/$REPOS exposes the repository.
lynx http://localhost/svn/$REPOS says: eat my shorts , i.e. 403-forbidden.

 

Now the sync:

 

  1. cd /var
  2. sudo mkdir svn
  3. sudo mkdir svn/repositories
  4. sudo svnadmin create /var/svn/repositories/company
  5. sudo adduser svn
    1. yourpassword is pwd
  6. sudo vipw
    1. change svn line from /bin/bash to /bin/false….we don’t want this user to log in to shell

 

 

Need to

 

 

An initial import:
svn import –username $AUTH_USER $A_FILE https://localhost/svn/$REPOS/testdir -m “Testing”

… and check-out:
svn co –username $AUTH_USER https://localhost/svn/$REPOS

To add a new repository just repeat the step 6 (without making the root directory of course).
If you wish to configure a single repository only, instead of point 6:
sudo svnadmin create /var/svn
sudo chown -R www-data:www-data /var/svn
sudo chmod -R g+ws /var/svn

and in /etc/apache2/mods-available/dav_svn.conf (step 8) use this instead of SVNParentPath:
SVNPath /var/svn

 

sudo svnsync initialize file:///var/svn/repositories/nbty https://svn01/svn/company –username svn –password yourpassword

 

sudo svnsync synchronize file:///var/svn/repositories/company –username svn –password yourpassword

Shell script to list current website IP

If your sites are in multiple geographical locations, this script will show where a site currently is being served from. It colors the output based on location.

#!/bin/bash
# where_are_you.sh
#do a dig against the company name servers and spit out the current IP of the sites.

array=( www.site.com www.site2.com www.site3.com www.site99.com )

for i in “${array[@]}”
do
dig @ns.server.company $i a | grep -v ‘;’ |grep $i | awk ‘{ if ( substr($5, 1, 8) == “x.x.x” ) printf “%-30s %s\n”, “\033[1;32;40m”$5,$1; else printf “%-30s %s\n”, “\033[1;34;40m”$5,$1 }’

done | sort -n
tput sgr0

Automatically update New Relic after app deployment.

I use TeamCity to build and deploy web applications. Using curl and an additional build step, I can update New Relic when the build is deployed to production.

Add a Build Step of build runner type Command Line. The command and options are:

curl -H “x-api-key:xxxxxxxxxxxxxxxx” -d “deployment[application_id]=xxxxxx” -d “deployment[host]=%system.agent.name%” -d “deployment[description]=This deployment was sent using curl.” -d “deployment[revision]=”%build.number% https://rpm.newrelic.com/deployments.xml

This will update New Relic with the build agent and build number.

Watching log files

Multitail is a nice utility to watch multiple log files at once. It also can color the output.

I usually use the command like this:

multitail -s 2 /var/log/apache2/site01_access.log /var/log/apache2/site02_access.log

http://www.vanheusden.com/multitail/index.php

Tealeaf Troubleshooting

There is a delay processing data acquired after 03/05/2013 21:22:20. Reports, alerts and indexes may not have complete data until the processing completes. 

Every once in a while, my Tealeaf instance goes belly up. It is usually the Canister Server. Here is how I fix it.

First, check Services Control Panel. You may notice some of the Tealeaf services are stopped or in a Stopping state. Now use the Stop Tealeaf Services applet to stop all of the Tealeaf services. If the applet gets stuck stopping a service, end the process in Task Manager. Wait for the applet to close.

Ensure that the only services running are the TeaLeaf Management Service and the TeaLeaf Transport Service. Now use the Start Tealeaf Services applet to start all the services. Once the applet closes, check to see if all the services are started.

You should now see a process named TLTMaint.exe running. When this process finishes, the queued packets will start decreasing in the pipeline.