2009-07-28 01:44:19 -07:00
|
|
|
#!/usr/bin/env bash
|
2009-10-10 10:06:36 -10:00
|
|
|
# This script links your clone into $install_base, so you can keep the .git
|
|
|
|
# directory out of the way. Default for no parameters is /usr/local
|
2009-07-28 01:44:19 -07:00
|
|
|
|
|
|
|
mode=$1
|
|
|
|
if [[ -z $mode ]]; then
|
|
|
|
mode="install"
|
|
|
|
fi
|
|
|
|
|
2009-10-10 10:06:36 -10:00
|
|
|
install_base=$2
|
|
|
|
if [[ -z $install_base ]]; then
|
|
|
|
install_base="/usr/local"
|
|
|
|
fi
|
|
|
|
|
2009-07-28 01:44:19 -07:00
|
|
|
source_base=`pwd`
|
|
|
|
|
|
|
|
if [[ $mode == install ]]; then
|
2009-10-10 10:06:36 -10:00
|
|
|
# Ensure that the Cellar exists -- otherwise Homebrew breaks
|
2009-07-28 01:54:45 -07:00
|
|
|
if [[ ! -e "$source_base/Cellar" ]] ; then
|
2009-12-04 22:33:09 -08:00
|
|
|
mkdir -p "$install_base/Cellar"
|
2009-07-28 01:54:45 -07:00
|
|
|
fi
|
|
|
|
|
2009-12-04 22:33:09 -08:00
|
|
|
if [[ ! -e "$source_base/bin" ]] ; then
|
2009-10-10 10:06:36 -10:00
|
|
|
mkdir -p $install_base/bin
|
2009-07-31 21:38:46 -07:00
|
|
|
fi
|
|
|
|
|
2009-10-10 10:06:36 -10:00
|
|
|
ln -s "$source_base/bin/brew" "$install_base/bin/brew";
|
|
|
|
ln -s "$source_base/Cellar" "$install_base/Cellar";
|
2009-07-28 01:54:45 -07:00
|
|
|
elif [[ $mode == undo ]]; then
|
2009-10-10 10:06:36 -10:00
|
|
|
if [[ -h "$install_base/bin/brew" ]] ; then
|
|
|
|
rm "$install_base/bin/brew"
|
2009-07-28 01:54:45 -07:00
|
|
|
fi
|
|
|
|
|
2009-10-10 10:06:36 -10:00
|
|
|
if [[ -h "$install_base/Cellar" ]] ; then
|
|
|
|
rm "$install_base/Cellar"
|
2009-07-28 01:54:45 -07:00
|
|
|
fi
|
2009-07-28 01:44:19 -07:00
|
|
|
else
|
|
|
|
echo "Unknown command: $mode";
|
2009-12-04 22:33:09 -08:00
|
|
|
echo " selflink.sh [install] >> symlinks to $install_base"
|
|
|
|
echo " selflink.sh undo >> removes symlinks from $install_base"
|
2009-07-28 01:44:19 -07:00
|
|
|
fi
|