Thursday, June 27, 2013

Installing many openerp on same server with different codes

Hello friends

I have created a scrip u just need to u just need to copy paste it and change the permission to be executable and let the script run answer the question asked by script and
you can have a openerp on your system with different names like
 openerp-server,nick-server,navneet-server etc .

#!/bin/bash
#make sure server has all the latest versions
#& patches by doing an update
#
sudo apt-get update
sudo apt-get dist-upgrade
#
#Install SSH
#
sudo apt-get install openssh-server denyhosts
#
#Create User
#
echo "Enter The Openerp Username"
read user
sudo adduser --system --home=/opt/$user --group $user
#
#Make Sure that Postgresql is installed on the system
#
sudo apt-get -y install postgresql
#
#Creating the user same as for postgres
#
createuser --createdb --username postgres --no-createrole --no-superuser $user
#
#Install all the dependencies
#
sudo apt-get -y install python-dateutil python-docutils python-feedparser python-gdata \
python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid \
python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing \
python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject \
python-webdav python-werkzeug python-xlwt python-yaml python-zsi
#
#Downloading the Source
#
wget http://nightly.openerp.com/7.0/nightly/src/openerp-7.0-latest.tar.gz
cd /opt/$user
sudo tar xvf ~/openerp-7.0-latest.tar.gz
#changing the ownwrship of code so that it can be accessiable to the $user
#
sudo chown -R  $user: *
echo "owner ship is given"
sudo cp -a openerp-7.0* /opt/$user/server
rm -rf openerp*
echo "openerp is removed"
sudo cp /opt/$user/server/install/openerp-server.conf /etc/$user-server.conf
sudo chown $user: /etc/$user-server.conf
sudo chmod 640 /etc/$user-server.conf
echo "Enter the Port Number on which Openerp will start"
read port
echo "xmlrpc_port=$port" >>/etc/$user-server.conf
echo "init.d started"
cat<< 'EOT' > /etc/init.d/$user
#!/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
EOT
echo "conf file is genrated"
sudo chmod 755 /etc/init.d/$user
sudo chown root: /etc/init.d/$user
echo "permission are applied"
sed -i "s/openerp/$user/" /etc/init.d/$user
sed -i "s/peer/trust/" /etc/postgresql/9.1/main/pg_hba.conf
sed -i "s/md5/trust/" /etc/postgresql/9.1/main/pg_hba.conf
service postgresql restart
/etc/init.d/$user start
su postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt $user
echo "restart postgresql"
echo "open erp is started"


After the script ran completely add a user in postgresql with same name as you have mention in the script and you are ready to go.

Thanks..

No comments:

Post a Comment