diff options
Diffstat (limited to 'install.sh')
| -rw-r--r-- | install.sh | 54 |
1 files changed, 46 insertions, 8 deletions
@@ -2,8 +2,8 @@ set -e # Makima CLI Installer -# Usage: curl -fsSL https://raw.githubusercontent.com/soryu-co/soryu/master/install.sh | bash -# curl -fsSL https://raw.githubusercontent.com/soryu-co/soryu/master/install.sh | INSTALL_DIR=/opt/bin bash +# Usage: curl -fsSL https://raw.githubusercontent.com/soryu-co/makima/master/install.sh | bash +# curl -fsSL https://raw.githubusercontent.com/soryu-co/makima/master/install.sh | INSTALL_DIR=/opt/bin bash INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}" BINARY_NAME="makima" @@ -38,6 +38,10 @@ check_dependencies() { missing="$missing curl" fi + if ! command -v tar &> /dev/null; then + missing="$missing tar" + fi + if [ -n "$missing" ]; then print_error "Missing required tools:$missing" print_info "Please install the missing tools and try again." @@ -85,11 +89,26 @@ detect_arch() { esac } +# Get the latest release tag from GitHub +get_latest_tag() { + local tag + tag=$(curl -fsSL "https://api.github.com/repos/soryu-co/makima/releases/latest" 2>/dev/null | grep '"tag_name"' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/') + + if [ -z "$tag" ]; then + print_error "Failed to determine latest release tag from GitHub" + print_info "Please check your internet connection or try again later." + exit 1 + fi + + echo "$tag" +} + # Construct the download URL for the binary get_download_url() { local os=$1 local arch=$2 - echo "https://api.makima.jp/api/v1/daemon/download/${os}-${arch}" + local tag=$3 + echo "https://github.com/soryu-co/makima/releases/download/${tag}/makima-${tag}-${os}-${arch}.tar.gz" } # Download and install the binary @@ -97,23 +116,38 @@ install_binary() { local url=$1 local tmpdir tmpdir=$(mktemp -d) - local binary="$tmpdir/$BINARY_NAME" + local tarball="$tmpdir/makima.tar.gz" print_info "Downloading from: $url" - if ! curl -fsSL "$url" -o "$binary"; then + if ! curl -fsSL "$url" -o "$tarball"; then print_error "Failed to download from: $url" print_info "Please check if the binary is available for your platform." rm -rf "$tmpdir" exit 1 fi - if [ ! -f "$binary" ] || [ ! -s "$binary" ]; then + if [ ! -f "$tarball" ] || [ ! -s "$tarball" ]; then print_error "Downloaded file is empty or missing" rm -rf "$tmpdir" exit 1 fi + # Extract the tarball + print_info "Extracting archive..." + if ! tar xzf "$tarball" -C "$tmpdir"; then + print_error "Failed to extract archive" + rm -rf "$tmpdir" + exit 1 + fi + + local binary="$tmpdir/$BINARY_NAME" + if [ ! -f "$binary" ]; then + print_error "Binary '$BINARY_NAME' not found in archive" + rm -rf "$tmpdir" + exit 1 + fi + chmod +x "$binary" # Create install directory if needed @@ -166,13 +200,17 @@ main() { check_dependencies - local os arch + local os arch tag os=$(detect_os) arch=$(detect_arch) print_info "Detected platform: $os-$arch" + print_info "Fetching latest release..." + tag=$(get_latest_tag) + print_info "Latest release: $tag" + local url - url=$(get_download_url "$os" "$arch") + url=$(get_download_url "$os" "$arch" "$tag") print_info "" install_binary "$url" |
