fix installer script
Some checks failed
CI / test-build (push) Failing after 2m12s

This commit is contained in:
2025-12-15 01:37:04 +07:00
parent 7ac7e77f1d
commit 5abcbb7dda

View File

@@ -5,6 +5,8 @@
#
# Usage: sudo ./install.sh [options]
#
# Note: Run this script from the atlas repository root directory
#
set -e
@@ -25,6 +27,7 @@ HTTP_ADDR=":8080"
DB_PATH="/var/lib/atlas/atlas.db"
BUILD_BINARIES=true
SKIP_DEPS=false
REPO_DIR=""
# Parse command line arguments
while [[ $# -gt 0 ]]; do
@@ -49,6 +52,10 @@ while [[ $# -gt 0 ]]; do
HTTP_ADDR="$2"
shift 2
;;
--repo-dir)
REPO_DIR="$2"
shift 2
;;
-h|--help)
echo "AtlasOS Installation Script"
echo ""
@@ -60,6 +67,7 @@ while [[ $# -gt 0 ]]; do
echo " --skip-deps Skip dependency installation"
echo " --skip-build Skip building binaries (use existing)"
echo " --http-addr ADDR HTTP address (default: :8080)"
echo " --repo-dir DIR Repository directory (if not in current dir)"
echo " -h, --help Show this help message"
exit 0
;;
@@ -76,6 +84,9 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi
# Get script directory early (for path resolution)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Detect distribution
detect_distro() {
if [[ -f /etc/os-release ]]; then
@@ -204,16 +215,49 @@ build_binaries() {
echo -e "${GREEN}Building binaries...${NC}"
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Check if we're in the right directory
# Use REPO_DIR if specified, otherwise try current directory, then script directory
if [[ -n "$REPO_DIR" ]] && [[ -d "$REPO_DIR/cmd" ]] && [[ -f "$REPO_DIR/cmd/atlas-api/main.go" ]]; then
BUILD_DIR="$(cd "$REPO_DIR" && pwd)"
elif [[ -d "./cmd" ]] && [[ -f "./cmd/atlas-api/main.go" ]]; then
BUILD_DIR="$(pwd)"
elif [[ -d "$SCRIPT_DIR/cmd" ]] && [[ -f "$SCRIPT_DIR/cmd/atlas-api/main.go" ]]; then
BUILD_DIR="$SCRIPT_DIR"
elif [[ -d "$SCRIPT_DIR/../cmd" ]] && [[ -f "$SCRIPT_DIR/../cmd/atlas-api/main.go" ]]; then
BUILD_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
else
echo -e "${RED}Error: Cannot find source code directory${NC}"
echo " Current directory: $(pwd)"
echo " Script directory: $SCRIPT_DIR"
echo " Looking for: cmd/atlas-api/main.go"
echo ""
echo " Please ensure you're running the installer from the atlas repository root"
echo " Or specify the repository path with: --repo-dir /path/to/atlas"
exit 1
fi
cd "$BUILD_DIR"
echo "Building from: $(pwd)"
# Verify source files exist
if [[ ! -f "$BUILD_DIR/cmd/atlas-api/main.go" ]]; then
echo -e "${RED}Error: Cannot find cmd/atlas-api/main.go${NC}"
echo " Expected at: $BUILD_DIR/cmd/atlas-api/main.go"
exit 1
fi
# Build binaries
echo "Building atlas-api..."
go build -o "$INSTALL_DIR/bin/atlas-api" ./cmd/atlas-api
if ! go build -o "$INSTALL_DIR/bin/atlas-api" ./cmd/atlas-api; then
echo -e "${RED}Error: Failed to build atlas-api${NC}"
exit 1
fi
echo "Building atlas-tui..."
go build -o "$INSTALL_DIR/bin/atlas-tui" ./cmd/atlas-tui
if ! go build -o "$INSTALL_DIR/bin/atlas-tui" ./cmd/atlas-tui; then
echo -e "${RED}Error: Failed to build atlas-tui${NC}"
exit 1
fi
# Set permissions
chown root:root "$INSTALL_DIR/bin/atlas-api"
@@ -221,7 +265,7 @@ build_binaries() {
chmod 755 "$INSTALL_DIR/bin/atlas-api"
chmod 755 "$INSTALL_DIR/bin/atlas-tui"
echo -e "${GREEN}Binaries built${NC}"
echo -e "${GREEN}Binaries built successfully${NC}"
}
# Create systemd service