Skip to content

Instantly share code, notes, and snippets.

@kagarlickij
Last active May 22, 2022 16:19
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kagarlickij/7cb9ca510695027b0fd2f811a70825e1 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Installing SqlCmd.."
if [[ $(sqlcmd | grep Version) != *"13."* ]]; then {
repoPrConf="/etc/yum/pluginconf.d/priorities.conf"
rm -f ${repoPrConf}
cat >> ${repoPrConf} << EOF
[main]
enabled = 0
EOF
chmod 644 ${repoPrConf}
curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/msprod.repo
yum update -y
ACCEPT_EULA=y yum install mssql-tools -y
sudo ln -s /opt/mssql-tools/bin/sqlcmd /usr/local/bin
if [[ $(sqlcmd | grep Version) != *"13."* ]]; then {
echo "SqlCmd has been installed with error"
exit 1
} else {
echo "SqlCmd has been installed successfully"
}
fi
} else {
echo "SqlCmd has been already installed"
}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment