Wednesday, December 19, 2012

Remote Installation Service in LINUX


Required Softwares:

DHCP server
NFS server
TFTP-HDA server

Command to install

1.) sudo apt-get install tftpd-hpa dhcp3-server nfs-kernel-server syslinux

sudo mkdir /srv
sudo mkdir /srv/tftpboot
then edit the tftp-hpa file

2.) sudo vi /etc/default/tftpd-hpa


and add the following lines in that

TFTP_USERNAME="tftp"

TFTP_DIRECTORY="/srv/tftpboot"

TFTP_ADDRESS="<IP.OF.YOUR.SERVER>:69"

TFTP_OPTIONS="--secure -l"


3.) Configure the /etc/dhcp3/dhcpd.conf file like so:

sudo vi /etc/dhcp3/dhcpd.conf

allow booting;
allow bootp;
group
{
    next-server IP.OF.YOUR.SERVER;
    filename     "/pxelinux.0";
    host laptop
    {
            hardware ethernet    mac:address:of:device;
            option host-name     "laptop";
    }
}


4.) Create the Ubuntu PXE Environment(s):

sudo mkdir -p /srv/tftpboot/pxelinux.cfg

sudo mkdir /srv/tftpboot/OS1

sudo mkdir /srv/tftpboot/OS2



5.) Loop mount the ISOs into place:

sudo mount -o loop /path/to/OS1.iso /srv/tftpboot/OS1

sudo mount -o loop /path/to/OS2.iso /srv/tftpboot/OS2


6.) Create a nice message screen that will be displayed upon PXE boot:

sudo vi /srv/tftpboot/message

:: Ubuntu PXE Environment ::
============================
OPTIONS:           DESCRIPTIONS:
OS1 (Default) == OS1  
OS2       == OS2  
----------------------------------------------------
Type the option, and hit enter:





7.) Create the default pxelinux config file:

sudo vi /srv/tftpboot/pxelinux.cfg/default

DISPLAY message
DEFAULT OS1
PROMPT 1
TIMEOUT 0
LABEL OS1
    kernel 11.04x86desktop/casper/vmlinuz
    append root=/dev/nfs boot=casper netboot=nfs nfsroot=IP.OF.YOUR.SERVER:/srv/tftpboot/11.04x86desktop initrd=11.04x86desktop/casper/initrd.lz --
LABEL OS2
    kernel 11.04x64desktop/casper/vmlinuz
    append root=/dev/nfs boot=casper netboot=nfs nfsroot=IP.OF.YOUR.SERVER:/srv/tftpboot/11.04x64desktop initrd=11.04x64desktop/casper/initrd.lz --

8.) Copy the pxelinux.0 file into place:

sudo cp /usr/lib/syslinux/pxelinux.0 /srv/tftpboot/


9.) Configure the NFS server like so:

sudo vi /etc/exports

/srv/tftpboot/OS1  *(ro,sync,no_root_squash,no_subtree_check)
/srv/tftpboot/OS2  *(ro,sync,no_root_squash,no_subtree_check)

10.) Start all the appropriate services:

sudo exportfs -va
sudo service tftpd-hpa start
sudo service dhcp3-server start
sudo service nfs-kernel-server start



11.) Go boot the laptop, and you should be presented with the "

:: Ubuntu PXE Environment ::" menu.
Enjoy!

Mass VirtualHosting with apache

MASS Virtual Hosting with Apache

Hosting multiple server without changing the Apache config



config put all the content in the /etc/apache2/httpd.conf
sample config for IP 172.16.1.200

<VirtualHost 172.16.1.200:80>
LimitInternalRecursion 100
AccessFileName .htaccess
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog /var/logs/access_log vcommon
VirtualDocumentRoot /var/www/vhosts/%0
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory /var/www/vhosts/%0>
#DirectoryIndex index.php index.html index.htm index.shtml
Options Indexes FollowSymLinks +Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<Directory /usr/lib/cgi-bin/>
AllowOverride None
# Options ExecCGI
Options +ExecCGI +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
</VirtualHost>

create a directory vhosts

sudo mkdir /var/www/vhosts

suppose you have to create a subdomain nrathi.xyz.com so create a directory by name nrathi.xyz.com

mkdir nrathi,xyz.com

and put the contents in the directory if required make host entry and create a directory /var/logs/
mkdir /var/logs
restart the apache to reload the new configuration

sudo service apache2 restart
or
sudo service httpd restart
make a entry in local if required in host file
in linux
/etc/hosts
in windows
c:/windows/system32/drivers/etc/hosts
add the entry like
<ipaddress of server> <hostname>
you are ready to go.

