-
Notifications
You must be signed in to change notification settings - Fork 18
/
install.sh
executable file
·97 lines (84 loc) · 2.54 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
## USAGE: bash install.sh $INSTALL_DIR
## $ bash install.sh $INSTALL_DIR
set -eu
# OS detection
KERNEL="$(uname -s | tr '[:upper:]' '[:lower:]')"
if [ "$KERNEL" = "darwin" ]; then
PLATFORM='osx'
elif [ "$KERNEL" = "linux" ]; then
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
PLATFORM='linux-x86_64'
fi
fi
# If there is an argument then there is where GV will installed
if [ "$0" = 'sh' ]; then
# I.e. when piping from curl
INSTALL_DIR=$PWD/genevalidator
elif [[ "$0" = *install.sh ]]; then
# I.e. when running directly
INSTALL_DIR=$PWD/genevalidator
else
INSTALL_DIR="$0"
fi
GV_URL=$(curl -sL https://api.github.com/repos/wurmlab/genevalidator/releases/latest \
| grep browser_download_url \
| grep -i $PLATFORM \
| cut -d '"' -f 4)
# Check if the GV_URL is set (e.g. when the GITHUB API does not return what we expect)
if [ -z "$GV_URL" ]; then
echo >&2 '==> Unable find the link to the latest version of the standalone GeneValidator Package.'
echo >&2 ' Please download the latest version of GeneValidator from the following link:'
echo >&2 ' https://github.com/wurmlab/genevalidator/releases/latest'
exit 1
fi
echo >&2 "==> Installing GeneValidator to:"
echo >&2 " ${INSTALL_DIR}"
echo >&2
mkdir "${INSTALL_DIR}"
curl -SL "$GV_URL" | tar zxf - -C "${INSTALL_DIR}" --strip-components 1
echo >&2
echo >&2 "==> GeneValidator successfully installed."
### Check which SHELL and then test different profile files
case $SHELL in
*/zsh)
# assume Zsh
if test -e "${HOME}/.zshrc"; then
DOT_FILE=${HOME}/.zshrc
elif test -e "${HOME}/.zprofile"; then
DOT_FILE=${HOME}/.zprofile
elif test -e "${HOME}/.profile"; then
DOT_FILE=${HOME}/.profile
fi
;;
*/bash)
# assume Bash
if test -e "${HOME}/.bashrc"; then
DOT_FILE=${HOME}/.bashrc
elif test -e "${HOME}/.bash_profile"; then
DOT_FILE=${HOME}/.bash_profile
elif test -e "${HOME}/.profile"; then
DOT_FILE=${HOME}/.profile
fi
;;
*)
if test -e "${HOME}/.profile"; then
DOT_FILE=${HOME}/.profile
fi
esac
if [ -z ${DOT_FILE+x} ]; then
# DOT File hasn't been set.
echo >&2
echo >&2 '==> No profile files were found.'
echo >&2 ' Please create one and add the following line to that file:'
echo >&2
echo >&2 ' export PATH="'"${INSTALL_DIR}"'/bin:${PATH}"'
else
echo >&2 'export PATH="'"${INSTALL_DIR}"'/bin:${PATH}"' >> "${DOT_FILE}"
echo >&2
echo >&2 "==> Added GeneValidator to your PATH in ${DOT_FILE}"
echo >&2
echo >&2 "==> Run \`genevalidator -h\` in a new terminal window to get started."
fi
echo >&2