add new installer for alpha

This commit is contained in:
Warp Agent
2026-01-04 15:39:19 +07:00
parent 990c114531
commit 20af99b244
18 changed files with 2492 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
#!/bin/bash
#
# Application build and installation
#
build_and_install_application() {
log_info "Building and installing Calypso application..."
# Build backend
build_backend
# Build frontend
build_frontend
# Install binaries and assets
install_application_files
log_info "✓ Application built and installed"
}
build_backend() {
log_info "Building backend..."
cd "$PROJECT_ROOT/backend"
# Ensure Go is in PATH
export PATH=$PATH:/usr/local/go/bin
# Download dependencies
log_info "Downloading Go dependencies..."
go mod download
# Build binary
log_info "Building Go binary..."
go build -ldflags "-X main.version=$CALYPSO_VERSION -X main.buildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ) -X main.gitCommit=$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')" \
-o "$INSTALL_PREFIX/releases/$CALYPSO_VERSION/bin/calypso-api" \
./cmd/calypso-api
if [[ -f "$INSTALL_PREFIX/releases/$CALYPSO_VERSION/bin/calypso-api" ]]; then
chmod +x "$INSTALL_PREFIX/releases/$CALYPSO_VERSION/bin/calypso-api"
log_info "✓ Backend built successfully"
else
log_error "Backend build failed"
exit 1
fi
}
build_frontend() {
log_info "Building frontend..."
cd "$PROJECT_ROOT/frontend"
# Install dependencies
if [[ ! -d "node_modules" ]]; then
log_info "Installing frontend dependencies..."
npm install
fi
# Build frontend
log_info "Building frontend assets..."
npm run build
# Copy built assets
if [[ -d "dist" ]]; then
log_info "Copying frontend assets..."
cp -r dist/* "$INSTALL_PREFIX/releases/$CALYPSO_VERSION/web/"
log_info "✓ Frontend built successfully"
else
log_error "Frontend build failed"
exit 1
fi
}
install_application_files() {
log_info "Installing application files..."
# Copy migrations
if [[ -d "$PROJECT_ROOT/db/migrations" ]]; then
cp -r "$PROJECT_ROOT/db/migrations"/* "$INSTALL_PREFIX/releases/$CALYPSO_VERSION/migrations/" 2>/dev/null || true
fi
# Copy scripts
if [[ -d "$PROJECT_ROOT/scripts" ]]; then
cp -r "$PROJECT_ROOT/scripts"/* "$INSTALL_PREFIX/releases/$CALYPSO_VERSION/scripts/" 2>/dev/null || true
chmod +x "$INSTALL_PREFIX/releases/$CALYPSO_VERSION/scripts"/*.sh 2>/dev/null || true
fi
# Set ownership
chown -R calypso:calypso "$INSTALL_PREFIX" 2>/dev/null || chown -R root:root "$INSTALL_PREFIX"
log_info "✓ Application files installed"
}

View File

@@ -0,0 +1,110 @@
#!/bin/bash
#
# Component installation (ZFS, SCST, MHVTL, Bacula)
#
install_zfs() {
if command_exists zpool && command_exists zfs; then
log_info "ZFS already installed"
return 0
fi
log_info "Installing ZFS..."
# Check if ZFS module is loaded
if lsmod | grep -q zfs; then
log_info "ZFS kernel module already loaded"
return 0
fi
# Install ZFS
apt-get install -y \
zfsutils-linux \
zfs-dkms || {
log_warn "ZFS installation failed. You may need to install manually."
return 1
}
# Load ZFS module
modprobe zfs || true
log_info "✓ ZFS installed"
return 0
}
install_scst() {
if [[ -f /etc/scst.conf ]] || lsmod | grep -q scst; then
log_info "SCST appears to be installed"
return 0
fi
log_info "Installing SCST..."
log_warn "SCST requires building from source. This may take a while..."
# Check if SCST source is available
if [[ -d "$PROJECT_ROOT/src/scst" ]] || [[ -d "/usr/src/scst" ]]; then
log_info "SCST source found, building..."
# SCST build would go here
# This is a placeholder - actual SCST installation is complex
log_warn "SCST installation requires manual steps. See documentation."
return 1
else
log_warn "SCST source not found. Please install SCST manually."
log_info "See: docs/on-progress/scst-installation.md"
return 1
fi
}
install_mhvtl() {
if command_exists vtlcmd || systemctl is-active --quiet mhvtl 2>/dev/null; then
log_info "MHVTL already installed"
return 0
fi
log_info "Installing MHVTL..."
# Install MHVTL from package or source
if apt-cache show mhvtl &>/dev/null; then
apt-get install -y mhvtl mhvtl-utils || {
log_warn "MHVTL package installation failed"
return 1
}
else
log_warn "MHVTL package not available. Building from source..."
# MHVTL build from source would go here
log_warn "MHVTL installation requires manual steps. See documentation."
return 1
fi
# Enable and start MHVTL service
systemctl enable mhvtl || true
systemctl start mhvtl || true
log_info "✓ MHVTL installed"
return 0
}
install_bacula() {
log_info "Installing Bacula (optional)..."
# Check if Bacula is already installed
if command_exists bconsole || systemctl is-active --quiet bacula-sd 2>/dev/null; then
log_info "Bacula already installed"
return 0
fi
# Install Bacula packages
apt-get install -y \
bacula-common \
bacula-sd \
bacula-client \
bacula-console || {
log_warn "Bacula installation failed or packages not available"
log_info "Bacula can be installed separately if needed"
return 1
}
log_info "✓ Bacula installed (configuration required separately)"
return 0
}

View File

@@ -0,0 +1,108 @@
#!/bin/bash
#
# Configuration setup
#
setup_configuration() {
log_info "Setting up configuration..."
# Generate secrets
generate_secrets
# Copy configuration templates
copy_configuration_templates
# Setup environment file
setup_environment_file
log_info "✓ Configuration setup complete"
}
generate_secrets() {
log_info "Generating secrets..."
# Generate JWT secret if not set
if [[ -z "${CALYPSO_JWT_SECRET:-}" ]]; then
CALYPSO_JWT_SECRET=$(generate_jwt_secret)
fi
# Store secrets
echo "CALYPSO_JWT_SECRET=$CALYPSO_JWT_SECRET" > "$CONFIG_DIR/secrets.env"
echo "CALYPSO_DB_PASSWORD=$CALYPSO_DB_PASSWORD" >> "$CONFIG_DIR/secrets.env"
chmod 600 "$CONFIG_DIR/secrets.env"
log_info "✓ Secrets generated and stored in $CONFIG_DIR/secrets.env"
}
copy_configuration_templates() {
log_info "Copying configuration templates..."
# Copy main config if it doesn't exist
if [[ ! -f "$CONFIG_DIR/config.yaml" ]]; then
if [[ -f "$PROJECT_ROOT/backend/config.yaml.example" ]]; then
cp "$PROJECT_ROOT/backend/config.yaml.example" "$CONFIG_DIR/config.yaml"
log_info "✓ Configuration file created: $CONFIG_DIR/config.yaml"
else
# Create minimal config
create_minimal_config
fi
else
log_info "Configuration file already exists, skipping..."
fi
}
create_minimal_config() {
cat > "$CONFIG_DIR/config.yaml" <<EOF
# AtlasOS - Calypso API Configuration
server:
port: 8080
host: "0.0.0.0"
read_timeout: 15s
write_timeout: 15s
idle_timeout: 60s
cache:
enabled: true
default_ttl: 5m
max_age: 300
database:
host: "localhost"
port: 5432
user: "calypso"
password: "" # Set via CALYPSO_DB_PASSWORD environment variable
database: "calypso"
ssl_mode: "disable"
max_connections: 25
max_idle_conns: 5
conn_max_lifetime: 5m
auth:
jwt_secret: "" # Set via CALYPSO_JWT_SECRET environment variable
token_lifetime: 24h
argon2:
memory: 65536
iterations: 3
parallelism: 4
salt_length: 16
key_length: 32
logging:
level: "info"
format: "json"
EOF
log_info "✓ Minimal configuration file created"
}
setup_environment_file() {
log_info "Setting up environment file..."
# Create systemd environment file
mkdir -p /etc/systemd/system/calypso-api.service.d/
cat > /etc/systemd/system/calypso-api.service.d/env.conf <<EOF
[Service]
EnvironmentFile=$CONFIG_DIR/secrets.env
EOF
log_info "✓ Environment file configured"
}

View File

@@ -0,0 +1,143 @@
#!/bin/bash
#
# Service configuration (NFS, SMB, ClamAV)
#
configure_nfs() {
log_info "Configuring NFS server..."
# Create NFS exports directory if it doesn't exist
mkdir -p /etc/exports.d
# Create base exports file (empty, will be managed by Calypso)
if [[ ! -f /etc/exports.d/calypso.exports ]]; then
touch /etc/exports.d/calypso.exports
echo "# Calypso managed NFS exports" > /etc/exports.d/calypso.exports
echo "# This file is managed by Calypso. Manual edits may be overwritten." >> /etc/exports.d/calypso.exports
fi
# Include calypso exports in main exports file
if ! grep -q "calypso.exports" /etc/exports 2>/dev/null; then
echo "" >> /etc/exports
echo "# Include Calypso managed exports" >> /etc/exports
echo "/etc/exports.d/calypso.exports" >> /etc/exports || true
fi
log_info "✓ NFS configured"
}
configure_samba() {
log_info "Configuring Samba..."
# Backup original smb.conf if it exists and hasn't been backed up
if [[ -f /etc/samba/smb.conf ]] && [[ ! -f /etc/samba/smb.conf.calypso-backup ]]; then
cp /etc/samba/smb.conf /etc/samba/smb.conf.calypso-backup
log_info "Backed up original smb.conf"
fi
# Create Calypso Samba configuration directory
mkdir -p "$CONFIG_DIR/samba"
# Create base Samba config (minimal, will be extended by Calypso)
if [[ ! -f "$CONFIG_DIR/samba/smb.conf.calypso" ]]; then
cat > "$CONFIG_DIR/samba/smb.conf.calypso" <<EOF
# Calypso managed Samba configuration
# This file is included in main smb.conf
# Manual edits may be overwritten by Calypso
[global]
workgroup = WORKGROUP
server string = Calypso File Server
security = user
map to guest = Bad User
dns proxy = no
# Logging
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
# Performance
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072
read raw = yes
write raw = yes
max xmit = 65536
dead time = 15
getwd cache = yes
# Calypso shares will be added here dynamically
EOF
log_info "Created Calypso Samba configuration"
fi
# Include Calypso config in main smb.conf if not already included
if ! grep -q "smb.conf.calypso" /etc/samba/smb.conf 2>/dev/null; then
echo "" >> /etc/samba/smb.conf
echo "# Include Calypso managed shares" >> /etc/samba/smb.conf
echo "include = $CONFIG_DIR/samba/smb.conf.calypso" >> /etc/samba/smb.conf
fi
# Test Samba configuration
if command_exists testparm; then
if testparm -s &>/dev/null; then
log_info "✓ Samba configuration valid"
else
log_warn "Samba configuration test failed, but continuing..."
fi
fi
log_info "✓ Samba configured"
}
configure_clamav() {
log_info "Configuring ClamAV..."
# Create ClamAV configuration directory
mkdir -p "$CONFIG_DIR/clamav"
# Configure ClamAV daemon
if [[ -f /etc/clamav/clamd.conf ]]; then
# Backup original
if [[ ! -f /etc/clamav/clamd.conf.calypso-backup ]]; then
cp /etc/clamav/clamd.conf /etc/clamav/clamd.conf.calypso-backup
fi
# Update configuration for Calypso
sed -i 's|^#LocalSocket|LocalSocket|' /etc/clamav/clamd.conf || true
sed -i 's|^LocalSocket.*|LocalSocket /var/run/clamav/clamd.ctl|' /etc/clamav/clamd.conf || true
# Set quarantine directory
if ! grep -q "QuarantineDir" /etc/clamav/clamd.conf; then
echo "QuarantineDir $DATA_DIR/quarantine" >> /etc/clamav/clamd.conf
fi
fi
# Configure freshclam
if [[ -f /etc/clamav/freshclam.conf ]]; then
# Backup original
if [[ ! -f /etc/clamav/freshclam.conf.calypso-backup ]]; then
cp /etc/clamav/freshclam.conf /etc/clamav/freshclam.conf.calypso-backup
fi
# Enable automatic updates
sed -i 's|^#Checks|Checks|' /etc/clamav/freshclam.conf || true
fi
# Create quarantine directory
mkdir -p "$DATA_DIR/quarantine"
chown clamav:clamav "$DATA_DIR/quarantine" 2>/dev/null || chown root:root "$DATA_DIR/quarantine"
chmod 755 "$DATA_DIR/quarantine"
log_info "✓ ClamAV configured"
}
configure_all_services() {
log_info "Configuring file sharing and antivirus services..."
configure_nfs
configure_samba
configure_clamav
log_info "✓ All services configured"
}

View File

@@ -0,0 +1,78 @@
#!/bin/bash
#
# Database setup and configuration
#
setup_database() {
log_info "Setting up database..."
# Generate database password if not set
if [[ -z "${CALYPSO_DB_PASSWORD:-}" ]]; then
CALYPSO_DB_PASSWORD=$(generate_db_password)
log_info "Generated database password"
fi
# Create database and user
create_database_user
# Run migrations
run_migrations
# Create default admin user
create_default_admin
log_info "✓ Database setup complete"
}
create_database_user() {
log_info "Creating database and user..."
# Create database
sudo -u postgres psql -c "CREATE DATABASE calypso;" 2>/dev/null || log_info "Database already exists"
# Create user
sudo -u postgres psql -c "CREATE USER calypso WITH PASSWORD '$CALYPSO_DB_PASSWORD';" 2>/dev/null || {
log_info "User already exists, updating password..."
sudo -u postgres psql -c "ALTER USER calypso WITH PASSWORD '$CALYPSO_DB_PASSWORD';"
}
# Grant privileges
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE calypso TO calypso;"
sudo -u postgres psql -c "ALTER DATABASE calypso OWNER TO calypso;"
log_info "✓ Database and user created"
}
run_migrations() {
log_info "Running database migrations..."
# Migrations will be run on first API startup
# But we can verify the database is accessible
export PGPASSWORD="$CALYPSO_DB_PASSWORD"
if psql -h localhost -U calypso -d calypso -c "SELECT 1;" &>/dev/null; then
log_info "✓ Database connection verified"
else
log_warn "Database connection test failed. Migrations will run on first API start."
fi
unset PGPASSWORD
}
create_default_admin() {
log_info "Creating default admin user..."
# Generate admin password
ADMIN_PASSWORD=$(generate_random_string 16)
echo "$ADMIN_PASSWORD" > /tmp/calypso_admin_password
chmod 600 /tmp/calypso_admin_password
# Hash password (using Go's password hashing)
# This will be done by the API on first login or via setup script
log_info "Default admin credentials:"
log_info " Username: admin"
log_info " Password: $ADMIN_PASSWORD"
log_warn "Please change the default password after first login!"
# Store password hash in database (if API is available)
# Otherwise, it will be created on first API run
}

View File

@@ -0,0 +1,223 @@
#!/bin/bash
#
# System dependencies installation
#
install_system_dependencies() {
log_info "Installing system dependencies..."
# Update package lists
log_info "Updating package lists..."
apt-get update -qq
# Install base tools
log_info "Installing base build tools..."
apt-get install -y \
build-essential \
curl \
wget \
git \
ca-certificates \
gnupg \
lsb-release \
jq \
uuid-runtime \
net-tools \
iproute2 \
systemd \
chrony \
ufw \
sudo
# Install Go
install_go
# Install Node.js
install_nodejs
# Install PostgreSQL
install_postgresql
# Install storage tools
install_storage_tools
# Install tape tools
install_tape_tools
# Install SCST prerequisites
install_scst_prerequisites
# Install file sharing services
install_file_sharing_services
# Install antivirus
install_antivirus
log_info "✓ System dependencies installed"
}
install_go() {
if command_exists go; then
local installed_ver=$(get_installed_version go)
log_info "Go already installed: $installed_ver"
return 0
fi
log_info "Installing Go 1.22..."
local GO_VERSION="1.22.0"
local GO_ARCH="linux-amd64"
cd /tmp
wget -q "https://go.dev/dl/go${GO_VERSION}.${GO_ARCH}.tar.gz"
rm -rf /usr/local/go
tar -C /usr/local -xzf "go${GO_VERSION}.${GO_ARCH}.tar.gz"
rm "go${GO_VERSION}.${GO_ARCH}.tar.gz"
# Add to PATH
if ! grep -q "/usr/local/go/bin" /etc/profile; then
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
fi
export PATH=$PATH:/usr/local/go/bin
log_info "✓ Go installed"
}
install_nodejs() {
if command_exists node; then
local installed_ver=$(get_installed_version node)
log_info "Node.js already installed: $installed_ver"
return 0
fi
log_info "Installing Node.js 20.x LTS..."
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs
# Install pnpm
if ! command_exists pnpm; then
npm install -g pnpm
fi
log_info "✓ Node.js and pnpm installed"
}
install_postgresql() {
if command_exists psql; then
local installed_ver=$(get_installed_version psql)
log_info "PostgreSQL already installed: $installed_ver"
systemctl start postgresql || true
return 0
fi
log_info "Installing PostgreSQL..."
apt-get install -y \
postgresql \
postgresql-contrib \
libpq-dev
systemctl enable postgresql
systemctl start postgresql
wait_for_service postgresql
log_info "✓ PostgreSQL installed and started"
}
install_storage_tools() {
log_info "Installing storage tools..."
apt-get install -y \
lvm2 \
xfsprogs \
thin-provisioning-tools \
smartmontools \
nvme-cli \
parted \
gdisk
log_info "✓ Storage tools installed"
}
install_tape_tools() {
log_info "Installing tape tools..."
apt-get install -y \
lsscsi \
sg3-utils \
mt-st \
mtx
log_info "✓ Tape tools installed"
}
install_scst_prerequisites() {
log_info "Installing SCST prerequisites..."
apt-get install -y \
dkms \
linux-headers-$(uname -r) \
build-essential
log_info "✓ SCST prerequisites installed"
}
install_file_sharing_services() {
log_info "Installing file sharing services (NFS and SMB)..."
# Install NFS server
if ! systemctl is-active --quiet nfs-server 2>/dev/null; then
log_info "Installing NFS server..."
apt-get install -y \
nfs-kernel-server \
nfs-common
# Enable NFS services
systemctl enable nfs-server || true
systemctl enable rpcbind || true
log_info "✓ NFS server installed"
else
log_info "NFS server already installed"
fi
# Install Samba (SMB/CIFS)
if ! systemctl is-active --quiet smbd 2>/dev/null; then
log_info "Installing Samba (SMB/CIFS)..."
apt-get install -y \
samba \
samba-common-bin
# Enable Samba services
systemctl enable smbd || true
systemctl enable nmbd || true
log_info "✓ Samba installed"
else
log_info "Samba already installed"
fi
}
install_antivirus() {
log_info "Installing ClamAV antivirus..."
if ! command_exists clamscan; then
apt-get install -y \
clamav \
clamav-daemon \
clamav-freshclam \
clamav-unofficial-sigs || {
log_warn "ClamAV installation failed"
return 1
}
# Update virus definitions
log_info "Updating ClamAV virus definitions (this may take a while)..."
freshclam || log_warn "Virus definition update failed, will update on first service start"
# Enable ClamAV daemon
systemctl enable clamav-daemon || true
systemctl enable clamav-freshclam || true
log_info "✓ ClamAV installed"
else
log_info "ClamAV already installed"
fi
}

View File

@@ -0,0 +1,60 @@
#!/bin/bash
#
# Filesystem structure setup
#
create_filesystem_structure() {
log_info "Creating filesystem structure..."
# Binary directory structure
log_info "Creating binary directory structure..."
mkdir -p "$INSTALL_PREFIX/releases/$CALYPSO_VERSION"/{bin,web,migrations,scripts}
mkdir -p "$INSTALL_PREFIX/third_party"
# Create symlink for current version
if [[ -L "$INSTALL_PREFIX/current" ]]; then
rm "$INSTALL_PREFIX/current"
fi
ln -sf "releases/$CALYPSO_VERSION" "$INSTALL_PREFIX/current"
# Configuration directory structure (per architecture spec)
log_info "Creating configuration directory structure..."
mkdir -p "$CONFIG_DIR"/{tls,integrations,system,scst,nfs,samba,clamav}
chmod 755 "$CONFIG_DIR"
chmod 700 "$CONFIG_DIR/tls" 2>/dev/null || true
# Data directory structure (per architecture spec: /srv/calypso/)
log_info "Creating data directory structure..."
mkdir -p "$DATA_DIR"/{db,backups,object,shares,vtl,iscsi,uploads,cache,_system,quarantine}
chown -R calypso:calypso "$DATA_DIR" 2>/dev/null || chown -R root:root "$DATA_DIR"
chmod 755 "$DATA_DIR"
# Create quarantine directory for ClamAV
mkdir -p "$DATA_DIR/quarantine"
chmod 700 "$DATA_DIR/quarantine"
# Log directory
log_info "Creating log directory..."
mkdir -p "$LOG_DIR"
chmod 755 "$LOG_DIR"
# Runtime directory
log_info "Creating runtime directory..."
mkdir -p "$LIB_DIR" "$RUN_DIR"
chmod 755 "$LIB_DIR"
chmod 755 "$RUN_DIR"
# Create calypso user if it doesn't exist
if ! id "calypso" &>/dev/null; then
log_info "Creating calypso user..."
useradd -r -s /bin/false -d "$LIB_DIR" -c "Calypso Appliance" calypso || true
fi
# Set ownership
chown -R calypso:calypso "$INSTALL_PREFIX" 2>/dev/null || chown -R root:root "$INSTALL_PREFIX"
chown -R calypso:calypso "$LIB_DIR" 2>/dev/null || chown -R root:root "$LIB_DIR"
chown -R calypso:calypso "$LOG_DIR" 2>/dev/null || chown -R root:root "$LOG_DIR"
log_info "✓ Filesystem structure created"
}

View File

@@ -0,0 +1,124 @@
#!/bin/bash
#
# Helper functions for Calypso installer
#
# Check prerequisites
check_prerequisites() {
log_info "Checking prerequisites..."
# Check network connectivity
if ! ping -c 1 -W 2 8.8.8.8 &>/dev/null; then
log_warn "Network connectivity check failed. Some installations may fail."
else
log_info "✓ Network connectivity OK"
fi
# Check disk space (need at least 10GB free)
AVAILABLE_SPACE=$(df -BG / | awk 'NR==2 {print $4}' | sed 's/G//')
if [[ $AVAILABLE_SPACE -lt 10 ]]; then
log_error "Insufficient disk space. Need at least 10GB, have ${AVAILABLE_SPACE}GB"
exit 1
else
log_info "✓ Disk space OK (${AVAILABLE_SPACE}GB available)"
fi
# Check if already installed
if [[ -d "$INSTALL_PREFIX/current" ]]; then
log_warn "Calypso appears to be already installed at $INSTALL_PREFIX"
read -p "Continue anyway? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
log_info "✓ Prerequisites check complete"
}
# Generate random string
generate_random_string() {
local length=${1:-32}
openssl rand -hex $((length / 2)) | head -c $length
}
# Generate JWT secret
generate_jwt_secret() {
generate_random_string 64
}
# Generate database password
generate_db_password() {
generate_random_string 32
}
# Wait for service
wait_for_service() {
local service=$1
local max_wait=${2:-30}
local count=0
while ! systemctl is-active --quiet "$service" && [[ $count -lt $max_wait ]]; do
sleep 1
((count++))
done
if systemctl is-active --quiet "$service"; then
return 0
else
return 1
fi
}
# Check command exists
command_exists() {
command -v "$1" &> /dev/null
}
# Get installed version
get_installed_version() {
local command=$1
if command_exists "$command"; then
case $command in
go)
go version | awk '{print $3}' | sed 's/go//'
;;
node)
node --version | sed 's/v//'
;;
psql)
psql --version | awk '{print $3}'
;;
*)
"$command" --version 2>/dev/null | head -1
;;
esac
fi
}
# Print installation summary
print_installation_summary() {
log_info ""
log_info "=========================================="
log_info "Installation Summary"
log_info "=========================================="
log_info ""
log_info "Installation Paths:"
log_info " Binaries: $INSTALL_PREFIX/releases/$CALYPSO_VERSION"
log_info " Configuration: $CONFIG_DIR"
log_info " Data: $DATA_DIR"
log_info " Logs: $LOG_DIR"
log_info ""
log_info "Services:"
log_info " calypso-api: $(systemctl is-enabled calypso-api 2>/dev/null || echo 'not enabled')"
log_info ""
log_info "Default Credentials:"
log_info " Username: admin"
log_info " Password: $(cat /tmp/calypso_admin_password 2>/dev/null || echo 'Check installation log')"
log_info ""
log_info "Access:"
log_info " Web UI: http://$(hostname -I | awk '{print $1}'):3000"
log_info " API: http://$(hostname -I | awk '{print $1}'):8080"
log_info ""
}

View File

@@ -0,0 +1,60 @@
#!/bin/bash
#
# Post-installation setup and verification
#
post_install_setup() {
log_info "Running post-installation setup..."
# Start services
log_info "Starting services..."
systemctl start calypso-api || log_warn "Failed to start calypso-api service"
# Wait for API to be ready
log_info "Waiting for API to be ready..."
local max_wait=30
local count=0
while ! curl -s http://localhost:8080/api/v1/health &>/dev/null && [[ $count -lt $max_wait ]]; do
sleep 1
((count++))
done
if curl -s http://localhost:8080/api/v1/health &>/dev/null; then
log_info "✓ API is ready"
else
log_warn "API did not become ready within $max_wait seconds"
fi
# Print access information
print_access_info
log_info "✓ Post-installation setup complete"
}
print_access_info() {
local server_ip=$(hostname -I | awk '{print $1}')
log_info ""
log_info "=========================================="
log_info "Calypso Appliance is Ready!"
log_info "=========================================="
log_info ""
log_info "Access Information:"
log_info " Web UI: http://$server_ip:3000"
log_info " API: http://$server_ip:8080"
log_info " Health: http://$server_ip:8080/api/v1/health"
log_info ""
log_info "Default Credentials:"
log_info " Username: admin"
log_info " Password: $(cat /tmp/calypso_admin_password 2>/dev/null || echo 'Check installation log')"
log_info ""
log_info "Configuration:"
log_info " Config: /etc/calypso/config.yaml"
log_info " Secrets: /etc/calypso/secrets.env"
log_info " Logs: sudo journalctl -u calypso-api -f"
log_info ""
log_warn "IMPORTANT: Change the default admin password after first login!"
log_info ""
}

View File

@@ -0,0 +1,138 @@
#!/bin/bash
#
# Systemd services setup
#
install_systemd_services() {
log_info "Installing systemd services..."
# Install API service
install_api_service
# Reload systemd
systemctl daemon-reload
# Enable services
systemctl enable calypso-api
# Enable file sharing services (if installed)
if systemctl list-unit-files | grep -q nfs-server.service; then
systemctl enable nfs-server || true
systemctl start nfs-server || true
log_info "✓ NFS server enabled"
fi
if systemctl list-unit-files | grep -q smbd.service; then
systemctl enable smbd || true
systemctl enable nmbd || true
systemctl start smbd || true
systemctl start nmbd || true
log_info "✓ Samba services enabled"
fi
# Enable ClamAV services (if installed)
if systemctl list-unit-files | grep -q clamav-daemon.service; then
systemctl enable clamav-daemon || true
systemctl enable clamav-freshclam || true
systemctl start clamav-daemon || true
systemctl start clamav-freshclam || true
log_info "✓ ClamAV services enabled"
fi
log_info "✓ Systemd services installed"
}
install_api_service() {
log_info "Installing calypso-api service..."
cat > /etc/systemd/system/calypso-api.service <<EOF
[Unit]
Description=AtlasOS - Calypso API Server
After=network.target postgresql.service
Requires=postgresql.service
[Service]
Type=simple
User=calypso
Group=calypso
WorkingDirectory=$INSTALL_PREFIX/current
EnvironmentFile=$CONFIG_DIR/secrets.env
ExecStart=$INSTALL_PREFIX/current/bin/calypso-api -config $CONFIG_DIR/config.yaml
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal
SyslogIdentifier=calypso-api
# Security settings
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=$DATA_DIR $LOG_DIR $LIB_DIR $RUN_DIR
# Resource limits
LimitNOFILE=65536
LimitNPROC=4096
[Install]
WantedBy=multi-user.target
EOF
log_info "✓ API service file created"
}
verify_installation() {
log_info "Verifying installation..."
local errors=0
# Check binary exists
if [[ ! -f "$INSTALL_PREFIX/current/bin/calypso-api" ]]; then
log_error "Binary not found: $INSTALL_PREFIX/current/bin/calypso-api"
((errors++))
else
log_info "✓ Binary exists"
fi
# Check frontend assets
if [[ ! -d "$INSTALL_PREFIX/current/web" ]] || [[ -z "$(ls -A $INSTALL_PREFIX/current/web 2>/dev/null)" ]]; then
log_warn "Frontend assets not found or empty"
else
log_info "✓ Frontend assets exist"
fi
# Check configuration
if [[ ! -f "$CONFIG_DIR/config.yaml" ]]; then
log_error "Configuration file not found: $CONFIG_DIR/config.yaml"
((errors++))
else
log_info "✓ Configuration file exists"
fi
# Check database connection
export PGPASSWORD="$CALYPSO_DB_PASSWORD"
if psql -h localhost -U calypso -d calypso -c "SELECT 1;" &>/dev/null; then
log_info "✓ Database connection OK"
else
log_warn "Database connection test failed"
fi
unset PGPASSWORD
# Check service file
if [[ ! -f "/etc/systemd/system/calypso-api.service" ]]; then
log_error "Service file not found"
((errors++))
else
log_info "✓ Service file exists"
fi
if [[ $errors -gt 0 ]]; then
log_error "Installation verification found $errors error(s)"
return 1
else
log_info "✓ Installation verification complete"
return 0
fi
}

View File

@@ -0,0 +1,96 @@
#!/bin/bash
#
# Reverse Proxy Setup (Nginx/Caddy)
#
setup_nginx() {
log_info "Setting up Nginx reverse proxy..."
# Install Nginx if not installed
if ! command_exists nginx; then
apt-get install -y nginx
fi
# Create Nginx configuration
cat > /etc/nginx/sites-available/calypso <<EOF
server {
listen 80;
server_name _;
# Redirect to HTTPS (if SSL is configured)
# return 301 https://\$server_name\$request_uri;
# For development, serve HTTP directly
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_cache_bypass \$http_upgrade;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
location /api {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
location /ws {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
}
}
EOF
# Enable site
ln -sf /etc/nginx/sites-available/calypso /etc/nginx/sites-enabled/
rm -f /etc/nginx/sites-enabled/default
# Test and reload
nginx -t && systemctl reload nginx
log_info "✓ Nginx reverse proxy configured"
}
setup_caddy() {
log_info "Setting up Caddy reverse proxy..."
# Install Caddy if not installed
if ! command_exists caddy; then
apt-get install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
apt-get update
apt-get install -y caddy
fi
# Create Caddyfile
cat > /etc/caddy/Caddyfile <<EOF
:80 {
reverse_proxy /api localhost:8080
reverse_proxy /ws localhost:8080 {
header_up Connection "Upgrade"
header_up Upgrade "websocket"
}
reverse_proxy / localhost:3000
}
EOF
# Reload Caddy
systemctl reload caddy
log_info "✓ Caddy reverse proxy configured"
}