#! /bin/bash -ex

host=$1
name=shell-env
repo="https://github.com/guppy4j/${name}.git"
dir=".${name}"

ssh_run() {
  ssh "${host}" -C "$1"
}

ssh_run "rm -rf ${dir}"
ssh_run "svn co ${repo} ${dir}" || ssh_run "git clone ${repo} ${dir}"

etc="${dir}/src/main/config/etc"
scripts="${dir}/src/main/scripts"

ssh_run "ln -s --force --backup=simple ${etc} .etc"
ssh_run "ln -s --force --backup=simple ${scripts} ."
ssh_run "chmod ugo+x ${scripts}/*.sh"

ssh_run "${scripts}/setup-symlinks.sh"


#! /bin/bash -ex

name=shell-env
source="https://github.com/guppy4j/shell-env.git"
target=$1

ssh_run() {
  ssh $target -C "$1"
}

ssh_run "svn co ${source} .${name}" || ssh_run "git clone ${source} .${name}"

scripts=".${name}/src/main/scripts"
etc=".${name}/src/main/config/etc"

ssh_run "ln -s --force --backup=simple ${etc} .etc"
ssh_run "ln -s --force --backup=simple ${scripts} ."
ssh_run "chmod ugo+x ${scripts}/*.sh"

ssh_run "${scripts}/setup-symlinks.sh"


--- 
+++ 
@@ -1,19 +1,17 @@
 #! /bin/bash -ex
 
-host=$1
 name=shell-env
-repo="https://github.com/guppy4j/${name}.git"
-dir=".${name}"
+source="https://github.com/guppy4j/shell-env.git"
+target=$1
 
 ssh_run() {
-  ssh "${host}" -C "$1"
+  ssh $target -C "$1"
 }
 
-ssh_run "rm -rf ${dir}"
-ssh_run "svn co ${repo} ${dir}" || ssh_run "git clone ${repo} ${dir}"
+ssh_run "svn co ${source} .${name}" || ssh_run "git clone ${source} .${name}"
 
-etc="${dir}/src/main/config/etc"
-scripts="${dir}/src/main/scripts"
+scripts=".${name}/src/main/scripts"
+etc=".${name}/src/main/config/etc"
 
 ssh_run "ln -s --force --backup=simple ${etc} .etc"
 ssh_run "ln -s --force --backup=simple ${scripts} ."
Use simpler variables and always clear install dir
