Files
drt/install_odbc_debian.sh
2026-01-03 22:05:49 +07:00

112 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# ODBC Driver Installation Script for Debian 12
# This script installs Microsoft ODBC Driver 18 for SQL Server
set -e
echo "=========================================="
echo "ODBC Driver Installation for Debian 12"
echo "=========================================="
echo ""
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run with sudo: sudo bash install_odbc_debian.sh"
exit 1
fi
# Detect OS
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
VER=$VERSION_ID
echo "Detected OS: $PRETTY_NAME"
else
echo "Cannot detect OS version"
exit 1
fi
# Clean up any corrupted repository files
echo ""
echo "Step 1: Cleaning up any previous installation attempts..."
if [ -f /etc/apt/sources.list.d/mssql-release.list ]; then
echo "Removing corrupted mssql-release.list..."
rm -f /etc/apt/sources.list.d/mssql-release.list
fi
# Install prerequisites
echo ""
echo "Step 2: Installing prerequisites..."
apt-get update
apt-get install -y curl gnupg2 apt-transport-https ca-certificates
# Add Microsoft GPG key
echo ""
echo "Step 3: Adding Microsoft GPG key..."
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
# Add Microsoft repository based on OS
echo ""
echo "Step 4: Adding Microsoft repository..."
if [ "$OS" = "debian" ]; then
if [ "$VER" = "12" ]; then
curl https://packages.microsoft.com/config/debian/12/prod.list | tee /etc/apt/sources.list.d/mssql-release.list
elif [ "$VER" = "11" ]; then
curl https://packages.microsoft.com/config/debian/11/prod.list | tee /etc/apt/sources.list.d/mssql-release.list
else
echo "Unsupported Debian version: $VER"
exit 1
fi
elif [ "$OS" = "ubuntu" ]; then
curl https://packages.microsoft.com/config/ubuntu/$VER/prod.list | tee /etc/apt/sources.list.d/mssql-release.list
else
echo "Unsupported OS: $OS"
exit 1
fi
# Update package list
echo ""
echo "Step 5: Updating package list..."
apt-get update
# Install ODBC Driver
echo ""
echo "Step 6: Installing ODBC Driver 18 for SQL Server..."
ACCEPT_EULA=Y apt-get install -y msodbcsql18
# Install unixODBC development headers
echo ""
echo "Step 7: Installing unixODBC development headers..."
apt-get install -y unixodbc-dev
# Verify installation
echo ""
echo "Step 8: Verifying installation..."
if odbcinst -q -d -n "ODBC Driver 18 for SQL Server" > /dev/null 2>&1; then
echo "✓ ODBC Driver 18 for SQL Server installed successfully"
odbcinst -q -d -n "ODBC Driver 18 for SQL Server"
else
echo "✗ ODBC Driver installation failed"
exit 1
fi
# Check for ODBC Driver 17 as fallback
if odbcinst -q -d -n "ODBC Driver 17 for SQL Server" > /dev/null 2>&1; then
echo "✓ ODBC Driver 17 for SQL Server also available"
fi
echo ""
echo "=========================================="
echo "Installation completed successfully!"
echo "=========================================="
echo ""
echo "Next steps:"
echo "1. Install Python dependencies: pip install -r requirements.txt"
echo "2. Install the framework: pip install -e ."
echo "3. Test the installation: drt --version"
echo ""
echo "For Windows Authentication, you'll also need to:"
echo "1. Install Kerberos: apt-get install -y krb5-user"
echo "2. Configure /etc/krb5.conf with your domain settings"
echo "3. Get a Kerberos ticket: kinit username@YOUR_DOMAIN.COM"
echo ""