Pages

Wednesday, 4 October 2017

ODBC Setup on Ubuntu for PostgreSQL

ODBC Setup on Ubuntu for PostgreSQL

#Install the basic config tools for the UNIX ODBC:
sudo apt-get install unixodbc-bin unixodbc

#ODBC drivers for PostgreSQL:
sudo apt-get install odbc-postgresql

#Apply the template file provided to setup driver entries:
sudo odbcinst -i -d -f /usr/share/psqlodbc/odbcinst.ini.template

#Setup the a sample DSN
sudo odbcinst -i -s -l  -n adyoung-pg -f /usr/share/doc/odbc-postgresql/examples/odbc.ini.template

#Now modify /etc/odbc.ini according to your DB:
[test]                                                                                                                                                       Description = PostgreSQL                                                                                                                         Driver      = PostgreSQL ANSI                                                                                                                 Trace       = No                                                                                                                                           TraceFile   = /tmp/psqlodbc.log                                                                                                                 Database    = Databasename                                                                                                                       Servername  = localhost                                                                                                                             UserName    = ubuntu                                                                                                                               Password    = ubuntu                                                                                                                                 Port        = 5432                                                                                                                                         ReadOnly         = Yes                                                                                                                                 RowVersioning    = No                                                                                                                               ShowSystemTables = No                                                                                                                           ShowOidColumn    = No                                                                                                                           FakeOidIndex     = No                                                                                                                               ConnSettings     =      


#Now modify /etc/odbcinst.ini:
[PostgreSQL ANSI]
Description=PostgreSQL ODBC driver (ANSI version)
Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
Debug=0
CommLog=1
UsageCount=1

[PostgreSQL Unicode]
Description=PostgreSQL ODBC driver (Unicode version)
Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
Debug=0
CommLog=1
UsageCount=1

#Check Connection
isql -v test


Reference:
http://digitalitility.com/tutori-alitility/postgresql/odbc-setup-on-ubuntu-for-postgresql/
https://support.zegami.com/tutorials/odbc/index.html

Install Odoo 9.0 in Ubuntu 16.04


#Install Odoo in Ubuntu 16.04

#Update Packages
sudo apt-get update

#Install Postgresql
sudo apt-get install postgresql postgresql-contrib

#Install PGAdmin3
sudo apt-get install pgadmin3

#Start Postgres
sudo su postgres

#Create user in postgres
createuser -s $USER

#Type exit after creating Postgres User
exit

#Install python requirements by following commands.
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 python-decorator python-unittest2 python-psutil python-requests python-jinja2 python-docutils python-pypdf python-passlib python-xlsxwriter python-suds

#Install NodeJS and npm
sudo apt-get install -y nodejs
sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs /usr/bin/node

sudo npm install -g less
sudo npm install -g less less-plugin-clean-css

#Download openERP/odoo for Linux platform from the below site.
https://www.odoo.com/page/download

#or download for git
https://github.com/odoo/odoo/releases

#Create configuration file for openerp server:
#Create “openerp-server.conf” file and copy and paste below content.
[options]
; This is the password that allows database operations:
admin_passwd = password for admin
db_host = localhost
db_port = 5432
db_user = ubuntu
db_password = password for postgres database user
addons_path = /opt/odoo/odoo/openerp/addons (It may change according to your downloaded bundle)
logfile = /var/log/openerp/openerp-server.log

#Provide password in the admin_passwd. Here, db_user = ubuntu and db_password = ***** are for the user created in postgres for ubuntu user.
#Copy “openerp-server.conf” file to “/etc” folder, and change odoo server’s folder ownership and permissions by executing below commands.
useradd -d /opt/odoo/odoo -s /bin/bash ubuntu
chown ubuntu: -R /opt/odoo/odoo
chown ubuntu: /etc/openerp-server.conf
chmod 640 /etc/openerp-server.conf

#Install the boot script
#Create an “openerp-server” file with the following content and copy-paste this file in “/etc/init.d/” folder
#!/bin/sh
### BEGIN INIT INFO
# Provides: odoo-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: Business Applications
# Description: ODOO Business Applications.
### END INIT INFO
PATH=/bin:/sbin:/usr/bin
DAEMON=/opt/odoo/odoo/openerp-server (It may change according to your downloaded bundle)
NAME=openerp-server
DESC=openerp-server


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


# Specify an alternate config file (Default: /etc/odoo-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

#Make this file executable using the following commands :
chmod 755 /etc/init.d/openerp-server
chown ubuntu: /etc/init.d/openerp-server

#Create a log file for the odoo server and make this file executable using the following commands.
mkdir /var/log/openerp
chown ubuntu: /var/log/openerp
touch /var/log/openerp/openerp-server.log
chmod 777 /var/log/openerp/openerp-server.log

#Start the server
/etc/init.d/openerp-server start

#To view logs of the server execute below command.
tail -f /var/log/openerp/openerp-server.log

#Now you can access the odoo server by hitting the “localhost:8069” in web browser.

#Once the server started successfully then make this server start and stop automatically using below command.
sudo update-rc.d openerp-server defaults


#Reference:
http://www.surekhatech.com/blog/running-odoo-8-0-as-a-servi-2


#for sublime
#sudo add-apt-repository ppa:webupd8team/sublime-text-3
#sudo apt-get update
#sudo apt-get install sublime-text-installer