|
1 | 1 | #!/bin/bash |
2 | | -# OpenLinear Installer Script |
| 2 | +# OpenLinear Desktop App Installer |
3 | 3 | # Usage: curl -fsSL https://rixie.in/api/install | bash |
4 | 4 |
|
5 | 5 | set -e |
6 | 6 |
|
7 | | -# Colors |
8 | | -RED='\033[0;31m' |
9 | | -GREEN='\033[0;32m' |
10 | | -BLUE='\033[0;34m' |
11 | | -YELLOW='\033[1;33m' |
12 | | -NC='\033[0m' # No Color |
13 | | - |
14 | | -# Configuration |
15 | 7 | REPO="kaizen403/openlinear" |
16 | 8 | API_URL="https://api.github.com/repos/${REPO}/releases/latest" |
17 | | -INSTALL_DIR="${HOME}/.local/bin" |
18 | | -BIN_NAME="openlinear" |
| 9 | +INSTALL_DIR="${HOME}/.openlinear" |
| 10 | +BINARY_NAME="openlinear.AppImage" |
19 | 11 |
|
20 | | -echo -e "${BLUE}OpenLinear Installer${NC}" |
| 12 | +echo "OpenLinear Installer" |
21 | 13 | echo "====================" |
22 | 14 | echo "" |
23 | 15 |
|
24 | | -# Detect OS and architecture |
25 | | -OS=$(uname -s | tr '[:upper:]' '[:lower:]') |
| 16 | +OS=$(uname -s) |
26 | 17 | ARCH=$(uname -m) |
27 | 18 |
|
28 | | -case "$OS" in |
29 | | - linux) |
30 | | - case "$ARCH" in |
31 | | - x86_64) PLATFORM="linux-x64" ;; |
32 | | - aarch64|arm64) PLATFORM="linux-arm64" ;; |
33 | | - *) echo -e "${RED}Unsupported architecture: $ARCH${NC}"; exit 1 ;; |
34 | | - esac |
35 | | - ;; |
36 | | - darwin) |
37 | | - case "$ARCH" in |
38 | | - x86_64) PLATFORM="macos-x64" ;; |
39 | | - arm64) PLATFORM="macos-arm64" ;; |
40 | | - *) echo -e "${RED}Unsupported architecture: $ARCH${NC}"; exit 1 ;; |
41 | | - esac |
42 | | - ;; |
43 | | - *) |
44 | | - echo -e "${RED}Unsupported OS: $OS${NC}" |
45 | | - exit 1 |
46 | | - ;; |
| 19 | +if [ "$OS" != "Linux" ]; then |
| 20 | + echo "Error: OpenLinear desktop app is currently only available for Linux" |
| 21 | + echo "Your OS: $OS" |
| 22 | + exit 1 |
| 23 | +fi |
| 24 | + |
| 25 | +case "$ARCH" in |
| 26 | + x86_64) PLATFORM="amd64" ;; |
| 27 | + aarch64|arm64) PLATFORM="arm64" ;; |
| 28 | + *) echo "Error: Unsupported architecture: $ARCH"; exit 1 ;; |
47 | 29 | esac |
48 | 30 |
|
49 | | -echo -e "Detected: ${YELLOW}$PLATFORM${NC}" |
| 31 | +echo "Detected: Linux $PLATFORM" |
50 | 32 | echo "" |
51 | 33 |
|
52 | | -# Check for required tools |
53 | 34 | if ! command -v curl &> /dev/null && ! command -v wget &> /dev/null; then |
54 | | - echo -e "${RED}Error: curl or wget is required${NC}" |
| 35 | + echo "Error: curl or wget is required" |
55 | 36 | exit 1 |
56 | 37 | fi |
57 | 38 |
|
58 | | -# Get latest release |
| 39 | +echo "Fetching latest release..." |
| 40 | + |
59 | 41 | if command -v curl &> /dev/null; then |
60 | 42 | RELEASE_DATA=$(curl -s "$API_URL") |
61 | 43 | else |
62 | 44 | RELEASE_DATA=$(wget -qO- "$API_URL") |
63 | 45 | fi |
64 | 46 |
|
65 | 47 | if [ -z "$RELEASE_DATA" ] || echo "$RELEASE_DATA" | grep -q "Not Found"; then |
66 | | - echo -e "${RED}Error: Failed to fetch release information${NC}" |
| 48 | + echo "Error: Failed to fetch release information" |
67 | 49 | exit 1 |
68 | 50 | fi |
69 | 51 |
|
70 | | -# Parse version |
71 | 52 | VERSION=$(echo "$RELEASE_DATA" | grep -o '"tag_name": "[^"]*"' | cut -d'"' -f4) |
72 | 53 | if [ -z "$VERSION" ]; then |
73 | | - echo -e "${RED}Error: Failed to parse version${NC}" |
| 54 | + echo "Error: Failed to parse version" |
74 | 55 | exit 1 |
75 | 56 | fi |
76 | 57 |
|
77 | | -echo -e "Latest version: ${GREEN}$VERSION${NC}" |
| 58 | +echo "Latest version: $VERSION" |
78 | 59 | echo "" |
79 | 60 |
|
80 | | -# Find asset URL |
81 | | -ASSET_PATTERN="${PLATFORM}" |
82 | | -ASSET_URL=$(echo "$RELEASE_DATA" | grep -o '"browser_download_url": "[^"]*' | grep "$ASSET_PATTERN" | head -1 | cut -d'"' -f4) |
| 61 | +ASSET_URL=$(echo "$RELEASE_DATA" | grep -o '"browser_download_url": "[^"]*\.AppImage"' | grep -i "linux.*${PLATFORM}\|${PLATFORM}.*linux\|appimage" | head -1 | cut -d'"' -f4) |
83 | 62 |
|
84 | 63 | if [ -z "$ASSET_URL" ]; then |
85 | | - echo -e "${YELLOW}No prebuilt binary found for $PLATFORM${NC}" |
86 | | - echo "Falling back to npm installation..." |
87 | | - echo "" |
88 | | - |
89 | | - if ! command -v npm &> /dev/null; then |
90 | | - echo -e "${RED}Error: npm is not installed${NC}" |
91 | | - echo "Please install Node.js first: https://nodejs.org" |
92 | | - exit 1 |
93 | | - fi |
94 | | - |
95 | | - echo -e "${BLUE}Installing via npm...${NC}" |
96 | | - npm install -g openlinear |
97 | | - |
98 | | - if command -v openlinear &> /dev/null; then |
99 | | - echo "" |
100 | | - echo -e "${GREEN}✓ OpenLinear installed successfully!${NC}" |
101 | | - echo "" |
102 | | - echo "Run 'openlinear --help' to get started" |
103 | | - else |
104 | | - echo -e "${RED}Error: Installation failed${NC}" |
105 | | - exit 1 |
106 | | - fi |
107 | | - |
108 | | - exit 0 |
109 | | -fi |
110 | | - |
111 | | -echo -e "${BLUE}Downloading...${NC}" |
112 | | - |
113 | | -# Create temp directory |
114 | | -TMP_DIR=$(mktemp -d) |
115 | | -trap "rm -rf $TMP_DIR" EXIT |
116 | | - |
117 | | -# Download |
118 | | -DOWNLOAD_FILE="$TMP_DIR/openlinear-${PLATFORM}.tar.gz" |
119 | | - |
120 | | -if command -v curl &> /dev/null; then |
121 | | - curl -fsSL "$ASSET_URL" -o "$DOWNLOAD_FILE" --progress-bar |
122 | | -else |
123 | | - wget -q --show-progress "$ASSET_URL" -O "$DOWNLOAD_FILE" |
| 64 | + echo "Error: No AppImage found for Linux $PLATFORM" |
| 65 | + exit 1 |
124 | 66 | fi |
125 | 67 |
|
| 68 | +echo "Downloading OpenLinear..." |
126 | 69 | echo "" |
127 | | -echo -e "${BLUE}Extracting...${NC}" |
128 | 70 |
|
129 | | -# Extract |
130 | | -tar -xzf "$DOWNLOAD_FILE" -C "$TMP_DIR" |
131 | | - |
132 | | -# Install |
133 | 71 | mkdir -p "$INSTALL_DIR" |
134 | 72 |
|
135 | | -# Find the binary in extracted files |
136 | | -if [ -f "$TMP_DIR/openlinear" ]; then |
137 | | - BINARY_PATH="$TMP_DIR/openlinear" |
138 | | -elif [ -f "$TMP_DIR/openlinear-desktop" ]; then |
139 | | - BINARY_PATH="$TMP_DIR/openlinear-desktop" |
| 73 | +if command -v curl &> /dev/null; then |
| 74 | + curl -fsSL "$ASSET_URL" -o "$INSTALL_DIR/$BINARY_NAME" --progress-bar |
140 | 75 | else |
141 | | - BINARY_PATH=$(find "$TMP_DIR" -type f -executable | head -1) |
| 76 | + wget -q --show-progress "$ASSET_URL" -O "$INSTALL_DIR/$BINARY_NAME" |
142 | 77 | fi |
143 | 78 |
|
144 | | -cp "$BINARY_PATH" "$INSTALL_DIR/$BIN_NAME" |
145 | | -chmod +x "$INSTALL_DIR/$BIN_NAME" |
146 | | - |
147 | | -# Check if install dir is in PATH |
148 | | -if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then |
149 | | - echo "" |
150 | | - echo -e "${YELLOW}Warning: $INSTALL_DIR is not in your PATH${NC}" |
151 | | - echo "" |
152 | | - echo "Add the following to your shell profile (~/.bashrc, ~/.zshrc, etc.):" |
153 | | - echo "" |
154 | | - echo " export PATH=\"\$PATH:$INSTALL_DIR\"" |
155 | | - echo "" |
156 | | -fi |
| 79 | +chmod +x "$INSTALL_DIR/$BINARY_NAME" |
157 | 80 |
|
158 | 81 | echo "" |
159 | | -echo -e "${GREEN}✓ OpenLinear $VERSION installed successfully!${NC}" |
| 82 | +echo "✓ OpenLinear $VERSION installed successfully!" |
160 | 83 | echo "" |
161 | | -echo "Location: $INSTALL_DIR/$BIN_NAME" |
| 84 | +echo "Location: $INSTALL_DIR/$BINARY_NAME" |
162 | 85 | echo "" |
163 | | - |
164 | | -if command -v openlinear &> /dev/null; then |
165 | | - echo "Run 'openlinear --help' to get started" |
166 | | -else |
167 | | - echo "Please restart your terminal or run:" |
168 | | - echo " export PATH=\"\$PATH:$INSTALL_DIR\"" |
169 | | -fi |
| 86 | +echo "Run OpenLinear with:" |
| 87 | +echo " $INSTALL_DIR/$BINARY_NAME" |
| 88 | +echo "" |
| 89 | +echo "Or install the npm wrapper for easier access:" |
| 90 | +echo " npm install -g openlinear" |
0 commit comments