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 9a57dc5 commit f67ed12
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 13 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ COMMIT=$(shell git rev-parse --short HEAD)
#project:game prize pusher socket
#type:api srv web

.PHONY : ver
ver :

@echo "执行环境变量"
@chmod +x ./scripts/.variables.sh && ./scripts/.variables.sh
@echo "完成环境变量"


.PHONY : install
install :

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
1. git >= 2.17
2. wget
3. make
4. unzip
5. tar

- 可选部署安装(**任何一种都可以,也可直接部署二进制文件**)
1. docker >= 1.13.1
Expand All @@ -57,9 +59,11 @@
```bash
git clone https://github.com/xiaomeng79/istio-micro.git
```

3.
3. 安装运行环境
```bash
cd istio-micro && sudo make install
cd istio-micro && make ver && make install
```

4. 编译代码
Expand Down
11 changes: 10 additions & 1 deletion scripts/.variables.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ TARGET=${TARGET:-'main'}

#执行环境
GOPROXY=${GOPROXY:-"https://goproxy.io"}
#go mod是否开启
GO111MODULE=${GO111MODULE:-"auto"}
#GOPATH的路径
GOPATH=${GOPATH:-${HOME}/"go_path"}
#其他软件的安装目录
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 All @@ -25,4 +33,5 @@ echo "GO111MODULE=${GO111MODULE}" >>${HOME}/.profile
echo "GOPATH=${GOPATH}" >>${HOME}/.profile
echo "PATH=${soft_dir}/go/bin:${GOPATH}/bin:${PATH}" >>${HOME}/.profile

source ${HOME}/.profile
#手动执行
#source ~/.profile
34 changes: 34 additions & 0 deletions scripts/INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## 安装依赖

#### 配置环境变量

GOPROXY=${GOPROXY:-"https://goproxy.io"}
GO111MODULE=${GO111MODULE:-"auto"}
GOPATH=${GOPATH:-${HOME}/"go_path"}
soft_dir=${soft_dir:-${HOME}}
go_version=${go_version:-"1.12.9"}
protoc_version=${protoc_version:-"3.6.1"}
protoc_include_path=${protoc_include_path:-"${soft_dir}/protoc-${protoc_version}-linux-x86_64/include"}
cloc_version=${cloc_version:-"1.76"}
cmd_path=${cmd_path:-"${GOPATH}/bin"}

```bash
echo "GOPROXY=https://goproxy.io" >>${HOME}/.profile
echo "protoc_include_path=${HOME}/protoc/include" >>${HOME}/.profile
echo "GO111MODULE=auto" >>${HOME}/.profile
echo "GOPATH=${HOME}/go_path" >>${HOME}/.profile
echo "PATH=${soft_dir}/go/bin:${GOPATH}/bin:${PATH}" >>${HOME}/.profile
```

#### 安装系统依赖
```bash
1. git >= 2.17
2. wget
3. make
4. unzip
5. tar
```
#### 安装go程序
```bash

```
18 changes: 7 additions & 11 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,50 @@ GOPROXY=${GOPROXY:-"https://goproxy.io"}
soft_dir=${HOME:-"/tmp"}
go_version=${go_version:-"1.11"}
protoc_version=${protoc_version:-"3.6.1"}
protoc_include_path=${protoc_include_path:-"${soft_dir}/protoc-${protoc_version}-osx-x86_64/include"}
protoc_include_path=${protoc_include_path:-"${soft_dir}/protoc-${protoc_version}-linux-x86_64/include"}
cloc_version=${cloc_version:-"1.76"}
GOPATH=${GOPATH:-${HOME}"/go_path"}
cmd_path=${cmd_path:-"${GOPATH}/bin"}


#go
go_install(){
hash go 2>/dev/null || `
echo "安装golang环境 go"${go_version} && \
mkdir -p ${soft_dir} && cd ${soft_dir} && \
wget -c https://dl.google.com/go/go${go_version}.linux-amd64.tar.gz && \
tar -xzvf go${go_version}.linux-amd64.tar.gz && \
go version `
go version
}

#圈复杂分析
cloc_install(){
#安装cloc
hash cloc 2>/dev/null || `
echo "安装代码统计工具 cloc" && \
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文件已经存在"; } && \
echo "cloc 的版本是:" && cloc --version `
echo "cloc 的版本是:" && cloc --version

}

protoc_install(){
hash protoc 2>/dev/null || `
echo "安装protobuf工具 " && \
mkdir -p ${soft_dir} && cd ${soft_dir} && \
wget -c https://github.com/protocolbuffers/protobuf/releases/download/v${protoc_version}/protoc-${protoc_version}-linux-x86_64.zip && \
unzip protoc-${protoc_version}-linux-x86_64.zip -d ./protoc-${protoc_version}-linux-x86_64 && \
mv ${soft_dir}/protoc-${protoc_version}-linux-x86_64/bin/protoc ${cmd_path} && \
echo "路径为:"${cmd_path} && \
echo "protoc 的版本是:" && ${cmd_path}/protoc --version`
echo "protoc 的版本是:" && protoc --version
}

go_plug(){
cd ${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
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
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
go get github.com/favadi/protoc-go-inject-tag
echo "安装gocyclo圈复杂度计算工具"
go get github.com/fzipp/gocyclo
Expand Down

0 comments on commit f67ed12

Please sign in to comment.