diff --git a/bootstrap.sh b/bootstrap.sh index 37d18c6..734e456 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,53 +1,13 @@ #!/bin/bash -firstRun=0 -[ "$1" == "-f" ] && firstRun=1 - -cd ~ -if [ ! -d ".dotfiles" ] -then - git clone http://adamgoldsmith.name/cgit/bootstrap.git .dotfiles - firstRun=1 -else - echo "~/.dotfiles already exists, not cloning" -fi - +git clone http://adamgoldsmith.name/cgit/bootstrap.git .dotfiles cd .dotfiles -if [ $firstRun -eq 1 ] +git remote set-url origin http://adamgoldsmith.name/cgit/bootstrap.git +git remote set-url --push origin ssh://adamgoldsmith.name:443/srv/git/bootstrap.git + +targets="$@" +if [ -n "$targets" ] then - git remote set-url origin http://adamgoldsmith.name/cgit/bootstrap.git - git remote set-url --push origin ssh://adamgoldsmith.name:443/srv/git/bootstrap.git -else - echo "Updating .dotfiles" - git pull + ./getter.sh "$@" + ./stower.sh "$@" fi - -echo "Getting emacs, zsh, and git" -for i in emacs zsh git -do - git clone "http://adamgoldsmith.name/cgit/dotfiles/$i.git" - cd $i - git remote set-url origin http://adamgoldsmith.name/cgit/dotfiles/$i.git - git remote set-url --push origin ssh://adamgoldsmith.name:443/srv/git/dotfiles/$i.git - cd .. -done - -echo "getting prezto" -cd zsh -git submodule init -git submodule update - -echo "Updating .dotfiles/zsh/.zprezto" -cd .zprezto -if [ $firstRun -eq 1 ] -then - git remote set-url origin http://adamgoldsmith.name/cgit/prezto.git - git remote set-url --push origin ssh://adamgoldsmith.name:443/srv/git/prezto.git - git remote add upstream https://github.com/sorin-ionescu/prezto.git -fi -git submodule init -git submodule update - -echo "Stowing emacs, zsh, and git" -cd ~/.dotfiles/ -stow emacs zsh git diff --git a/getter.sh b/getter.sh new file mode 100755 index 0000000..543c849 --- /dev/null +++ b/getter.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +targets="$@" +for t in $targets +do + if [ -d "$t" ] + then + echo "$t already exists, not getting" + else + echo "Getting $t" + git clone "http://adamgoldsmith.name/cgit/dotfiles/$t.git" + cd $t + git remote set-url origin http://adamgoldsmith.name/cgit/dotfiles/$t.git + git remote set-url --push origin ssh://adamgoldsmith.name:443/srv/git/dotfiles/$t.git + cd .. + fi +done diff --git a/stower.sh b/stower.sh new file mode 100755 index 0000000..63dd4d1 --- /dev/null +++ b/stower.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +targets="$@" +for t in $targets +do + if [ -d "$t" ] + then + echo "Stowing $t" + if [ -e "$t/PRESTOW" ] + then + echo "Running $t/PRESTOW" + "$t/PRESTOW" + fi + + stow -t"$HOME" --ignore="^PRESTOW$" --ignore="^POSTSTOW$" "$t" + + if [ -e "$t/POSTSTOW" ] + then + echo "Running $t/POSTSTOW" + "$t/POSTSTOW" + fi + else + echo "target $t does not exist or is not a directory" + exit + fi +done