install-msodbc-driver.sh 1.0 KB

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. # Install the MS SQL Server ODBC driver on a Debian-based system.
  3. # https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
  4. set -euo pipefail
  5. if [ ! -f /etc/debian_version ]; then
  6. echo "This script is only intended for Debian-based systems"
  7. exit 1
  8. fi
  9. apt-get -qq update && apt-get install -yqq curl gpg
  10. # shellcheck disable=SC1091
  11. . /etc/os-release
  12. # ubuntu
  13. curl -fsSL https://packages.microsoft.com/keys/microsoft.asc > /etc/apt/trusted.gpg.d/microsoft.asc
  14. # debian
  15. curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
  16. curl -fsSL "https://packages.microsoft.com/config/${ID}/${VERSION_ID}/prod.list" > /etc/apt/sources.list.d/mssql-release.list
  17. apt-get -qq update
  18. ACCEPT_EULA=Y apt-get install -yqq msodbcsql18 unixodbc-dev
  19. ## and not needed to modify /etc/odbcinst.ini
  20. ## docker-compose will mount one in .ci/docker-compose-file/odbc
  21. sed -i 's/ODBC Driver 18 for SQL Server/ms-sql/g' /etc/odbcinst.ini