Skip to content

Commit

Permalink
download the github release of flyctl
Browse files Browse the repository at this point in the history
  • Loading branch information
a-ovi committed Aug 15, 2024
1 parent 28e61a8 commit 0cad0b4
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/flyctl/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

set -eax

USER_HOME=$(eval echo ~$_REMOTE_USER)

export FLYCTL_INSTALL="$USER_HOME/.fly"
export PATH="$FLYCTL_INSTALL/bin:$PATH"
ARCH=amd64
if [ "$(uname -m)" = "aarch64" ]; then ARCH=arm64; fi

echo "Installing flyctl..."
sudo -E -u $_REMOTE_USER zsh <<EOF
export FLYCTL_INSTALL="$USER_HOME/.fly"
export PATH="\$FLYCTL_INSTALL/bin:\$PATH"
if [ "\$VERSION" = "latest" ]; then
curl -L https://fly.io/install.sh | sh
else
curl -L https://fly.io/install.sh | sh -s "\$VERSION"
fi
EOF

# get the download link of github release from the api
URL=$(curl -s https://api.fly.io/app/flyctl_releases/linux/$ARCH/$VERSION)

# download and extract the binary
curl -fL $URL | tar -xz

# make the binary executable and create a symlink
chmod +x flyctl
ln -s flyctl fly

# move the binary and symlink to /usr/local/bin
mv fly /usr/local/bin/fly
mv flyctl /usr/local/bin/flyctl

0 comments on commit 0cad0b4

Please sign in to comment.