|
28 | 28 |
|
29 | 29 | echo "Found ~/bin" |
30 | 30 |
|
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 ) |
44 | 36 |
|
45 | 37 | for SCRIPT_NAME in silver silver-custom |
46 | 38 | do |
| 39 | + SRC_SCRIPT="${SCRIPT_DIR}/${SCRIPT_NAME}" |
| 40 | + DST_SCRIPT="${HOME}/bin/${SCRIPT_NAME}" |
47 | 41 |
|
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}" |
54 | 45 | 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." |
66 | 47 | fi |
67 | 48 |
|
68 | | - ln -s "$("$READLINK" -f "$SCRIPT")" ~/bin/ |
| 49 | + echo "Created ${DST_SCRIPT}" |
69 | 50 |
|
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}" |
74 | 53 |
|
75 | 54 | done |
76 | 55 |
|
77 | 56 | echo "Install finished." |
78 | | - |
0 commit comments