lunedì 25 giugno 2012

Convert HG to Git repository






On Ubuntu:


~# ls
repository.hg
~# apt-get install hg-fast-export
~# git init new_repository.git



~# ls
repository.hg new_repository.git
~# cd new_repository.git
~/new_repository.git# hg-fast-export -r ../repository.hg



You will recieve a summary text in the end, like


git-fast-import statistics:
---------------------------------------------------------------------
Alloc'd objects: 5000
Total objects: 478 ( 14 duplicates )
blobs : 133 ( 14 duplicates 54 deltas of 133 attempts)
trees : 216 ( 0 duplicates 194 deltas of 196 attempts)
commits: 129 ( 0 duplicates 0 deltas of 0 attempts)
tags : 0 ( 0 duplicates 0 deltas of 0 attempts)
Total branches: 4 ( 1 loads )
marks: 1024 ( 129 unique )
atoms: 16
Memory total: 2344 KiB
pools: 2110 KiB
objects: 234 KiB
---------------------------------------------------------------------
pack_report: getpagesize() = 4096
pack_report: core.packedGitWindowSize = 1073741824
pack_report: core.packedGitLimit = 8589934592
pack_report: pack_used_ctr = 901
pack_report: pack_mmap_calls = 215
pack_report: pack_open_windows = 1 / 1
pack_report: pack_mapped = 331971 / 331971
---------------------------------------------------------------------


In the end do:


~/new_repository.git# git checkout HEAD



Test your repo with git log.

giovedì 14 giugno 2012

Migrate PhpBB3 on Ubuntu server

PhpBB version: 3.0.9
Backend: Mysql
Mode: Fcgi



Dump the database

ubuntu~# mysqldump -u root -p phpbb3 > /tmp/phpbb3.sql


On the new machine

new~# apt-get update && apt-get install phpbb3


During the installation, choose to configure mysql/phpbb3 via debconf and answer about passwords in this order
* Mysql root password
* Phpbb3 database password
* Phpbb3 admin interface password

Afterwords, setup the web server. You have a configuration example in /etc/phpbb3/apache2.conf; you can directly copy this file in your /etc/apache2/sites-available directory and run

new:/etc/phpbb3# cp apache2.conf /etc/apache2/sites-available/phpbb3
new:/etc/phpbb3# cd /etc/apache2/sites-available/
new:/etc/apache2/sites-available# a2ensite phpbb3 && service apache2 reload


Try to login and surf the admin interface (APC). If you had a custom theme in the previous server, do the follow:

ubuntu~# scp -r /srv/phpbb3/theme/ (or wherever it is) new:/usr/share/phpbb3/styles


Important , make a sym link in /etc/phpbb3/styles directory to make phpbb see the custom theme

new~# cd /etc/phpbb3/styles
new:/etc/phpbb3/styles# ln -s /usr/share/phpbb3/styles/theme theme


Once the link is ok, configure the new theme in the APC (administrative panel)

If everything seems to be fine, move on and restore the database

new~# mysql -u root -p phpbb3 < phpbb3.sql


Configure FCGI

new~# apt-get install php5-cgi
new~# cd /etc/apache2/
new:/etc/apache2/# a2dismod php5
new:/etc/apache2/# service apache2 restart


Setup fcgi environment

new~# cd /srv (or wherever you'll locate it)
new:/srv# mkdir php-fcgi
new:/srv# cd (alt+.)
new:/srv/php-fcgi# ls
phpbb.fcgi
phpbbrc -> /etc/php5/cgi/


phpbb.fcgi

#!/bin/sh
PHP_FCGI_MAX_REQUESTS=10000
PHP_FCGI_CHILDREN=0
export PHPRC=/srv/php-fcgi/php53rc
export PHP_FCGI_MAX_REQUESTS PHP_FCGI_CHILDREN
# Replace with the path to your FastCGI-enabled PHP executable
exec /usr/bin/php-cgi


NOTE: phpbbrc is a link to /etc/php5/cgi/ directory

The virtualhost section should be something like

<VirtualHost *:80>
    ServerName forum.example.org
    DocumentRoot /usr/share/phpbb3/www
    ErrorLog /var/log/apache2/forum_error.log
    CustomLog /var/log/apache2/forum_access.log combined
    Alias / /usr/share/phpbb3/www/

   <Directory>
      Order allow,deny
      Allow from all
      Options +ExecCGI
      AddHandler fcgid-script .php
      FcgidWrapper /srv/php-fcgi/phpbb.fcgi .php
   </Directory>
</VirtualHost>



