Recently, the company's domain name changed, resulting in the need to batch modify Gitlab account. This work for the OPS staff, the workload is relatively large. Therefore, you try to modify the database in batches by using a script.
The process is broadly divided into several stages:
1) Figuring out the GITLAB database structure
2) Use Python to modify the relevant fields, if you find the domain name ending with @xxx, replace it with the @aaa domain name automatically.
Note: The Gitlab installation method used in this article is the official default Yum installation
1) Gitlab database uses PostgreSQL, the connection library needs to modify the Pg_hba.conf file's related configuration
Vim/var/opt/gitlab/postgresql/data/pg_hba.conf
hostallallcidr/masktrust# Add the Host network address and subnet mask that need to connect to the database
2) Modify the postgresql.conf configuration local_ip_address
Vim postgresql.conf
listen_addresses = ' local_ip_address ' #local_ip_address为服务器ip
3) Restart the database
Gitlab-ctl Restart PostgreSQL
4) Connect to the database
cd/opt/gitlab/embedded/
Bin/psql-u gitlab-psql-d gitlabhq_production-h local_ip_address# tested successfully, able to connect to database
5) because PostgreSQL's SQL statements are not well understood, the Navicat for PostgreSQL tool is used for database connectivity
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8D/27/wKiom1iPY1XRQSdAAABf8PJ3jDY925.png-wh_500x0-wm_3 -wmp_4-s_876224087.png "title=" 1.png "width=" "height=" 252 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:400px; height:252px; "alt=" Wkiom1ipy1xrqsdaaabf8pj3jdy925.png-wh_50 "/>
6) connecting to the database is OK, and finally we just need to focus on the changes.
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8D/25/wKioL1iPY4PxPnauAABdaZh9aqM282.png-wh_500x0-wm_3 -wmp_4-s_3558078465.png "title=" 2.png "alt=" Wkiol1ipy4pxpnauaabdazh9aqm282.png-wh_50 "/>
This article is from the "Hifour" blog, please be sure to keep this source http://hifour.blog.51cto.com/2733096/1894442
Gitlab Connect and bulk Modify Database account email address (top)