A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
feat: add Linux Desktop OS Binary Installer creator.
towfiqie2e2027fdfc4
diff --git a/.gitignore b/.gitignoreindex 515773f..45a7c87 100644--- a/.gitignore+++ b/.gitignore@@ -10,9 +10,15 @@ lerna-debug.log*node_modulesdistdist-ssr+dist-lib*.local/.turbo+# Installer build artifacts+*.AppImage+*.zsync+.DirIcon+# Editor directories and files.vscode/*diff --git a/backend/src/utils/binaryPathResolver.ts b/backend/src/utils/binaryPathResolver.tsindex 1b1022c..1ea5e29 100644--- a/backend/src/utils/binaryPathResolver.ts+++ b/backend/src/utils/binaryPathResolver.ts@@ -4,8 +4,12 @@ import fs from 'fs';/*** Resolves the path to a bundled binary ('restic', 'rclone' or 'rear').- * In a pkg-packaged application, it looks for binaries in {executableDir}/binaries/{platform}-{arch}/- * In development, it points to the local './binaries' folder.+ * Checks multiple locations in priority order:+ * 1. AppImage: $APPDIR/usr/bin/binaries/{platform}-{arch}/+ * 2. pkg-packaged: {executableDir}/binaries/{platform}-{arch}/+ * 3. Production: {executableDir}/{binaryName}+ * 4. Development: {cwd}/binaries/{platform}-{arch}/+ * 5. Fallback: System PATH** @param binaryName The name of the binary ('restic', 'rclone', or 'rear').* @returns The absolute path to the executable.@@ -13,10 +17,24 @@ import fs from 'fs';export function getBinaryPath(binaryName: 'restic' | 'rclone' | 'rear'): string {const isWindows = os.platform() === 'win32';const fileName = isWindows ? `${binaryName}.exe` : binaryName;+ const platformId = `${os.platform()}-${os.arch()}`;++ // Priority 1: Check if running inside an AppImage+ const appDir = process.env.APPDIR;+ if (appDir) {+ const appImageBinaryPath = path.join(appDir, 'usr', 'bin', 'binaries', platformId, fileName);- // Priority 1: Check if running as a pkg-packaged executable+ if (fs.existsSync(appImageBinaryPath)) {+ return appImageBinaryPath;+ }++ console.warn(+ `[binaryPathResolver] Expected binary at '${appImageBinaryPath}' (AppImage) but not found. Trying fallbacks...`+ );+ }++ // Priority 2: Check if running as a pkg-packaged executableif ((process as any).pkg) {- const platformId = `${os.platform()}-${os.arch()}`;const execDir = path.dirname(process.execPath);const pkgBinaryPath = path.join(execDir, 'binaries', platformId, fileName);@@ -29,7 +47,7 @@ export function getBinaryPath(binaryName: 'restic' | 'rclone' | 'rear'): string);}- // Priority 2: Production/installed binary next to executable+ // Priority 3: Production/installed binary next to executableconst installDir = path.dirname(process.execPath);const productionPath = path.join(installDir, fileName);@@ -37,8 +55,7 @@ export function getBinaryPath(binaryName: 'restic' | 'rclone' | 'rear'): stringreturn productionPath;}- // Priority 3: Development - Look in the project's 'binaries' folder- const platformId = `${os.platform()}-${os.arch()}`;+ // Priority 4: Development - Look in the project's 'binaries' folderconst devPath = path.resolve(process.cwd(), 'binaries', platformId, fileName);if (fs.existsSync(devPath)) {diff --git a/backend/src/utils/installHelpers.ts b/backend/src/utils/installHelpers.tsindex 3750a59..bbfe845 100644--- a/backend/src/utils/installHelpers.ts+++ b/backend/src/utils/installHelpers.ts@@ -37,11 +37,17 @@ export function getInstallType(): InstallType {/*** Checks if running on a Linux desktop environment (not headless/server)- * by checking for common display environment variables+ * by checking for common display environment variables or the PLUTON_LINUX_DESKTOP flag+ * set by the AppImage installer for systemd service mode.*/export function isLinuxDesktop(): boolean {if (process.platform !== 'linux') return false;+ // Check for explicit desktop flag (set by AppImage installer for systemd service)+ if (process.env.PLUTON_LINUX_DESKTOP === 'true' || process.env.PLUTON_LINUX_DESKTOP === '1') {+ return true;+ }+// Check for display server (X11 or Wayland)const hasDisplay = !!(process.env.DISPLAY || process.env.WAYLAND_DISPLAY);diff --git a/installers/linux/.gitignore b/installers/linux/.gitignorenew file mode 100644index 0000000..a5c9ed8--- /dev/null+++ b/installers/linux/.gitignore@@ -0,0 +1,17 @@+# Downloaded tools+appimagetool-*.AppImage++# Build outputs+*.zsync+*.AppImage++# Files copied during build (from dist/)+AppDir/pluton.png+AppDir/usr/bin/pluton+AppDir/usr/bin/binaries/+AppDir/usr/bin/node_modules/+AppDir/usr/bin/drizzle/++# Legacy locations (if any)+AppDir/usr/lib/+AppDir/usr/share/pluton/drizzle/diff --git a/installers/linux/AppDir/AppRun b/installers/linux/AppDir/AppRunnew file mode 100644index 0000000..8507202--- /dev/null+++ b/installers/linux/AppDir/AppRun@@ -0,0 +1,57 @@+#!/bin/bash+# AppRun - Entry point for Pluton AppImage+# Supports: direct run, --install, --uninstall modes++set -e++# Get the directory where the AppImage is mounted+APPDIR="$(dirname "$(readlink -f "$0")")"+export APPDIR++# Export AppImage-specific environment variables for binary resolution+export APPIMAGE_MODE=1++# Set library path for native modules+export LD_LIBRARY_PATH="${APPDIR}/usr/lib:${APPDIR}/usr/lib/node_modules:${LD_LIBRARY_PATH}"++# Handle command line arguments+case "$1" in+ --install)+ # Installation mode - requires root+ if [ "$EUID" -ne 0 ]; then+ echo "Installation requires root privileges. Please run with sudo:"+ echo " sudo $APPIMAGE --install"+ exit 1+ fi+ exec "${APPDIR}/usr/share/pluton/install.sh" "$@"+ ;;+ --uninstall)+ # Uninstallation mode - requires root+ if [ "$EUID" -ne 0 ]; then+ echo "Uninstallation requires root privileges. Please run with sudo:"+ echo " sudo $APPIMAGE --uninstall"+ exit 1+ fi+ exec "${APPDIR}/usr/share/pluton/uninstall.sh" "$@"+ ;;+ --help|-h)+ echo "Pluton - Automated Backup Solution"+ echo ""+ echo "Usage:"+ echo " ./Pluton.AppImage Run Pluton directly"+ echo " sudo ./Pluton.AppImage --install Install as system service"+ echo " sudo ./Pluton.AppImage --uninstall Uninstall system service"+ echo ""+ echo "Options:"+ echo " --install Install Pluton as a systemd service (requires root)"+ echo " --uninstall Remove Pluton service and files (requires root)"+ echo " --help, -h Show this help message"+ echo ""+ echo "After installation, access Pluton at: http://localhost:5173"+ exit 0+ ;;+ *)+ # Normal run mode - execute the pluton binary+ exec "${APPDIR}/usr/bin/pluton" "$@"+ ;;+esacdiff --git a/installers/linux/AppDir/pluton.desktop b/installers/linux/AppDir/pluton.desktopnew file mode 100644index 0000000..041e37a--- /dev/null+++ b/installers/linux/AppDir/pluton.desktop@@ -0,0 +1,10 @@+[Desktop Entry]+Name=Pluton+Comment=Automated Backup Solution+Exec=pluton+Icon=pluton+Type=Application+Categories=Utility;+Terminal=false+StartupNotify=true+X-AppImage-Version=0.0.1diff --git a/installers/linux/AppDir/usr/share/pluton/install.sh b/installers/linux/AppDir/usr/share/pluton/install.shnew file mode 100644index 0000000..5238697--- /dev/null+++ b/installers/linux/AppDir/usr/share/pluton/install.sh@@ -0,0 +1,235 @@+#!/bin/bash+# Pluton Installation Script+# Installs Pluton as a systemd service running with root privileges++set -e++# Colors for output+RED='\033[0;31m'+GREEN='\033[0;32m'+YELLOW='\033[1;33m'+BLUE='\033[0;34m'+NC='\033[0m' # No Color++# Installation paths+INSTALL_DIR="/opt/pluton"+DATA_DIR="/var/lib/pluton"+SERVICE_FILE="/etc/systemd/system/pluton.service"++# Default configuration+DEFAULT_PORT=5173+DEFAULT_MAX_CONCURRENT=2++echo -e "${BLUE}"+echo "╔═══════════════════════════════════════════════════════════╗"+echo "║ Pluton Backup Service - Installer ║"+echo "╚═══════════════════════════════════════════════════════════╝"+echo -e "${NC}"++# Check for root privileges+if [ "$EUID" -ne 0 ]; then+ echo -e "${RED}Error: This script must be run as root.${NC}"+ echo "Please run: sudo $0"+ exit 1+fi++# Get APPDIR (set by AppRun or passed as argument)+if [ -z "$APPDIR" ]; then+ APPDIR="$(dirname "$(readlink -f "$0")")/.."+fi++# Check if already installed+if systemctl is-active --quiet pluton 2>/dev/null; then+ echo -e "${YELLOW}Pluton service is already running.${NC}"+ read -p "Do you want to reinstall? This will stop the current service. [y/N] " -n 1 -r+ echo+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then+ echo "Installation cancelled."+ exit 0+ fi+ echo "Stopping existing service..."+ systemctl stop pluton+ systemctl disable pluton+fi++# Configuration: Check for config file or prompt user+CONFIG_FILE="${APPDIR}/pluton-config.env"+if [ -f "$CONFIG_FILE" ]; then+ echo -e "${GREEN}Found configuration file: ${CONFIG_FILE}${NC}"+ source "$CONFIG_FILE"+ SERVER_PORT="${SERVER_PORT:-$DEFAULT_PORT}"+ MAX_CONCURRENT_BACKUPS="${MAX_CONCURRENT_BACKUPS:-$DEFAULT_MAX_CONCURRENT}"+else+ echo -e "${BLUE}Configuration Setup${NC}"+ echo "Press Enter to accept default values."+ echo ""++ # Server Port+ read -p "Server Port [${DEFAULT_PORT}]: " SERVER_PORT+ SERVER_PORT="${SERVER_PORT:-$DEFAULT_PORT}"++ # Validate port+ if ! [[ "$SERVER_PORT" =~ ^[0-9]+$ ]] || [ "$SERVER_PORT" -lt 1024 ] || [ "$SERVER_PORT" -gt 65535 ]; then+ echo -e "${RED}Error: Invalid port. Must be between 1024 and 65535.${NC}"+ exit 1+ fi++ # Max Concurrent Backups+ read -p "Max Concurrent Backups [${DEFAULT_MAX_CONCURRENT}]: " MAX_CONCURRENT_BACKUPS+ MAX_CONCURRENT_BACKUPS="${MAX_CONCURRENT_BACKUPS:-$DEFAULT_MAX_CONCURRENT}"++ # Validate max concurrent+ if ! [[ "$MAX_CONCURRENT_BACKUPS" =~ ^[0-9]+$ ]] || [ "$MAX_CONCURRENT_BACKUPS" -lt 1 ] || [ "$MAX_CONCURRENT_BACKUPS" -gt 10 ]; then+ echo -e "${RED}Error: Invalid value. Must be between 1 and 10.${NC}"+ exit 1+ fi+fi++echo ""+echo -e "${BLUE}Installing Pluton...${NC}"++# Create installation directory+echo " Creating installation directory: ${INSTALL_DIR}"+mkdir -p "${INSTALL_DIR}"+mkdir -p "${INSTALL_DIR}/binaries"+mkdir -p "${INSTALL_DIR}/node_modules"+mkdir -p "${INSTALL_DIR}/drizzle"++# Create data directory with subdirectories+echo " Creating data directory: ${DATA_DIR}"+mkdir -p "${DATA_DIR}/config"+mkdir -p "${DATA_DIR}/db"+mkdir -p "${DATA_DIR}/logs"+mkdir -p "${DATA_DIR}/backups"+mkdir -p "${DATA_DIR}/progress"+mkdir -p "${DATA_DIR}/rescue"+mkdir -p "${DATA_DIR}/restore"+mkdir -p "${DATA_DIR}/stats"+mkdir -p "${DATA_DIR}/sync"++# Copy executable+echo " Copying executable..."+cp "${APPDIR}/usr/bin/pluton" "${INSTALL_DIR}/pluton"+chmod +x "${INSTALL_DIR}/pluton"++# Copy binaries (restic, rclone)+echo " Copying binaries..."+if [ -d "${APPDIR}/usr/bin/binaries" ]; then+ cp -r "${APPDIR}/usr/bin/binaries"/* "${INSTALL_DIR}/binaries/"+ chmod +x "${INSTALL_DIR}/binaries"/*/*+fi++# Copy native modules (from usr/bin/node_modules where pkg expects them)+echo " Copying native modules..."+if [ -d "${APPDIR}/usr/bin/node_modules" ]; then+ cp -r "${APPDIR}/usr/bin/node_modules"/* "${INSTALL_DIR}/node_modules/"+fi++# Copy drizzle migrations+echo " Copying database migrations..."+if [ -d "${APPDIR}/usr/bin/drizzle" ]; then+ cp -r "${APPDIR}/usr/bin/drizzle"/* "${INSTALL_DIR}/drizzle/"+fi++# Write configuration file+echo " Writing configuration..."+cat > "${DATA_DIR}/config/config.json" << EOF+{+ "SERVER_PORT": ${SERVER_PORT},+ "MAX_CONCURRENT_BACKUPS": ${MAX_CONCURRENT_BACKUPS}+}+EOF++# Create systemd service file+echo " Creating systemd service..."+cat > "${SERVICE_FILE}" << EOF+[Unit]+Description=Pluton Backup Service+After=network.target++[Service]+Type=simple+ExecStart=${INSTALL_DIR}/pluton+WorkingDirectory=${DATA_DIR}+User=root+Restart=on-failure+RestartSec=5+StandardOutput=append:${DATA_DIR}/logs/stdout.log+StandardError=append:${DATA_DIR}/logs/stderr.log+Environment="PLUTON_DATA_DIR=${DATA_DIR}"+Environment="NODE_ENV=production"+Environment="PLUTON_LINUX_DESKTOP=true"++[Install]+WantedBy=multi-user.target+EOF++# Copy uninstall script+echo " Installing uninstall script..."+cp "${APPDIR}/usr/share/pluton/uninstall.sh" "${INSTALL_DIR}/uninstall.sh"+chmod +x "${INSTALL_DIR}/uninstall.sh"++# Copy icon for desktop shortcut+echo " Copying icon..."+if [ -f "${APPDIR}/pluton.png" ]; then+ cp "${APPDIR}/pluton.png" "${INSTALL_DIR}/pluton.png"+fi++# Create desktop shortcut for browser access+echo " Creating desktop shortcut..."+DESKTOP_FILE="/usr/share/applications/pluton.desktop"+cat > "${DESKTOP_FILE}" << EOF+[Desktop Entry]+Name=Pluton+Comment=Open Pluton Backup Dashboard+Exec=xdg-open http://localhost:${SERVER_PORT}+Icon=${INSTALL_DIR}/pluton.png+Type=Application+Categories=Utility;+Terminal=false+StartupNotify=false+EOF++# Update desktop database+update-desktop-database /usr/share/applications 2>/dev/null || true++# Reload systemd and enable service+echo " Enabling service..."+systemctl daemon-reload+systemctl enable pluton++# Start the service+echo " Starting service..."+systemctl start pluton++# Wait a moment for the service to start+sleep 2++# Check status+if systemctl is-active --quiet pluton; then+ echo ""+ echo -e "${GREEN}╔═══════════════════════════════════════════════════════════╗${NC}"+ echo -e "${GREEN}║ Pluton installed successfully! ║${NC}"+ echo -e "${GREEN}╚═══════════════════════════════════════════════════════════╝${NC}"+ echo ""+ echo -e " ${BLUE}Access Pluton at:${NC} http://localhost:${SERVER_PORT}"+ echo ""+ echo -e " ${BLUE}Service commands:${NC}"+ echo " sudo systemctl status pluton - Check status"+ echo " sudo systemctl stop pluton - Stop service"+ echo " sudo systemctl start pluton - Start service"+ echo " sudo systemctl restart pluton - Restart service"+ echo ""+ echo -e " ${BLUE}Logs:${NC}"+ echo " ${DATA_DIR}/logs/stdout.log"+ echo " ${DATA_DIR}/logs/stderr.log"+ echo ""+ echo -e " ${BLUE}Uninstall:${NC}"+ echo " sudo ${INSTALL_DIR}/uninstall.sh"+ echo ""+else+ echo ""+ echo -e "${RED}Warning: Service may not have started correctly.${NC}"+ echo "Check status with: sudo systemctl status pluton"+ echo "Check logs with: sudo journalctl -u pluton -f"+fidiff --git a/installers/linux/AppDir/usr/share/pluton/pluton.service.template b/installers/linux/AppDir/usr/share/pluton/pluton.service.templatenew file mode 100644index 0000000..5e64a2d--- /dev/null+++ b/installers/linux/AppDir/usr/share/pluton/pluton.service.template@@ -0,0 +1,19 @@+[Unit]+Description=Pluton Backup Service+After=network.target++[Service]+Type=simple+ExecStart=/opt/pluton/pluton+WorkingDirectory=/var/lib/pluton+User=root+Restart=on-failure+RestartSec=5+StandardOutput=append:/var/lib/pluton/logs/stdout.log+StandardError=append:/var/lib/pluton/logs/stderr.log+Environment="PLUTON_DATA_DIR=/var/lib/pluton"+Environment="NODE_ENV=production"+Environment="PLUTON_LINUX_DESKTOP=true"++[Install]+WantedBy=multi-user.targetdiff --git a/installers/linux/AppDir/usr/share/pluton/uninstall.sh b/installers/linux/AppDir/usr/share/pluton/uninstall.shnew file mode 100644index 0000000..43f9414--- /dev/null+++ b/installers/linux/AppDir/usr/share/pluton/uninstall.sh@@ -0,0 +1,120 @@+#!/bin/bash+# Pluton Uninstallation Script+# Removes Pluton service and optionally all data++set -e++# Colors for output+RED='\033[0;31m'+GREEN='\033[0;32m'+YELLOW='\033[1;33m'+BLUE='\033[0;34m'+NC='\033[0m' # No Color++# Installation paths+INSTALL_DIR="/opt/pluton"+DATA_DIR="/var/lib/pluton"+SERVICE_FILE="/etc/systemd/system/pluton.service"+DESKTOP_FILE="/usr/share/applications/pluton.desktop"+ICON_FILE="/usr/share/icons/hicolor/256x256/apps/pluton.png"++echo -e "${BLUE}"+echo "╔═══════════════════════════════════════════════════════════╗"+echo "║ Pluton Backup Service - Uninstaller ║"+echo "╚═══════════════════════════════════════════════════════════╝"+echo -e "${NC}"++# Check for root privileges+if [ "$EUID" -ne 0 ]; then+ echo -e "${RED}Error: This script must be run as root.${NC}"+ echo "Please run: sudo $0"+ exit 1+fi++# Check if Pluton is installed+if [ ! -f "${SERVICE_FILE}" ] && [ ! -d "${INSTALL_DIR}" ]; then+ echo -e "${YELLOW}Pluton does not appear to be installed.${NC}"+ exit 0+fi++echo -e "${YELLOW}This will remove Pluton from your system.${NC}"+echo ""++# Stop and disable service if it exists+if [ -f "${SERVICE_FILE}" ]; then+ echo "Stopping Pluton service..."+ systemctl stop pluton 2>/dev/null || true++ echo "Disabling Pluton service..."+ systemctl disable pluton 2>/dev/null || true++ echo "Removing service file..."+ rm -f "${SERVICE_FILE}"++ echo "Reloading systemd..."+ systemctl daemon-reload+fi++# Ask about data removal+echo ""+echo -e "${YELLOW}Do you want to remove all configuration and backup data?${NC}"+echo " Data directory: ${DATA_DIR}"+echo ""+echo " This includes:"+echo " - Configuration files"+echo " - Database"+echo " - Logs"+echo " - Local backup copies"+echo ""+read -p "Remove all data? [y/N] " -n 1 -r+echo ""++REMOVE_DATA=false+if [[ $REPLY =~ ^[Yy]$ ]]; then+ REMOVE_DATA=true+fi++# Remove installation directory+if [ -d "${INSTALL_DIR}" ]; then+ echo "Removing installation directory: ${INSTALL_DIR}"+ rm -rf "${INSTALL_DIR}"+fi++# Remove desktop shortcut and icon+if [ -f "${DESKTOP_FILE}" ]; then+ echo "Removing desktop shortcut..."+ rm -f "${DESKTOP_FILE}"+fi++if [ -f "${ICON_FILE}" ]; then+ echo "Removing application icon..."+ rm -f "${ICON_FILE}"+fi++# Update desktop database+if command -v update-desktop-database &> /dev/null; then+ update-desktop-database /usr/share/applications 2>/dev/null || true+fi++# Remove data directory if requested+if [ "$REMOVE_DATA" = true ]; then+ if [ -d "${DATA_DIR}" ]; then+ echo "Removing data directory: ${DATA_DIR}"+ rm -rf "${DATA_DIR}"+ fi+else+ echo -e "${BLUE}Keeping data directory: ${DATA_DIR}${NC}"+fi++echo ""+echo -e "${GREEN}╔═══════════════════════════════════════════════════════════╗${NC}"+echo -e "${GREEN}║ Pluton uninstalled successfully! ║${NC}"+echo -e "${GREEN}╚═══════════════════════════════════════════════════════════╝${NC}"+echo ""++if [ "$REMOVE_DATA" = false ]; then+ echo -e "${BLUE}Note:${NC} Your data has been preserved at: ${DATA_DIR}"+ echo "To completely remove all data, run: sudo rm -rf ${DATA_DIR}"+fi++echo ""diff --git a/installers/linux/build-appimage.sh b/installers/linux/build-appimage.shnew file mode 100644index 0000000..998da6e--- /dev/null+++ b/installers/linux/build-appimage.sh@@ -0,0 +1,261 @@+#!/bin/bash+# Build script for Pluton AppImage+# Run this script in WSL on Windows (access project via /mnt/c/ or /mnt/f/)+#+# Usage:+# ./build-appimage.sh # Build for all available architectures+# ./build-appimage.sh all # Build for all available architectures+# ./build-appimage.sh x64 # Build for x86_64 only+# ./build-appimage.sh arm64 # Build for ARM64 only+# ./build-appimage.sh x64 pluton-pro # Build x86_64 with custom name+# ./build-appimage.sh all pluton-pro # Build all with custom name (for PRO edition)+#+# From Windows, run in WSL:+# wsl -e bash -c "cd /mnt/f/JS/apps/pluton/codebase/pluton-app/pluton/installers/linux && ./build-appimage.sh"++set -e++# Colors for output+RED='\033[0;31m'+GREEN='\033[0;32m'+YELLOW='\033[1;33m'+BLUE='\033[1;34m'+NC='\033[0m' # No Color++# Get script directory+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+ROOT_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"+APPDIR="${SCRIPT_DIR}/AppDir"++# Get version from package.json+VERSION=$(grep -o '"version": *"[^"]*"' "${ROOT_DIR}/backend/package.json" | head -1 | cut -d'"' -f4)+if [ -z "$VERSION" ]; then+ VERSION="0.0.0"+fi++# Output name (default: Pluton, can be overridden for PRO edition)+# Passed as second argument: ./build-appimage.sh x64 pluton-pro+OUTPUT_NAME="${2:-Pluton}"+# Capitalize first letter for display name+DISPLAY_NAME="$(echo "$OUTPUT_NAME" | sed 's/.*/\u&/')"++# Output directory+OUTPUT_DIR="${ROOT_DIR}/dist/installers"+mkdir -p "$OUTPUT_DIR"++# Track built architectures+BUILT_ARCHS=()+FAILED_ARCHS=()++#######################################+# Build AppImage for a specific architecture+# Arguments:+# $1 - Architecture (x64 or arm64)+#######################################+build_appimage() {+ local INPUT_ARCH="$1"+ local ARCH+ local PLATFORM_ID+ local APPIMAGETOOL_ARCH++ case "$INPUT_ARCH" in+ x64|x86_64|amd64)+ ARCH="x86_64"+ PLATFORM_ID="linux-x64"+ APPIMAGETOOL_ARCH="x86_64"+ ;;+ arm64|aarch64)+ ARCH="aarch64"+ PLATFORM_ID="linux-arm64"+ APPIMAGETOOL_ARCH="x86_64" # Use x86_64 appimagetool with --appimage-extract-and-run+ ;;+ *)+ echo -e "${RED}Error: Unsupported architecture: ${INPUT_ARCH}${NC}"+ return 1+ ;;+ esac++ echo ""+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"+ echo -e "${BLUE} Building for: ${ARCH} (${PLATFORM_ID})${NC}"+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"++ # Check for distribution files (try both locations)+ # For PRO edition, look for pluton-pro-linux-x64, for regular look for pluton-linux-x64+ local DIST_NAME="$(echo "$OUTPUT_NAME" | tr '[:upper:]' '[:lower:]')"+ local DIST_DIR="${ROOT_DIR}/dist/executables/${DIST_NAME}-${PLATFORM_ID}"+ if [ ! -d "$DIST_DIR" ]; then+ # Fallback to old location+ DIST_DIR="${ROOT_DIR}/dist/${DIST_NAME}-${PLATFORM_ID}"+ fi+ if [ ! -d "$DIST_DIR" ]; then+ echo -e "${YELLOW}Skipping ${ARCH}: Distribution directory not found${NC}"+ echo -e "${YELLOW} Checked: ${ROOT_DIR}/dist/executables/${DIST_NAME}-${PLATFORM_ID}${NC}"+ echo -e "${YELLOW} Checked: ${ROOT_DIR}/dist/${DIST_NAME}-${PLATFORM_ID}${NC}"+ echo -e "${YELLOW} Run 'node scripts/build-executables.js --name ${DIST_NAME}' first.${NC}"+ FAILED_ARCHS+=("$ARCH (no dist)")+ return 0+ fi++ # Download appimagetool if not present (always use x86_64 version)+ local APPIMAGETOOL="${SCRIPT_DIR}/appimagetool-${APPIMAGETOOL_ARCH}.AppImage"+ if [ ! -f "$APPIMAGETOOL" ]; then+ echo -e "${BLUE}Downloading appimagetool...${NC}"+ local APPIMAGETOOL_URL="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${APPIMAGETOOL_ARCH}.AppImage"+ curl -L -o "$APPIMAGETOOL" "$APPIMAGETOOL_URL"+ chmod +x "$APPIMAGETOOL"+ fi++ # Clean and prepare AppDir+ echo " Preparing AppDir..."+ rm -rf "${APPDIR}/usr/bin/pluton"+ rm -rf "${APPDIR}/usr/bin/binaries"+ rm -rf "${APPDIR}/usr/bin/node_modules"+ rm -rf "${APPDIR}/usr/bin/drizzle"++ mkdir -p "${APPDIR}/usr/bin"+ mkdir -p "${APPDIR}/usr/bin/binaries/${PLATFORM_ID}"+ mkdir -p "${APPDIR}/usr/bin/node_modules"+ mkdir -p "${APPDIR}/usr/bin/drizzle"++ # Copy main executable+ echo " Copying executable..."+ cp "${DIST_DIR}/pluton" "${APPDIR}/usr/bin/pluton"+ chmod +x "${APPDIR}/usr/bin/pluton"++ # Copy binaries (restic, rclone)+ echo " Copying binaries..."+ if [ -d "${DIST_DIR}/binaries/${PLATFORM_ID}" ]; then+ cp -r "${DIST_DIR}/binaries/${PLATFORM_ID}"/* "${APPDIR}/usr/bin/binaries/${PLATFORM_ID}/"+ chmod +x "${APPDIR}/usr/bin/binaries/${PLATFORM_ID}"/*+ fi++ # Copy native modules (must be next to executable for pkg to find them)+ echo " Copying native modules..."+ if [ -d "${DIST_DIR}/node_modules" ]; then+ cp -r "${DIST_DIR}/node_modules"/* "${APPDIR}/usr/bin/node_modules/"+ fi++ # Copy drizzle migrations (next to executable)+ echo " Copying database migrations..."+ if [ -d "${DIST_DIR}/drizzle" ]; then+ cp -r "${DIST_DIR}/drizzle"/* "${APPDIR}/usr/bin/drizzle/"+ fi++ # Copy icon (use 256x256 PNG)+ echo " Copying icon..."+ local ICON_SRC="${ROOT_DIR}/frontend/public/icons/icon-256x256.png"+ if [ -f "$ICON_SRC" ]; then+ cp "$ICON_SRC" "${APPDIR}/pluton.png"+ else+ echo -e "${YELLOW} Warning: Icon not found at ${ICON_SRC}${NC}"+ fi++ # Ensure AppRun is executable+ chmod +x "${APPDIR}/AppRun"++ # Ensure scripts are executable+ chmod +x "${APPDIR}/usr/share/pluton/install.sh"+ chmod +x "${APPDIR}/usr/share/pluton/uninstall.sh"++ # Update version in desktop file dynamically+ echo " Updating desktop file version..."+ sed -i "s/^X-AppImage-Version=.*/X-AppImage-Version=${VERSION}/" "${APPDIR}/pluton.desktop"++ # Build AppImage+ echo " Building AppImage..."+ local OUTPUT_FILE="${OUTPUT_DIR}/${DISPLAY_NAME}-${VERSION}-${ARCH}.AppImage"++ # Build with update information for delta updates+ local UPDATE_INFO="gh-releases-zsync|plutonhq|pluton|latest|${DISPLAY_NAME}-*-${ARCH}.AppImage.zsync"++ # Set ARCH environment variable for the target architecture+ ARCH="$ARCH" VERSION="$VERSION" "$APPIMAGETOOL" \+ --appimage-extract-and-run \+ -u "$UPDATE_INFO" \+ "$APPDIR" \+ "$OUTPUT_FILE"++ # Make AppImage executable+ chmod +x "$OUTPUT_FILE"++ # Calculate checksum+ echo " Generating checksum..."+ sha256sum "$OUTPUT_FILE" > "${OUTPUT_FILE}.sha256"++ echo -e "${GREEN} ✓ Built: ${OUTPUT_FILE}${NC}"+ echo " Size: $(du -h "$OUTPUT_FILE" | cut -f1)"++ BUILT_ARCHS+=("$ARCH")+}++#######################################+# Main script+#######################################++echo -e "${BLUE}"+echo "╔═══════════════════════════════════════════════════════════╗"+echo "║ ${DISPLAY_NAME} AppImage Builder ║"+echo "╚═══════════════════════════════════════════════════════════╝"+echo -e "${NC}"+echo " Name: ${DISPLAY_NAME}"+echo " Version: ${VERSION}"+echo " Output: ${OUTPUT_DIR}"+echo ""++# Determine which architectures to build+TARGET_ARCH="${1:-all}"++case "$TARGET_ARCH" in+ all|"")+ echo " Mode: Build all available architectures"+ build_appimage "x64"+ build_appimage "arm64"+ ;;+ x64|x86_64|amd64)+ echo " Mode: Build x86_64 only"+ build_appimage "x64"+ ;;+ arm64|aarch64)+ echo " Mode: Build ARM64 only"+ build_appimage "arm64"+ ;;+ *)+ echo -e "${RED}Error: Unknown architecture: ${TARGET_ARCH}${NC}"+ echo "Usage: $0 [all|x64|arm64]"+ exit 1+ ;;+esac++# Summary+echo ""+echo -e "${GREEN}╔═══════════════════════════════════════════════════════════╗${NC}"+echo -e "${GREEN}║ Build Complete ║${NC}"+echo -e "${GREEN}╚═══════════════════════════════════════════════════════════╝${NC}"+echo ""++if [ ${#BUILT_ARCHS[@]} -gt 0 ]; then+ echo -e " ${GREEN}Successfully built:${NC}"+ for arch in "${BUILT_ARCHS[@]}"; do+ echo " ✓ ${DISPLAY_NAME}-${VERSION}-${arch}.AppImage"+ done+fi++if [ ${#FAILED_ARCHS[@]} -gt 0 ]; then+ echo ""+ echo -e " ${YELLOW}Skipped:${NC}"+ for arch in "${FAILED_ARCHS[@]}"; do+ echo " ⚠ ${arch}"+ done+fi++echo ""+echo " Output directory: ${OUTPUT_DIR}"+echo ""+echo " Test an AppImage:"+echo " chmod +x ${DISPLAY_NAME}-${VERSION}-x86_64.AppImage"+echo " ./${DISPLAY_NAME}-${VERSION}-x86_64.AppImage"+echo ""+echo " Install as service:"+echo " sudo ./${DISPLAY_NAME}-${VERSION}-x86_64.AppImage --install"+echo ""diff --git a/package.json b/package.jsonindex bd015dd..626016a 100644--- a/package.json+++ b/package.json@@ -6,6 +6,7 @@"scripts": {"build": "turbo run build","build:executables": "node ./scripts/build-executables.js",+ "build:appimage:local": "wsl -e bash -c \"cd /mnt/f/JS/apps/pluton/codebase/pluton-app/pluton/installers/linux && ./build-appimage.sh all pluton\"","dev:backend": "pnpm --filter @plutonhq/core-backend dev","dev:frontend": "pnpm --filter @plutonhq/core-frontend dev","dev": "concurrently \"pnpm dev:backend\" \"pnpm dev:frontend\" "