Indefero GIT Versioning Server
(Testado e a funcionar com CentOS 6.4)
INSTALAÇÃO:
yum -y install httpd mysql mysql-server php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml indefero
CONFIGURAÇÃO:
Preparação da base de dados:
cd /usr/share/indefero
nano /etc/indefero/idf.php (Editar e alterar as seguintes linhas)
$cfg['db_engine'] = 'MySQL';
$cfg['db_database'] = 'indefero';
$cfg['db_server'] = 'localhost';
$cfg['db_login'] = 'indefero';
$cfg['db_password'] = 'q1w2e3r4';
Criar base de dados e dar privilégios:
echo "create database indefero;" | mysql -u root -p
echo "GRANT ALL ON indefero.* TO 'indefero'@’localhost’ identified by 'YOUR_NEW_SECURE_RANDOM_PASSWORD';" | mysql -u root -p
(Insert your MySQL root password)
Instalar tabelas por defeito na base de dados:
php /usr/share/php/pluf/migrate.php --conf=/etc/indefero/idf.php -a -i –d
Gerar secret key:
dd if=/dev/urandom bs=1 count=64 2>/dev/null | base64 -w 0
(O resultado será semelhante ao seguinte e deve ser copiado para a linha “$cfg['secret_key'] =…” em “nano /etc/indefero/idf.php” conforme indicado a seguir)
LCT+ZI6nxW8iHIjQJpftNEenTiPwyzDnMBx5eeRQ8CiU06FIDIvCYQl0TrYoYW9MrfO0AJMRRQ12fX2y8MWA2g==
nano /etc/indefero/idf.php (Editar e alterar as seguintes linhas)
# DEEC - Assuming URL https://git.deec.uc.pt
$sl_server_address = 'git.deec.uc.pt';
$sl_url_base = 'https://' . $sl_server_address; // this is a new line!
$cfg['url_base'] = $sl_url_base;
$cfg['url_media'] = $sl_url_base . '/media';
$cfg['url_upload'] = $sl_url_base . '/media/upload';
$cfg['idf_base'] = ''; // you NEED the REWRITE in the apache enabled (see below)
$cfg['secret_key'] = ‘LCT+ZI6nxW8iHIjQJpftNEenTiPwyzDnMBx5eeRQ8CiU06FIDIvCYQl0TrYoYW9MrfO0AJMRRQ12fX2y8MWA2g==’;
$cfg['time_zone'] = 'Europe/Lisbon';
# Descomentar estas linhas para activar git support.
$cfg['allowed_scm']['git'] = 'IDF_Scm_Git';
$cfg['git_remote_url'] = 'git@' . $sl_server_address . ':%s.git';
$cfg['git_write_remote_url'] = 'git@' . $sl_server_address . ':%s.git';
Configurar site
nano /etc/httpd/conf.d/git.deec.uc.pt.conf
ServerAdmin git@deec.uc.pt
ServerName git.deec.uc.pt
# force over https, always
RedirectMatch / https://git.deec.uc.pt
ServerAdmin git@deec.uc.pt
ServerName git.deec.uc.pt
SSLEngine On
SSLCertificateFile /etc/ssl/streamline/git.deec.uc.pt.ca.crt
SSLCertificateKeyFile /etc/ssl/streamline/git.deec.uc.pt.ca.key
# Apache 2.2
Order allow,deny
Allow from all
DocumentRoot /usr/share/indefero/www
AllowOverride All
Options +Indexes
# Apache 2.4
Require all granted
# Uncomment following lines to activate rewrite rules
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php/$1
RewriteCond %{REQUEST_URI} !/media
Order allow,deny
Allow from all
INICIALIZAÇÃO
Criar um ficheiro de inicialização para criar o user admin, por exemplo,em
`/usr/share/doc/indefero-x.y.z/bootstrap.php.sample`.
cd /root
cp /usr/share/doc/indefero-1.3.3/bootstrap.php.sample ./indefero-bootstrap.php
nano indefero-bootstrap.php
require '/etc/indefero/path.php';
require 'Pluf.php';
Pluf::start('/etc/indefero/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
$user = new Pluf_User();
$user->first_name = 'Americo';
$user->last_name = 'Coutinho'; // Required!
$user->login = 'coutinho'; // must be lowercase!
$user->email = 'coutinho@streamline.pt’;
$user->password = 'q1w2e3r4'; // the password is salted/hashed
// in the cd /usr/share/indefero
nano /etc/indefero/idf.php
$cfg['db_engine'] = 'MySQL';
$cfg['db_database'] = 'indefero';
$cfg['db_server'] = 'localhost';
$cfg['db_login'] = 'indefero';
$cfg['db_password'] = 'q1w2e3r4';
echo "create database indefero;" | mysql -u root -p
echo "GRANT ALL ON indefero.* TO 'indefero'@’localhost’ identified by 'YOUR_NEW_SECURE_RANDOM_PASSWORD';" | mysql -u root -p
php /usr/share/php/pluf/migrate.php --conf=/etc/indefero/idf.php -a -i –d
dd if=/dev/urandom bs=1 count=64 2>/dev/null | base64 -w 0
nano /etc/indefero/idf.php
# DEEC - Assuming URL https://git.deec.uc.pt
$sl_server_address = 'git.deec.uc.pt';
$sl_url_base = 'https://' . $sl_server_address; // this is a new line!
$cfg['url_base'] = $sl_url_base;
$cfg['url_media'] = $sl_url_base . '/media';
$cfg['url_upload'] = $sl_url_base . '/media/upload';
$cfg['idf_base'] = ''; // you NEED the REWRITE in the apache enabled (see below)
$cfg['secret_key'] = ‘LCT+ZI6nxW8iHIjQJpftNEenTiPwyzDnMBx5eeRQ8CiU06FIDIvCYQl0TrYoYW9MrfO0AJMRRQ12fX2y8MWA2g==’;
$cfg['time_zone'] = 'Europe/Lisbon';
# Descomentar estas linhas para ativar git support.
$cfg['allowed_scm']['git'] = 'IDF_Scm_Git';
$cfg['git_remote_url'] = 'git@' . $sl_server_address . ':%s.git';
$cfg['git_write_remote_url'] = 'git@' . $sl_server_address . ':%s.git';
nano /etc/httpd/conf.d/git.deec.uc.pt.conf
ServerAdmin git@deec.uc.pt
ServerName git.deec.uc.pt
# force over https, always
RedirectMatch / https://git.deec.uc.pt
ServerAdmin git@deec.uc.pt
ServerName git.deec.uc.pt
SSLEngine On
SSLCertificateFile /etc/ssl/streamline/git.deec.uc.pt.ca.crt
SSLCertificateKeyFile /etc/ssl/streamline/git.deec.uc.pt.ca.key
# Apache 2.4
Require all granted
# Apache 2.2
Order allow,deny
Allow from all
DocumentRoot /usr/share/indefero/www
AllowOverride All
Options +Indexes
# Apache 2.4
Require all granted
# Uncomment following lines to activate rewrite rules
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php/$1
RewriteCond %{REQUEST_URI} !/media
Order allow,deny
Allow from all
cd /root
cp /usr/share/doc/indefero-1.3.3/bootstrap.php.sample ./indefero-bootstrap.phpnano indefero-bootstrap.php
require '/etc/indefero/path.php';
require 'Pluf.php';
Pluf::start('/etc/indefero/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
$user = new Pluf_User();
$user->first_name = 'Americo';
$user->last_name = 'Coutinho'; // Required!
$user->login = 'coutinho'; //
database, so do not worry :)
$user->administrator = true;
$user->active = true;
$user->create();
print "Bootstrap ok\n";
?>
Correr:
php indefero-bootstrap.php
Remover o ficheiro `bootstrap.php`
Agora podemos fazer login deste user através da interface
https://git.deec.uc. pt
Na barra de tarefas no separador Forge Management pode criar o primeiro projecto.
CONFIGURAÇÃO DO MODULO GIT
É necessário criar uma nova conta ‘GIT’. Esta conta só é usada para aceder aos repositórios GIT não podendo ser partilhada para outros usos.
Criação de nova conta GIT
useradd \
--system \
--shell /bin/sh \
--comment 'GIT Version control Account' \
--group nobody \
--home-dir /home/git \
git
mkdir -p /home/git/.ssh
chmod 755 /home/git
chown -R git:nobody /home/git
Criamos o ficheiro que vai conter as permissões SSH
su - git
touch /home/git/.ssh/authorized_keys
chmod 0700 /home/git/.ssh
chmod 0600 /home/git/.ssh/authorized_keys
exit
Adicionamos o user do apache ao grupo GIT para que possa ter acesso ao conteúdo dos repositórios
usermod -a -G git apache
Não esquecer fazer restart do apache para que a adição anterior seja considerada
service httpd restart
Criação dos repositórios base
sudo -H -u git mkdir /home/git/repositories
Cada projecto usando git em Indefero criará um repositório próprio em
‘/home/git/repositories’. Por exemplo se o nome do seu ficheiro for ‘myproject’ será criado:
‘/home/git/repositories/myproject.git`
Sincronização de repositório:
nano /etc/crontab
*/5 * * * * git php /usr/share/indefero/scripts/gitcron.php
service crond restart
Abrir a porta TCP 9418:
nano /etc/sysconfig/iptables
-A INPUT -p tcp --dport 9418 -j ACCEPT