forked from vmware-tanzu/tanzu-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·67 lines (52 loc) · 1.75 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
#!/bin/bash
# Copyright 2021 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# Inspired by - https://github.com/vmware-tanzu/community-edition/blob/main/hack/install.sh
# Script to install tanzu framework
# Usage: ./hack/install.sh /path/to/tanzu-framework/core/binary
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
TF_INSTALL_PATH="${1:?Tanzu-Framework path argument empty. Example usage: ./hack/install.sh /path/to/tanzu-framework/core/binary}"
ALLOW_INSTALL_AS_ROOT="${ALLOW_INSTALL_AS_ROOT:-""}"
if [[ "$EUID" -eq 0 && "${ALLOW_INSTALL_AS_ROOT}" != "true" ]]; then
echo "Do not run this script as root"
exit 1
fi
MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH="amd64"
case "${OS}" in
linux)
XDG_DATA_HOME="${HOME}/.local/share"
;;
darwin)
XDG_DATA_HOME="${HOME}/Library/Application Support"
;;
*)
echo "${OS} is unsupported"
exit 1
;;
esac
echo "${XDG_DATA_HOME}"
# check if the tanzu CLI already exists and remove it to avoid conflicts
if [[ -n "$(command -v tanzu)" ]]; then
# best effort, so just ignore errors
sudo rm -f "$(command -v tanzu)" > /dev/null
fi
# set install dir to /usr/local/bin
TANZU_BIN_PATH="/usr/local/bin"
echo Installing tanzu cli to "${TANZU_BIN_PATH}"
# if plugin cache pre-exists, remove it so new plugins are detected
TANZU_PLUGIN_CACHE="${HOME}/.cache/tanzu/catalog.yaml"
if [[ -n "${TANZU_PLUGIN_CACHE}" ]]; then
echo "Removing old plugin cache from ${TANZU_PLUGIN_CACHE}"
rm -f "${TANZU_PLUGIN_CACHE}" > /dev/null
fi
# install tanzu cli
sudo install "${TF_INSTALL_PATH}" "${TANZU_BIN_PATH}/tanzu"
# install plugins
tanzu plugin sync
tanzu plugin list
echo "Installation complete!"