Sunday, 27 November 2011

Install ProFTP server for Galaxy


Its not wise to use user sudo apt-get install proftpd or proftpd-basic because there are no postgres modules in default package.but if you have GUI interface udo apt-get install gadmin-proftpd is important
chanaka@localhost:~# wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.4a.tar.gz
chanaka@localhost:~# tar xfvz proftpd-1.3.4a.tar.gz
chanaka@localhost:~/proftpd-1.3.4a#
chanaka@localhost:~/proftpd-1.3.4a# ./configure --disable-auth-file --disable-ncurses               \
        --disable-ident --disable-shadow --enable-openssl           \
        --with-modules=mod_sql:mod_sql_postgres:mod_sql_passwd
chanaka@localhost:~/proftpd-1.3.4a# make
chanaka@localhost:~/proftpd-1.3.4a# make install

Then create PostgreSQL user called galaxyftp with least privileges.
chanaka@localhost:~$  createuser -SDR galaxyftp
chanaka@localhost:~$ psql galaxy_prod
psql (8.4.9)
Type "help" for help.

galaxy_prod=# ALTER ROLE galaxyftp PASSWORD '[password]';
ALTER ROLE
galaxy_prod=# GRANT SELECT ON galaxy_user TO galaxyftp;
GRANT
galaxy_prod=# \q

Here is the final proftd.conf (/usr/local/proftpd/proftpd.conf)
# Basics, some site-specific
ServerName                      "myserver.org"
ServerType                      standalone
DefaultServer                   on
Port                            21
Umask                           077
SyslogFacility                  DAEMON
SyslogLevel                     debug
MaxInstances                    30
User                            nobody
Group                           nogroup
DisplayConnect                  /ftp/proftpd_welcome.txt
# Passive port range for the firewall
PassivePorts                    30000 40000
# Cause every FTP user to be "jailed" (chrooted) into their home directory
DefaultRoot                     ~
# Automatically create home directory if it doesn't exist
CreateHome                      on dirmode 700
# Allow users to overwrite their files
AllowOverwrite                  on
# Allow users to resume interrupted uploads
AllowStoreRestart               on
# Bar use of SITE CHMOD
<Limit SITE_CHMOD>
  DenyAll
</Limit>
# Bar use of RETR (download) since this is not a public file drop
<Limit RETR>
  DenyAll
</Limit>
# Do not authenticate against real (system) users
<IfModule mod_auth_pam.c>
AuthPAM                         off
</IfModule>
# Set up mod_sql_password - Galaxy passwords are stored as hex-encoded SHA1
SQLPasswordEngine               on
SQLPasswordEncoding             hex
# Set up mod_sql to authenticate against the Galaxy database
SQLEngine                       on
SQLBackend                      postgres
SQLConnectInfo                  galaxy_prod@myserver.org galaxyftp [password]
SQLAuthTypes                    SHA1
SQLAuthenticate                 users
# An empty directory in case chroot fails
SQLDefaultHomedir               /ftp/proftpd
# Define a custom query for lookup that returns a passwd-like entry.  UID and GID should match your Galaxy user.
SQLUserInfo                     custom:/LookupGalaxyUser
SQLNamedQuery                   LookupGalaxyUser SELECT "email,password,'512','512','/ftp/%U','/bin/bash' FROM galaxy_user WHERE email='%U'"

Note! Don't forget to configure  pg_hba.conf entry for host "XXXXX", Also check the firewall for ftp usually 21,We need to use galaxy user like 512. Done!

We can see the errors by using following
chanaka@localhost:~# cd /usr/local/sbin
chanaka@localhost:~/usr/local/sbin# ./proftpd -nd9
or check PostgreSQL or proftpd log files

If you get "Fatal: unknown configuration directive 'AuthPAM' " error use following solution.

<IfModule mod_auth_pam.c>
AuthPAM                         off
</IfModule>

Also following lines may useful to you:(/usr/local/sbin)
chanaka@localhost:~#ps aux | grep proftpd
chanaka@localhost:~#Kill [pid]
chanaka@localhost:~#Where is proftpd

To start
sudo /etc/init.d/proftpd start

