-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathflyio-install.sh
More file actions
executable file
·64 lines (56 loc) · 2.17 KB
/
flyio-install.sh
File metadata and controls
executable file
·64 lines (56 loc) · 2.17 KB
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
#!/bin/bash
# This script installs Fly.io CLI (flyctl) on your machine.
set -e
# Function to check if the script is run with sudo (for Linux)
check_sudo() {
if [ "$EUID" -ne 0 ]; then
echo "ERROR: Please run this script with sudo or as root."
exit 1
fi
}
# Function to print verbose output
verbose_echo() {
echo "[VERBOSE] $1"
}
# Detect the OS
OS=$(uname -s)
verbose_echo "Detected OS: $OS"
if [ "$OS" == "Linux" ]; then
verbose_echo "Starting installation process for Linux..."
check_sudo
verbose_echo "Downloading and running Fly.io installation script..."
curl -L https://fly.io/install.sh | sh
verbose_echo "Adding flyctl to PATH for all users..."
FLYCTL_INSTALL="/usr/local/bin"
echo "export FLYCTL_INSTALL=\"$FLYCTL_INSTALL\"" | sudo tee /etc/profile.d/flyctl.sh > /dev/null
echo "export PATH=\"\$FLYCTL_INSTALL:\$PATH\"" | sudo tee -a /etc/profile.d/flyctl.sh > /dev/null
verbose_echo "Sourcing the new environment variables..."
source /etc/profile.d/flyctl.sh
elif [ "$OS" == "Darwin" ]; then
verbose_echo "Starting installation process for macOS..."
if ! command -v brew &> /dev/null; then
echo "ERROR: Homebrew is not installed. Please install Homebrew first: https://brew.sh/"
exit 1
fi
verbose_echo "Using Homebrew to install flyctl..."
brew install flyctl
elif [[ "$OS" == CYGWIN* || "$OS" == MINGW* || "$OS" == MSYS* ]]; then
verbose_echo "Starting installation process for Windows..."
verbose_echo "Downloading and running Fly.io PowerShell installation script..."
powershell -Command "iwr https://fly.io/install.ps1 -useb | iex"
else
echo "ERROR: Unsupported OS: $OS"
exit 1
fi
# Verify installation
verbose_echo "Verifying flyctl installation..."
if command -v flyctl &> /dev/null; then
echo "SUCCESS: flyctl successfully installed."
verbose_echo "Checking flyctl version..."
flyctl version
else
echo "ERROR: flyctl installation failed. Please check the above output for errors."
exit 1
fi
echo "Installation complete. Please restart your terminal or run 'source /etc/profile.d/flyctl.sh' to use flyctl."
verbose_echo "Script execution finished."