From: W. Trevor King Date: Wed, 26 Nov 2008 18:08:39 +0000 (-0500) Subject: Added update.sh and some small adjustments in _bashrc. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1ef5e7a356439d286e3a74859a0a0a04c3b8dc90;p=dotfiles-public.git Added update.sh and some small adjustments in _bashrc. --- diff --git a/_bashrc b/_bashrc index d993c94..200b201 100644 --- a/_bashrc +++ b/_bashrc @@ -168,12 +168,17 @@ fi # If we don't have checked out copies of our dotfiles, get them if [ ! -d ~/.dotfiles/ ]; then + http="http://einstein.physics.drexel.edu/~wking/code/git/dotfiles.git" + ssh="http://einstein.physics.drexel.edu/~wking/code/git/dotfiles.git" + tgz="http://einstein.physics.drexel.edu/~wking/code/tar/dotfiles.tgz" if [ $GIT_INSTALLED == "true" ]; then - git clone http://einstein.physics.drexel.edu/~wking/code/git/dotfiles.git ~/.dotfiles + git clone $http ~/.dotfiles + # setup to use ssh by default. + sed -i "s/$http/$ssh/" ~/.dotfiles/.git/config else # fallback on wgetting the tarball pushd ~ - wget http://einstein.physics.drexel.edu/~wking/code/tar/dotfiles.tgz + wget --output-document dotfiles.tgz $tgz tar -xzvf dotfiles.tgz rm -rf dotfiles.tgz popd diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..6bf4855 --- /dev/null +++ b/update.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Get the current dotfiles from the server using a variety of methods. +# +# In order of decreasing preference: +# if we have git installed +# git over ssh, if there is an ssh agent running +# git over http +# otherwise +# wget a tarball + +# The default ssh url is stored in .git/config, so we don't need it here +http="http://einstein.physics.drexel.edu/~wking/code/git/dotfiles.git" +tgz="http://einstein.physics.drexel.edu/~wking/code/tar/dotfiles.tgz" + + +# Check for Git (versioning system) so we know how to get our .dotfiles +if [ -d .git ];then + GIT_INSTALLED="true" +else + GIT_INSTALLED="false" +fi + +# Check for a SSH agent +if [ -n "$SS_AUTH_SOCK" ] && [ -n "$SSH_AGENT_PID" ]; then + SSH_AGENT="true" +else + SSH_AGENT="false" +fi + +if [ $GIT_INSTALLED == "true" ]; then + if [ $SSH_AGENT == "true" ]; then + git pull || exit 1 + else + git pull $http master || exit 1 + fi +else + # fallback on wgetting the tarball + pushd ~ + wget --output-document dotfiles.tgz $tgz || exit 1 + tar -xzvf dotfiles.tgz || exit 1 + rm -rf dotfiles.tgz || exit 1 + popd +fi