Thursday, 6 October 2011

Add multiple columns to Advanced Data Grid

Since three days I was trying to add multiple columns to Flex ADG Finally end up with one line solution amazing!
here is the 72 hours work :)
//tl add the column number
ADG.validateNow();

thanks to http://riaflex.blogspot.com/2008/05/dynamic-advanceddatagrid-columns.html

Monday, 20 December 2010

Install Redmine on Ubuntu server

First Install the following packages.

sudo apt-get install build-essential ruby ruby1.8-dev libopenssl-ruby libmysql-ruby rubygems rake

Install rails.

sudo gem install rails -v=2.3.5

Then create symbolic link to rails.

sudo ln -s /var/lib/gems/1.8/bin/rails /usr/bin/rails

Go to www directory and checkout redmine from SVN.

cd /var/www
svn checkout http://redmine.rubyforge.org/svn/trunk redmine

Copy config file.

sudo cp redmine/config/database.yml.example redmine/config/database.yml

Change database configuration.

sudo nano redmine/config/database.yml
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: redmine's password
encoding: utf8

Optional to change email configuration.

sudo cp redmine/config/email.yml.example redmine/config/email.yml
sudo nano redmine/config/email.yml
production:
delivery_method: :sendmail

Then go to redmine directory and generate a session store secret.

cd redmine
RAILS_ENV=production rake config/initializers/session_store.rb

Create database structure.

RAILS_ENV=production rake db:migrate

Add default configuration data to database.

RAILS_ENV=production rake redmine:load_default_data

Now run Redmine for firs time temporally.

ruby script/server webrick -e production

Now we can access Redmine at http://localhost:3000
Use following commands to running redmine on apache and Enable mod proxy and rewrite.

sudo a2enmod proxy
sudo a2enmod rewrite

Restart apache and install mongrel.

sudo /etc/init.d/apache2 restart
sudo apt-get install mongrel

Create folder mongrel inside /var/log.

sudo mkdir /var/log/mongrel

When you are in redmine directory Start mongrel.

sudo mongrel_rails start -d -p 3000 -e production -P /var/log/mongrel/mongrel-1.pid -l /var/log/mongrel/mongrel.log

Access redmine at http://localhost:3000
Create apache’s virtual host.

sudo nano /etc/apache2/sites-available/redmine

Add following proxy configuration.

<virtualhost *:80>
ServerName http://localhost
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000
ProxyPreserveHost on
<proxy *>
Order allow,deny
Allow from all
</Proxy>
</VirtualHost>

Create symbolic link.

sudo ln -s /etc/apache2/sites-available/redmine /etc/apache2/sites-enabled/redmine

Restart apache.

sudo /etc/init.d/apache2 restart

Access redmine at http://localhost:3000
If you need to stop mongrel, run the following command inside redmine directory.

sudo mongrel_rails mongrel::stop -P /var/log/mongrel/mongrel-1.pid

Possible errors and solutions
To see the running rubby sessions

lsof|grep 3000

This will give you a line starting with.

ruby 6205 admin 4u IPv4

If you need destroy the session

kill -9 6205

If you see followwing error

** !!! PID file /var/log/mongrel/mongrel-1.pid already exists. Mongrel could be running already. Check your /var/log/mongrel/mongrel.log for errors.
** !!! Exiting with error. You must stop mongrel and clear the .pid before I'll attempt a start.

Use following command or destroy session using above step.

rm /var/log/mongrel/mongrel-1.pid
rm /var/log/mongrel/mongrel.log

Thank goes to Just Notes

Sunday, 21 November 2010

MySQL to PostgreSQL migration


According to common sense mysql to postgre migration should be work with dump mysql script to file (A) and import script(A) to postgre but its not that simple because mysql and postgre has different syntax.so we need to change syntax before import sql file to postgre.There are perl scripts which will help us to change mysql dump file to postgre dump file we can use that wrapper file to change syntax bulk operation.

perl mysql2perl.perl mysqldump.sql(A) postgredump.sql(B)
now we can import compatible postgre script to postgre databse.

therefor abstract of above operations as follows,
Psuedo,

