diff --git a/docs/en/install.mdx b/docs/en/install.mdx index 96d4f90ed..4085c76d2 100644 --- a/docs/en/install.mdx +++ b/docs/en/install.mdx @@ -184,7 +184,7 @@ Here are three ways to get KubeVela Cli: ** macOS/Linux ** ```shell script -curl -fsSl https://kubevela.io/install.sh | bash +curl -fsSl https://kubevela.io/script/install.sh | bash ``` **Windows** diff --git a/docs/install.ps1 b/docs/install.ps1 deleted file mode 100644 index 708a9c4ba..000000000 --- a/docs/install.ps1 +++ /dev/null @@ -1,116 +0,0 @@ -# Implemented based on Dapr Cli https://github.com/dapr/cli/tree/master/install - -param ( - [string]$Version, - [string]$VelaRoot = "c:\vela" -) - -Write-Output "" -$ErrorActionPreference = 'stop' - -#Escape space of VelaRoot path -$VelaRoot = $VelaRoot -replace ' ', '` ' - -# Constants -$VelaCliFileName = "vela.exe" -$VelaCliFilePath = "${VelaRoot}\${VelaCliFileName}" - -# GitHub Org and repo hosting Vela CLI -$GitHubOrg = "oam-dev" -$GitHubRepo = "kubevela" - -# Set Github request authentication for basic authentication. -if ($Env:GITHUB_USER) { - $basicAuth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($Env:GITHUB_USER + ":" + $Env:GITHUB_TOKEN)); - $githubHeader = @{"Authorization" = "Basic $basicAuth" } -} -else { - $githubHeader = @{} -} - -if ((Get-ExecutionPolicy) -gt 'RemoteSigned' -or (Get-ExecutionPolicy) -eq 'ByPass') { - Write-Output "PowerShell requires an execution policy of 'RemoteSigned'." - Write-Output "To make this change please run:" - Write-Output "'Set-ExecutionPolicy RemoteSigned -scope CurrentUser'" - break -} - -# Change security protocol to support TLS 1.2 / 1.1 / 1.0 - old powershell uses TLS 1.0 as a default protocol -[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" - -# Check if KubeVela CLI is installed. -if (Test-Path $VelaCliFilePath -PathType Leaf) { - Write-Warning "vela is detected - $VelaCliFilePath" - Invoke-Expression "$VelaCliFilePath --version" - Write-Output "Reinstalling KubeVela..." -} -else { - Write-Output "Installing Vela..." -} - -# Create Vela Directory -Write-Output "Creating $VelaRoot directory" -New-Item -ErrorAction Ignore -Path $VelaRoot -ItemType "directory" -if (!(Test-Path $VelaRoot -PathType Container)) { - throw "Cannot create $VelaRoot" -} - -# Get the list of release from GitHub -$releases = Invoke-RestMethod -Headers $githubHeader -Uri "https://api.github.com/repos/${GitHubOrg}/${GitHubRepo}/releases" -Method Get -if ($releases.Count -eq 0) { - throw "No releases from github.com/oam-dev/kubevela repo" -} - -# Filter windows binary and download archive -$os_arch = "windows-amd64" -if (!$Version) { - $windowsAsset = $releases | Where-Object { $_.tag_name -notlike "*rc*" } | Select-Object -First 1 | Select-Object -ExpandProperty assets | Where-Object { $_.name -Like "*${os_arch}.zip" } - if (!$windowsAsset) { - throw "Cannot find the windows KubeVela CLI binary" - } - $zipFileUrl = $windowsAsset.url - $assetName = $windowsAsset.name -} else { - $assetName = "vela-${Version}-${os_arch}.zip" - $zipFileUrl = "https://github.com/${GitHubOrg}/${GitHubRepo}/releases/download/${Version}/${assetName}" -} - -$zipFilePath = $VelaRoot + "\" + $assetName -Write-Output "Downloading $zipFileUrl ..." - -$githubHeader.Accept = "application/octet-stream" -Invoke-WebRequest -Headers $githubHeader -Uri $zipFileUrl -OutFile $zipFilePath -if (!(Test-Path $zipFilePath -PathType Leaf)) { - throw "Failed to download Vela Cli binary - $zipFilePath" -} - -# Extract KubeVela CLI to $VelaRoot -Write-Output "Extracting $zipFilePath..." -Microsoft.Powershell.Archive\Expand-Archive -Force -Path $zipFilePath -DestinationPath $VelaRoot -$ExtractedVelaCliFilePath = "${VelaRoot}\${os_arch}\${VelaCliFileName}" -Copy-Item $ExtractedVelaCliFilePath -Destination $VelaCliFilePath -if (!(Test-Path $VelaCliFilePath -PathType Leaf)) { - throw "Failed to extract Vela Cli archive - $zipFilePath" -} - -# Check the KubeVela CLI version -Invoke-Expression "$VelaCliFilePath --version" - -# Clean up zipfile -Write-Output "Clean up $zipFilePath..." -Remove-Item $zipFilePath -Force - -# Add VelaRoot directory to User Path environment variable -Write-Output "Try to add $VelaRoot to User Path Environment variable..." -$UserPathEnvironmentVar = [Environment]::GetEnvironmentVariable("PATH", "User") -if ($UserPathEnvironmentVar -like '*vela*') { - Write-Output "Skipping to add $VelaRoot to User Path - $UserPathEnvironmentVar" -} -else { - [System.Environment]::SetEnvironmentVariable("PATH", $UserPathEnvironmentVar + ";$VelaRoot", "User") - $UserPathEnvironmentVar = [Environment]::GetEnvironmentVariable("PATH", "User") - Write-Output "Added $VelaRoot to User Path - $UserPathEnvironmentVar" -} - -Write-Output "`r`nKubeVela CLI is installed successfully." -Write-Output "To get started with KubeVela, please visit https://kubevela.io." diff --git a/docs/install.sh b/docs/install.sh deleted file mode 100644 index a7fec950c..000000000 --- a/docs/install.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/env bash - -# Implemented based on Dapr Cli https://github.com/dapr/cli/tree/master/install - -# Vela CLI location -: ${VELA_INSTALL_DIR:="/usr/local/bin"} - -# sudo is required to copy binary to VELA_INSTALL_DIR for linux -: ${USE_SUDO:="false"} - -# Http request CLI -VELA_HTTP_REQUEST_CLI=curl - -# GitHub Organization and repo name to download release -GITHUB_ORG=oam-dev -GITHUB_REPO=kubevela - -# Vela CLI filename -VELA_CLI_FILENAME=vela - -VELA_CLI_FILE="${VELA_INSTALL_DIR}/${VELA_CLI_FILENAME}" - -getSystemInfo() { - ARCH=$(uname -m) - case $ARCH in - armv7*) ARCH="arm";; - aarch64) ARCH="arm64";; - x86_64) ARCH="amd64";; - esac - - OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') - - # Most linux distro needs root permission to copy the file to /usr/local/bin - if [ "$OS" == "linux" ] && [ "$VELA_INSTALL_DIR" == "/usr/local/bin" ]; then - USE_SUDO="true" - fi -} - -verifySupported() { - local supported=(darwin-amd64 linux-amd64 linux-arm linux-arm64) - local current_osarch="${OS}-${ARCH}" - - for osarch in "${supported[@]}"; do - if [ "$osarch" == "$current_osarch" ]; then - echo "Your system is ${OS}_${ARCH}" - return - fi - done - - echo "No prebuilt binary for ${current_osarch}" - exit 1 -} - -runAsRoot() { - local CMD="$*" - - if [ $EUID -ne 0 -a $USE_SUDO = "true" ]; then - CMD="sudo $CMD" - fi - - $CMD -} - -checkHttpRequestCLI() { - if type "curl" > /dev/null; then - VELA_HTTP_REQUEST_CLI=curl - elif type "wget" > /dev/null; then - VELA_HTTP_REQUEST_CLI=wget - else - echo "Either curl or wget is required" - exit 1 - fi -} - -checkExistingVela() { - if [ -f "$VELA_CLI_FILE" ]; then - echo -e "\nVela CLI is detected:" - $VELA_CLI_FILE --version - echo -e "Reinstalling Vela CLI - ${VELA_CLI_FILE}...\n" - else - echo -e "Installing Vela CLI...\n" - fi -} - -getLatestRelease() { - local velaReleaseUrl="https://api.github.com/repos/${GITHUB_ORG}/${GITHUB_REPO}/releases" - local latest_release="" - - if [ "$VELA_HTTP_REQUEST_CLI" == "curl" ]; then - latest_release=$(curl -s $velaReleaseUrl | grep \"tag_name\" | grep -v rc | awk 'NR==1{print $2}' | sed -n 's/\"\(.*\)\",/\1/p') - else - latest_release=$(wget -q --header="Accept: application/json" -O - $velaReleaseUrl | grep \"tag_name\" | grep -v rc | awk 'NR==1{print $2}' | sed -n 's/\"\(.*\)\",/\1/p') - fi - - ret_val=$latest_release -} - -downloadFile() { - LATEST_RELEASE_TAG=$1 - - VELA_CLI_ARTIFACT="${VELA_CLI_FILENAME}-${LATEST_RELEASE_TAG}-${OS}-${ARCH}.tar.gz" - # convert `-` to `_` to let it work - DOWNLOAD_BASE="https://github.com/${GITHUB_ORG}/${GITHUB_REPO}/releases/download" - DOWNLOAD_URL="${DOWNLOAD_BASE}/${LATEST_RELEASE_TAG}/${VELA_CLI_ARTIFACT}" - - # Create the temp directory - VELA_TMP_ROOT=$(mktemp -dt vela-install-XXXXXX) - ARTIFACT_TMP_FILE="$VELA_TMP_ROOT/$VELA_CLI_ARTIFACT" - - echo "Downloading $DOWNLOAD_URL ..." - if [ "$VELA_HTTP_REQUEST_CLI" == "curl" ]; then - curl -SsL "$DOWNLOAD_URL" -o "$ARTIFACT_TMP_FILE" - else - wget -q -O "$ARTIFACT_TMP_FILE" "$DOWNLOAD_URL" - fi - - if [ ! -f "$ARTIFACT_TMP_FILE" ]; then - echo "failed to download $DOWNLOAD_URL ..." - exit 1 - fi -} - -installFile() { - tar xf "$ARTIFACT_TMP_FILE" -C "$VELA_TMP_ROOT" - local tmp_root_vela_cli="$VELA_TMP_ROOT/${OS}-${ARCH}/$VELA_CLI_FILENAME" - - if [ ! -f "$tmp_root_vela_cli" ]; then - echo "Failed to unpack Vela CLI executable." - exit 1 - fi - - chmod o+x $tmp_root_vela_cli - runAsRoot cp "$tmp_root_vela_cli" "$VELA_INSTALL_DIR" - - if [ -f "$VELA_CLI_FILE" ]; then - echo "$VELA_CLI_FILENAME installed into $VELA_INSTALL_DIR successfully." - - $VELA_CLI_FILE --version - else - echo "Failed to install $VELA_CLI_FILENAME" - exit 1 - fi -} - -fail_trap() { - result=$? - if [ "$result" != "0" ]; then - echo "Failed to install Vela CLI" - echo "For support, go to https://kubevela.io" - fi - cleanup - exit $result -} - -cleanup() { - if [[ -d "${VELA_TMP_ROOT:-}" ]]; then - rm -rf "$VELA_TMP_ROOT" - fi -} - -installCompleted() { - echo -e "\nTo get started with KubeVela, please visit https://kubevela.io" -} - -# ----------------------------------------------------------------------------- -# main -# ----------------------------------------------------------------------------- -trap "fail_trap" EXIT - -getSystemInfo -verifySupported -checkExistingVela -checkHttpRequestCLI - - -if [ -z "$1" ]; then - echo "Getting the latest Vela CLI..." - getLatestRelease -else - ret_val=v$1 -fi - -echo "Installing $ret_val Vela CLI..." - -downloadFile $ret_val -installFile -cleanup - -installCompleted