Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
servers_config
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
servers_config
Commits
0b78fc33
Commit
0b78fc33
authored
Jul 17, 2018
by
ifool
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor setup script
parent
b62c7083
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
68 deletions
+80
-68
README.md
+11
-5
ik_invoicing/dingding/staging/server.json
+0
-0
ik_invoicing/dingding/testing/server.json
+0
-0
script_generator.rb
+40
-0
setup.rb
+29
-33
setup_script.rb
+0
-30
vcooline_ikcrm/ding/prod/server.json
+0
-0
No files found.
README.md
View file @
0b78fc33
## 操作说明
进入配置文件项目(
`cd vcooline_ikcrm_config`
),执行如下命令:
进入配置文件项目(
`cd vcooline_ikcrm_config
; git checkout ding
`
),执行如下命令:
```
bash
ruby
-e
"
`
curl http://gitlab.ikcrm.com/ikcrm_common/servers_config/raw/master/setup
_script.rb
`
"
crm
prod
ruby
-e
"
`
curl http://gitlab.ikcrm.com/ikcrm_common/servers_config/raw/master/setup
.rb
`
"
prod
```
### 说明
1.
上述脚本中的参数
`crm`
需匹配该项目的1级子目录名称
1.
项目配置文件(vcooline_ikcrm_config)的分支名称(
`ding`
分支)需匹配该项目的2级子目录名称
1.
上述脚本中的参数
`prod`
需匹配该项目的3级子目录名称
1.
项目配置文件名称(
`vcooline_ikcrm_config`
)去掉
`_config`
后需匹配该项目的1级子目录名称。
1.
项目配置文件(
`vcooline_ikcrm_config`
)的分支名称(
`ding`
分支)需匹配该项目的2级子目录名称
1.
上述脚本中的参数
`prod`
为环境名称,需匹配该项目的3级子目录名称
#### 以CRM钉钉版生产环境为例:
1.
配置文件项目名称为
`vcooline_ikcrm_config`
,去掉
`_config`
后对应1级子目录为
`vcooline_ikcrm`
1.
分支为
`ding`
,对应2级子目录为
`ding`
1.
环境名称为
`prod`
,对应3级子目录为
`prod`
1.
`server.json`
url对应的全路径为: http://gitlab.ikcrm.com/ikcrm_common/servers_config/raw/master/
`vcooline_ikcrm`
/
`ding`
/
`prod`
/server.json
...
...
jxc
/dingding/staging/server.json
→
ik_invoicing
/dingding/staging/server.json
View file @
0b78fc33
File moved
jxc
/dingding/testing/server.json
→
ik_invoicing
/dingding/testing/server.json
View file @
0b78fc33
File moved
script_generator.rb
0 → 100644
View file @
0b78fc33
require
'erb'
require
'json'
class
ScriptGenerator
attr_accessor
:product_name
,
:git_branch
,
:config_root
def
initialize
self
.
config_root
=
File
.
expand_path
(
'..'
,
__FILE__
)
self
.
product_name
=
File
.
basename
(
File
.
expand_path
(
'..'
,
config_root
).
gsub
(
"_config"
,
""
))
self
.
git_branch
=
`cd
#{
config_root
}
; git rev-parse --abbrev-ref HEAD`
.
chop
end
def
download_server_json
env_name
=
File
.
basename
config_root
server_conf_url
=
"http://gitlab.ikcrm.com/ikcrm_common/servers_config/raw/master/
#{
product_name
}
/
#{
git_branch
}
/
#{
env_name
}
/server.json"
puts
"Use server config url:
#{
server_conf_url
}
"
system
"curl
#{
server_conf_url
}
>
#{
config_root
}
/server.json"
end
def
deploy_binding
config_root
=
File
.
expand_path
(
'..'
,
__FILE__
)
server_conf
=
JSON
(
File
.
read
(
"
#{
__dir__
}
/server.json"
))
binding
end
def
generate_push_config
template
=
ERB
.
new
File
.
read
(
"
#{
__dir__
}
/push_config.sh.erb"
),
nil
,
'>'
script_content
=
template
.
result
(
deploy_binding
)
puts
"
\n\n\n
******************* push_config content *******************
\n\n\n
"
puts
script_content
File
.
open
(
"
#{
__dir__
}
/push_config.sh"
,
"w"
)
{
|
f
|
f
.
write
(
script_content
)
}
end
def
generate_pull_config
template
=
ERB
.
new
File
.
read
(
"
#{
__dir__
}
/pull_config.sh.erb"
),
nil
,
'>'
script_content
=
template
.
result
(
deploy_binding
)
puts
"
\n\n\n
******************* pull_config content *******************
\n\n\n
"
puts
script_content
File
.
open
(
"
#{
__dir__
}
/pull_config.sh"
,
"w"
)
{
|
f
|
f
.
write
(
script_content
)
}
end
end
setup.rb
View file @
0b78fc33
require
'erb'
require
'json'
def
download_server_json
product_name
=
ARGV
[
0
]
config_root
=
File
.
expand_path
(
'..'
,
__FILE__
)
git_branch
=
`cd
#{
config_root
}
; git rev-parse --abbrev-ref HEAD`
.
chop
dir_basename
=
File
.
basename
config_root
server_conf_url
=
"http://gitlab.ikcrm.com/ikcrm_common/servers_config/raw/master/
#{
product_name
}
/
#{
git_branch
}
/
#{
dir_basename
}
/server.json"
puts
"Use server config url:
#{
server_conf_url
}
"
system
"curl
#{
server_conf_url
}
>
#{
config_root
}
/server.json"
end
#!/usr/bin/env ruby
def
deploy_binding
config_root
=
File
.
expand_path
(
'..'
,
__FILE__
)
server_conf
=
JSON
(
File
.
read
(
"
#{
__dir__
}
/server.json"
))
binding
env_name
=
ARGV
[
0
]
# dev, test, staging, prod
config_root
=
File
.
expand_path
(
"../
#{
env_name
}
"
,
__FILE__
)
if
env_name
.
nil?
raise
"Dir name is required!"
elsif
!
Dir
.
exists?
(
config_root
)
raise
"Dir:
#{
config_root
}
not exists!"
end
def
generate_push_config
template
=
ERB
.
new
File
.
read
(
"
#{
__dir__
}
/push_config.sh.erb"
),
nil
,
'>'
script_content
=
template
.
result
(
deploy_binding
)
puts
"
\n\n\n
******************* push_config content *******************
\n\n\n
"
puts
script_content
File
.
open
(
"
#{
__dir__
}
/push_config.sh"
,
"w"
)
{
|
f
|
f
.
write
(
script_content
)
}
end
puts
"======================= config_root is:
#{
config_root
}
======================="
def
generate_pull_config
template
=
ERB
.
new
File
.
read
(
"
#{
__dir__
}
/pull_config.sh.erb"
),
nil
,
'>'
script_content
=
template
.
result
(
deploy_binding
)
puts
"
\n\n\n
******************* pull_config content *******************
\n\n\n
"
puts
script_content
File
.
open
(
"
#{
__dir__
}
/pull_config.sh"
,
"w"
)
{
|
f
|
f
.
write
(
script_content
)
}
end
git_config_url
=
"http://gitlab.ikcrm.com/ikcrm_common/servers_config/raw/master"
setup_url
=
"
#{
git_config_url
}
/script_generator.rb"
puts
"Use script_generator url:
#{
setup_url
}
"
system
"curl
#{
setup_url
}
>
#{
config_root
}
/script_generator.rb"
push_script_url
=
"
#{
git_config_url
}
/push_config.sh.erb"
puts
"Use push script url:
#{
push_script_url
}
"
system
"curl
#{
push_script_url
}
>
#{
config_root
}
/push_config.sh.erb"
pull_script_url
=
"
#{
git_config_url
}
/pull_config.sh.erb"
puts
"Use pull script url:
#{
pull_script_url
}
"
system
"curl
#{
pull_script_url
}
>
#{
config_root
}
/pull_config.sh.erb"
require
"
#{
config_root
}
/script_generator.rb"
generator
=
ScriptGenerator
.
new
generator
.
download_server_json
generator
.
generate_push_config
generator
.
generate_pull_config
download_server_json
generate_push_config
generate_pull_config
# Usage example:
# `ruby setup_script.rb crm prod` OR ./setup_script.rb crm prod
setup_script.rb
deleted
100644 → 0
View file @
b62c7083
#!/usr/bin/env ruby
product_name
=
ARGV
[
0
]
# crm, jxc, bms
dir_name
=
ARGV
[
1
]
# dev, test, staging, prod
config_root
=
File
.
expand_path
(
"../
#{
dir_name
}
"
,
__FILE__
)
if
dir_name
.
nil?
raise
"Dir name is required!"
elsif
!
Dir
.
exists?
(
config_root
)
raise
"Dir:
#{
config_root
}
not exists!"
end
puts
"======================= config_root is:
#{
config_root
}
======================="
git_config_url
=
"http://gitlab.ikcrm.com/ikcrm_common/servers_config/raw/master"
setup_url
=
"
#{
git_config_url
}
/setup.rb"
puts
"Use setup url:
#{
setup_url
}
"
system
"curl
#{
setup_url
}
>
#{
config_root
}
/setup.rb"
push_script_url
=
"
#{
git_config_url
}
/push_config.sh.erb"
puts
"Use push script url:
#{
push_script_url
}
"
system
"curl
#{
push_script_url
}
>
#{
config_root
}
/push_config.sh.erb"
pull_script_url
=
"
#{
git_config_url
}
/pull_config.sh.erb"
puts
"Use pull script url:
#{
pull_script_url
}
"
system
"curl
#{
pull_script_url
}
>
#{
config_root
}
/pull_config.sh.erb"
require
"
#{
config_root
}
/setup.rb"
# Usage example:
# `ruby setup_script.rb crm prod` OR ./setup_script.rb crm prod
crm/ding/prod/server.json
→
vcooline_ik
crm/ding/prod/server.json
View file @
0b78fc33
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment