selflink.sh install directory is now configurable
Signed-off-by: Max Howell <max@methylblue.com> I preserved the behaviour where the whole Library directory is symlinked as no explanation for this change was given…
This commit is contained in:
parent
9802bb0e19
commit
3e04b3f0d6
@ -1,41 +1,46 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# This script links your clone into /usr/local, so you can keep the .git
|
# This script links your clone into $install_base, so you can keep the .git
|
||||||
# directory out of the way.
|
# directory out of the way. Default for no parameters is /usr/local
|
||||||
|
|
||||||
mode=$1
|
mode=$1
|
||||||
if [[ -z $mode ]]; then
|
if [[ -z $mode ]]; then
|
||||||
mode="install"
|
mode="install"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
install_base=$2
|
||||||
|
if [[ -z $install_base ]]; then
|
||||||
|
install_base="/usr/local"
|
||||||
|
fi
|
||||||
|
|
||||||
source_base=`pwd`
|
source_base=`pwd`
|
||||||
|
|
||||||
if [[ $mode == install ]]; then
|
if [[ $mode == install ]]; then
|
||||||
# Ensure that the Cellar exists
|
# Ensure that the Cellar exists -- otherwise Homebrew breaks
|
||||||
if [[ ! -e "$source_base/Cellar" ]] ; then
|
if [[ ! -e "$source_base/Cellar" ]] ; then
|
||||||
mkdir -p "$source_base/Cellar"
|
mkdir -p "$source_base/Cellar"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -e "/usr/local/bin" ]] ; then
|
if [[ ! -e "$install_base/bin" ]] ; then
|
||||||
mkdir -p /usr/local/bin
|
mkdir -p $install_base/bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -s "$source_base/bin/brew" "/usr/local/bin/brew";
|
ln -s "$source_base/bin/brew" "$install_base/bin/brew";
|
||||||
ln -s "$source_base/Library" "/usr/local/Library";
|
ln -s "$source_base/Library" "$install_base/Library";
|
||||||
ln -s "$source_base/Cellar" "/usr/local/Cellar";
|
ln -s "$source_base/Cellar" "$install_base/Cellar";
|
||||||
elif [[ $mode == undo ]]; then
|
elif [[ $mode == undo ]]; then
|
||||||
if [[ -h "/usr/local/bin/brew" ]] ; then
|
if [[ -h "$install_base/bin/brew" ]] ; then
|
||||||
rm "/usr/local/bin/brew"
|
rm "$install_base/bin/brew"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -h "/usr/local/Library" ]] ; then
|
if [[ -h "$install_base/Library" ]] ; then
|
||||||
rm "/usr/local/Library"
|
rm "$install_base/Library"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -h "/usr/local/Cellar" ]] ; then
|
if [[ -h "$install_base/Cellar" ]] ; then
|
||||||
rm "/usr/local/Cellar"
|
rm "$install_base/Cellar"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Unknown command: $mode";
|
echo "Unknown command: $mode";
|
||||||
echo "\tselflink.sh [install] >> symlinks to /usr/local"
|
echo "\tselflink.sh [install] >> symlinks to $install_base"
|
||||||
echo "\tselflink.sh undo >> removes symlinks from /usr/local"
|
echo "\tselflink.sh undo >> removes symlinks from $install_base"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user