From 1ef5e7a356439d286e3a74859a0a0a04c3b8dc90 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 26 Nov 2008 13:08:39 -0500 Subject: [PATCH] Added update.sh and some small adjustments in _bashrc. --- _bashrc | 9 +++++++-- update.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100755 update.sh 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 -- 2.26.2