
October 2009
August 2009
April 2009
March 2009
December 2008
October 2008
September 2008
August 2008
July 2008
June 2008
A few months ago, I wrote a post about installing svnserve on DV hosting at Media Temple. It was a great quick solution to get started, but I really wanted to get to svn via ssh instead for the long term.
Rather than scour the Internet for how to do this (I’ve done it a few times in my career, but I’m no sysadmin), I sat down for lunch one day with Collin, who used to be a mighty fine sysadmin! Saved me hours of time, hopefully this will help some of you all too.
Keep in mind that you’ll have to check out your files from scratch, so you’ll want to make sure all of your current changes are checked in (or otherwise managed) before you get started on this project.
Log into your server. I have root access from ssh disabled, and you may want to consider doing this as well.
I use the su – username notation to be sure the console session is refreshed. Now add a new group called svn that members will be a part of
Because we’re on CentOS, there are certain permissions that make the owner only having default permissions of the file, so we’ll have to deal with that here as well so that we can avoid permissions issues when users commit their changes to SVN.
Take a look to verify, in the group file, that your user is added to the correct group:
You also want to verify that svn is the secondary group by doing this:
You should see something like this:
Now you’ll set up the ssh keys. We’ll set up dummy keys for now because we’re going to copy the public key from our local computer, not the other way around. Make sure you are still acting as the new user.
when it prompts you for a filename, enter id_rsa
when it prompts you for a password, hit enter, leave it blank, we won’t be using these keys.
Now, go back to you local computer and generate the keys again as described above, but this time use a password. If you already have keys, you’ll just need to copy them to the server.
From your local computer, do a secure copy. My keys happen to be named identity. Also note that I am renaming the keys to authorized_keys2 for this CentOS environment.
Double check that the user can now log in properly without any trouble. Now to go back and change the permissions on the repository
You’ll want to make sure your repository has a group owner of svn and a user owner of someone in that group. Make sure you’re running as root here, and it never hurts to refresh the console using the dash notation.
Since the owner can read/write but the group can only read/view on the CentOS, we need to change the default umask for the user to avoid collisions:
In the .profile file, add the following:
then reload the environment again by doing:
Now we need to make joe’s default group SVN:
Now refresh enviro
You should see something similar to the following–notice the default group is svn now:
Now, if you’d previously been using svnserv, you’ll want to turn it off. Let’s start by viewing the running processes on the server:
I had more than one instance running, so I ended up doing the following (do at your own risk)
Double check that you can then check out, change and commit files. If you can’t, there is likely a permissions issue. Also double check that you can’t access the repository with plan svn://. If so, you may have not properly terminated svnserve. You will also want to clean up for yourself by making sure that you’ve removed any information from the passwd and svnserv.conf files in the /var/svn/reponame folder.
Cheers!
Tags: reference, server admin, ssh, svn
I’ve been spending a lot of time on Wicket lately for some exciting things that will be coming soon from Me.dium. One cool trick I started using the ListView. If you’ve come from PHP or any other web language, you know the drill– display query data from the database on a web page.
Here’s a simple implementation of the ListView to help you get started. I’m going to take a list of employees and output them to the screen. This tutorial assumes you know the basics of how Wicket works. This is the portion where we’re adding components to the display piece.
EmployeesPage.java
//Now I’ll populate the ListView with the query results
add(new ListView(“employeesRptr”, employees) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem item) {
User employee = (User) item.getModelObject();
// image display
item.add(new StaticImage(“profilePic”, new Model(employee.getPicture())));
// name display
StringBuilder name = new StringBuilder();
name.append(employee.getFirstName());
name.append(” “);
name.append(employee.getLastName());
item.add(new Label(“profileName”, name.toString()));
// location display
item.add(new Label(“profileLocation”, employee.getLocation()));
}
});
Now for the display:
EmployeesPage.html
<span wicket:id=”employeesRptr”>
<img wicket:id=”profilePic” border=”0″ />
<p class=”name” wicket:id=”profileName”>Joe Schmo</p>
<p class=”location” wicket:id=”profileLocation”>location</p>
</span>
Enjoy!
Tags: frameworks, Java, reference, wicket
I’ve been using CodeIgniter now for a new project I’m working on called Giftola. CodeIgniter is an MVC framework for PHP. I like CodeIgniter because it’s very lightweight, yet it offers some pre-built functionality to deal with some of the tedium (like form validation) of web development.
I’ve used other PHP frameworks in the past, and I find the way CI organizes files to be very intuitive and things are easy to find.
One problem with using frameworks is that often developers don’t actually utilize all of the features of the framework, often reinventing the wheel. In this post, I’m going to go over a very simple, but useful feature of CI, helpers.
Helpers are functions that are stored in a central location in the CI framework, and then utilized anywhere in the application. I’m going to demonstrate a simple helper I wrote called timestamp. Timestamp formats a date time string for SQL insertion. This helper allows me to ensure consistency across my entire application.
Here’s how they work.
CI has its own helper functions, which are located in:
You can add your own helper functions to the following location:
Your file must be named in the form: helpername_helper.php. In my case, I’m going to create a file called:
where I’ll write a very simple function:
function timestamp(){
return date(“Y-m-d H:i:s”);
}
?>
I use this function most often in my Models, so I’ll load it up here. In this case, I have an event model, where I’ll use the helper quite a bit. So, I’ll load it in the constructor.
function Event_model()
{
parent::Model();
$this->load->helper(‘timestamp’);
}
}
?>
Finally, when I want to grab a timestamp, I simply call the function:
A pretty simple example, but hopefully it will get you thinking on how to consolidate functionality that you use often into the helpers structure.
Tags: CodeIgniter, frameworks, php, reference
(UPDATE: I’ve posted a followup to this article here.)
I just got myself a (dv) account at MediaTemple and set out to install SVN. I found pretty much nothing in their knowledge base on how to do this. I do this task so infrequently (but yet often enough to care), that each time I have to re-familiarize myself with how to set up Subversion repositories. Hopefully this post will save us all some agony when it’s time again to set up a new svn repo.
Contrary to some other blog posts out there, the (dv) hosting package actually DOES include Subversion, but you have to enable it through the developer tools [A complete list of the developer tools you get can be found here].
I have a brand new server and nothing on it yet, so I’m comfy doing this cowboy style. However, if you are adding SVN to an existing server, consider purchasing a snapshot that will preserve all settings prior to starting this process. Unfortunately, the free backup won’t do the trick.
First off, be sure that you have an account that has ssh privileges into your server. This could be your ftp account or another ssh user you set up for these purposes. This can be done in the Plesk control panel (process not covered here but can be found via the MediaTemple knowledge base).
Go to the overview tab
Click on your primary domain
Click “Root Access and Developer Tools”
Click “Install Developer Tools”
Now that your developer tools are enabled, you want to enable root access so that you can administer your tools.
Now you’ve opened up a can of worms enabling root access. One of the ways to contain those worms is to disable ssh for root as outlined here.
Next, ssh into your server using the user account created prior to starting this task and run the following command:
You will be prompted for the password you created when you enabled root access. You have to install and configure svn as root so that it has the correct permissions to write/save/generally do it’s thing.
We’ll pretend our new repository name is called reponame but you can choose any name you want here and this is what you’ll do each time you make new repositories that are served from this instance of Subversion.
Please note that I did not use Berkeley DB (instead I used fsfs as noted in the create command above). I have not had good experiences with Berkely DB and avoid using it, no offense I’m sure there’s a place for it and good intentions behind it.
% vi /var/svn/reponame/conf/svnserve.conf
configure the following items thusly:
anon-access = none
auth-access = write
password-db = passwd
realm = My Repo Yay
(ok, not really sure what realm is for other than it’s cute and displays when you checkout, but if you know a secret awesome benefit, please share!)
Next it’s time to create the authentication piece. Time for more vi
Each name = password pair must be in plain text. There are ways to set this up so that the passwords can be encrypted using Perl’s crypt but that is not covered here as this is the “Simple SVN setup”
Finally you need to start your svn daemon. Please note that there are other options for svnserve and you should familiarize yourself with the documentation just to be sure.
You can check out (or run similiar svn commands) from your local machine thusly:
Note that your domain.com is yours and could also represent a subdomain if you know how to configure that.
There are lots of other fine tunings and tweaks you can do to fit your needs, but this is the Simple svn setup, no? Tools like Eclipse’s SVN plugin make it even easier to utilize this method in terms of password caching and the like.
Lastly, the grad school training in me wants to cite sources, so here you go:
Version Control with Subversion reference
gregsidberry.com
tonyspencer.com
MediaTemple.net (dv) Developer’s Tools and Packages Listing
An Introduction to the Root User
How to disable ssh for root user
MediaTemple backup options
Tags: reference, server admin, svn