fix: cli install script, add manual instruction

This commit is contained in:
Pavel Sviderski
2025-02-06 14:38:55 +10:00
parent cfe5b018f3
commit fb68303825
+13 -13
View File
@@ -8,25 +8,25 @@ INSTALL_DIR=${INSTALL_DIR:-/usr/local/bin}
VERSION=${VERSION:-latest} VERSION=${VERSION:-latest}
print_manual_install() { print_manual_install() {
# TODO: review RELEASES_URL="https://github.com/${GITHUB_REPO}/releases/${VERSION}"
echo "You can manually install uncloud by:" echo "Failed while attempting to install uncloud CLI. You can install it manually:"
echo "1. Opening $RELEASES_URL" echo " 1. Open your web browser and go to ${RELEASES_URL}"
echo "2. Downloading uncloud_*_${OS}_${ARCH}.tar.gz for your platform" echo " 2. Download uncloud_<OS>_<ARCH>.tar.gz for your platform (OS: linux/macos, ARCH: amd64/arm64)."
echo "3. Verifying the checksum from checksums.txt" echo " 3. Extract the 'uncloud' binary from the archive: tar -xvf uncloud_*.tar.gz"
echo "4. Extracting the archive: tar xzf uncloud_*_${OS}_${ARCH}.tar.gz" echo " 4. Install the binary to /usr/local/bin: sudo install ./uncloud ${INSTALL_DIR}/uncloud"
echo "5. Installing the binary: sudo install -m 755 uncloud /usr/local/bin/" echo " 5. Optionally create a 'uc' symlink: sudo ln -sf ${INSTALL_DIR}/uncloud ${INSTALL_DIR}/uc"
echo "6. Creating symlink: sudo ln -sf /usr/local/bin/uncloud /usr/local/bin/uc" echo " 6. Delete the downloaded archive and extracted binary: rm uncloud*"
echo " 7. Run 'uncloud --help' to verify the installation. Enjoy! ✨"
} }
latest_version() { fetch_latest_version() {
api_url="https://api.github.com/repos/${GITHUB_REPO}/releases/latest" api_url="https://api.github.com/repos/${GITHUB_REPO}/releases/latest"
version=$(curl -fsSL "$api_url" | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4) VERSION=$(curl -fsSL "$api_url" | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4)
if [ -z "$version" ]; then if [ -z "$VERSION" ]; then
echo "Failed to fetch the latest version from GitHub." echo "Failed to fetch the latest version from GitHub."
print_manual_install print_manual_install
exit 1 exit 1
fi fi
echo "$version"
} }
# Check if not running as root and need to use sudo to write to INSTALL_DIR. # Check if not running as root and need to use sudo to write to INSTALL_DIR.
@@ -62,7 +62,7 @@ esac
# Use the latest version if not specified explicitly. # Use the latest version if not specified explicitly.
if [ "$VERSION" = "latest" ]; then if [ "$VERSION" = "latest" ]; then
VERSION=$(latest_version) fetch_latest_version
fi fi
BINARY_NAME="uncloud_${BINARY_OS}_${BINARY_ARCH}.tar.gz" BINARY_NAME="uncloud_${BINARY_OS}_${BINARY_ARCH}.tar.gz"
BINARY_URL="https://github.com/${GITHUB_REPO}/releases/download/${VERSION}/${BINARY_NAME}" BINARY_URL="https://github.com/${GITHUB_REPO}/releases/download/${VERSION}/${BINARY_NAME}"