Try to load a forum page and check with

new~# ps ax | grep cg[i]
2248 ? S 0:00 /usr/bin/php-cgi


that php-cgi is running ..

domenica 15 gennaio 2012

Handle voip customers with Siproxd on CentOS 5.7



Install Libosip2


cd /usr/local/src
wget http://www.antisip.com/download/exosip2/libosip2-3.5.0.tar.gz
tar xvf libosip2-3.5.0.tar.gz
yum install gcc
cd libosip2-3.5.0
./configure
make
make install
ll /usr/local/lib



Create a new file in /etc/ld.conf.d


echo "/usr/local/lib" > /etc/ld.conf.d/local.conf
ldconfig



Install Siproxd


cd /usr/local/src
wget http://sourceforge.net/projects/siproxd/files/siproxd/0.8.1/siproxd-0.8.1.tar.gz/download
tar xvf siproxd-0.8.1.tar.gz
cd siproxd-0.8.1/
./configure --with-libosip-prefix=/usr/local/lib
make
make install



Do this:


yum remove gcc

Create siproxd user:


useradd -c "Siproxd user" -r -s /bin/nologin siproxd

Basic Siproxd configuration:


vim /etc/siproxd_customer-name.conf


if_inbound = eth0
if_outbound = eth0


sip_listen_port = 5070
daemonize = 0
silence_log = 1
user = siproxd


hosts_allow_reg = 11.22.33.44/16


registration_file = /var/lib/siproxd/siproxd_registrations
autosave_registrations = 300
pid_file = /var/run/siproxd/siproxd.pid


outbound_proxy_host = voip.provider.example.com
outbound_proxy_port = 5060


rtp_proxy_enable = 0
rtp_port_low = 27000
rtp_port_high = 27100
rtp_timeout = 300
rtp_dscp = 46
sip_dscp = 0
rtp_input_dejitter = 0
rtp_output_dejitter = 0
tcp_timeout = 600
tcp_connect_timeout = 500
tcp_keepalive = 20


debug_level = 0x00000000
debug_port = 0

Start siproxd:


/usr/local/sbin/siproxd

