-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmobile-cli-root-install
59 lines (48 loc) · 1.5 KB
/
mobile-cli-root-install
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
#!/bin/bash
set -e
checkRoot() {
if (( `whoami` != "root" )); then
echo "This script needs root privileges to run."
echo "Use 'sudo $0'"
exit 1
fi
}
requireCfCli() {
echo "Mobile CLI requires Cloud Foundry CLI version 6.17 or later."
echo "Install the latest Cloud Foundry CLI from https://github.com/cloudfoundry/cli/releases"
exit 1
}
checkRoot
readonly DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if ! cf_path=$(type -p cf); then
requireCfCli
else
version=$3
majorversion=`echo "$version" | sed 's/^[^0-9]*\([0-9][0-9]*\)\..*$/\1/'`
minorversion=`echo "$version" | sed 's/^[^0-9]*[0-9][0-9]*\.\([0-9][0-9]*\).*$/\1/'`
if ! [[ $majorversion =~ ^[0-9]+$ ]] || ! [[ $minorversion =~ ^[0-9]+$ ]]; then
requireCfCli
fi
if [[ $majorversion < 6 ]] || [[ $majorversion == 6 && $minorversion < 17 ]]; then
requireCfCli
fi
fi
echo "Installing Predix Mobile CLI ..."
if [ ! -d "/usr/local/PredixMobile" ]; then
mkdir /usr/local/PredixMobile
fi
if [ ! -d "/usr/local/PredixMobile/bin" ]; then
mkdir /usr/local/PredixMobile/bin
fi
if [ "$(uname)" == "Darwin" ]; then
PLATFORM=osx
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
PLATFORM=linux64
fi
cp -f "$DIR/pm" /usr/local/PredixMobile/bin/
ln -sf /usr/local/PredixMobile/bin/pm /usr/local/bin/pm
chown -R root:0 /usr/local/PredixMobile
chmod -R 755 /usr/local/PredixMobile
echo "The Predix Mobile CLI has been installed successfully."
echo "Run 'pm help'."
echo "Open a new terminal to get PATH changes."