Movin in movin out

Every time I have a new shell account I end up customizing it. Making alterations to my vimrc, screenrc or whatever. It can be a huge pain when you have lots of slightly varying configs on different machines. I wrote this little script to grab my files and create a self extracting shell script so I can easily setup my environment on multiple machines.The usage is pretty straightforward. Define your remote path, and the filename along with your user that has scp access. Then define the files you want to include. To create the archive just run the moveout script. Once the self extracting script is uploaded you can just download it and execute it.

Example Restore:

wget example.com/movein && bash movein

moveout script

#!/bin/bash
# Nick Anderson
# http://www.cmdln.org

# This script eases “moving” into a new account.
# You define files that are staple configs like your vimrc,
# .bashrc, .screenrc etc … The files are added to a self
# extracting shell script and uploaded via scp to a remote
# server. Once the self extracting shell script is available
# you can wget it and execute it.

TMPDIR=$(mktemp -d -t moveout.XXXX)
PAYLOADDIR=$TMPDIR/payload
BUILDER=$TMPDIR/build
DECOMPRESSOR=$TMPDIR/decompress

# Create directories
mkdir $TMPDIR/payload

function addFile() {
cp -R $1 $PAYLOADDIR
}

#################################################
# Remote path (uses scp)
#################################################
export REMOTEPATHSPEC=”example.com:public_html/”
export REMOTEFILE=”movein”
export REMOTESSHUSER=”remoteuser”

#################################################
# Include these files in movin #
#################################################
addFile ~/.vim
addFile ~/.bashrc
addFile ~/.bash_logout
addFile ~/.screenrc
addFile ~/.profile
#################################################

cd $TMPDIR

# Generate selfextraction builder
cat >> $TMPDIR/build < movein
else
echo “payload.tar.gz does not exist”
exit 1
fi
else
echo “payload.tar does not exist”
exit 1
fi

echo “movein created”
exit 0
EOF
chmod +x $TMPDIR/build

# Generate decompression script
cat >> $TMPDIR/decompress <

4 Comments

  • harnir Debian Unknow wrote:

    Other way is to use a distributed version control system (I prefer Darcs), that way you can easily propagate changes in your config files to other accounts.

  • Why not just use an SVN/CVS/git repository, and ssh tunnel to the machine to update it?

    It’s a good idea to version control configs anyway :) You’ll end up not needing to modify it for most machines once you’ve got a few special cases covered (or you’ll at least separate the required local changes into another chunk that you include according to hostname, or something similar).

  • I have looked in to using git to version my home directory. This is just a simpler solution. It works on systems that don’t have git installed.

  • Great concept and discussion!

    Trackback

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha