modify sonarqube
This commit is contained in:
215
dist/airgap/calypso-appliance-1.0.0-airgap/install-airgap.sh
vendored
Executable file
215
dist/airgap/calypso-appliance-1.0.0-airgap/install-airgap.sh
vendored
Executable file
@@ -0,0 +1,215 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Calypso Appliance - Airgap Installer
|
||||
# Installs Calypso from bundled files without internet connection
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
BUNDLE_DIR="$SCRIPT_DIR"
|
||||
VERSION="${VERSION:-1.0.0}"
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
|
||||
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
log_step() { echo -e "\n${BLUE}==>${NC} $1"; }
|
||||
|
||||
# Check root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
log_error "This script must be run as root (use sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check OS
|
||||
if [ ! -f /etc/os-release ]; then
|
||||
log_error "Cannot detect OS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. /etc/os-release
|
||||
if [[ "$ID" != "ubuntu" ]] || [[ "$VERSION_ID" != "24.04" ]]; then
|
||||
log_warn "This installer is designed for Ubuntu 24.04 LTS"
|
||||
log_warn "Detected: $ID $VERSION_ID"
|
||||
read -p "Continue anyway? (y/N) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
log_step "Calypso Appliance - Airgap Installation"
|
||||
log_info "Bundle directory: $BUNDLE_DIR"
|
||||
|
||||
# 1. Install packages from bundle
|
||||
log_step "Installing system packages from bundle..."
|
||||
|
||||
if [ -d "$BUNDLE_DIR/packages/debs" ] && [ "$(ls -A $BUNDLE_DIR/packages/debs/*.deb 2>/dev/null)" ]; then
|
||||
log_info "Installing packages from bundle..."
|
||||
|
||||
# Create local apt repository
|
||||
DEBS_DIR="$BUNDLE_DIR/packages/debs"
|
||||
REPO_DIR="/tmp/calypso-local-repo"
|
||||
|
||||
mkdir -p "$REPO_DIR"
|
||||
cp "$DEBS_DIR"/*.deb "$REPO_DIR/" 2>/dev/null || true
|
||||
|
||||
# Create Packages.gz if not exists
|
||||
cd "$REPO_DIR"
|
||||
if [ ! -f Packages.gz ]; then
|
||||
dpkg-scanpackages . /dev/null 2>/dev/null | gzip -9c > Packages.gz
|
||||
fi
|
||||
|
||||
# Add to sources.list temporarily
|
||||
echo "deb [trusted=yes] file://$REPO_DIR ./" > /tmp/calypso-local.list
|
||||
mv /tmp/calypso-local.list /etc/apt/sources.list.d/calypso-local.list
|
||||
|
||||
# Update apt cache
|
||||
apt-get update -qq
|
||||
|
||||
# Install packages from list
|
||||
PACKAGE_LIST="$BUNDLE_DIR/packages/package-list.txt"
|
||||
PACKAGES=$(grep -v '^#' "$PACKAGE_LIST" | grep -v '^$' | tr '\n' ' ')
|
||||
|
||||
log_info "Installing packages..."
|
||||
apt-get install -y --allow-unauthenticated $PACKAGES || {
|
||||
log_warn "Some packages failed to install, trying individual installation..."
|
||||
while IFS= read -r package || [ -n "$package" ]; do
|
||||
[[ "$package" =~ ^#.*$ ]] && continue
|
||||
[[ -z "$package" ]] && continue
|
||||
apt-get install -y --allow-unauthenticated "$package" 2>/dev/null || log_warn "Failed: $package"
|
||||
done < "$PACKAGE_LIST"
|
||||
}
|
||||
|
||||
# Cleanup
|
||||
rm -f /etc/apt/sources.list.d/calypso-local.list
|
||||
apt-get update -qq
|
||||
|
||||
log_info "✓ Packages installed from bundle"
|
||||
else
|
||||
log_warn "Package DEB files not found in bundle"
|
||||
log_warn "You need to install packages manually"
|
||||
log_info "Package list: $BUNDLE_DIR/packages/package-list.txt"
|
||||
read -p "Install packages from system repositories? (y/N) " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
apt-get update
|
||||
xargs -a "$BUNDLE_DIR/packages/package-list.txt" -r apt-get install -y
|
||||
fi
|
||||
fi
|
||||
|
||||
# 2. Install Go from bundle (if available)
|
||||
if [ -f "$BUNDLE_DIR/third_party/go.tar.gz" ]; then
|
||||
log_step "Installing Go from bundle..."
|
||||
rm -rf /usr/local/go
|
||||
tar -C /usr/local -xzf "$BUNDLE_DIR/third_party/go.tar.gz"
|
||||
export PATH=$PATH:/usr/local/go/bin
|
||||
if ! grep -q "/usr/local/go/bin" /etc/profile; then
|
||||
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
|
||||
fi
|
||||
log_info "✓ Go installed"
|
||||
fi
|
||||
|
||||
# 3. Install Node.js from bundle (if available)
|
||||
if [ -f "$BUNDLE_DIR/third_party/nodejs.tar.xz" ]; then
|
||||
log_step "Installing Node.js from bundle..."
|
||||
rm -rf /usr/local/node
|
||||
mkdir -p /usr/local/node
|
||||
tar -C /usr/local/node -xJf "$BUNDLE_DIR/third_party/nodejs.tar.xz" --strip-components=1
|
||||
export PATH=$PATH:/usr/local/node/bin
|
||||
if ! grep -q "/usr/local/node/bin" /etc/profile; then
|
||||
echo 'export PATH=$PATH:/usr/local/node/bin' >> /etc/profile
|
||||
fi
|
||||
log_info "✓ Node.js installed"
|
||||
fi
|
||||
|
||||
# 4. Create filesystem structure
|
||||
log_step "Creating filesystem structure..."
|
||||
INSTALL_PREFIX="/opt/adastra/calypso"
|
||||
CONFIG_DIR="/etc/calypso"
|
||||
DATA_DIR="/srv/calypso"
|
||||
LOG_DIR="/var/log/calypso"
|
||||
LIB_DIR="/var/lib/calypso"
|
||||
|
||||
mkdir -p "$INSTALL_PREFIX/releases/${VERSION}"/{bin,web,migrations,scripts}
|
||||
mkdir -p "$INSTALL_PREFIX/third_party"
|
||||
mkdir -p "$CONFIG_DIR"/{tls,integrations,system,scst,nfs,samba,clamav}
|
||||
mkdir -p "$DATA_DIR"/{db,backups,object,shares,vtl,iscsi,uploads,cache,_system,quarantine}
|
||||
mkdir -p "$LOG_DIR" "$LIB_DIR" "/run/calypso"
|
||||
|
||||
# Create calypso user
|
||||
if ! id "calypso" &>/dev/null; then
|
||||
useradd -r -s /bin/false -d "$LIB_DIR" -c "Calypso Appliance" calypso
|
||||
fi
|
||||
|
||||
# 5. Install binaries
|
||||
log_step "Installing Calypso binaries..."
|
||||
cp "$BUNDLE_DIR/binaries/calypso-api" "$INSTALL_PREFIX/releases/${VERSION}/bin/"
|
||||
chmod +x "$INSTALL_PREFIX/releases/${VERSION}/bin/calypso-api"
|
||||
|
||||
# Install frontend
|
||||
cp -r "$BUNDLE_DIR/frontend"/* "$INSTALL_PREFIX/releases/${VERSION}/web/"
|
||||
|
||||
# Install migrations
|
||||
cp -r "$BUNDLE_DIR/migrations"/* "$INSTALL_PREFIX/releases/${VERSION}/migrations/" 2>/dev/null || true
|
||||
|
||||
# Install scripts
|
||||
cp -r "$BUNDLE_DIR/scripts"/* "$INSTALL_PREFIX/releases/${VERSION}/scripts/" 2>/dev/null || true
|
||||
chmod +x "$INSTALL_PREFIX/releases/${VERSION}/scripts"/*.sh 2>/dev/null || true
|
||||
|
||||
# Create symlink
|
||||
ln -sfn "releases/${VERSION}" "$INSTALL_PREFIX/current"
|
||||
|
||||
# Set ownership
|
||||
chown -R calypso:calypso "$INSTALL_PREFIX" "$LIB_DIR" "$LOG_DIR" "$DATA_DIR" 2>/dev/null || chown -R root:root "$INSTALL_PREFIX" "$LIB_DIR" "$LOG_DIR" "$DATA_DIR"
|
||||
|
||||
log_info "✓ Binaries installed"
|
||||
|
||||
# 6. Install systemd services
|
||||
log_step "Installing systemd services..."
|
||||
if [ -d "$BUNDLE_DIR/services" ]; then
|
||||
cp "$BUNDLE_DIR/services"/*.service /etc/systemd/system/ 2>/dev/null || true
|
||||
systemctl daemon-reload
|
||||
log_info "✓ Systemd services installed"
|
||||
fi
|
||||
|
||||
# 7. Setup database
|
||||
log_step "Setting up database..."
|
||||
if systemctl is-active --quiet postgresql 2>/dev/null || systemctl is-enabled --quiet postgresql 2>/dev/null; then
|
||||
sudo -u postgres createdb calypso 2>/dev/null || true
|
||||
sudo -u postgres createuser calypso 2>/dev/null || true
|
||||
sudo -u postgres psql -c "ALTER USER calypso WITH PASSWORD 'calypso_change_me';" 2>/dev/null || true
|
||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE calypso TO calypso;" 2>/dev/null || true
|
||||
log_info "✓ Database setup complete"
|
||||
else
|
||||
log_warn "PostgreSQL not running. Please start it and run database setup manually."
|
||||
fi
|
||||
|
||||
# 8. Generate configuration
|
||||
log_step "Generating configuration..."
|
||||
if [ -f "$BUNDLE_DIR/configs/config.yaml.template" ]; then
|
||||
cp "$BUNDLE_DIR/configs/config.yaml.template" "$CONFIG_DIR/calypso.yaml"
|
||||
# Generate secrets
|
||||
if command -v openssl &> /dev/null; then
|
||||
JWT_SECRET=$(openssl rand -hex 32)
|
||||
sed -i "s/CHANGE_ME_JWT_SECRET/$JWT_SECRET/g" "$CONFIG_DIR/calypso.yaml"
|
||||
fi
|
||||
log_info "✓ Configuration generated"
|
||||
fi
|
||||
|
||||
log_step "Installation Complete!"
|
||||
log_info ""
|
||||
log_info "Next steps:"
|
||||
log_info "1. Review configuration: $CONFIG_DIR/calypso.yaml"
|
||||
log_info "2. Install kernel modules (ZFS, SCST, mhVTL) if needed"
|
||||
log_info "3. Start services: systemctl start calypso-api"
|
||||
log_info "4. Enable services: systemctl enable calypso-api"
|
||||
log_info ""
|
||||
log_info "Calypso API will be available at: http://localhost:8080"
|
||||
Reference in New Issue
Block a user