forked from layer5io/service-mesh-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meshery-istio
101 lines (83 loc) · 3.04 KB
/
meshery-istio
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright 2019 Layer5 Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/usr/bin/env bash
####### COMMON FUNCTIONS
############################
command_exists() {
command -v $1 >/dev/null 2>&1
}
####### IDENTIFY OS
############################
OSARCHITECTURE="$(uname -m)"
OS="$(uname)"
if [ "x${OS}" = "xDarwin" ] ; then
OSEXT="Darwin"
else
OSEXT="Linux"
fi
####### PREFLIGHT CHECK
############################
if ! command_exists curl ; then
echo "Missing required utility: 'curl'. Please install 'curl' and try again."
exit;
fi
if [ "x${MESHERY_VERSION}" = "x" ] ; then
MESHERY_VERSION=$(curl -L -s https://api.github.com/repos/layer5io/meshery/releases | \
grep tag_name | sed "s/ *\"tag_name\": *\"\\(.*\\)\",*/\\1/" | \
grep -v "rc\.[0-9]$"| head -n 1 )
fi
if [ "x${MESHERY_VERSION}" = "x" ] ; then
printf "Unable to get latest mesheryctl version. Set MESHERY_VERSION env var and re-run. For example: export MESHERY_VERSION=v0.1.6"
exit;
fi
NAME="mesheryctl-${MESHERY_VERSION}"
URL="https://github.com/layer5io/meshery/releases/download/${MESHERY_VERSION}/mesheryctl_${MESHERY_VERSION:1}_${OSEXT}_${OSARCHITECTURE}.zip"
printf "\nDownloading %s for %s...\n\n" "$NAME" "$OSEXT"
curl -L ${URL} -o ${PWD}/meshery.zip
printf "\nExtracting %s...\n" "$NAME"
unzip ${PWD}/meshery.zip
printf "\nInstalling mesheryctl in /usr/local/bin.\n"
WHOAMI=$(whoami)
if mv ${PWD}/mesheryctl /usr/local/bin/mesheryctl ; then
echo "mesheryctl installed."
else
if sudo mv ${PWD}/mesheryctl /usr/local/bin/mesheryctl ; then
echo "Permission Resolved: mesheryctl installed using sudo permissions."
else
echo "Cannot install mesheryctl. Check permissions of $WHOAMI for /usr/local/bin."
exit 1
fi
fi
#Transfering permissions and ownership to client USER
if [ "$SUDO_USER" == "" ] ;
then
if chown $WHOAMI /usr/local/bin/mesheryctl ; then
echo "permissions moved to "$WHOAMI
else
echo "Unable to write to /usr/local/bin/mesheryctl. Please verify write permission for $WHOAMI."
exit 1
fi
else
if chown $SUDO_USER /usr/local/bin/mesheryctl ; then
echo "permissions moved to "$SUDO_USER
else
echo "Unable to write to /usr/local/bin/mesheryctl. Please verify write permission for $SUDO_USER."
exit 1
fi
fi
printf "Removing installation files and opening Meshery..."
rm -rf meshery.zip LICENSE README.md
curl -L https://raw.githubusercontent.com/layer5io/service-mesh-labs/master/meshery.yaml -o meshery.yaml
cp meshery.yaml $HOME/.meshery/meshery.yaml
mesheryctl system start