chore: clean publish artifacts and add sources
This commit is contained in:
118
install-sqlserver.sh
Executable file
118
install-sqlserver.sh
Executable file
@@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SQL Server 2022 Installation Script for Ubuntu
|
||||
# This script installs Microsoft SQL Server 2022 on Ubuntu
|
||||
|
||||
set -e
|
||||
|
||||
echo "=================================="
|
||||
echo "SQL Server 2022 Installation"
|
||||
echo "=================================="
|
||||
|
||||
# Check if running as root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Please run as root (use sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get Ubuntu version
|
||||
UBUNTU_VERSION=$(lsb_release -rs)
|
||||
echo "Detected Ubuntu version: $UBUNTU_VERSION"
|
||||
|
||||
# Import the public repository GPG keys
|
||||
echo "Adding Microsoft GPG key..."
|
||||
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
|
||||
|
||||
# Register the SQL Server Ubuntu repository
|
||||
echo "Adding SQL Server repository..."
|
||||
if [[ "$UBUNTU_VERSION" == "22.04" ]] || [[ "$UBUNTU_VERSION" == "24.04" ]]; then
|
||||
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list)"
|
||||
else
|
||||
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2022.list)"
|
||||
fi
|
||||
|
||||
# Update package list
|
||||
echo "Updating package list..."
|
||||
apt-get update
|
||||
|
||||
# Install SQL Server
|
||||
echo "Installing SQL Server 2022..."
|
||||
apt-get install -y mssql-server
|
||||
|
||||
# Run SQL Server setup
|
||||
echo ""
|
||||
echo "=================================="
|
||||
echo "SQL Server Configuration"
|
||||
echo "=================================="
|
||||
echo "Please choose edition and set SA password"
|
||||
echo ""
|
||||
|
||||
/opt/mssql/bin/mssql-conf setup
|
||||
|
||||
# Check SQL Server status
|
||||
echo ""
|
||||
echo "=================================="
|
||||
echo "Checking SQL Server Status"
|
||||
echo "=================================="
|
||||
systemctl status mssql-server --no-pager
|
||||
|
||||
# Install SQL Server command-line tools
|
||||
echo ""
|
||||
echo "=================================="
|
||||
echo "Installing SQL Server Tools"
|
||||
echo "=================================="
|
||||
|
||||
# Add repository for SQL tools
|
||||
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | tee /etc/apt/sources.list.d/msprod.list
|
||||
|
||||
# Update and install tools
|
||||
apt-get update
|
||||
ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev
|
||||
|
||||
# Add tools to PATH
|
||||
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
|
||||
# Configure firewall
|
||||
echo ""
|
||||
echo "=================================="
|
||||
echo "Configuring Firewall"
|
||||
echo "=================================="
|
||||
|
||||
if command -v ufw &> /dev/null; then
|
||||
echo "Allowing SQL Server port 1433..."
|
||||
ufw allow 1433/tcp
|
||||
echo "Firewall configured."
|
||||
else
|
||||
echo "UFW not installed. Skipping firewall configuration."
|
||||
fi
|
||||
|
||||
# Enable SQL Server to start on boot
|
||||
systemctl enable mssql-server
|
||||
|
||||
echo ""
|
||||
echo "=================================="
|
||||
echo "Installation Complete!"
|
||||
echo "=================================="
|
||||
echo ""
|
||||
echo "SQL Server 2022 has been successfully installed."
|
||||
echo ""
|
||||
echo "Connection Information:"
|
||||
echo " Server: localhost,1433"
|
||||
echo " Username: sa"
|
||||
echo " Password: (the one you just set)"
|
||||
echo ""
|
||||
echo "Command-line tools installed:"
|
||||
echo " sqlcmd - SQL Server command-line tool"
|
||||
echo " bcp - Bulk copy program"
|
||||
echo ""
|
||||
echo "Useful commands:"
|
||||
echo " systemctl status mssql-server - Check status"
|
||||
echo " systemctl restart mssql-server - Restart SQL Server"
|
||||
echo " sqlcmd -S localhost -U sa - Connect to SQL Server"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Test connection: sqlcmd -S localhost -U sa -P 'YourPassword'"
|
||||
echo " 2. Create database for SkyArtShop"
|
||||
echo " 3. Configure application connection string"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user