Skip to content

Instantly share code, notes, and snippets.

@danhantao
Last active August 29, 2015 14:04
Show Gist options
  • Save danhantao/be1b8163bf6e192cc7b3 to your computer and use it in GitHub Desktop.
Save danhantao/be1b8163bf6e192cc7b3 to your computer and use it in GitHub Desktop.
1.下载
wget http://gerrit-releases.storage.googleapis.com/gerrit-2.9-rc2.war
2.重命名
mv gerrit-2.9-rc2.war gerrit.war
3.
sudo adduser gerrit2 # 添加用户
sudo userdel gerrit2 # 删除用户
sudo su gerrit2
sudo passwd root # 设置root密码
sudo adduser xxx
chmod 777 /etc/sudoers
sudo vim /etc/sudoers
# User privilege specification
root ALL=(ALL) ALL
xxx ALL=(ALL) ALL
chmod 440 /etc/sudoers
4.
java -jar gerrit.war init -d ~/gerrit
java -jar gerrit.war init -d /home/gerrit2/gerrit
_______________________________________________________________________________________________
遇到的问题如下:
用openID认证:
Google:
400. That’s an error.
OpenID auth request contains an unregistered domain: http://dht.goodow.com:8081/code/
无法解决。
提示如下:
https://developers.google.com/accounts/docs/OpenID
_______________________________________________________________________________________________
Outgoing settings
SMTP server: smtp.gmail.com
Port: 465
Security type: SSL (always)
# cat gerrit/etc/gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://vpn.pheth.com
[database]
type = h2
database = db/ReviewDB
[index]
type = LUCENE
[auth]
type = HTTP
[sendemail]
smtpServer = smtp.gmail.com
smtpServerPort = 465
smtpEncryption = SSL
smtpUser = [email protected]
smtpPass = password
from = Code Review<[email protected]>
[container]
user = gerrit2
javaHome = /home/ubuntu/dev/tools/bin/jdk1.7.0_65/jre
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://*:8080/
[cache]
directory = cache
~~~~~~~~~~~~~~~~~~~~
由于反向代理服务器的配置等问题,造成登陆成功,但是clone的时候,地址如下:
git clone http://vpn.pheth.com/retech/drive-android
造成无法clone下来。
如果换成:git clone http://vpn.pheth.com:8080/retech/drive-android
clone完全没有问题。
canonicalWebUrl = http://vpn.pheth.com 后面加上端口号:8080
可是登陆成功后,http://vpn.pheth.com/#/q/status:open
没有端口号,然后偶然的将
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
删除,然后一切完好。
~~~~~~~~~~~~~~~~~~~~
到目前为止,无法去除8080的端口号。原因不详。
此时:输入http://vpn.pheth.com是不好用的,http://vpn.pheth.com/可以跳转。
sudo ln -snf /home/gerrit2/gerrit/bin/gerrit.sh /etc/init.d/gerrit
sudo ln -snf /etc/init.d/gerrit /etc/rc3.d/S90gerrit
sudo vim /etc/init.d/gerrit
添加:
GERRIT_SITE=/home/gerrit2/gerrit
NO_START=0
重启:
service gerrit restart
sudo apt-get install nginx
sudo vim /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name vpn.pheth.com;
location / {
auth_basic_user_file /home/gerrit2/gerrit/htpasswd.conf;
auth_basic "Gerrit2 Code Review";
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
sudo /etc/init.d/nginx restart
sudo apt-get install apache2-utils
添加账户:
htpasswd -d htpasswd.conf admin
无法登出:
You are using HTTP Basic authentication. There is no way to tell abrowser to quit sending basic authentication credentials, to logout with basicauthentication is to close the Webbrowser.
退出:
http://nobody:[email protected]/
gerrit.config
手动添加:
[gitweb]
cgi = /usr/share/gitweb/gitweb.cgi
需要添加权限,其他用户才能查看refs/meta/config的read权限
___________________________________________________________________
问题:
dan@dan-System-Product-Name:~/桌面/danhanta$ ssh -i id_rsa -p 29418 [email protected] gerrit gsql
fatal: admin does not have "Access Database" capability.
可以在access里面添加Acesss Database
#管理员用命令行穿件新项目。
ssh -p 29418 -i id_rsa [email protected] gerrit create-project --name retech/drive-android
#查看新项目已经成功创建。
ssh -p 29418 -i id_rsa [email protected] gerrit ls-projects
All-Users
#查看帮助信息
ssh -p 29418 -i id_rsa [email protected] gerrit --help
#管理数据库
ssh -p 29418 -i id_rsa [email protected] gerrit gsql
http://192.168.11.236/tools/hooks/commit-msg
——————————————————————————————————————————————————————————————————————————————————————————————————
ssl:
http://www.freehao123.com/startssl-ssl/
http://www.freehao123.com/nginx-startssl/
@danhantao
Copy link
Author

@danhantao
Copy link
Author

@danhantao
Copy link
Author

gerrit2安装和用Nginx设置HTTP基本验证
http://ruiming.blog.sohu.com/259221968.html

CI 系统搭建:三. Gerrit 的安装配置
http://longgeek.com/2013/12/26/ci-system-structures-iii-gerrit-installation-configuration/

@danhantao
Copy link
Author

删除数据库
http://blog.csdn.net/cn_chenfeng/article/details/6760343

删除数据库,没有找到Project的表。可能是表结构变化了。。。

@danhantao
Copy link
Author

修改为https方式:

@danhantao
Copy link
Author

@danhantao
Copy link
Author

openID无法认证的原因,不详。。。
可能有些原因不知道。

@danhantao
Copy link
Author

问题:
1.openId方式怎么取配置。
2.反向代理服务器怎么配置。

@danhantao
Copy link
Author

ssh -p 29418 -i id_rsa [email protected] gerrit ls-projects
ssh -p 29418 -i id_rsa [email protected] gerrit gsql


show tables;
show columns from system_config;


新建一个项目
ssh -p 29418 -i id_rsa [email protected] gerrit create-project --name drive-android

@danhantao
Copy link
Author

@danhantao
Copy link
Author

ubuntu下查找文件:
sudo find /* -name 'tools'

@danhantao
Copy link
Author

困扰我的问题:
nginx里面添加了http认证之后,就不在用git clone 的时候,转发就会失败。
原因不详。
可能需要用apache认证。

@danhantao
Copy link
Author

@danhantao
Copy link
Author

步骤如下:
apt-get install apache2
ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled/proxy.load
ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled/proxy_http.load

/etc/apache2/mods-enabled$ ls -l proxy.conf proxy.load proxy_http.load

/etc/init.d/apache2 restart
/etc/apache2/sites-available#
修改为如下:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
    ProxyRequests Off
    ProxyVia Off
    ProxyPreserveHost On

    <Proxy *>
      Order deny,allow
      Allow from all
    </Proxy>

    <Location /login/>
     AuthType Basic
     AuthName "Gerrit Code Review"
     Require valid-user
     AuthBasicProvider file
     AuthUserFile /home/gerrit2/gerrit/htpasswd.conf
    </Location>

    ProxyPass / http://127.0.0.1:8080/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /etc/apache2# 在apache2.conf结尾添加: Include sites-available/000-default.conf

@danhantao
Copy link
Author

@danhantao
Copy link
Author

卸载ngnix
sudo apt-get --purge remove nginx
卸载nginx的方法如下:
sudo rm -rf /etc/nginx/
sudo rm -rf /usr/sbin/nginx
sudo rm /usr/share/man/man1/nginx.1.gz
sudo apt-get remove nginx*

@danhantao
Copy link
Author

构建自己的Android代码托管服务器
http://blog.csdn.net/billpig/article/details/7604828

@danhantao
Copy link
Author

@danhantao
Copy link
Author

保持镜像和远程仓库代码同步:
1.git clone --mirror http://reporistry-url
2.mirror: 定时 git remote update

1.在远程仓库里的hooks目录下,建一个shell脚本:

!/bin/sh

pwd
git push http://reporistry-mirror-url master
用户名密码:~/.netrc 或者 http://name@password:reporistry-mirror-url

2.shell脚本可执行。
那么就可以定时的同步。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment