@@ -11,11 +11,13 @@ BLUE='\\033[0;34m'
1111YELLOW='\\033[1;33m'
1212NC='\\033[0m'
1313
14- REPO=" kaizen403/openlinear"
14+ REPO=' kaizen403/openlinear'
1515API_URL="https://api.github.com/repos/\${REPO}/releases/latest"
1616RELEASES_URL="https://github.com/\${REPO}/releases/latest"
1717INSTALL_DIR="\${HOME}/.openlinear"
1818APPIMAGE_PATH="\${INSTALL_DIR}/openlinear.AppImage"
19+ MACOS_APP_PATH="\${INSTALL_DIR}/OpenLinear.app"
20+ MACOS_BINARY_PATH="\${MACOS_APP_PATH}/Contents/MacOS/OpenLinear"
1921BIN_DIR="\${HOME}/.local/bin"
2022BIN_PATH="\${BIN_DIR}/openlinear"
2123
@@ -26,23 +28,49 @@ echo ""
2628OS=$(uname -s | tr '[:upper:]' '[:lower:]')
2729ARCH=$(uname -m)
2830
29- if [ "$OS" != "linux" ] || [ "$ARCH" != "x86_64" ]; then
30- echo -e "\${RED}This installer currently supports Linux x86_64 only.\${NC}"
31- echo "Use one of these instead:"
32- echo " npm install -g openlinear"
33- echo " paru -S openlinear-bin"
34- echo " \${RELEASES_URL}"
35- exit 1
36- fi
31+ INSTALL_MODE=""
32+ ASSET_PATTERN=""
33+ ASSET_LABEL=""
34+
35+ case "$OS/$ARCH" in
36+ linux/x86_64)
37+ INSTALL_MODE="linux-appimage"
38+ ASSET_PATTERN='-x86_64\\.AppImage$'
39+ ASSET_LABEL='Linux AppImage'
40+ ;;
41+ darwin/x86_64)
42+ INSTALL_MODE="macos-app"
43+ ASSET_PATTERN='-x86_64\\.app\\.tar\\.gz$'
44+ ASSET_LABEL='macOS app bundle'
45+ ;;
46+ darwin/arm64)
47+ INSTALL_MODE="macos-app"
48+ ASSET_PATTERN='-aarch64\\.app\\.tar\\.gz$'
49+ ASSET_LABEL='macOS app bundle'
50+ ;;
51+ *)
52+ echo -e "\${RED}This installer currently supports macOS (Apple Silicon / Intel) and Linux x86_64 only.\${NC}"
53+ echo "Use one of these instead:"
54+ echo " npm install -g openlinear"
55+ echo " paru -S openlinear-bin"
56+ echo " \${RELEASES_URL}"
57+ exit 1
58+ ;;
59+ esac
3760
3861echo -e "Detected: \${YELLOW}$OS / $ARCH\${NC}"
3962echo ""
4063
41- if ! command -v curl \u0026> /dev/null; then
64+ if ! command -v curl > /dev/null 2>&1 ; then
4265 echo -e "\${RED}Error: curl is required\${NC}"
4366 exit 1
4467fi
4568
69+ if [ "$INSTALL_MODE" = "macos-app" ] && ! command -v tar >/dev/null 2>&1; then
70+ echo -e "\${RED}Error: tar is required on macOS installs\${NC}"
71+ exit 1
72+ fi
73+
4674echo -e "\${BLUE}Fetching latest release metadata...\${NC}"
4775RELEASE_DATA=$(curl -fsSL -H "Accept: application/vnd.github+json" -H "User-Agent: openlinear-installer" "$API_URL")
4876
@@ -52,7 +80,7 @@ if [ -z "$RELEASE_DATA" ] || echo "$RELEASE_DATA" | grep -q "Not Found"; then
5280fi
5381
5482VERSION=$(echo "$RELEASE_DATA" | grep -o '"tag_name":[[:space:]]*"[^"]*"' | cut -d'"' -f4)
55- ASSET_URL=$(echo "$RELEASE_DATA" | grep -o '"browser_download_url":[[:space:]]*"[^"]*' | cut -d'"' -f4 | grep -- '-x86_64.AppImage$' | head -1)
83+ ASSET_URL=$(echo "$RELEASE_DATA" | grep -o '"browser_download_url":[[:space:]]*"[^"]*' | cut -d'"' -f4 | grep -E -- "$ASSET_PATTERN" | head -1)
5684
5785if [ -z "$VERSION" ]; then
5886 echo -e "\${RED}Error: Failed to parse version\${NC}"
@@ -63,25 +91,25 @@ echo -e "Latest version: \${GREEN}$VERSION\${NC}"
6391echo ""
6492
6593if [ -z "$ASSET_URL" ]; then
66- echo -e "\${RED}No Linux AppImage found in the latest release.\${NC}"
94+ echo -e "\${RED}No \${ASSET_LABEL} found in the latest release.\${NC}"
6795 echo "Open \${RELEASES_URL} and download it manually."
6896 exit 1
6997fi
7098
71- echo -e "\${BLUE}Downloading...\${NC}"
99+ echo -e "\${BLUE}Downloading \${ASSET_LABEL} ...\${NC}"
72100
73101TMP_DIR=$(mktemp -d)
74102trap 'rm -rf "$TMP_DIR"' EXIT
75103
76- DOWNLOAD_FILE="$TMP_DIR/openlinear.AppImage"
77-
78- curl -fL "$ASSET_URL" -o "$DOWNLOAD_FILE" --progress-bar
79-
80- echo ""
81104mkdir -p "$INSTALL_DIR" "$BIN_DIR"
82- install -m 755 "$DOWNLOAD_FILE" "$APPIMAGE_PATH"
83105
84- cat > "$BIN_PATH" <<'EOF'
106+ if [ "$INSTALL_MODE" = "linux-appimage" ]; then
107+ DOWNLOAD_FILE="$TMP_DIR/openlinear.AppImage"
108+ curl -fL "$ASSET_URL" -o "$DOWNLOAD_FILE" --progress-bar
109+ echo ""
110+ install -m 755 "$DOWNLOAD_FILE" "$APPIMAGE_PATH"
111+
112+ cat > "$BIN_PATH" <<'EOF'
85113#!/usr/bin/env bash
86114set -euo pipefail
87115
122150export APPIMAGE_EXTRACT_AND_RUN=1
123151exec "$APPIMAGE_PATH" "$@"
124152EOF
153+ else
154+ DOWNLOAD_FILE="$TMP_DIR/OpenLinear.app.tar.gz"
155+ EXTRACT_DIR="$TMP_DIR/extracted"
156+
157+ curl -fL "$ASSET_URL" -o "$DOWNLOAD_FILE" --progress-bar
158+ echo ""
159+
160+ mkdir -p "$EXTRACT_DIR"
161+ tar -xzf "$DOWNLOAD_FILE" -C "$EXTRACT_DIR"
162+
163+ APP_BUNDLE=$(find "$EXTRACT_DIR" -maxdepth 1 -type d -name '*.app' | head -n 1)
164+ if [ -z "$APP_BUNDLE" ]; then
165+ echo -e "\${RED}Failed to extract OpenLinear.app from the downloaded archive.\${NC}"
166+ exit 1
167+ fi
168+
169+ rm -rf "$MACOS_APP_PATH"
170+ mv "$APP_BUNDLE" "$MACOS_APP_PATH"
171+ chmod +x "$MACOS_BINARY_PATH"
172+
173+ cat > "$BIN_PATH" <<'EOF'
174+ #!/usr/bin/env bash
175+ set -euo pipefail
176+
177+ APP_PATH="\${HOME}/.openlinear/OpenLinear.app/Contents/MacOS/OpenLinear"
178+
179+ if [ ! -x "$APP_PATH" ]; then
180+ echo "OpenLinear macOS app not found at $APP_PATH" >&2
181+ echo "Reinstall with: curl -fsSL https://raw.githubusercontent.com/kaizen403/openlinear/main/install.sh | bash" >&2
182+ exit 1
183+ fi
184+
185+ exec "$APP_PATH" "$@"
186+ EOF
187+ fi
125188
126189chmod +x "$BIN_PATH"
127190
@@ -131,14 +194,18 @@ if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
131194 echo ""
132195 echo "Add the following to your shell profile (~/.bashrc, ~/.zshrc, etc.):"
133196 echo ""
134- echo " export PATH=\"\\ $HOME/.local/bin:\\ $PATH\""
197+ echo ' export PATH=" $HOME/.local/bin:$PATH"'
135198 echo ""
136199fi
137200
138201echo ""
139202echo -e "\${GREEN}✓ OpenLinear $VERSION installed successfully!\${NC}"
140203echo ""
141- echo "AppImage: $APPIMAGE_PATH"
204+ if [ "$INSTALL_MODE" = "linux-appimage" ]; then
205+ echo "AppImage: $APPIMAGE_PATH"
206+ else
207+ echo "App bundle: $MACOS_APP_PATH"
208+ fi
142209echo "Launcher: $BIN_PATH"
143210echo ""
144211echo "Run 'openlinear'"
0 commit comments