install-snowflake-driver.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. set -xeuo pipefail
  3. ## Specify your organization - account name as the account identifier
  4. SFACCOUNT=${SFACCOUNT:-myorganization-myaccount}
  5. VERSION="3.3.2"
  6. FILE="snowflake-odbc-${VERSION}.x86_64.deb"
  7. URL="https://sfc-repo.snowflakecomputing.com/odbc/linux/${VERSION}/${FILE}"
  8. SHA256="fdcf83aadaf92ec135bed0699936fa4ef2cf2d88aef5a4657a96877ae2ba232d"
  9. if [[ -f "${FILE}" && $(sha256sum "${FILE}" | cut -f1 -d' ') == "${SHA256}" ]]; then
  10. echo "snowflake package already downloaded"
  11. else
  12. echo "downloading snowflake package"
  13. wget -nc "$URL"
  14. fi
  15. function configure() {
  16. ODBC_INST_LIB=/usr/lib/x86_64-linux-gnu/libodbcinst.so
  17. sed -i -e "s#^ODBCInstLib=.*#ODBCInstLib=$ODBC_INST_LIB#" /usr/lib/snowflake/odbc/lib/simba.snowflake.ini
  18. sed -i -e "s#SF_ACCOUNT#${SFACCOUNT}#" /etc/odbc.ini
  19. cat >>/etc/odbc.ini <<EOF
  20. [ODBC Data Sources]
  21. snowflake = SnowflakeDSIIDriver
  22. EOF
  23. }
  24. if ! dpkg -l snowflake-odbc 1>/dev/null 2>/dev/null ; then
  25. apt update && apt install -yyq unixodbc-dev odbcinst
  26. dpkg -i "${FILE}"
  27. apt install -f
  28. configure
  29. echo "installed and configured snowflake"
  30. else
  31. echo "snowflake odbc already installed; not attempting to configure it"
  32. fi