Skip to content

Commit 1dd2793

Browse files
authored
Merge pull request #30 from vladlosev/patch-1
fix: Handles MacOS app bundles.
2 parents 4f7662b + 84a4c39 commit 1dd2793

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

lib/utils.bash

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ download_release() {
102102
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
103103
}
104104

105+
install_client_binary() {
106+
local install_path="$1"
107+
local binary="$2"
108+
109+
local binary_path="$install_path/$binary"
110+
111+
if [ ! -f "$binary_path" -a -d "${binary_path}.app" ]; then
112+
# Hanle MacOS application bundle.
113+
mv "${binary_path}.app" "$install_path/bin/${binary}.app"
114+
( cd "$install_path/bin" && ln -s "$binary" "${binary}.app/Contents/MacOS/$binary" )
115+
else
116+
mv "$binary_path" "$install_path/bin/$binary"
117+
fi
118+
}
119+
105120
install_version() {
106121
local install_type="$1"
107122
local version="$2"
@@ -115,11 +130,11 @@ install_version() {
115130
mkdir -p "$install_path"
116131
cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path"
117132
mkdir -p "$install_path"/bin
118-
mv "$install_path"/tsh "$install_path"/bin/tsh
119-
mv "$install_path"/tctl "$install_path"/bin/tctl
120-
mv "$install_path"/teleport "$install_path"/bin/teleport
133+
install_client_binary "$install_path" tsh
134+
install_client_binary "$install_path" tctl
135+
install_client_binary "$install_path" teleport
121136
# Machine ID is available starting from the Teleport 9.0.0 release. So tbot not exist in previous releases
122-
[[ -f "$install_path"/tbot ]] && mv "$install_path"/tbot "$install_path"/bin/tbot
137+
[[ -f "$install_path"/tbot ]] && install_client_binary "$install_path" tbot
123138

124139
# TODO: Asert teleport-ent executable exists.
125140
local tool_cmd

0 commit comments

Comments
 (0)