Friday, May 21, 2010

InDefero with Git on CentOS



In my never ending quest to improve the development environment at the office, I started looking at DVCS(distributed version control systems) and was leaning towards migrating from subversion to Git. I started looking for an easy way of managing a Git repository and came across InDefero.

InDefero is both a code and project management system that is similar to GoogleCode.

This post documents what I did to setup InDefero on a fresh install of CentOS 5.4.

First, we install apache2 and mysql as well as rsync which is needed by git
yum install sudo rsync screen httpd mysql-server mysql
Next the PHP version available for CentOS 5.4 does not meet the requirements of InDefero so we setup the CentOS-Testing repository so we can get a newer one.

sed -n 'p' >/etc/yum.repos.d/CentOS-Testing.repo <<EOF
[CentOS-Testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/\$releasever/testing/\$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
includepkgs=php*
EOF
yum install php php-pear php-mysql php-mbstring --disablerepo=* --enablerep=CentOS-Testing
Next we satisfy the pear dependencies of InDefero.
pear channel-update pear.php.net
pear upgrade-all
pear install --alldeps Mail
pear install --alldeps Mail_mime
Next we install git from the EPEL repository.
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
yum install git --disablerepo=* --enablerep=epel
Next we add and configure the git user
useradd git
usermod -a -G git apache
chmod g+rx /home/git
sudo su - git
mkdir /home/git/.ssh
touch /home/git/.ssh/authorized_keys
chmod 0700 /home/git/.ssh
chmod 0600 /home/git/.ssh/authorized_keys
mkdir /home/git/repositories
exit
Next we download indefero and its dependencies
mkdir /home/www
cd /home/www
git clone git://projects.ceondo.com/pluf.git
git clone git://projects.ceondo.com/indefero.git
chown apache:apache -R /home/www
Next we configure indefero
cp /home/www/indefero/src/IDF/conf/path.php-dist /home/www/indefero/src/IDF/conf/path.php
sed -n 'p' >/home/www/indefero/src/IDF/conf/idf.php <<EOF
<?php
$cfg = array();
$cfg['debug'] = true;
$cfg['debug_scm'] = true; 
$cfg['git_repositories'] = '/home/git/repositories/%s.git';
$cfg['git_remote_url'] = 'git://scm.yourdomain.com/%s.git';
$cfg['git_write_remote_url'] = 'git@scm.yourdomain.com:%s.git';
$cfg['idf_plugin_syncgit_remove_orphans'] = false;
$cfg['idf_plugin_syncgit_git_home_dir'] = '/home/git'; 
$cfg['idf_plugin_syncgit_base_repositories'] = '/home/git/repositories'; 
$cfg['idf_plugin_syncgit_path_gitserve'] = '/home/www/indefero/scripts/gitserve.py';
$cfg['idf_plugin_syncgit_path_authorized_keys'] = '/home/git/.ssh/authorized_keys';
$cfg['idf_plugin_syncgit_sync_file'] = '/tmp/SYNC-GIT';
$cfg['admins'] = array(array('Admin', 'admin@yourdomain.com'));
$cfg['send_emails'] = true;
$cfg['mail_backend'] = 'smtp';
$cfg['mail_host'] = 'mail.yourdomain.com';
$cfg['mail_port'] = 25;
$cfg['idf_base'] = '/index.php';
$cfg['url_base'] = 'http://scm.yourdomain.com';
$cfg['url_media'] = 'http://scm.yourdomain.com/media';
$cfg['url_upload'] = 'http://scm.yourdomain.com/media/upload';
$cfg['upload_path'] = '/home/www/indefero/www/media/upload';
$cfg['upload_issue_path'] = '/home/www/indefero/attachments';
$cfg['secret_key'] = 'foobarfoobarfoobarfoobarfoobarfoobarfoobar'; 
$cfg['from_email'] = 'scm@yourdomain.com'; 
$cfg['bounce_email'] = 'no-reply@yourdomain.com';
$cfg['tmp_folder'] = '/tmp';
$cfg['db_login'] = 'scmdb';
$cfg['db_password'] = 'f00b@r';
$cfg['db_server'] = '';
$cfg['db_version'] = '5.1'; # Only needed for MySQL
$cfg['db_table_prefix'] = 'indefero_'; 
$cfg['db_engine'] = 'MySQL';
$cfg['db_database'] = 'scmdb';
$cfg['pear_path'] = '/usr/share/php';
$cfg['login_success_url'] = $cfg['url_base'].$cfg['idf_base'];
$cfg['after_logout_page'] = $cfg['url_base'].$cfg['idf_base'];
$cfg['cache_engine'] = 'Pluf_Cache_File';
$cfg['cache_timeout'] = 300;
$cfg['cache_file_folder'] = $cfg['tmp_folder'].'/cache';
$cfg['template_folders'] = array(dirname(__FILE__).'/../templates',);
$cfg['installed_apps'] = array('Pluf', 'IDF');
$cfg['pluf_use_rowpermission'] = true;
$cfg['middleware_classes'] = array( 'Pluf_Middleware_Csrf', 'Pluf_Middleware_Session', 'IDF_Middleware', 'Pluf_Middleware_Translation',);
$cfg['template_context_processors'] = array('IDF_Middleware_ContextPreProcessor');
$cfg['idf_views'] = dirname(__FILE__).'/urls.php';
$cfg['languages'] = array('en', 'fr'); 
$cfg['allowed_scm'] = array('git' => 'IDF_Scm_Git');
$cfg['enable_new_user_registration'] = false;
return $cfg;
EOF
Configure a mysql database for indefero use
mysql -u root -p -e "create database scmdb"
mysql -u root -p -e "GRANT ALL PRIVILEGES ON scmdb.* TO 'scmdb'@'localhost' IDENTIFIED BY 'f00b@r';"
cd /home/www/indefero/src
php /home/www/pluf/src/migrate.php --conf=IDF/conf/idf.php -a -i -d
Create the admin user

sed -n 'p' >/home/www/indefero/bootstrap.php <<EOF
$lt;?php
require '/home/www/indefero/src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start('/home/www/indefero/src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
$user = new Pluf_User();
$user->first_name = 'Juan';
$user->last_name = 'Dela Cruz'; // Required!
$user->login = 'admin'; // must be lowercase!
$user->email = 'admin@yourdomain.com';
$user->password = 'yourpassword';
$user->administrator = true;
$user->active = true;
$user->create();
print "Bootstrap ok\n";
?>
EOF
php /home/www/indefero/bootstrap.php
rm /home/www/indefero/bootstrap.php
From here, you can now restart apache and login to your indefero instance.

You are also welcome to subscribe via email or subscribe via reader to get updates.

1 comment:

  1. thank y for great plugins, some of them I already use in some my projects.
    Wish y all the best.

    Regards
    Toby, ideals

    ReplyDelete