Moving SVN Repos

April 16, 2012

This one could obviously use some cleaning up and revision, but it’s a pretty effective script for moving from an older SVN to a newer one.

Note that it relies on my previously posted script for creating repositories, a text file of repositories that you want moved, and a and svnrdump, a new feature for Subversion that allows you to remotely dump a repo via HTTPS.

This script checks local and remote versions, dumps 1000 revisions to a .dmp file, commits that, and moves on to the next repo. It could easily be modified to run in a loop.


#!/bin/bash -l
cd [SVN script location]

logfile=./update_good_repos.log
repolist=$(cat ./good_repos.txt)

echo "About to update the following repos:"
echo $repolist
echo "This could take a VERY long time."
#echo "Press any key to continue..."
#read -n1 any_key0

for repo in $repolist
do
localversion=$(svn info [local SVN]/$repo --trust-server-cert --username [username] --password [password] --non-interactive | sed -n 's/^Last Changed Rev: //p')
if [ -z $localversion ]
then
# echo "localversion is null"
./create_repository.sh $repo
localversion=0
fi
localversion=$(svn info [local SVN]/$repo --trust-server-cert --username [username] --password [password] --non-interactive | sed -n 's/^Last Changed Rev: //p')
remoteversion=$(svn info [remote SVN]/$repo --trust-server-cert --username [username] --password [password] --non-interactive | sed -n 's/^Last Changed Rev: //p')
increment=$(($localversion+1000))
if [ $increment -gt $remoteversion ]
then
increment=$remoteversion
fi
echo -e "$repo\t\tLocal:$localversion\t\tRemote:$remoteversion"
if [ $localversion -lt $remoteversion ]
then
echo -e "Dumping versions $(($localversion+1)) through $increment of repo $repo to [SVN dump location]/$repo/$(($localversion+1))-$increment.dmp"
mkdir -p /[SVN dump location]/$repo
/usr/local/bin/svnrdump dump --trust-server-cert --username [username] --password [password] --non-interactive --incremental -r $(($localversion+1)):$increment [Remote SVN]/$repo > [SVN dump location]/$repo/$(($localversion+1))-$increment.dmp
/usr/local/bin/svnadmin load [local SVN]/$repo < [SVN dump location]/$repo/$(($localversion+1))-$increment.dmp
fi
done


Creating SVN Repositories

April 16, 2012

Here’s a quick and easy script for creating repositories using a centralized svnserve.conf file and apache_auth.conf file:


#!/bin/bash -l
svnrepos=[path to svn repos]
svnconfigs=[path to svn configs]

echo "Creating folder $svnrepos/$1"
mkdir $svnrepos/$1
echo "Creating svn repository at $svnrepos/$1"
/usr/local/bin/svnadmin create $svnrepos/$1
echo "Linking to master config"
rm $svnrepos/$1/conf/passwd
rm $svnrepos/$1/conf/svnserve.conf
ln -s svnconfigs/apache_auth.conf $svnrepos/$1/conf/svnserve.conf
ln -s svnconfigs/svn-auth-file $svnrepos/$1/conf/passwd
echo "Changing owner and permissions"
chown -R apache:apache $svnrepos/$1
chmod -R g+w $svnrepos/$1
echo "Configuring pre-revprop-change hook script"
cp svnconfigs/hooks/pre-revprop-change.tmpl $svnrepos/$1/hooks/pre-revprop-change
chmod a+x $svnrepos/$1/hooks/pre-revprop-change
echo "Done"


Building a Jenkins Slave Node

April 6, 2012

In our environment we use Jenkins CI for doing continuous integration of developer code. Setting up Jenkins server is plenty easy, but getting a node up and running has some road bumps. Here’s the process of getting any Windows7 desktop to perform builds of .NET4 code:

Install Required Build Tools

Once you’ve got all that installed, copy aspnet_merge.exe from C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools to C:\Program Files (x86)\MSBuild\Microsoft\WebDeployment\v10.0\

 

