You are not logged in.

#1 2009-08-26 06:07:12

jwcxz
Member
Registered: 2008-09-23
Posts: 239
Website

dotman - A Dotfile Config Manager for Multiple Environments

Some time ago, I started to get annoyed at the bothersome task of copying configuration files between my desktop, laptop, and remote environments.  First of all, copying the configs typically involved a lot of repetitive scp's. The second annoyance is a little worse: some of my dotfiles need a few special settings that are localized to one environment (e.g. just to my server), but I can't source some "local" config from the main one.

Of course, the answer was to come up with some ridiculous solution and today, I bring you:

dotman (aur package)

What on earth is it? It's a way of managing configuration files across multiple environments.  You can upload your configs to a remote repository and then download them from each of your environments.  Furthermore, when you grab them from the remote area, you can do a diff against your existing file to keep your localized changes.

Right now, dotman only supports transfer via SFTP (through Paramiko), but it's possible to add more protocols later.  The code is still a bit messy and needs some rewriting to properly handle exceptions, but as it stands, you can do quite a bit.  Take a look at the instructions on the above page to see how things work.

I've seen several different solutions to this kind of problem: some people use rsync and others use revision control systems.  I considered trying these out, but my "if you want something done right, do it yourself" mentality took hold and wouldn't let go.  So, some may consider dotman to be totally superfluous (and I might agree), but maybe others will get some use out if it.

Frankly, I wanted better diffing capabilities.  I really wanted something like Gentoo's powerful etc-update, but for now, vimdiff will have to do.

Examples:

    comp1 $ dotman commit bashrc
    -> ~/.bashrc gets uploaded to the remote repo

    comp2 $ dotman grab bashrc
    -> the remote bashrc gets pulled and vimdiff opens up, comparing your old config with the new one from the server (a copy of the old version gets stored to a backup directory)

Honestly, it's that simple.


-- jwc
http://jwcxz.com/ | blog
dotman - manage your dotfiles across multiple environments
icsy - an alarm for powernappers

Offline

#2 2009-08-26 09:25:15

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: dotman - A Dotfile Config Manager for Multiple Environments

jwcxz wrote:

First of all, copying the configs typically involved a lot of repetitive scp's. The second annoyance is a little worse: some of my dotfiles need a few special settings that are localized to one environment (e.g. just to my server)

I have often thought there had to be a better way of doing this but it's one of those things I have never really worked out. I once tried to keep a single bashrc for three machines with a whole bunch of tests in it depending on hostname bit it never really worked out.

I will definitely check this out.

Offline

#3 2009-08-26 11:05:35

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: dotman - A Dotfile Config Manager for Multiple Environments

You rock, I'll be checking this out tomorrow at work big_smile

Offline

#4 2009-08-27 02:23:14

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: dotman - A Dotfile Config Manager for Multiple Environments

EDIT: found my problem. I was missing the : between my hostname and the path to my repo...

Next problem though -- I run SSH on a non-standard port... How can I specify the port?

Last edited by fukawi2 (2009-08-27 02:26:11)

Offline

#5 2009-08-27 03:05:23

jwcxz
Member
Registered: 2008-09-23
Posts: 239
Website

Re: dotman - A Dotfile Config Manager for Multiple Environments

Ah, shoot...  I thought I built that into the regex; I must have been dreaming.  I'll have to mess with it a bit until I get that working.  Until then, you can look at the __sftpinit() function and set the port in self.ssh.connect().  I think it'd be something like:

self.ssh.connect(self.repo['host'], portnum, username=...);

-- jwc
http://jwcxz.com/ | blog
dotman - manage your dotfiles across multiple environments
icsy - an alarm for powernappers

Offline

#6 2009-08-27 03:07:37

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: dotman - A Dotfile Config Manager for Multiple Environments

Nah-uh, I ain't hacking Python... I have a personal hate on for Python and avoid writing in it at all costs tongue Happy for others to write in it though, but it does my head in.

I'll be patient and wait wink

Offline

#7 2009-08-27 03:25:20

jwcxz
Member
Registered: 2008-09-23
Posts: 239
Website

Re: dotman - A Dotfile Config Manager for Multiple Environments

Fair enough.  I've fixed the issue (and also added the ability for usernames to be optional).  I'm just updating the documentation and the new package will be ready in just a few minutes.

Edit: done!  Now, you can use the following syntaxes (or some combination thereof):

sftp://host.tld/dir1/dir2
sftp://user@host.tld/dir1/dir2
sftp://user:pass@host.tld/dir1/dir2
sftp://host.tld:22/dir1/dir2
sftp://host.tld:22:/dir1/dir2

If the user is not specified, dotman will try to use getpass.getuser() to get your username.

When I get a chance, I'll add a second protocol for local file operations (i.e. just copying files).

Last edited by jwcxz (2009-08-27 03:37:22)


-- jwc
http://jwcxz.com/ | blog
dotman - manage your dotfiles across multiple environments
icsy - an alarm for powernappers

Offline

#8 2009-08-27 06:57:49

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: dotman - A Dotfile Config Manager for Multiple Environments

Working much better, thanks smile

Offline

Board footer

Powered by FluxBB