enter the url <hostname>  in browser

Sunday, December 16, 2012

Installing OpenERp on ubuntu

Installing OpenERP on ubuntu 10.04

Step 1. Build your server

I install just the bare minimum from the install routine
sudo apt-get install ssh
Now make sure you are running all the latest patches by doing an update:
sudo apt-get update
sudo apt-get upgrade
Now we’re ready to start the OpenERP install.

Step 2. Create the OpenERP user that will own and run the application

sudo adduser --system --home=/opt/openerp --group openerp
This is a “system” user. It is there to own and run the application, it isn’t supposed to be a person type user with a login etc. In Ubuntu, a system user gets a UID below 1000, has no shell (it’s actually /bin/false) and has logins disabled. Note that I’ve specified a “home” of /opt/openerp, this is where the OpenERP server code will reside and is created automatically by the command above. The location of the server code is your choice of course, but be aware that some of the instructions and configuration files below may need to be altered if you decide to install to a different location.
A question I was asked a few times in the previous how to for 6.0 was how to run the OpenERP server as the openerp system user from the command line if it has no shell. This can be done quite easily:
sudo su - openerp -s /bin/bash
This will su your current terminal login to the openerp user (the “-” between su and openerp is correct) and use the shell /bin/bash. When this command is run you will be in openerp’s home directory: /opt/openerp.
When you have done what you need you can leave the openerp user’s shell by typing exit.

Step 3. Install and configure the database server, PostgreSQL

sudo apt-get install postgresql
Then configure the OpenERP user on postgres:
First change to the postgres user so we have the necessary privileges to configure the database.
sudo su - postgres
Now create a new database user. This is so OpenERP has access rights to connect to PostgreSQL and to create and drop databases. Remember what your choice of password is here; you will need it later on:
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt openerp
Enter password for new role: ********
Enter it again: ********
Finally exit from the postgres user account:
exit

Step 4. Install the necessary Python libraries for the server

sudo apt-get install python-dateutil python-feedparser python-gdata \
python-ldap python-libxslt1 python-lxml python-mako python-openid python-psycopg2 \
python-pybabel python-pychart python-pydot python-pyparsing python-reportlab \
python-simplejson python-tz python-vatnumber python-vobject python-webdav \
python-werkzeug python-xlwt python-yaml python-zsi

From what I can tell, on Ubuntu 10.04 the package python-werkzeug is too old and this will cause the server to not start properly. If you are trying this on a later version of Ubuntu then you might be OK, but just in-case you can also do the following.
I found it necessary to install a more recent version of Werkzeug using Python’s own package management library PIP. The python pip tool can be installed like this:
sudo apt-get install python-pip
Then remove Ubuntu’s packaged version of werkzeug:
sudo apt-get remove python-werkzeug
Then install the up-to-date version of werkzeug:
sudo pip install werkzeug
With that done, all the dependencies for installing OpenERP 6.1 are now satisfied, including for the new integral web interface.

Step 5. Install the OpenERP server

I tend to use wget for this sort of thing and I download the files to my home directory.
Make sure you get the latest version of the application. At the time of writing this it’s 6.1-1; I got the download links from their download page.
wget http://nightly.openerp.com/6.1/releases/openerp-6.1-1.tar.gz
Now install the code where we need it: cd to the /opt/openerp/ directory and extract the tarball there.
cd /opt/openerp
sudo tar xvf ~/openerp-6.1-1.tar.gz
Next we need to change the ownership of all the the files to the OpenERP user and group.
sudo chown -R openerp: *
And finally, the way I have done this is to copy the server directory to something with a simpler name so that the configuration files and boot scripts don’t need constant editing (I called it, rather unimaginatively, server). I started out using a symlink solution, but I found that when it comes to upgrading, it seems to make more sense to me to just keep a copy of the files in place and then overwrite them with the new code. This way you keep any custom or user-installed modules and reports etc. all in the right place.
sudo cp -a openerp-6.1-1 server
As an example, should OpenERP 6.1-2 come out soon, I can extract the tarballs into /opt/openerp/ as above. I can do any testing I need, then repeat the copy command so that the modified files will overwrite as needed and any custom modules, report templates and such will be retained. Once satisfied the upgrade is stable, the older 6.1-1 directories can be removed if wanted.
That’s the OpenERP server software installed. The last steps to a working system is to set up the configuration file and associated boot script so OpenERP starts and stops automatically when the server itself stops and starts.

Step 6. Configuring the OpenERP application

