Wednesday, 5 November 2014

Installing GitLab on 32-bit CentOS - Redis Permission Denied Issue

Installing GitLab on 64-bit Linux should be trivial, given that the deb/rpm packages are ready for 64-bit architecture. However, if you want to install it on a 32-bit Linux, there are quite a lot of issues you need to figure out manually.
I had the same issue and found this web site very useful. I was trying to install GitLab on a 32-bit CentOS (following this recipe). Every thing went fine, but when I was trying to access GitLab from browser, I was seeing a 500 server internal error. Checking the log files, I realised that the problem is with Redis component. The error message was:
Errno::EACCES (Permission denied - connect(2) for /var/run/redis/redis.sock)
Have seen some posts saying that updating redis should solve the problem, but that is also painful (given that I was using quite old version of a 32-bit CentOS). The simple solution is to edit the config file of redis (if you follow the above tutorial it will be /etc/redis.conf) and add this line to the end:
unixsocketperm 777

(My redis version was 2.4.10-1.el6)

Then enjoy your GitLab installation!

P.S. I also encountered a post installation problem, when cloning or pushing from/to server, an error message was appeared:
Check GitLab API access: /home/git/gitlab-shell/lib/gitlab_net.rb:122:in `read': No such file or directory @ rb_sysopen - /home/git/gitlab-shell/.gitlab_shell_secret (Errno::ENOENT)
Also the same error appears when you run gitlab-shell's check script (/home/git/gitlab-shell/bin/check). The silly solution is to create the required file in the shown path (ensure to set permissions and owenership of the file the git user).

Saturday, 18 October 2014

How to enable authentication in MongoDB?

I've been asked this question several times, it is simple indeed, but apparently it is causing some problems!
Here are some simple steps:
First fire mongo shell and create the user account

use admin
db.addUser('admin', '12345')
Then shutdown the server and exit:
Then you need to start the service with --auth parameter or add auth = true entry to the config file (e.g. in /etc/mongodb.conf). You're done! To see how this works, you can lunch MongoDB shell in two way:

mongo localhost:27017/admin -u admin-p 123456

Notice the admin (which is the db name).
Alternatively you can run the shell and then authenticate there:

use admin

Also in your code, you can specify the username and password e.g. this way in your Python code:

conn = pymongo.MongoClient("mongodb://username:password@localhost:27017")

Wednesday, 20 August 2014

A very brief comparison of few Python tools for working with Excel files

As a part of a small Python script, it was required to export some data to Excel spreadsheet. I had a quick search to see what are the options and found these two packages:

  • xlutils (xlrd for reading and xlwt for writing): it was simple and straightforward to use it, but I encountered a couple of issues with it: if your output has more than 256 columns, then you're partially in trouble! This is a limitation of older Excel formats (xls), Excel 2003 and greater (with xlsx format), does not have that problem. But this package is not very happy with xlxs, e.g. it does not support keeping the format of xlxs files. So I'd recommend to try the next package.
  • openpyxl is more compatible with xlxs and does not have separate reader/writer classes and is simpler than xlutils to use. Keeping formatting and other issues with xlxs files are better supported here and ended up using this package.
As the title says, this is a very brief and most probably not too much accurate comparison of the two packages, but just wanted to share this short experience!

Saturday, 2 August 2014

Using OpenSSL in Windows and PowerShell

OpenSSL has no official binary distribution for Windows, however there is a semi-official version from Shining Light Productions (a compiled + installer version of the official OpenSSL which is free to download and use). It can be downloaded from this page. The very simple problem of using that binaries is that it can't find the config file (it tried to load it from /usr/local/ssl/openssl.cnf and fails with this message WARNING: can't open config file: /usr/local/ssl/openssl.cnf)
If you're using Windows' default shell (Command Prompt), then you can specify the config file manually by running this command: Alternatively if you're on PowerShell, run this command to add the correct path of the config file to the environment variable name OPENSSL_CONF:
No need to mention that you need to specify the correct path to the openssl.cfg file according to the installation path of OpenSSL.
An alternative solution is to edit the source code manually and change the default path of the config file and then compile it and so forth.

Wednesday, 28 May 2014

Disable automatic printer adding in Ubuntu

In Ubuntu there is a service which scans the network for printers and adds them automatically. If your computer is in a large network and you really do not use most of the network printers, but just a few of them, then this feature really becomes annoying. To disable this feature, the easiest way is to prevent the service from running automatically.
So first stop the service:
Then edit/add the new configuration file for the service:

Then put 'manual' in the new config file (the config file should have only a single line with single word: 'manual' - of course without quotes) and start the service again:

Saturday, 10 May 2014

How to mount a remote file system through an intermediate machine?

Suppose that you've a remote machine from which you want to mount a file system on your local machine. However, your local machine can not connect directly to the remote machine. If you could connect directly, then you could have used sshfs to mount the file system without any problem.
In the current situation all you need to do is to create a tunnel to a third machine which will act as the middle-man. The tunnel is created with ssh command, as shown below. Before that, for further clarification on this scenario, the machines which are involved are: localpoint (which is your current local machine), endpoint (which is you machine of interest that you want to mount a file system from it) and middlepoint (which is the machine in between that have access to both machines).
First you need to create the tunnel:

ssh -f username@middlepoint -L 111:endpoint:22 -N

which basically tells to forward the local port 111 to port 22 of endpoint machine. You can use any port on your local machine as far as it is available for use.
Then mounting is performed through the tunnel:

sshfs -p 111 username@ /local_path

That's it! You've now mounted endpoint:/remote_path on your local machine localpoint:/local_path via middlepoint.

Mac users may have some issues when actually trying to access the mounted file system, most probably 'Permission Denied' problems. That could happen when Mac tries to infer the permission. To resolve this issues, when mounting the fs, ensure to pass -defer_permissions as a parameter to sshfs. Also it would be beneficial to add noappledouble option as well to tell the Mac not to write the .DS_Store files on the remote file system. In short, the final call to sshfs would be something like:

sshfs -p 111 -defer_permissions,noappledouble username@ /local_path

Further note for Mac users: it is assumed that FUSE for OS X is being used.