Create Node in Jenkins

Perform the following tasks from the new Jenkins slave

  1. Log into Jenkins, click Manage Jenkins, Manage Nodes, New Node
  2. Give it a name, and choose Dumb Slave
  3. Set up options for you new slave
    1. Description: optional
    2. # of executors: number of processors on the slave
    3. Remote FS Root: where Jenkins will store data (try to use a second drive/partition so you don’t accidentally fill up the boot partition.
    4. Labels: separate labels with spaces, useful for designating what projects can be compiled on each system – ex. “.NET4″ “Java”, or for grouping systems. Jobs can be configured to use only nodes with appropriate labels.
    5. Usage: whatever you prefer
    6. Launch Method: Launch Slave agents via Java Web Start
    7. Availability: whatever you prefer
  4. Click the name of the slave you just created
  5. Click the Launch button
    1. Accept security warnings to run plugin
    2. A tiny window will pop up that says “Connected”
    3. Click File > Install as a Windows service if you want it to become available on restart.

The system should now appear in Jenkins as an online slave.


Getting Started with OS X

February 14, 2012

I needed to write this up for one of the guys in the office, but I thought the world might get some use out of it, so I’m adding it here.

Applications I can’t live without:
Adium – IM client that works with everything
TextWrangler – good for editing code (syntax highlighting), there are other options, but this is what I use.
MS Remote Desktop – gotta RDP into Windows machines. May already be installed.
iTerm2 – WAY better than Putty or the Terminal
Quicksilver – I don’t use it, but power users absolutely swear by it. Worth trying.
Unarchiver – unzips anything
VLC – video player.

I’m sure you’ll need an SVN client. I’ve been using Synchro and haven’t had problems, but you might want to ask around since I’m not a developer and rarely use it.

Some guides you might find useful:
Basics of switching (a little dated, but not inaccurate):

http://lifehacker.com/224674/hack-attack-a-guide-for-switching-to-a-mac

Good tips for customizing & working with the interface:

http://www.huffingtonpost.com/2011/05/03/mac-os-x-tips-tricks_n_855102.html

Apple’s 101:

http://www.apple.com/support/switch101/

Apple’s list of keyboard shortcuts (WAY long):

http://support.apple.com/kb/HT1343

…find the ones you need and copy (Cmd + C) and paste (Cmd + V) them into a document.

Also, Cmd + Space is Spotlight. I use that all day every day to find documents, launch applications, etc.


List of New Files Shell Script

June 24, 2011

This one goes out to the nerds.

This is a pretty sweet bash script that I wrote today…

One of our Windows machines needed a to-do list of files to be processed based on files that had been created on several Linux boxes. The solution was to write a script on the Linux boxes that did the following:

  1. Get the current to-do list from the Windows box,
  2. Get a list of any files that had changed in the last few minutes,
  3. Strip the path and extension
  4. Append any new items to the to-do list,
  5. Copy the list back to the Windows box.

We’d be using this script to do some verification on new containers created in WebSphere, but you can use the basic idea for whatever you may need.

A couple of great things about this:

  • it will continue compiling the list even if the connection between the two machines is lost
  • each item appears on the list only once, so if a file is changed multiple times before the list is processed, the item will only be processed once
  • multiple machines can run the same script and keep appending to the same to-do list on a remote system

So here’s the script:

#Copy remaining "to_process" from Windows
cat /mnt/282787svnsrv/to_process.txt > /home/wasadmin/scripts/newContainers/to_process.txt
cat /mnt/282787svnsrv/to_process.txt > /home/wasadmin/scripts/newContainers/todo.txt

#Get any new containers
/usr/bin/find /opt/ibm/loganalysis/tmp -type f -cmin -5 -name *.ear | /bin/sed 's/.*\///' | /bin/sed 's/\(...*\)\..*/\1/' > /home/wasadmin/scripts/newContainers/newCont.txt

#Append "new Containers" not in "todo" to end of "todo"

#/usr/bin/comm -23 /home/wasadmin/scripts/newContainers/newCont.txt /home/wasadmin/scripts/newContainers/todo.txt >> /home/wasadmin/scripts/newContainers/todo.txt
cat /home/wasadmin/scripts/newContainers/to_process.txt > /home/wasadmin/scripts/newContainers/todo.txt
cat /home/wasadmin/scripts/newContainers/newCont.txt >> /home/wasadmin/scripts/newContainers/todo.txt
sort -u /home/wasadmin/scripts/newContainers/todo.txt > /home/wasadmin/scripts/newContainers/to_process.txt

#Copy "to_process" back
cat /home/wasadmin/scripts/newContainers/to_process.txt > /mnt/282787svnsrv/to_process.txt

And this is the cron entry to have this process every 20 minutes:

*/20 * * * * /home/wasadmin/scripts/newContainers/newContainers.sh 2>&1 > /dev/null

SNMP OID for Disk Usage on a Mac

March 30, 2011

.1.3.6.1.2.1.25.2.3.1.6.31

It took me a really long time to find that, but that’s the OID for this MIB:

.iso.org.dod.internet.mgmt.mib-2.host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageUsed.31

Which, when divided by 262144 gives you the total GB used on a Mac HD.

I know you don’t care. But I do.

I got it by running this command to get the MIB descriptions and finding the value I needed (4096/1024^3 = 1/262144):

snmpwalk -c whp localhost

Then I ran this to get the MIBs for everything:

snmpwalk -Os -c whp -v localhost

Then I searched the output of that command for the same value as was returned by the first command, and Bob’s your uncle.


Thank you

September 19, 2010

I am in awe.
I have the most amazing friends of all time.
My mind is blown.


New York City

May 2, 2010

I’m in NYC on a business trip and though I worked an 11 hour day yesterday, have spent all my free time wandering SoHo.

I could definitely live here, though it is hipster central. The picture is hundreds of them crowding the opening of Shepard Fairey’s opening last night.

We got lunch yesterday at this little Italian sandwich shop called Alidoro and it was awesome. Highly recommended and apparently little-known.

Last night I went to this bar called “The Room” because they specialize in beer. I talked to the bar tender (Rob) a little and he gave me some recommendations for other places that have good beer lists. So after I finished a couple of beers there (I’d had almost their entire draft and bottle menu) I went to one of them.

Blind Tiger (7th & Bleeker) was awesome. They’d just had an event with Bear Republic from CA and their menu was almost all BR and lots I’d never had or seen before. Including an imperial IPA on cask. I told the bartender Rob had sent me and he hooked me up.

The others he recommended:
DBA (1st? 4th? Near there.)
Union Pool (hipster alert)
Trophy (on Broadway, tell ‘em Rob sent you)
Hot Bird (Clinton & Atlantic, Rob’s other job)

This is mostly for my future reference since I’ll likely be back here soon, but thought anyone reading this might like to know where to get beers in NYC.


OS X Command to return last successful backup

January 14, 2010

This may not be useful to everyone, but it’s useful to me, so I’m documenting it here.

At my work we have a number of systems that use Time Machine to back up locally or to remote, networked storage.

Part of my job is to make sure that this is working properly for all users. Until I figured this out, I would have to walk around to each computer, or call up each user, and manually check using the Time Machine preferences. This can take hours (or days if they’re not available), and is a major hassle for everyone involved.

This is much better.

This is the UNIX command to return the last 5 successful backups for OS X:

grep “Backup completed successfully.” /var/log/system.log | sed s_/System/Library/CoreServices/__g | tail -n 5

By issuing this command via Apple Remote Desktop, I get a quick report breaking down each computer and the last 5 times it was backed up.


…and I quote…

December 30, 2009

“And so these parties divided upon the midnight plain, each passing back the way the other had come, pursuing as all travelers must inversions without end upon other men’s journeys.”

-Cormac McCarthy in
Blood Meridian


Follow

Get every new post delivered to your Inbox.