leslie-tsang commented on a change in pull request #5209: URL: https://github.com/apache/apisix/pull/5209#discussion_r727374723
########## File path: utils/install-dependencies.sh ########## @@ -0,0 +1,100 @@ +#!/usr/bin/env bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Install dependencies on centos and fedora +function install_dependencies_with_yum() { + # add OpenResty source + sudo yum install yum-utils + sudo yum-config-manager --add-repo https://openresty.org/package/"${1}"/openresty.repo + + # install OpenResty and some compilation tools + sudo yum install -y openresty curl git gcc openresty-openssl111-devel unzip pcre pcre-devel +} + +# Install dependencies on ubuntu and debian +function install_dependencies_with_apt() { + # add OpenResty source + sudo apt-get update + sudo apt-get -y install software-properties-common wget lsb-release + wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add - + if [[ "${1}" == "ubuntu" ]]; then + sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" + elif [[ "${1}" == "debian" ]]; then + sudo add-apt-repository -y "deb http://openresty.org/package/debian $(lsb_release -sc) openresty" + fi + sudo apt-get update + + # install OpenResty and some compilation tools + sudo apt-get install -y git openresty curl openresty-openssl111-dev make gcc libpcre3 libpcre3-dev +} + +# Install dependencies on mac osx +function install_dependencies_on_mac_osx() { + # install OpenResty, etcd and some compilation tools + brew install openresty/brew/openresty luarocks [email protected] etcd curl git pcre + + # start etcd server + brew services start etcd +} + +# Identify the different distributions and call the corresponding function +function multi_distro_installation() { + if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then + install_dependencies_with_yum "centos" + elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then + install_dependencies_with_yum "fedora" + elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then + install_dependencies_with_apt "debian" + elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then + install_dependencies_with_apt "ubuntu" + else + echo "Non-supported operating system version" + fi +} + +# Install etcd +function install_etcd() { + ETCD_VERSION='3.4.13' + wget https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz + tar -xvf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz && \ + cd etcd-v${ETCD_VERSION}-linux-amd64 && \ + sudo cp -a etcd etcdctl /usr/bin/ + nohup etcd & +} + +# Install LuaRocks +function install_luarocks() { + curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash - +} + +# Entry +function main() { + OS_NAME=$(uname -s | tr '[:upper:]' '[:lower:]') + if [[ ${OS_NAME} == "linux" ]]; then + multi_distro_installation + install_luarocks + install_etcd + elif [[ ${OS_NAME} == "darwin" ]]; then + install_dependencies_on_mac_osx + else + echo "Non-surported distribution" Review comment: ```suggestion if [[ "${OS_NAME}" == "linux" ]]; then multi_distro_installation install_luarocks install_etcd elif [[ "${OS_NAME}" == "darwin" ]]; then install_dependencies_on_mac_osx else echo "Non-surported distribution" ``` Ref to [#SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) ########## File path: utils/install-dependencies.sh ########## @@ -0,0 +1,100 @@ +#!/usr/bin/env bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + Review comment: ```suggestion set -ex ``` ########## File path: utils/install-dependencies.sh ########## @@ -0,0 +1,100 @@ +#!/usr/bin/env bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Install dependencies on centos and fedora +function install_dependencies_with_yum() { + # add OpenResty source + sudo yum install yum-utils + sudo yum-config-manager --add-repo https://openresty.org/package/"${1}"/openresty.repo Review comment: ```suggestion sudo yum-config-manager --add-repo "https://openresty.org/package/${1}/openresty.repo" ``` ########## File path: docs/zh/latest/install-dependencies.md ########## @@ -44,115 +40,18 @@ title: 安装依赖 - OpenResty 是 APISIX 的一个依赖项,如果是第一次部署 APISIX 并且不需要使用 OpenResty 部署其他服务,可以在 OpenResty 安装完成后停止并禁用 OpenResty,这不会影响 APISIX 的正常工作,请根据自己的业务谨慎操作。例如 Ubuntu:`systemctl stop openresty && systemctl disable openresty`。 -## CentOS 7 +## 安装 -```shell -# 安装 etcd -wget https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz -tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \ - cd etcd-v3.4.13-linux-amd64 && \ - sudo cp -a etcd etcdctl /usr/bin/ +在支持的操作系统上运行以下指令即可安装 Apache APISIX dependencies. -# 添加 OpenResty 源 -sudo yum install yum-utils -sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo +支持的操作系统版本: CentOS7, Fedora31 & 32, Ubuntu 16.04 & 18.04, Debian 9 & 10, Mac OSX -# 安装 OpenResty 和 编译工具 -sudo yum install -y openresty curl git gcc openresty-openssl111-devel unzip pcre pcre-devel - -# 安装 LuaRocks -curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash - - -# 开启 etcd server -nohup etcd & ``` - -## Fedora 31 & 32 - -```shell -# 添加 OpenResty 源 -sudo yum install yum-utils -sudo yum-config-manager --add-repo https://openresty.org/package/fedora/openresty.repo - -# 安装 etcd -wget https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz -tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \ - cd etcd-v3.4.13-linux-amd64 && \ - sudo cp -a etcd etcdctl /usr/bin/ - -# 安装 OpenResty 和 编译工具 -sudo yum install -y openresty curl git gcc openresty-openssl111-devel pcre pcre-devel - -# 安装 LuaRocks -curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash - - -# 开启 etcd server -nohup etcd & +curl https://raw.githubusercontent.com/apache/apisix/master/utils/install-dependencies.sh -sL | bash - ``` -## Ubuntu 16.04 & 18.04 - -```shell -# 添加 OpenResty 源 -wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add - -sudo apt-get update -sudo apt-get -y install software-properties-common -sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" -sudo apt-get update - -# 安装 etcd -wget https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz -tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \ - cd etcd-v3.4.13-linux-amd64 && \ - sudo cp -a etcd etcdctl /usr/bin/ - -# 安装 OpenResty 和 编译工具 -sudo apt-get install -y git openresty curl openresty-openssl111-dev make gcc libpcre3 libpcre3-dev - -# 安装 LuaRocks -curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash - +如果你已经克隆了Apache APISIX仓库,在根目录运行已下指令安装 Apache APISIX dependencies: Review comment: Ref to [chinese-copywriting-guidelines](https://github.com/sparanoid/chinese-copywriting-guidelines#%E4%B8%AD%E8%8B%B1%E6%96%87%E4%B9%8B%E9%96%93%E9%9C%80%E8%A6%81%E5%A2%9E%E5%8A%A0%E7%A9%BA%E6%A0%BC) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
