You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scripts/publish/installers/install.sh
+36-47Lines changed: 36 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -19,47 +19,37 @@ function error() {
19
19
exit 10
20
20
}
21
21
22
-
if [[ "$OSTYPE"=="linux"* ]];then
22
+
if [[ "${OSTYPE}"=="linux"* ]];then
23
23
OS=linux
24
-
elif [[ "$OSTYPE"=="darwin"* ]];then
24
+
elif [[ "${OSTYPE}"=="darwin"* ]];then
25
25
OS=darwin
26
26
else
27
-
error "Unsupported operating system: $OSTYPE. Please checkout the CLI docs on docs.stackstate.com or contact StackState for support with your OS."
27
+
error "Unsupported operating system: ${OSTYPE}. Please checkout the CLI docs on docs.stackstate.com or contact StackState for support with your OS."
28
28
fi
29
29
ARCH=`uname -m`
30
-
if [[ "$ARCH"!="x86_64"&&"$ARCH"!="arm64"&&"$ARCH"!="aarch64" ]];then
31
-
error "Unsupported architecture: $ARCH. Please checkout the CLI docs on docs.stackstate.com or contact StackState for support with your OS."
30
+
if [[ "${ARCH}"!="x86_64"&&"${ARCH}"!="arm64"&&"${ARCH}"!="aarch64" ]];then
31
+
error "Unsupported architecture: ${ARCH}. Please checkout the CLI docs on docs.stackstate.com or contact StackState for support with your OS."
32
32
fi
33
33
34
34
# binaries are only published for arm64
35
-
if [[ "$ARCH"=="aarch64" ]];then
35
+
if [[ "${ARCH}"=="aarch64" ]];then
36
36
ARCH="arm64"
37
37
fi
38
38
39
-
# Check if custom location was defined
40
-
if [[ -z"$STS_CLI_LOCATION" ]];then
41
-
# Use default installation location
42
-
TARGET_CLI_PATH="$(pwd)"
43
-
# check if the user has permissions to write on default location
44
-
if [[ !-w "$TARGET_CLI_PATH" ]];then
45
-
# user has no writing permissions, exit because no explicit location given.
46
-
echo"Cannot write to the current directory. Please either execute the script from a writeable directory or set STS_CLI_LOCATION to a different directory."
47
-
exit 1
48
-
fi
49
-
else
50
-
# Check if the custom installation location is valid
51
-
if [[ !-d"$STS_CLI_LOCATION" ]];then
52
-
error "Provided directory does not exist: $STS_CLI_LOCATION."
53
-
# Check if the user has writing permissions on custom location
54
-
elif [[ !-w"$STS_CLI_LOCATION" ]];then
55
-
# Location exists but user doesn't have writing permission.
56
-
echo"Sudo will be used on the provided location $STS_CLI_LOCATION."
57
-
else
58
-
# Location exists and user has writing permission
59
-
NO_SUDO=true
60
-
fi
61
-
# Set installation location as defined by the input
# check if custom location was passed to avoid redundant printing
76
-
if [[ -z"$STS_CLI_LOCATION" ]];then
77
-
echo"STS requires sudo permission to install."
78
-
echo"Alternatively, you can provide a custom location with STS_CLI_LOCATION="
79
-
echo"Make sure that the provided 'STS_CLI_LOCATION' is in your OS Path."
80
-
fi
64
+
if [[ "$SUDO_REQUIRED"=="true" ]];then
65
+
echo"STS requires sudo permission to install."
66
+
echo"Alternatively, you can provide a custom destination directory with STS_CLI_LOCATION="
67
+
echo"Make sure that the provided 'STS_CLI_LOCATION' is in your OS PATH."
81
68
82
69
# sudo password will be asked when executing the command.
83
-
curl $DL| sudo tar xz --directory $TARGET_CLI_PATH
70
+
curl $DL| sudo tar xz --directory ${TARGET_CLI_PATH}
84
71
else
85
-
curl $DL| tar xz --directory $TARGET_CLI_PATH
72
+
curl $DL| tar xz --directory ${TARGET_CLI_PATH}
86
73
fi
87
74
88
75
# Verify that 'sts' works
89
-
sts > /dev/null 2>&1
90
-
if [ $?-ne 0 ];then
91
-
error "Can not find 'sts' on the path or execute it"
92
-
fi
76
+
${TARGET_CLI_PATH}/sts > /dev/null 2>&1
93
77
94
78
# Configure the CLI if config parameters have been set
95
-
if [[ -n"$STS_URL"&&-n"$STS_API_TOKEN" ]];then
96
-
sts context save --url $STS_URL --api-token $STS_API_TOKEN
79
+
if [[ -n"${STS_URL}"&&-n"${STS_API_TOKEN}" ]];then
80
+
${TARGET_CLI_PATH}/sts context save --url ${STS_URL} --api-token ${STS_API_TOKEN}
97
81
fi
98
82
99
-
printf"Success! Type ${GREEN}sts${NO_COLOR} to get started!\n"
83
+
if [ "$(whereis -q sts)"=="" ];then
84
+
printf"${RED}[WARNING]${NO_COLOR} Can not find 'sts' on the PATH or execute it. Consider adding the directory to your PATH: PATH=\"\$PATH:${TARGET_CLI_PATH}\"\n"
85
+
printf"Type ${GREEN}${TARGET_CLI_PATH}/sts${NO_COLOR} to get started!\n"
86
+
else
87
+
printf"Success! Type ${GREEN}sts${NO_COLOR} to get started!\n"
0 commit comments