Skip to content

Commit

Permalink
自动化安装
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomeng79 committed Aug 31, 2019
1 parent 472051e commit 0d26fb9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ bin
deployments/bin
vendor
check.log
*.pid
*.pid

*/myvariables.sh
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,33 @@ sudo make allbuild
sudo make compose up
```

**可在scripts下新建安装环境变量配置文件(myvariables.sh)**
```bash
#项目相关的
ProjectName=${ProjectName:-"github.com/xiaomeng79/istio-micro"}
Version=${Version:-"unknow"}
TARGET=${TARGET:-'main'}

#执行环境
GOPROXY=${GOPROXY:-"https://goproxy.io"}
#go mod是否开启
GO111MODULE=${GO111MODULE:-"auto"}
#GOPATH的路径
GOPATH=${GOPATH:-${HOME}"/com_go"}
#其他软件的安装目录
soft_dir=${soft_dir:-${HOME}}
#go安装的版本
go_version=${go_version:-"1.12.9"}
#protoc的版本
protoc_version=${protoc_version:-"3.6.1"}
#protoc引用的路径
protoc_include_path=${protoc_include_path:-"${soft_dir}/protoc-${protoc_version}-linux-x86_64/include"}
#cloc版本
cloc_version=${cloc_version:-"1.76"}
#执行文件路径
cmd_path=${cmd_path:-"${GOPATH}/bin"}
```


#### 测试

Expand Down
9 changes: 7 additions & 2 deletions scripts/.variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#set -u

#获取用户自定义变量(myvariables.sh)
if [ -f "scripts/myvariables.sh" ];then
source scripts/myvariables.sh
fi
#项目相关的
ProjectName=${ProjectName:-"github.com/xiaomeng79/istio-micro"}
Version=${Version:-"unknow"}
Expand All @@ -12,7 +16,7 @@ GOPROXY=${GOPROXY:-"https://goproxy.io"}
#go mod是否开启
GO111MODULE=${GO111MODULE:-"auto"}
#GOPATH的路径
GOPATH="/com_go"
GOPATH=${GOPATH:-${HOME}"/com_go"}
#其他软件的安装目录
soft_dir=${soft_dir:-${HOME}}
#go安装的版本
Expand All @@ -26,7 +30,8 @@ cloc_version=${cloc_version:-"1.76"}
#执行文件路径
cmd_path=${cmd_path:-"${GOPATH}/bin"}

mkdir -p ${GOPATH/{bin,src}
mkdir -p ${GOPATH}/bin
mkdir -p ${GOPATH}/src

#将环境变量存入本地环境配置
echo "GOPROXY=${GOPROXY}" >>${HOME}/.profile
Expand Down
11 changes: 7 additions & 4 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -uxe

source scripts/.variables.sh
set -uxe

#定义变量
GOPROXY=${GOPROXY:-"https://goproxy.io"}
Expand Down Expand Up @@ -29,7 +29,7 @@ cloc_install(){
mkdir -p ${soft_dir} && cd ${soft_dir} && \
wget -c https://github.com/AlDanial/cloc/archive/v${cloc_version}.zip && \
unzip v${cloc_version}.zip && \
cp ${soft_dir}/cloc-${cloc_version}/cloc ${cmd_path}/cloc || { echo "cloc文件已经存在"; } && \
mv ${soft_dir}/cloc-${cloc_version}/cloc ${cmd_path} || { echo "cloc文件已经存在"; } && \
echo "cloc 的版本是:" && cloc --version

}
Expand All @@ -44,11 +44,14 @@ protoc_install(){
}

go_plug(){
cd ${GOPATH} && export GOPROXY=https://goproxy.io && GO111MODULE=off && \
cd ${GOPATH} && export GOPROXY=https://goproxy.io && export GO111MODULE=off && export GOPATH=${GOPATH} && \
echo "GOPATH为:"${GOPATH} && \
echo "安装 protobuf golang插件 protoc-gen-go protoc-gen-grpc-gateway protoc-gen-swagger protoc-go-inject-tag" && \
echo "大概耗时30分钟" && \
go get github.com/golang/protobuf/proto && \
mkdir -p ${GOPATH}/src/golang && cd ${GOPATH}/src/golang && git clone https://github.com/golang/protobuf.git --depth 1
mkdir -p ${GOPATH}/src/google.golang.org && cd ${GOPATH}/src/google.golang.org && \
git clone https://github.com/google/go-genproto.git --depth 1 && mv go-genproto/ genproto/ && \
cd ${GOPATH} && \
go get github.com/golang/protobuf/protoc-gen-go && \
go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway && \
go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger && \
Expand Down

0 comments on commit 0d26fb9

Please sign in to comment.