#!/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 </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 }