#!/bin/bash
# -*- coding: utf-8 -*-
# Author: CIASM
# update 2023/06/12
<<!
The system supports the Sql Server 2019 2022 deployment in rpm mode,ubuntu(20.04, not included 22.04), centos,redhat,oracle(7,8,9),rockylinux,almalinux(8,9), suse(12,15)
# Official website automated script reference
https://learn.microsoft.com/en-us/sql/linux/sample-unattended-install-redhat?view=sql-server-ver16
# download Linux all sql server package
https://packages.microsoft.com/
# SQL server Linux repo
https://packages.microsoft.com/config/
# ubuntu To execute this script
ln -sf bash /bin/sh
!
install_sqlserver() {
# Check if the script is being run as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root."
exit 1
fi
# Check the CentOS/Red Hat version
if [[ -f /etc/redhat-release ]]; then
OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)
# Check the oralce Linux version
elif [[ -f /etc/oracle-release ]]; then
OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)
# Check the Rock Linux version
elif [[ -f /etc/rocky-release ]]; then
OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)
# Check the AlmaLinux version
elif [[ -f /etc/almalinux-release ]]; then
OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)
# Check the ubuntu version
elif [[ -f /etc/os-release ]]; then
OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)
# Check the suse version
elif [[ -f /etc/SuSE-release ]]; then
OS=$(cat /etc/*release* | grep "^PRETTY_NAME=" | cut -d'=' -f2- | tr -d '"')
VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)
# Check the Debian version
elif [[ -f /etc/os-release ]]; then
OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
VERSION=$(cat /etc/*release* | grep -oE '[0-9]+' | head -n1)
# Check the Fedora version
elif [[ -f /etc/fedora-release ]]; then
OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
VERSION=$(cat /etc/*release* | grep -oE '[0-9]+' | head -n1)
else
echo -e "\033[31mThis script only supports $OS $VERSION...\033[0m"
exit 1
fi
# Check the SQL Server version
#if ! command -v sqlservr &> /dev/null; then
if [ ! -d "/opt/mssql" ]; then
echo -e "\033[32mInstalling SQL Server for $OS $VERSION...\033[0m"
case $VERSION in
# CentOS/RedHat/oracle 7 install Sql Server 2019
7.?)
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
echo Installing SQL Server...
sudo yum install -y net-tools vim
sudo yum install -y bzip2 cyrus-sasl cyrus-sasl-gssapi gdb libatomic libsss_nss_idmap libtirpc python3 python3-libs python3-pip python3-setuptools cyrus-sasl-lib
sudo yum install -y mssql-server
sudo ACCEPT_EULA=Y yum install -y mssql-tools unixODBC unixODBC-devel
sudo yum install -y mssql-server-fts
firewall-cmd --zone=public --add-port=1433/tcp --permanent && firewall-cmd --reload
;;
# CentOS/RedHat/oracle/RockLinux/AlmaLinux 8 install Sql Server 2022
8.?)
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2022.repo
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo
echo Installing SQL Server...
sudo yum install -y net-tools vim
sudo yum install -y gc gdb libatomic_ops libipt python3-pip gdb-headless python36 bzip2 cyrus-sasl-gssapi cyrus-sasl libatomic libbabeltrace python3-setuptools chkconfig guile platform-python-pip
sudo yum install -y mssql-server
sudo ACCEPT_EULA=Y yum install -y mssql-tools unixODBC unixODBC-devel
sudo yum install -y mssql-server-fts
firewall-cmd --zone=public --add-port=1433/tcp --permanent && firewall-cmd --reload
;;
# CentOS/RedHat/oracle/RockLinux/AlmaLinux 9 install Sql Server 2022
9.?)
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/9.0/mssql-server-2022.repo
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/9.0/prod.repo
echo Installing SQL Server...
sudo yum install -y net-tools vim
sudo yum install -y gc gdb libatomic_ops libipt python3-pip gdb-headless python36 bzip2 cyrus-sasl-gssapi cyrus-sasl libatomic libbabeltrace python3-setuptools chkconfig guile platform-python-pip
sudo yum install -y mssql-server
sudo ACCEPT_EULA=Y yum install -y mssql-tools unixODBC unixODBC-devel
sudo yum install -y mssql-server-fts
firewall-cmd --zone=public --add-port=1433/tcp --permanent && firewall-cmd --reload
;;
# ubuntu 20.04,22.04 Linux install Sql Server 2019
20.0?|22.0?)
sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
repoargs="$(curl https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)"
sudo add-apt-repository "${repoargs}"
repoargs="$(curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list)"
sudo add-apt-repository "${repoargs}"
sudo apt-get install -y gdb gdbserver libatomic1 libbabeltrace1 libc++1 libc++1-10 libc++abi1-10 libc6 libc6-dbg libcc1-0 libdw1 libsasl2-modules-gssapi-mit libsss-nss-idmap0
sudo apt-get install -y autoconf automake autotools-dev binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-9 gcc gcc-9 gcc-9-base libasan5 libbinutils libc-dev-bin libc6-dev libcrypt-dev libctf-nobfd0 libctf0 libgcc-9-dev libgomp1 libisl22 libitm1 liblsan0 libltdl-dev libmpc3 libodbc1 libquadmath0 libtool libtsan0 libubsan1 linux-libc-dev m4 manpages-dev msodbcsql17 odbcinst odbcinst1debian2
sudo apt-get install -y net-tools vim
sudo apt-get install -y mssql-server
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc unixodbc-dev
sudo apt-get install -y mssql-server-fts
sudo ufw allow 1433/tcp
sudo ufw reload
;;
# Debian 10, 11
10|11)
echo "Not supported by official website"
;;
# Fedora 31,32,33
31|32|33)
echo "Not supported by official website"
;;
# SUSE 12 install Sql Server 2019
12.?)
sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2019.repo
sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/prod.repo
sudo zypper --gpg-auto-import-keys refresh
sudo SUSEConnect -p sle-sdk/12.4/x86_64
echo Installing SQL Server...
sudo zypper install -y net-tools vim
sudo zypper install -y mssql-server
sudo ACCEPT_EULA=Y zypper install -y mssql-tools unixODBC-devel
sudo zypper install -y mssql-server-fts
sudo SuSEfirewall2 open INT TCP 1433
sudo SuSEfirewall2 stop
sudo SuSEfirewall2 start
;;
# SUSE 15 install Sql Server 2022
15.?)
sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/15/mssql-server-2022.repo
sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/15/prod.repo
sudo zypper --gpg-auto-import-keys refresh
sudo SUSEConnect -p sle-sdk/15.3/x86_64
echo Installing SQL Server...
sudo zypper install -y net-tools vim
sudo zypper install -y mssql-server
sudo ACCEPT_EULA=Y zypper install -y mssql-tools unixODBC-devel
sudo zypper install -y mssql-server-fts
sudo SuSEfirewall2 open INT TCP 1433
sudo SuSEfirewall2 stop
sudo SuSEfirewall2 start
;;
*)
echo -e "\033[31mUnsupported $OS $VERSION...\033[0m"
exit 1
;;
esac
#initialized_database
echo "SQL Server initialized_database $OS $VERSION..."
initialized_database
echo -e "\033[32mSQL Server for $OS $VERSION successful
没有合适的资源?快使用搜索试试~ 我知道了~
SQL-Server-all-auto
共7个文件
ps1:6个
sh:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 98 浏览量
2024-06-11
15:50:24
上传
评论
收藏 18KB ZIP 举报
温馨提示
Windows Server 支持 SQL Server 2012 SQL Server 2014 SQL Server 2016 SQL Server 2017 SQL Server 2019 SQL Server 2022 Linux Redha支持系列,ubuntu,suse
资源推荐
资源详情
资源评论
收起资源包目录
SQL_Server-auto.zip (7个子文件)
SQL_Server-auto
Windows
powershell-install-SQL-Server-2017.ps1 6KB
powershell-install-SQL-Server-2016.ps1 7KB
powershell-install-SQL-Server-2012.ps1 6KB
powershell-install-SQL-Server-2014.ps1 6KB
powershell-install-SQL-Server-2022.ps1 6KB
powershell-install-SQL-Server-2019.ps1 6KB
Linux
Sql_Server_install.sh 10KB
共 7 条
- 1
资源评论
CIAS
- 粉丝: 1137
- 资源: 298
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功