Sunday 23 June 2013

How to Create a shared Git Repository in Debian (ssh, git-daemon, gitweb)


Git is a distributed revision control system.

We are going to create a remote shared git repository and add the following functionality to it:

- Read and write access using ssh protocol.
- Anonymous read only access via git-daemon.
- Browse every git repository via web.
- Send an email notification when user pushes a commit.


This article shows how to set a Git repository in a Debian distro (Sid).


Create the repository in the remote machine


First we are going to configure the remote machine where the git repository will be installed.


Create a directory where we will place every git repository:
$ mkdir /gitrepo

Install git
$ sudo aptitude install git

Every user able to read and write to the git repository must pertain to gitgroup group.
$ sudo groupadd gitgroup
$ sudo chgrp -R gitgroup /gitrepo
$ sudo chmod g+w /gitrepo

Generic home for users pertaining to gitgroup group:
$ sudo mkdir /home/gitgroup
$ sudo chgrp -R gitgroup /home/gitgroup


We add our current user to gitgroup group.
$ sudo adduser my_user gitgroup
Changes will become effective after login in again.
$ groups
my_user sudo gitgroup


We create now a bare git repository
$ cd /gitrepo
$ git init --bare --shared=0664 my_git_project
Initialized empty shared Git repository in /gitrepo/bar/

NOTE:
0664: other user has read only permissions.
0660: other user has no permissions.

$ chgrp -R gitgroup my_git_project

--shared option sets directories, new files etc to the right permissions.


Now we have a bare repository where we could upload our commits or another preexisting repository.


Read and write access

Sunday 16 June 2013

How to call BTC-e API using LUA language


BTC-e.com is a web site where you can exchange virtual coins (like bitcoins, litecoins, etc), US dollars, euros and Russian rubles.

It provides a web interface for you to manually interact with.

Also if you are interested in building a bot to perform operations automatically, you could use their API.


In this article I am going to call the API from my Debian Sid system using Lua language.


Install Lua and dependencies


First I install lua 5.1 and luarocks to manage lua rocks.
$ sudo aptitude install lua5.1
$ sudo aptitude install luarocks

Once luarocks is already installed I install luasockets, and luasec. This will allow us to perform request using https protocol.
$ sudo luarocks install luasocket
$ sudo luarocks install luasec


INSTALL SHA2

http://code.google.com/p/sha2

Next we install sha2 rock to calculate hmac sha512 hashes.
$ sudo luarocks install sha2
$ cd /usr/local/lib/luarocks/rocks/sha2
$ sudo aptitude install lua-filesystem
$ sudo aptitude install lua5.1-md5-dev

Now we perform the tests:
$ lua test_sha2.lua
$ lua test_hmac.lua
They should pass OK.


INSTALL JSON