forked from cnti-testcatalog/testsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
curl_install.sh
executable file
·65 lines (53 loc) · 2.22 KB
/
curl_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
#!/bin/bash
set -o errexit
if [[ "$SHELL" == *"bash"* ]]; then
SHELL_PROFILE=~/.bashrc
SHELL_DOT_DIR=~/.bash.d/
elif [[ "$SHELL" == *"zsh"* ]]; then
SHELL_PROFILE=~/.zshrc
SHELL_DOT_DIR=~/.zsh.d/
else
SHELL_UNSUPPORTED=true
fi
if [ "$1" = "cleanup" ]; then
if [ -z ${SHELL_UNSUPPORTED+x} ]; then
rm "$SHELL_DOT_DIR"cnf-testsuite
fi
rm -rf ~/.cnf-testsuite
exit 0
fi
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Install CNF-TestSuite
LATEST_RELEASE=$(get_latest_release cnti-testcatalog/testsuite)
mkdir -p ~/.cnf-testsuite
curl --silent -L https://github.com/cnti-testcatalog/testsuite/releases/download/$LATEST_RELEASE/cnf-testsuite-$LATEST_RELEASE.tar.gz -o ~/.cnf-testsuite/cnf-testsuite.tar.gz
tar -C ~/.cnf-testsuite -xf ~/.cnf-testsuite/cnf-testsuite.tar.gz
chmod a+x ~/.cnf-testsuite/cnf-testsuite
rm ~/.cnf-testsuite/cnf-testsuite.tar.gz
if [ -z ${SHELL_UNSUPPORTED+x} ]; then
if ! grep -Fxq "for s in $SHELL_DOT_DIR*" $SHELL_PROFILE; then
echo "for s in $SHELL_DOT_DIR*" >> $SHELL_PROFILE
echo 'do' >> $SHELL_PROFILE
echo ' [[ -f "$s" ]] && source $s' >> $SHELL_PROFILE
echo 'done' >> $SHELL_PROFILE
fi
mkdir -p $SHELL_DOT_DIR
echo 'export PATH=$HOME/.cnf-testsuite:$PATH' > ${SHELL_DOT_DIR}cnf-testsuite
fi
if [ -z ${SHELL_UNSUPPORTED+x} ]; then
if (return 0 2>/dev/null); then
export PATH=$HOME/.cnf-testsuite:$PATH
echo "cnf-testsuite has been successfully installed to ~/.cnf-testsuite and added to your PATH"
else
echo "cnf-testsuite has been successfully installed to: ~/.cnf-testsuite"
echo "To use the cnf-testsuite please restart you terminal session to load the new PATH"
echo "Or you can manually run 'export PATH=\$HOME/.cnf-testsuite:\$PATH' in your current session"
fi
else
echo "Because an unsupported shell was detected you will need to manually set you PATH, eg.:"
echo "'export PATH=\$HOME/.cnf-testsuite:\$PATH'"
fi