diff --git a/bin/install_centeros.sh b/bin/install_centeros.sh index a6a3167..5d2ee0b 100644 --- a/bin/install_centeros.sh +++ b/bin/install_centeros.sh @@ -1,3 +1,72 @@ -#!/bin/sh +#!/bin/bash + +NGX_CONF="/usr/local/openresty/nginx/conf/nginx.conf" +NGX_TL_OPS_CONF="/usr/local/openresty/nginx/conf/nginx_tlops.conf" +TL_OPS_PATH="/usr/local/tl-ops-manage/" +TL_OPS_CONF_PATH="/usr/local/tl-ops-manage/conf/tl_ops_manage.conf" +TL_OPS_LUA_PATH="/usr/local/openresty/lualib/?.lua;;/usr/local/tl-ops-manage/?.lua;;" +TL_OPS_LUAC_PATH="/usr/local/openresty/lualib/?.so;;" +TL_OPS_VER="v2.8.7" + +echo_msg(){ + cur_time=$(date "+%Y-%m-%d %H:%M:%S") + echo "------------------------------------------------------------------------------------" + echo "-----------------------------【tl-ops-manage】--------------------------------------" + echo "--------------------------TIME: $cur_time" + echo "--------------------------MSG: $1 " + echo "------------------------------------------------------------------------------------" + sleep 1 +} + +tl_ops_manage_install(){ +mkdir -p $TL_OPS_PATH + + echo_msg "tl-ops-manage install start" + wget -O tlopsmanage.tar.gz https://github.com/iamtsm/tl-ops-manage/archive/refs/tags/$TL_OPS_VER.tar.gz + + echo_msg "unpackage tl-ops-manage start" + tar -zxvf tlopsmanage.tar.gz -C $TL_OPS_PATH + + mv $TL_OPS_PATH/tl-ops-manage*/* $TL_OPS_PATH + rm -rf $TL_OPS_PATH/tl-ops-manage*/ + + sed -i "s:/path/to/tl-ops-manage/:$TL_OPS_PATH:g" $TL_OPS_PATH"conf/tl_ops_manage.conf" + sed -i "s:/path/to/tl-ops-manage/:$TL_OPS_PATH:g" $TL_OPS_PATH"tl_ops_manage_env.lua" + + cp $NGX_CONF $NGX_TL_OPS_CONF + + LINE=$(sed -n '/include/=' $NGX_TL_OPS_CONF | sed -n "1"p) + sed -e "$LINE a\ \t include $TL_OPS_CONF_PATH;\n\t lua_package_path \"$TL_OPS_LUA_PATH\";\n\t lua_package_cpath \"$TL_OPS_LUAC_PATH\";" $NGX_TL_OPS_CONF > $NGX_CONF + + echo_msg "tl-ops-manage start done !" +} + +main(){ + echo_msg "centos env check start" + + if [ ! -x "$(command -v openresty)" ]; then + wget https://openresty.org/package/centos/openresty.repo + mv openresty.repo /etc/yum.repos.d/ + + echo_msg "update package start" + + yum check-update + + yum install -y openresty + + echo_msg "install openresty done !" + + echo_msg "$(command openresty -v)" + else + echo_msg "openresty already installed" + fi + + if [ -d $TL_OPS_PATH ]; then + echo_msg "$TL_OPS_PATH dir already exist" + exit + fi + tl_ops_manage_install +} + +main -echo "【tl-ops-manage】 centeros install start" \ No newline at end of file diff --git a/bin/install_ubuntu.sh b/bin/install_ubuntu.sh index 9496089..f3033fa 100644 --- a/bin/install_ubuntu.sh +++ b/bin/install_ubuntu.sh @@ -1,3 +1,118 @@ -#!/bin/sh +#!/bin/bash + +NGX_CONF="/usr/local/openresty/nginx/conf/nginx.conf" +NGX_TL_OPS_CONF="/usr/local/openresty/nginx/conf/nginx_tlops.conf" +TL_OPS_PATH="/usr/local/tl-ops-manage/" +TL_OPS_CONF_PATH="/usr/local/tl-ops-manage/conf/tl_ops_manage.conf" +TL_OPS_LUA_PATH="/usr/local/openresty/lualib/?.lua;;/usr/local/tl-ops-manage/?.lua;;" +TL_OPS_LUAC_PATH="/usr/local/openresty/lualib/?.so;;" +TL_OPS_VER="v2.8.7" + +echo_msg(){ + cur_time=$(date "+%Y-%m-%d %H:%M:%S") + echo "------------------------------------------------------------------------------------" + echo "-----------------------------【tl-ops-manage】--------------------------------------" + echo "--------------------------TIME: $cur_time" + echo "--------------------------MSG: $1 " + echo "------------------------------------------------------------------------------------" + sleep 1 +} + +x86_amd_openresty_install(){ + # for 16 ~ 20 + if [[ $(lsb_release -d) =~ 'Ubuntu 1' ]] || [[ $(lsb_release -d) =~ 'Ubuntu 20' ]]; then + echo_msg "$(arch) - $(lsb_release -d) install start" + apt-get -y install --no-install-recommends wget gnupg ca-certificates + wget -O - https://openresty.org/package/pubkey.gpg | apt-key add - + echo "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/openresty.list + + # for 22+ + elif [[ $(lsb_release -d) =~ 'Ubuntu 2' ]]; then + echo_msg "$(arch) - $(lsb_release -d) install start" + apt-get -y install --no-install-recommends wget gnupg ca-certificates + wget -O - https://openresty.org/package/pubkey.gpg | apt-key add - + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" \ + | tee /etc/apt/sources.list.d/openresty.list > /dev/null + fi + + apt-get update + apt-get -y install openresty +} + +arm_aarch_openresty_install(){ + # for 16 ~ 20 + if [[ $(lsb_release -d) =~ 'Ubuntu 1' ]] || [[ $(lsb_release -d) =~ 'Ubuntu 20' ]]; then + echo_msg "$(arch) - $(lsb_release -d) install start" + apt-get -y install --no-install-recommends wget gnupg ca-certificates + wget -O - https://openresty.org/package/pubkey.gpg | apt-key add - + echo "deb http://openresty.org/package/arm64/ubuntu $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/openresty.list + + # for 22+ + elif [[ $(lsb_release -d) =~ 'Ubuntu 2' ]]; then + echo_msg "$(arch) - $(lsb_release -d) install start" + apt-get -y install --no-install-recommends wget gnupg ca-certificates + wget -O - https://openresty.org/package/pubkey.gpg | apt-key add - + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/arm64/ubuntu $(lsb_release -sc) main" \ + | tee /etc/apt/sources.list.d/openresty.list > /dev/null + fi + + apt-get update + apt-get -y install openresty +} + + +tl_ops_manage_install(){ + mkdir -p $TL_OPS_PATH + + echo_msg "tl-ops-manage install start" + wget -O tlopsmanage.tar.gz https://github.com/iamtsm/tl-ops-manage/archive/refs/tags/$TL_OPS_VER.tar.gz + + echo_msg "unpackage tl-ops-manage start" + tar -zxvf tlopsmanage.tar.gz -C $TL_OPS_PATH + + mv $TL_OPS_PATH/tl-ops-manage*/* $TL_OPS_PATH + rm -rf $TL_OPS_PATH/tl-ops-manage*/ + + sed -i "s:/path/to/tl-ops-manage/:$TL_OPS_PATH:g" $TL_OPS_PATH"conf/tl_ops_manage.conf" + sed -i "s:/path/to/tl-ops-manage/:$TL_OPS_PATH:g" $TL_OPS_PATH"tl_ops_manage_env.lua" + + cp $NGX_CONF $NGX_TL_OPS_CONF + + LINE=$(sed -n '/include/=' $NGX_TL_OPS_CONF | sed -n "1"p) + sed -e "$LINE a\ \t include $TL_OPS_CONF_PATH;\n\t lua_package_path \"$TL_OPS_LUA_PATH\";\n\t lua_package_cpath \"$TL_OPS_LUAC_PATH\";" $NGX_TL_OPS_CONF > $NGX_CONF + + echo_msg "tl-ops-manage start done !" +} + + +main(){ + echo_msg "ubuntu env check start" + + if [ ! -x "$(command -v openresty)" ]; then + echo_msg "update package start" + apt-get update + + if [[ $(arch) =~ "x86_64" ]] || [[ $(arch) =~ "amd64" ]]; then + x86_amd_openresty_install + elif [[ $(arch) =~ "arm64" ]] || [[ $(arch) =~ "aarch64" ]]; then + arm_aarch_openresty_install + else + echo_msg "arch unknown!!" + exit + fi + + echo_msg "install openresty done !" + echo_msg "$(command openresty -v)" + else + echo_msg "openresty already installed" + fi + + if [ -d $TL_OPS_PATH ]; then + echo_msg "$TL_OPS_PATH dir already exist" + exit + fi + tl_ops_manage_install +} + +main -echo "【tl-ops-manage】 ubuntu install start" \ No newline at end of file diff --git a/doc/change.md b/doc/change.md index a8a7ac9..4411033 100644 --- a/doc/change.md +++ b/doc/change.md @@ -1,6 +1,13 @@ ## 事务更新日程 +2022-08-31 + + 1. 支持脚本安装 + + 2. 事务日程调整 + + 2022-08-30 1. 调整协议 diff --git a/doc/feature.md b/doc/feature.md index 3db15c9..4497d2c 100644 --- a/doc/feature.md +++ b/doc/feature.md @@ -61,7 +61,7 @@ - [ ] 支持配置灰度发布 -- [ ] 支持安装部署脚本 +- [x] 支持安装部署脚本 - [ ] 支持docker环境部署 diff --git a/doc/feature_en.md b/doc/feature_en.md index d6107a7..74b9079 100644 --- a/doc/feature_en.md +++ b/doc/feature_en.md @@ -61,7 +61,7 @@ - [ ] Support configuring grayscale publishing -- [ ] Support install deployment scripts +- [x] Support install deployment scripts - [ ] Support docker environment deployment