Skip to content

Commit 302685d

Browse files
committed
simplify the install script
1 parent abed9e9 commit 302685d

File tree

1 file changed

+14
-36
lines changed

1 file changed

+14
-36
lines changed

support/bin/install-silver-bin

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,51 +28,29 @@ fi
2828

2929
echo "Found ~/bin"
3030

31-
case `uname` in
32-
*Darwin*)
33-
READLINK=greadlink
34-
if [ ! -f `which greadlink` ]; then
35-
echo "Missing greadlink. Please install coreutils:"
36-
echo -e "\tbrew install coreutils"
37-
exit 4
38-
fi
39-
;;
40-
*)
41-
READLINK=readlink
42-
;;
43-
esac
31+
# get REPO location from git
32+
REPO=$(git rev-parse --show-toplevel)
33+
echo "Found $REPO"
34+
35+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4436

4537
for SCRIPT_NAME in silver silver-custom
4638
do
39+
SRC_SCRIPT="${SCRIPT_DIR}/${SCRIPT_NAME}"
40+
DST_SCRIPT="${HOME}/bin/${SCRIPT_NAME}"
4741

48-
if [ -f $SCRIPT_NAME ]; then
49-
REPO=$("$READLINK" -f ../..)
50-
SCRIPT=$SCRIPT_NAME
51-
elif [ -f support/bin/$SCRIPT_NAME ]; then
52-
REPO=$("$READLINK" -f .)
53-
SCRIPT=support/bin/$SCRIPT_NAME
42+
if [ -f "${SRC_SCRIPT}" ]; then
43+
rm -f "${DST_SCRIPT}"
44+
ln -s "${SRC_SCRIPT}" "${DST_SCRIPT}"
5445
else
55-
echo "Couldn't find the Silver jars!"
56-
echo "(if this is a fresh checkout, run fetch-jars before this script.)"
57-
exit 2
58-
fi
59-
60-
echo "Found $REPO"
61-
62-
if [ -e ~/bin/$SCRIPT_NAME -o -h ~/bin/$SCRIPT_NAME ]; then
63-
# -h needed in case the link exists but the targeted file does not
64-
rm ~/bin/$SCRIPT_NAME
65-
echo "Removed old(?) ~/bin/$SCRIPT_NAME file."
46+
echo "Couldn't find ${SRC_SCRIPT}, there is a problem with the setup. Checkout from github again."
6647
fi
6748

68-
ln -s "$("$READLINK" -f "$SCRIPT")" ~/bin/
49+
echo "Created ${DST_SCRIPT}"
6950

70-
echo "Created ~/bin/$SCRIPT_NAME"
71-
72-
# Just in case
73-
chmod +x "$SCRIPT"
51+
# Just in case...ahem...
52+
chmod +x "${DST_SCRIPT}"
7453

7554
done
7655

7756
echo "Install finished."
78-

0 commit comments

Comments
 (0)