一.用户和SSH密码
1.用户
a.为Redmine(redmine)创建用户,为Gitolite(git)创建另一个用户:
$ sudo adduser --system --shell /bin/bash --gecos 'Git Administrator' --group --disabled-password --home /opt/gitolite git
$ sudo adduser --system --shell /bin/bash --gecos 'Redmine Administrator' --group --disabled-password --home /opt/redmine redmine
b.为redmine用户生成一个ssh-key。 该用户将作为Gitolite的管理员。 密钥的名称应为redmine_gitolite_admin_id_rsa。
$ sudo su - redmine
$ ssh-keygen -t rsa -N '' -f ~/.ssh/redmine_gitolite_admin_id_rsa
$ exit
2.配置Gitolite
$ sudo dpkg-reconfigure gitolite
根据提示输入以下内容:
- user: git
- repos path: /opt/gitolite
-
admin ssh-key: /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub
用户名
![](https://img.haomeiwen.com/i13474785/bd500f1b693fadb5.jpg)
![](https://img.haomeiwen.com/i13474785/a7e9e9bc8728efbf.jpg)
3.Visudo配置
a.编辑配置文件
$ sudo visudo
添加以下内容
# temp - *REMOVE* after installation
redmine ALL=(ALL) NOPASSWD:ALL
# redmine gitolite integration
redmine ALL=(git) NOPASSWD:ALL
git ALL=(redmine) NOPASSWD:ALL
请注意,redmine用户将能够运行root命令,但这只是为了简化后续步骤。 安装后删除此行。
二.Redmine Git 主机
1.下载Git,以1.2.3版本为例,更改其他版本的版本号
$ sudo su - redmine
$ cd /opt/redmine/redmine/plugins
$ git clone https://github.com/jbox-web/redmine_bootstrap_kit.git
$ cd redmine_bootstrap_kit/
$ git checkout 0.2.5
$ git clone https://github.com/jbox-web/redmine_git_hosting.git
$ cd redmine_git_hosting
$ git checkout 1.2.3
在运行bundle exec之前,您必须编辑插件的Gemfile(REDMINE_ROOT / plugins / redmine_git_hosting / Gemfile)并注释/取消注释与Redmine版本(2.x或3.x)对应的行。
$ vi Gemfile
## Redmine 3.x
## Ruby/Rack Git Smart-HTTP Server Handler (use our own repository because Redmine uses Rails 4.2 and Rack 1.6)
gem 'gitlab-grack', git: 'https://github.com/jbox-web/grack.git', require: 'grack', branch: 'fix_rails4'
#gem 'redcarpet', '~> 3.3.2'
2.配置
$ ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa /opt/redmine/redmine/plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa
$ ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub /opt/redmine/redmine/plugins/redmine_git_hosting/ssh_keys/redmine_gitolite_admin_id_rsa.pub
$ ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa /opt/redmine/.ssh/id_rsa
$ ln -s /opt/redmine/.ssh/redmine_gitolite_admin_id_rsa.pub /opt/redmine/.ssh/id_rsa.pub
3.配置GL_GITCONFIG_KEYS
此版本现在使用一些钩子,默认情况下在gitolite v2上,将被var GL_GITCONFIG_KEYS阻止。 在gitolite v3上,此var名为GIT_CONFIG_KEYS。
$ sudo su - git
$ sed -i 's/$GL_GITCONFIG_KEYS = ""/$GL_GITCONFIG_KEYS = ".*"/g' /opt/gitolite/.gitolite.rc
$ exit
上面的* sed *命令可能无效,所以最好在/opt/gitolite/.gitolite.rc之后查看更改或者只使用nano。显示如下效果即可:
$GL_GITCONFIG_KEYS = ".*";
4.配置自动存储库初始化
a.要配置新功能“自动存储库初始化”(可选),必须自定义gitolite.conf文件。
$ cd ~
$ git clone git@localhost:gitolite-admin.git
$ cd gitolite-admin
b.编辑Gitolite配置文件
$ vi conf/gitolite.conf
c.添加以下配置信息
repo @all
RW+ = admin
d.输入以下命令;
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
$ git commit -m 'Automatic Repository Initialization' conf/gitolite.conf
$ git push
$ cd ~
$ rm -rf gitolite-admin
请记住,此存储库将由redmine及其插件管理。
5.构建
$ cd redmine
$ bundle install --without development test postgresql sqlite
$ RAILS_ENV=production rake redmine:plugins:migrate
$ RAILS_ENV=production rake redmine_git_hosting:update_repositories
$ RAILS_ENV=production rake redmine_git_hosting:fetch_changesets
$ RAILS_ENV=production rake redmine_git_hosting:restore_default_settings
$ RAILS_ENV=production rake redmine_git_hosting:install_hook_files
$ RAILS_ENV=production rake redmine_git_hosting:install_hook_parameters
$ RAILS_ENV=production rake redmine_git_hosting:install_gitolite_hooks
$ exit
网友评论