forked from bennwei/Flight_delay_prediction_web_app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jq_install.sh
74 lines (65 loc) · 2.52 KB
/
jq_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
#!/usr/bin/env bash
#
# Script to install jq utility locally, across all platforms (hopefully)
#
export PROJECT_HOME=`pwd`
echo "This script will install the utility jq locally in '$PROJECT_HOME/bin' ..."
echo "Making bin directory"
mkdir bin
echo "Adding '$PROJECT_HOME/bin' to \$PATH ..."
export PATH=$PATH:$PROJECT_HOME/bin
echo "Creating backup of '~/.bash_profile' to '~/.bash_profile.jq_install.bak' ..."
cp ~/.bash_profile ~/.bash_profile.jq_install.bak
echo "Adding \$PROJECT_HOME/bin to ~/.bash_profile"
echo "" >> ~/.bash_profile
echo "# Added by $PROJECT_HOME/jq_install.sh" >> ~/.bash_profile
echo "export PATH=$PATH:$PROJECT_HOME/bin" >> ~/.bash_profile
echo "" >> ~/.bash_profile
echo "Detecting platform ..."
if [ "$(uname)" == "Darwin" ]; then
PLATFORM="Darwin"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
PLATFORM="Linux"
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
PLATFORM="Windows"
fi
echo "Platform is '$PLATFORM' ..."
echo "Performing installation for platform '$PLATFORM' ..."
if [ $PLATFORM == "Darwin" ]; then
echo "Detecting Mac frameworks (must have Homebrew or MacPorts installed) ..."
if [ ! -z `which brew` ]; then
echo "Homebrew detected, performing install via homebrew ..."
brew install jq
elif [ ! -z `which port` ]; then
echo "MacPorts detected, performing install via MacPorts ..."
echo "Executing sudo: 'sudo port install jq'"
sudo port install jq
else
# If neither homebrew or macports are detected, exit
echo "Install failed."
echo "Please install Homebrew or MacPorts to continue installation. Or see install directions (including from source) at https://github.com/stedolan/jq/wiki/Installation#or-build-from-source"
echo ""
exit 1
fi
elif [ $PLATFORM == "Linux" ]; then
echo "Detecting Debian/Ubuntu ..."
if [ ! -z `python -mplatform | grep debian` ]; then
echo "Debian/Ubuntu detected. Performing 'apt-get install jq' ..."
sudo apt-get install -y jq
else
echo "CentOS detected. Detecting 'dnf' ..."
if [ -z `which dnf` ]; then
echo "Detected dnf! Performing sudo!: 'sudo dnf install jq' ..."
sudo dnf install jq
else
echo "dnf not detected! Using yum. Performing sudo!: 'sudo yum install jq' ..."
sudo yum install jq
fi
fi
elif [$PLATFORM == "Windows" ]; then
echo "Using choco to install jq ..."
choco install jq
fi
echo ""
echo "Installation complete. If you have any issues, try the install instructions for jq at https://github.com/stedolan/jq/wiki/Installation"
echo ""