mysqldump --compatible=postgresql -u username -ppassword databse> mysqldump.sql(A);
perl mysql2pg.perl mysqldump.sql(A) postgredump.sql(B);
psql -h localhost -d postgredatabse -U postgres -W < postgredump.sql(B);

here you can find the mysql2pg.perl script,

Backups
Postgres backup

pg_dump -h localhost - drupaldb -U postgres > /file path/file.sql


Saturday, 23 October 2010

What is Organic User Interfaces (OUI)?


Organic User Interfaces: In the future of computing flourishing with thousands of shapes of computing devices that will be as scalable, flexible, and transformable as organic life itself.Organic User Interfaces we can see following characteristics.


1.) Input Equals Output -->In other words output display will become Input.currently we use joystick,keyboard or mouse in order interact with display devices.But in near future those input devices are not sufficient.Therefore OUI use same output as its input device.




2.) Function Equals Forms-->Where the display can take any shape alternatively,Physical shape will results what can do with it.Physical shape goes with its function in other words form of the display equals its function.




3.) Forms Follow Flow-->Where the display can change their shape.Shape can be dynamically change according to situation and activity.e.g. the ubiquitous 'clamshell' phone, where incoming calls alter the phone's function when opening the phone during an incoming call.





sources Wikipedia and organicui

Tuesday, 12 October 2010

How to install Gitosis


Firstly, grab the source from the git web repository.
$ cd /usr/local/src
$ git clone git://eagain.net/gitosis.git
Initialized empty Git repository in /usr/local/src/gitosis/.git/
remote: Counting objects: 603, done.
remote: Compressing objects: 100% (172/172), done.
remote: Total 603 (delta 425), reused 597 (delta 422) Receiving objects: 100% (603/603), 92.87 KiB | 23 KiB/s, done. Resolving deltas: 100% (425/425), done.
Once downloaded, we can run the installation.
$ cd gitosis
$ python setup.py install
Then we need to create user
sudo adduser \
    --system \
    --shell /bin/sh \
    --gecos 'git version control' \
    --group \
    --disabled-password \
    --home /home/git \
    git
