51 lines
1.3 KiB
Bash
Executable file
51 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# Determine the platform
|
|
OS=$(uname -s)
|
|
ARCH=$(uname -m)
|
|
|
|
# Map architecture
|
|
if [ "$ARCH" == "x86_64" ]; then
|
|
ARCH="amd64"
|
|
elif [[ "$ARCH" == "arm64" || "$ARCH" == "aarch64" ]]; then
|
|
ARCH="arm64"
|
|
else
|
|
echo "Unsupported architecture: $ARCH"
|
|
exit 1
|
|
fi
|
|
|
|
# Map OS
|
|
case "$OS" in
|
|
Linux) OS="linux" ;;
|
|
Darwin) OS="darwin" ;;
|
|
MSYS_NT-10.0-26100) OS="windows" ;; # gitbash
|
|
*) echo "Unsupported OS: $OS"; exit 1 ;;
|
|
esac
|
|
|
|
VERSION="v0.0.5"
|
|
BINARY_URL="https://codeberg.org/headshed/infctl-cli/releases/download/$VERSION/infctl-$OS-$ARCH"
|
|
|
|
# Download the binary
|
|
echo "Downloading infctl binary for $OS-$ARCH..."
|
|
|
|
if [ "$OS" == "windows" ]; then
|
|
# Create ~/bin if it doesn't exist
|
|
mkdir -p "$HOME/bin"
|
|
curl -s -L "$BINARY_URL.exe" -o "$HOME/bin/infctl.exe"
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to download infctl for Windows"
|
|
exit 1
|
|
fi
|
|
# Ensure ~/bin is in PATH for future sessions
|
|
if ! grep -q 'export PATH="$HOME/bin:$PATH"' "$HOME/.bash_profile" 2>/dev/null; then
|
|
echo 'export PATH="$HOME/bin:$PATH"' >> "$HOME/.bash_profile"
|
|
echo "Added ~/bin to PATH in ~/.bash_profile. Please restart your shell or run: source ~/.bash_profile"
|
|
fi
|
|
else
|
|
sudo curl -s -L "$BINARY_URL" -o /usr/local/bin/infctl
|
|
sudo chmod +x /usr/local/bin/infctl
|
|
fi
|
|
|
|
echo "infctl install done."
|