The default configuration file for the server (in /opt/openerp/server/install/) is actually very minimal and will, with only one small change work fine so we’ll simply copy that file to where we need it and change it’s ownership and permissions:
sudo cp /opt/openerp/server/install/openerp-server.conf /etc/
sudo chown openerp: /etc/openerp-server.conf
sudo chmod 640 /etc/openerp-server.conf

The above commands make the file owned and writeable only by the openerp user and group and only readable by openerp and root.
To allow the OpenERP server to run initially, you should only need to change one line in this file. Toward to the top of the file change the line db_password = False to the same password you used back in step 3. Use your favourite text editor here. I tend to use nano, e.g.
sudo nano /etc/openerp-server.conf
One other line we might as well add to the configuration file now, is to tell OpenERP where to write its log file. To complement my suggested location below add the following line to the openerp-server.conf file:
logfile = /var/log/openerp/openerp-server.log
Once the configuration file is edited and saved, you can start the server just to check if it actually runs.
sudo su - openerp -s /bin/bash
/opt/openerp/server/openerp-server
If you end up with a few lines eventually saying OpenERP is running and waiting for connections then you are all set. Just type CTL+C to stop the server then exit to leave the openerp user’s shell.
If there are errors, you’ll need to go back and check where the problem is.

Step 7. Installing the boot script

For the final step we need to install a script which will be used to start-up and shut down the server automatically and also run the application as the correct user. There is a script you can use in /opt/openerp/server/install/openerp-server.init but this will need a few small modifications to work with the system installed the way I have described above.

vi /etc/init.d/openerp

#!/bin/sh

### BEGIN INIT INFO
# Provides:             openerp-server
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Should-Start:         $network
# Should-Stop:          $network
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Enterprise Resource Management software
# Description:          Open ERP is a complete ERP and CRM software.
### END INIT INFO

PATH=/bin:/sbin:/usr/bin
DAEMON=/opt/openerp/server/openerp-server
NAME=openerp-server
DESC=openerp-server

# Specify the user name (Default: openerp).
USER=openerp

# Specify an alternate config file (Default: /etc/openerp-server.conf).
CONFIGFILE="/etc/openerp-server.conf"

# pidfile
PIDFILE=/var/run/$NAME.pid

# Additional options that are passed to the Daemon.
DAEMON_OPTS="-c $CONFIGFILE"

[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0

checkpid() {
    [ -f $PIDFILE ] || return 1
    pid=`cat $PIDFILE`
    [ -d /proc/$pid ] && return 0
    return 1
}

case "${1}" in
        start)
                echo -n "Starting ${DESC}: "

                start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
                        --chuid ${USER} --background --make-pidfile \
                        --exec ${DAEMON} -- ${DAEMON_OPTS}

                echo "${NAME}."
                ;;

        stop)
                echo -n "Stopping ${DESC}: "

                start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
                        --oknodo

                echo "${NAME}."
                ;;

        restart|force-reload)
                echo -n "Restarting ${DESC}: "

                start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
                        --oknodo
      
                sleep 1

                start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
                        --chuid ${USER} --background --make-pidfile \
                        --exec ${DAEMON} -- ${DAEMON_OPTS}

                echo "${NAME}."
                ;;

        *)
                N=/etc/init.d/${NAME}
                echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2
                exit 1
                ;;
esac

exit 0




sudo chmod 755 /etc/init.d/openerp-server
sudo chown root: /etc/init.d/openerp-server
In the configuration file there’s an entry for the server’s log file. We need to create that directory first so that the server has somewhere to log to and also we must make it writeable by the openerp user:
sudo mkdir /var/log/openerp
sudo chown openerp:root /var/log/openerp

Step 8. Testing the server

To start the OpenERP server type:
sudo /etc/init.d/openerp-server start
You should now be able to view the logfile and see that the server has started.
less /var/log/openerp/openerp-server.log
If there are any problems starting the server you need to go back and check. There’s really no point ploughing on if the server doesn’t start…
OpenERP 6.1 Home Screen
OpenERP 6.1 Home Screen

If the log file looks OK, now point your web browser at the domain or IP address of your OpenERP server (or localhost if you are on the same machine) and use port 8069. The url will look something like this: http://IP_or_domain.com:8069
What you should see is a screen like this one:

Now it’s time to make sure the server stops properly too:
sudo /etc/init.d/openerp-server stop
Check the logfile again to make sure it has stopped and/or look at your server’s process list.

Step 9. Automating OpenERP startup and shutdown

If everything above seems to be working OK, the final step is make the script start and stop automatically with the Ubuntu Server. To do this type:
sudo update-rc.d openerp-server defaults

Thats it and we are ready to go

Open the browser  http://ipaddressofhost:8069