$ sudo -s
root $ su -git
$ ssh-keygen -t rsa
Generating public/private rsa key pair. Enter file in which to save the key (/home/git/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/git/.ssh/id_rsa. Your public key has been saved in /home/git/.ssh/id_rsa.pub. The key fingerprint is: 59:a8:a8:0a:f7:b5:0e:eb:74:c4:66:cb:ac:03:84:da git@localhost The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|         .       |
| .      . .      |
|. .  o . o       |
|.o  . * S        |
|. E. * .         |
|. o.o *          |
|.o o.* .         |
|.  .=oo          |
+-----------------+
git$ ls -al .ssh
total 16
drwx------ 2 git git 4096 2009-02-11 14:52 .
drwx------ 5 git git 4096 2009-02-11 14:52 ..
-rw------- 1 git git 1743 2009-02-11 14:52 id_rsa
-rw-r--r-- 1 git git  393 2009-02-11 14:52 id_rsa.pub
Now we initialize keys to git repository
git$ gitosis-init < .ssh/id_rsa.pub
Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/ Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/
Just look at the file permissions it is important the git user has privileges to access data.
git$ ls -al
Same way look at the repositories.
git$ ls -al repositories/
total 12
drwxr-xr-x 3 git git 4096 2009-02-11 14:57 .
drwx------ 7 git git 4096 2009-02-11 14:57 ..
drwxr-x--- 8 git git 4096 2009-02-11 14:57 gitosis-admin.git
Now we are going to clone gitosis-admin.git.
git$ git clone git@localhost:gitosis-admin.git
Initialized empty Git repository in /home/git/gitosis-admin/.git/ Enter passphrase for key '/home/git/.ssh/id_rsa':
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 5 (delta 0) Receiving objects: 100% (5/5), done.
Creating New Repositories
Lets allow group persmissions.
git$ ls -al repositories/gitosis-admin.git/hooks/post-update-rw-r--r-- 1 git git 69 2009-02-11 14:57 repositories/gitosis-admin.git/hooks/post-updategit$ chmod 755 repositories/gitosis-admin.git/hooks/post-update
git$ ls -al repositories/gitosis-admin.git/hooks/post-update 
-rwxr-xr-x 1 git git 69 2009-02-11 14:57 repositories/gitosis-admin.git/hooks/post-update
Now, Lets take a look at the gitosis-admin source code we checked out .
git$ ls -al gitosis-admin
total 20
drwxr-xr-x 4 git git 4096 2009-02-11 15:38 .
drwx------ 8 git git 4096 2009-02-11 15:49 ..
drwxrwxr-x 8 git git 4096 2009-02-11 15:38 .git
-rw-rw-r-- 1 git git   81 2009-02-11 15:38 gitosis.conf
drwxrwxr-x 2 git git 4096 2009-02-11 15:38 keydir
We can configure gitosis.conf.
git$ cd gitosis-admin
git$ vi gitosis.conf
  1 [gitosis]
  2
  3 [group gitosis-admin]
  4 writable = gitosis-admin
  5 members = git@localhost
  6
  7 [group my-staff]
  8 writable = my-first-repo
  9 members = git@localhost

git$ git commit -a -m "Allow my staff access to my-first-repo"
[master]: created 0c6a685: "Allow my staff access to my-first-repo"
1 files changed, 3 insertions(+), 0 deletions(-)

git$ git push
Enter passphrase for key '/home/git/.ssh/id_rsa':
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 381 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@localhost:gitosis-admin.git
   7b3ddbe..0c6a685  master -&gt; master

git$ cd
Then we are going to create our first repository.
git$ mkdir my-first-repo
git$ cd my-first-repo
git$ git init
Initialized empty Git repository in /home/git/my-first-repo/.git/
git$ git remote add origin git@localhost:my-first-repo.git
git$ echo "Hello" &gt; README.txt
git$ git add README.txt
git$ git commit -a -m "Initial Revision"
[master (root-commit)]: created 6f567f9: "Initial Revision"
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 README.txt
git$ git push origin master:refs/heads/master
Enter passphrase for key '/home/git/.ssh/id_rsa':
Counting objects: 3, done.
Writing objects: 100% (3/3), 220 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@localhost:my-first-repo.git
* [new branch]      master -&gt; master
git$ cd ..
Now we have new repository,finally we can add new users.
git$ cd gitosis-admin
git$ cp ~/alice.pub keydir
git$ cp ~/bob.pub keydir
git$ git add keydir
git$ vi gitosis.conf
  1 [gitosis]
  2
  3 [group gitosis-admin]
  4 writable = gitosis-admin
  5 members = git@localhost
  6
  7 [group my-staff]
  8 writable = my-first-repo
  9 members = alice bob
git$ git commit -a -m "alice/bob writable to my-first-repo"
[master]: created 17b3295: "alice/bob writable to my-first-repo"
1 files changed, 1 insertions(+), 1 deletions(-)
create mode 100644 keydir/alice.pub
create mode 100644 keydir/bob.pub
git$ git push
Enter passphrase for key '/home/git/.ssh/id_rsa':
Counting objects: 8, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 430 bytes, done.
Total 5 (delta 1), reused 0 (delta 0)
To git@magneto:gitosis-admin.git
   305600f..17b3295  master -&gt; master
now users can access our central repository.
alice$ git clone git@SERVER_HOSTNAME:my-first-repo.git

Monday, 4 October 2010

Install GIT

How to install Git

sudo apt-get install git-core
add user name and email

 git config --global user.name "name"
 git config --global user.email "email id"

go to the project folder and

cd project folder
we can see our config file by typing this

cat /project folder/.config/
we can enable command colors by using

git config --global color.ui true
we go to folder  and  initialize the project repository.

git init
git commit
git commit  -m ' comment'
git add  

now we can use following commands

git diff --cached
git log  


finally update the server info

sudo -u git update-server-info
now we have access to repository .we can use commit pull push command
For instance http://localhost/efp/.git/


I found some useful resources
http://git.or.cz/course/svn.html
http://sysmonblog.co.uk/misc/git_by_example/
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html