-
Notifications
You must be signed in to change notification settings - Fork 282
/
bootstrap
executable file
·71 lines (64 loc) · 2.16 KB
/
bootstrap
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
#!/usr/bin/env bash
#
# Install dependencies for the training manual and scripts
determine_package_manager() {
# If script is running on macOS
if [[ $OSTYPE == darwin* ]]; then
# If Homebrew is not installed
if ! type brew &>/dev/null; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
package_manager="Homebrew"
elif type apt &>/dev/null; then
package_manager="APT"
else
package_manager="Unknown"
fi
}
determine_package_manager
# Check if docsify-cli is installed globally (and install it if not)
if ! npm list -g docsify-cli &>/dev/null; then
echo "Installing docsify-cli..."
npm install -g docsify-cli
fi
# Check if jq is installed (and install it if not)
if ! type -p jq &>/dev/null; then
echo "Installing jq..."
case $package_manager in
"Homebrew") brew install jq ;;
"APT") apt install jq ;;
*) echo "Unable to install jq. Please install and try again." && exit 1 ;;
esac
fi
# Check if HTTPie is installed (and install it if not)
if ! type -p http &>/dev/null; then
echo "Installing HTTPie..."
case $package_manager in
"Homebrew") brew install httpie ;;
"APT") apt install httpie ;;
"Unknown") # Use the universal installation method (https://httpie.io/docs#installation)
# Make sure we have an up-to-date version of pip and setuptools
python -m pip install --upgrade pip setuptools
# Install HTTPie
python -m pip install --upgrade httpie
# If HTTPie installation is unsuccessful using the method above, try the following:
# Attempt #1: Install without multidict compilation
type -p http &>/dev/null || MULTIDICT_NO_EXTENSIONS=1 python -m pip install --no-cache-dir httpie
# Attempt #2: Install older version that does not require multidict
type -p http &>/dev/null || python -m pip install httpie==2.6.0
;;
*) echo "Unable to install HTTPie. Please install and try again." && exit 1 ;;
esac
fi
# Load the error code
ERROR_CODE=$?
# Check the shell for errors
if [ $ERROR_CODE -eq 0 ]; then
# Success
echo "Bootstrap successful!"
else
# Failure
echo "Error! Failed to bootstrap."
exit 1
fi