Monday, December 28, 2009

Django and Oracle support

To get work Django and Oracle client in Ubuntu:

Download cx_Oracle (choose for your system), Oracle InstantClient and Sql*Plus (in this page you can choose your OS and download the packages (in my case are oracle-instantclient11.2-basic-11.2.0.0.2-1.x86_64.rpm and oracle-instantclient11.2-sqlplus-11.2.0.0.2-1.x86_64.rpm).

Move the files into one directory for simplicity and run

alien -k *.rpm
dpkg -i *.deb
to convert all the downloaded packages to ubuntu deb-format and install them.

Then make symlink to lib, otherwise module won't be found by Django

cd /usr/lib/python2.6
ln -s site-packages/cx_Oracle.so

To avoid

Traceback (most recent call last):
  File "", line 1, in 
ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory
add to ~/.bashrc (or /etc/bash.bashrc to system-wide apply)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/11.2/client64/lib

If you see the message
Traceback (most recent call last):
  File "", line 1, in 
ImportError: libaio.so.1: cannot open shared object file: No such file or directory
run
sudo apt-get install -y libaio1

P.S. If you choose more modern (or older) version of Oracle IntstantClient you have to create symlinks for necessary version, e.g. you see the following error:

Traceback (most recent call last):
  File "", line 1, in 
ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory
but in /usr/lib/oracle/11.2/client64/lib directory exists libclntsh.so.11.1. Just make it symbolic link with
ln -s libclntsh.so.11.1 libclntsh.so.10.1

Install RPM in Ubuntu

To install Rpm-package in Ubuntu Linux (to run commands needs to be a superuser or using sudo):
  1. install alien package:
    sudo apt-get install alien
  2. Convert Rpm to Deb (in current directory)
    alient -k <package-file>.rpm
  3. Install the new Deb package
    dpkg -i <package-file>.deb

Problems with VPN-connections in Ubuntu Karmic

I need to connect to Cisco VPN. I had got a file with connection settings. Through NetworkManager I created new VPN connection by import the settings file. Trying to connect - no result. In /var/log/syslog I found the line:
NetworkManager: nm-vpn-connection.c.828: NeedSecrets failed: dbus-glib-error-quark Rejected se
nd message, 1 matched rules; type="method_call", sender=":1.5" (uid=0 pid=969 comm="NetworkManager) interface="org.freedeskt
op.NetworkManager.VPN.Plugin" member="NeedSecrets" error name="(unset)" requested_reply=0 destination="org.freedesktop.Netwo
rkManager.vpnc" (uid=0 pid=7971 comm="/usr/lib/network-manager-vpnc/nm-vpnc-service))
Some googling gives me a bit of information - Keyring manager denied connection of the VPN service. And how to grand access I didn't know. Googling more brings me the answer:
In /etc/dbus-1/system.d/nm-vpnc-service.conf
--- nm-vpnc-service.conf.fixed 2009-04-18 17:56:45.000000000 -0500
+++ nm-vpnc-service.conf 2009-04-18 17:57:37.000000000 -0500
@@ -6,6 +6,10 @@
   <allow own="org.freedesktop.NetworkManager.vpnc"/>
   <allow send_destination="org.freedesktop.NetworkManager.vpnc"/>
  </policy>
+ <policy user="at_console">
+  <allow own="org.freedesktop.NetworkManager.vpnc"/>
+  <allow send_destination="org.freedesktop.NetworkManager.vpnc"/>
+ </policy>
  <policy context="default">
   <deny own="org.freedesktop.NetworkManager.vpnc"/>
   <deny send_destination="org.freedesktop.NetworkManager.vpnc"/>

Thursday, December 24, 2009

Ubuntu's Archive Manager and RAR-archives support

To add support of RAR-archives for Ubuntu's Archive Manager run
sudo apt-get install unrar

Wednesday, December 16, 2009

Disabled Mercurial's strip command

Mercurial command hg strip is disabled by default in Ubuntu. To enable it add to hgrc file (in .hg directory of repository or /etc/mercurial/hgrc) these lines
[extensions]
hgext.mq =

Wednesday, December 9, 2009

Reinstall Ubuntu automatically

There is a very simple command that reinstalls all the distribution packages and reconfigures them automatically. This is particularly helpful when you have done a partial upgrade and eventually have broken the system dependencies tree.
sudo dpkg-reconfigure -phigh -a
since this command would take a lot of time to process (~1 hour) depending on your hardware in case you have a minor dependency problem you can fix it via
sudo apt-get install -f
Source.

Tuesday, December 8, 2009

Create a MySQL database for new user

To create a database and a user, to grant some privileges:

CREATE DATABASE test_db DEFAULT CHARACTER SET UTF8;
CREATE USER 'user'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON test_db.* TO 'user'@'%';

Mercurial server in haste

Just now I need to pull to spontaneous remote Mercurial repository. I ran hg serve and have tried to push. The server rejects my connection, because it demands secure connection. Attempts to change protocol to HTTPS were failed.
As decision I found the following: in hgrc (or mercurial.ini in Windows) add
[web]
allow_push = *
push_ssl = false

Profit :)