Skip to content

Commit

Permalink
feat: 支持脚本部署安装
Browse files Browse the repository at this point in the history
feat: 事务日程调整
  • Loading branch information
iamtsm committed Aug 31, 2022
1 parent 670aa0c commit 2fcd850
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 6 deletions.
73 changes: 71 additions & 2 deletions bin/install_centeros.sh
Original file line number Diff line number Diff line change
@@ -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"
119 changes: 117 additions & 2 deletions bin/install_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 7 additions & 0 deletions doc/change.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

## 事务更新日程

2022-08-31

1. 支持脚本安装

2. 事务日程调整


2022-08-30

1. 调整协议
Expand Down
2 changes: 1 addition & 1 deletion doc/feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

- [ ] 支持配置灰度发布

- [ ] 支持安装部署脚本
- [x] 支持安装部署脚本

- [ ] 支持docker环境部署

Expand Down
2 changes: 1 addition & 1 deletion doc/feature_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

- [ ] Support configuring grayscale publishing

- [ ] Support install deployment scripts
- [x] Support install deployment scripts

- [ ] Support docker environment deployment

Expand Down

0 comments on commit 2fcd850

Please sign in to comment.