Some explanations:
if_inbound/if_outbound - It's the same interface (eth0) because we just have one
hosts_allow_reg - Put here your customer IP (if he has a static one) with the right mask (/16, /24..); you can calculate the mask using a subnet calculator (http://www.subnet-calculator.com)
rtp_proxy_enable = 0 - We just want to proxy the signaling protocol (SIP) not the audio stream (RTP)
outbound_proxy_host - Put here the customer voip provider that you want to connect to

Before setup asterisk, try siproxd configuration using a softphone such as twinkle, ekiga.. It's better a softphone which includes a "Outbound Proxy" field. Twinkle does the trick.

Twinkle example configuration_
User Tab:
User name* = user ID for voip.provider.example.com
Domain* = user ID for voip.provider.example.com
Authentication Name = password for voip.provider.example.com

SIP server Tab:
check on Use Outbound Proxy
Outbound Proxy = your.siproxd.server:5070

If something goes wrong revisit you siproxd configuration running siproxd in debug mode:


/usr/local/sbin/siproxd -c /etc/siproxd_customer-name.conf -d -1 2

NOTE: do different "/etc/siproxd_customer-name.conf" files to give to each siproxd instance you need.


Asterisk trunk configuration
(on the customer PBX)


contact="user ID for voip.provider.example.com"
context=from-trunk
fromuser="user ID for voip.provider.example.com"
outboundproxy="your.siproxd.server:5070"
type=peer
nat=never
host="your.siproxd.server"
port=5070
insecure=very
secret="password for voip.provider.example.com"
username="user ID for voip.provider.example.com"

NOTE: i'm currently still testing this setup. It works pretty fine, but i cant hide some weird behavior with asterisk trunk. For instance, it's easy encounter a voip congestion placing 2 calls one after another. Using siproxd directly with twinkle doesn't. Given this, the trunk works. Any tips will be appreciate

giovedì 22 dicembre 2011

Upgrade apt-cacher-ng on Fedora 15

Get the last version of apt-cacher:


cd /usr/src
wget http://ftp.debian.org/debian/pool/main/a/apt-cacher-ng/apt-cacher-ng_x.x.x.orig.tar.xz
tar xvf apt-cacher-ng_x.x.x.orig.tar.xz


Compile it:


cd /usr/src/apt-cacher-ng_last_release
make
(if something goes wrong or missing, do a 'make clean' and retype 'make')
cp /usr/local/sbin/apt-cacher-ng /usr/lcoal/sbin/back_apt-cacher-ng
cp build/apt-cacher-ng /usr/local/sbin/
cp build/in.acng /usr/local/sbin



Integrate all missing file from the sources/conf directory to your /etc/apt-cacher-ng (dont overwrite acng.conf)


cp archlx_mirrors backends_debian.default backends_ubuntu.default cygwin_mirrors delconfirm.html epel_mirrors fedora_mirrors maint.html security.conf report.html sfnet_mirrors sl_mirrors style.css ubuntu_mirrors userinfo.html /etc/apt-cacher-ng


Test everything is working restarting the service:


/etc/init.d/apt-cacher-ng restart


Test the maintenance page to:

http://your_apt-cacher_server:3142/acng-report.html



CONFIGURE YUM FOR RETRIEVE PACKAGES FROM THE CACHER


sudo vim /etc/yum.conf
...
# ZMo: apt-cacher for yum
proxy=http://your_apt-cacher_server:3142
...

lunedì 28 novembre 2011

OpenERP 6 on Fedora 15

postgresql installation


[fedora@lovelock ~]$ sudo yum install postgresql-server postgresql-libs postgresql



Initialize postgresql db and start the daemon:


[fedora@lovelock ~]$ /etc/init.d/postgresql initdb
Initializing database:                                     [  OK  ]
[fedora@lovelock ~]$ /etc/init.d/postgresql start
Starting postgresql (via systemctl):                       [  OK  ]



postgresql user
Become postgres and create the db user:


[fedora@lovelock]$ su - postgres
-bash-4.2$ createuser openerp
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n



openerp user and environment
Create openerp system user and give a him a password:


[fedora@lovelock]$ sudo adduser --system openerp
[fedora@lovelock]$ sudo passwd openerp
Changing password for user openerp.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.



Create the OpenERP release directory:


[fedora@lovelock]$ su openerp -c mkdir /home/openerp/6



setup and test the server
Download the server tarball and unpack it:


[fedora@lovelock]$ su - openerp
[openerp@lovelock]$ cd 6
[openerp@lovelock]$ wget http://www.openerp.com/download/stable/source/openerp-server-6.0.0.tar.gz
[openerp@lovelock]$ tar xvf openerp-server-6.0.0.tar.gz


Install dependencies for the server:


[fedora@lovelock]$ sudo yum install python-lxml.i686 python-mako python-dateutil python-psycopg2 pychart pydot pytz python-vobject python-reportlab PyYAML python-imaging




NOTE: to generally test openerp releases, you don't need to perform a complete installation. Inside the /bin directory, in the untarred openerp archive, you can run "opnenerp-server.py". Running openerp-server.py will also notify you for every missing dependence.



[openerp@lovelock]$ cd openerp-server-6.0.0/bin
[openerp@lovelock]$ ./openerp-server.py"
...
[2011-11-18 17:07:43,573][?] INFO:server:OpenERP version - 6.0.0
[2011-11-18 17:07:43,574][?] INFO:server:addons_path - /home/openerp/6/openerp-server-6.0.0/bin/addons
[2011-11-18 17:07:43,575][?] INFO:server:database hostname - localhost
[2011-11-18 17:07:43,576][?] INFO:server:database port - 5432
[2011-11-18 17:07:43,577][?] INFO:server:database user - openerp
[2011-11-18 17:07:43,578][?] INFO:server:initialising distributed objects services
[2011-11-18 17:07:43,940][?] INFO:web-services:starting HTTP service at 0.0.0.0 port 8069
[2011-11-18 17:07:43,944][?] INFO:web-services:starting HTTPS service at 0.0.0.0 port 8071
[2011-11-18 17:07:43,946][?] INFO:web-services:Registered XML-RPC over HTTP
[2011-11-18 17:07:43,948][?] INFO:web-services:starting NET-RPC service at 0.0.0.0 port 8070
[2011-11-18 17:07:43,950][?] INFO:server:Starting 3 services
[2011-11-18 17:07:43,952][?] INFO:server:OpenERP server is running, waiting for connections...



..ctrl+c to exit the test.

install the server


[fedora@lovelock]$ su - root
[root@lovelock]# yum install python-setuptools
[root@lovelock]# cd /home/openerp/6/openerp-server-6.0.0
[root@lovelock]# python setup.py install
...
copying doc/migrate/3.4.0-4.0.0/post-tiny.py -> /usr/share/doc/openerp-server-6.0.0/migrate/3.4.0-4.0.0
running install_egg_info
Copying openerp_server.egg-info to /usr/lib/python2.7/site-packages/openerp_server-6.0.0-py2.7.egg-info
running install_scripts
copying build/scripts-2.7/openerp-server -> /usr/bin
changing mode of /usr/bin/openerp-server to 755
[root@lovelock]#



Copy the configuration file for the server:


[root@lovelock]# cp doc/openerp-server.conf /etc/openerp-server.cfg
[root@lovelock]# chown openerp.openerp /etc/openerp-server.cfg



setup and test the client
Install client dependencies:


[fedora@lovelock]$ sudo yum install python-lxml.i686 python-mako python-dateutil python-psycopg2 pychart pydot pytz python-vobject python-reportlab PyYAML python-imaging pygtk2 glade2 python-matplotlib python-dateutil pytz pydot hippo-canvas-python mx-devel python-imaging


Download openerp-client tarball and untar it:


[fedora@lovelock]$ su - openerp
[openerp@lovelock]$ cd 6
[openerp@lovelock]$ wget http://www.openerp.com/download/stable/source/openerp-client-6.0.0.tar.gz
[openerp@lovelock]$ tar xvf openerp-client-6.0.0.tar.gz



Test openerp-client:


[openerp@lovelock]$ cd openerp-client-6.0.0/bin
[openerp@lovelock]$ python openerp-client.py



install the client


[fedora@lovelock]$ su - root
[root@lovelock]# cd /home/openerp/6/openerp-client-6.0.0
[root@lovelock]# python setup.py install



setup and test openerp-web
OpenERP-web dependencies:


yum install python-cherrypy python-formencode python-babel



Download OpenERP-web tarball and unpack it:


[fedora@lovelock]$ su - openerp
[openerp@lovelock]$ cd 6
[openerp@lovelock]$ wget http://www.openerp.com/download/stable/source/openerp-web-6.0.0.tar.gz
[openerp@lovelock]$ tar xvf openerp-web-6.0.0.tar.gz



Run OpenERP-web:


[openerp@lovelock]$ cd openerp-web-6.0.0
[openerp@lovelock]$ python openerp-web.py
[21/Nov/2011:05:12:44] ENGINE Bus STARTING
[21/Nov/2011:05:12:44] ENGINE Started monitor thread '_TimeoutMonitor'.
[21/Nov/2011:05:12:44] ENGINE Started monitor thread 'Autoreloader'.
[21/Nov/2011:05:12:44] ENGINE Serving on 0.0.0.0:8080
[21/Nov/2011:05:12:44] ENGINE Bus STARTED



install openerp-web


[openerp@lovelock]$ su - root
[root@lovelock]# cd /home/openerp/6/openerp-web-6.0.0
[root@lovelock]# python setup.py install
...
Using /usr/lib/python2.7/site-packages
Finished processing dependencies for openerp-web==6.0.0



Put the openerp-web configuration file in /etc:


[root@lovelock]# cp doc/openerp-web.cfg /etc
[root@lovelock]# chown openerp.openerp /etc/openerp-web.cfg



Uncomment log section:


[root@lovelock]# vim /etc/openerp-web.cfg
change:
...
#log.access_file = "/var/log/openerp-web/access.log"
#log.error_file = "/var/log/openerp-web/error.log"
...
to:
...
log.access_file = "/var/log/openerp-web/access.log"
log.error_file = "/var/log/openerp-web/error.log"
...



Create openerp log files dir:


[root@lovelock]# mkdir /var/log/openerp-web
[root@lovelock]# chown openerp.openerp /var/log/openerp-web



init scripts
I've found these scripts on-line, optimized for CentOS Linux, so thanks to the author for avoid me to rewrite both from scratch. I've made few modifications there, and now they works on Fedora.

Put these files in /etc/init.d/ directory and give "x" permissions to the both.

Download (right mouse click and "Save link as..."):


openerp-server
openerp-web




[root@lovelock]# cd /etc/init.d/
[root@lovelock]# wget http://www.simoneroselli.eu/files/2011/11/openerp-server.txt
[root@lovelock]# wget http://www.simoneroselli.eu/files/2011/11/openerp-web.txt



[root@lovelock]# mv openerp-server.txt openerp-server
[root@lovelock]# mv openerp-web.txt openerp-web



[root@lovelock]# chmod +x openerp-*



Make pid directory for the daemons:


[root@lovelock]# mkdir /var/run/openerp
[root@lovelock]# chown openerp.openerp /var/run/openerp



Start the daemons


[root@lovelock]# /etc/init.d/openerp-server start
[root@lovelock]# /etc/init.d/openerp-web start