-
Notifications
You must be signed in to change notification settings - Fork 51
/
install.sh
45 lines (35 loc) · 1.33 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
set -e
function getDistributionTag {
local ext=""
if [[ `uname -m` == "386" ]]; then
machine="386"
else
machine="amd64"
fi
if [[ `uname -s` == "Darwin" ]]; then
kernel="darwin"
elif [[ `uname -s` =~ CYGWIN*|MINGW32*|MSYS* ]]; then
kernel="windows"
ext=".exe"
else
kernel="linux"
fi
echo "captain_${kernel}_${machine}${ext}"
}
CAPTAIN_DIR=$HOME/.captain
CAPTAIN_BIN_DIR=$CAPTAIN_DIR/bin
CAPTAIN_BINARIES_DIR=$CAPTAIN_DIR/binaries
CAPTAIN_CURRENT_VERSION_URL=$(curl -sS https://raw.githubusercontent.com/harbur/captain/master/VERSION)
CAPTAIN_CURRENT_VERSION_PATH="${CAPTAIN_BINARIES_DIR}/captain-${CAPTAIN_CURRENT_VERSION_URL}"
CAPTAIN_DISTRIBUTION=$(getDistributionTag)
echo "Creating folders in ${CAPTAIN_DIR}"
mkdir -p $CAPTAIN_BIN_DIR $CAPTAIN_BINARIES_DIR
echo "Start downloading Captain ${CAPTAIN_CURRENT_VERSION_URL}"
curl -sSL https://github.com/harbur/captain/releases/download/${CAPTAIN_CURRENT_VERSION_URL}/${CAPTAIN_DISTRIBUTION} > ${CAPTAIN_CURRENT_VERSION_PATH}
ln -snf ${CAPTAIN_CURRENT_VERSION_PATH} "${CAPTAIN_BIN_DIR}/captain"
chmod +x "${CAPTAIN_BIN_DIR}/captain"
echo "Captain ${CAPTAIN_CURRENT_VERSION_URL} installed"
echo ""
echo "IMPORTANT: Add ${CAPTAIN_BIN_DIR} in your path. E.g.:"
echo "export PATH=${CAPTAIN_BIN_DIR}:\$PATH"