Cheap Time Capsule alternative using Ubuntu 12.10

Why spent $260 for Time Capsule, when You can make Your Ubuntu to act exactly the same? Here is how to do this.

First we’re gonna install couple of things that we need for further setup:

sudo apt-get install avahi-daemon libavahi-client-dev libdb5.3-dev \
db-util db5.3-util libgcrypt11 libgcrypt11-dev

Then download the latest version of Netatalk – Open Source AFP fileserver. We’ll use netatalk 3.* because its much easier to setup as Time Capsule. Because the latest version in repositories is 2.2.* we’ll have to compile it by ourselves.

tar xvjf netatalk-3.*.tar.bz2
cd netatalk-3.*
./configure --with-init-style=debian --with-zeroconf
sudo make install

When everything is installed it’s time to do some configuration. First we’ll create a dir when we we’ll store all time machine backups.

sudo mkdir /media/Time-Machine/

Then we’ll add new user called timemachine, who will own this directory

sudo adduser timemachine
# here comes some data that You'll have to fill up
sudo chown -R timemachine. /media/Time-Machine

Now we’re ready to edit /usr/local/etc/afp.conf

; Netatalk 3.x configuration file

; Global server settings

uam list =,,,

; [Homes]
; basedir regex = /xxxx

; [My AFP Volume]
; path = /path/to/volume

[Time Machine MediaPC]

path = /media/Time-Machine
time machine = yes

Then it’s time to configure avahi-daemon which will propagate our Time Capsule over the local network.
Let’s create /etc/avahi/services/afpd.service

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <name replace-wildcards="yes">TimeCapsule %h</name>

So let’s start everything

sudo service netatalk start
sudo service avahi-daemon start

# to ensure that netatalk will start on boot
sudo update-rc.d netatalk defaults

Now You can enjoy your fresh Time Capsule alternative for the cost of HDD :)

This guide should also work for Raspberry Pi, XBMCbuntu, Debian 6.

Git – submodules

We’re developing project which has 3 different apps with its own repositories. So we have repos of main app, node server, admin app. All of these we want to deploy to production server, so our project repo will have deployment scripts, puppet manifests and these 3 repos included. We achieve these goal by using git’s submodules:

// repo central server - RCS
mkdir project.git
cd project.git
git --bare init

// on deployment machine
git clone RCS:project.git
cd project
git submodule add RCS:main_app.git main_app
git submodule add RCS:node_server.git node_server
git submodule add RCS:admin_app.git admin_app
git commit -am 'Initial project commit'
git push origin master

Now You can create deployment scripts and also include them in project repository.

To clone this repository on another machine we use command:

git clone --recursive RCS:project.git

To pull changes from all submodules just type:

git submodule foreach git pull

Git – setting up a remote repository and doing an initial “push”

There is a great deal of documentation and many posts on Git out there, so this is more of a note for myself as I keep forgetting the steps needed to set up a remote repository and doing an initial “push”.

So, firstly setup the remote repository:

mkdir my_project.git
cd my_project.git
git init --bare
git-update-server-info # If planning to serve via HTTP

On local machine:

cd my_project
git init
git add *
git commit -m "My initial commit message"
git remote add origin
git push -u origin master


Team members can now clone and track the remote repository using the following:

git clone
cd my_project


To have your terminal prompt display what branch you are currently on in green, add the following to your ~/.bash_profile:

function parse_git_branch_and_add_brackets {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
PS1="\h:\W \u\[33[0;32m\]\$(parse_git_branch_and_add_brackets) \[33[0m\]\$ "

If You made a mistake and want to edit remote origin address just vim .git/config and You are all done.


Centos 6 – Adding EPEL repository

rpm --import RPM-GPG-KEY-EPEL-6

Now create /etc/yum.repos.d/EPEL.repo and paste:

name=EPEL RPM Repository for Red Hat Enterprise Linux

Now when You want to use repository You just do it like this:

yum --enablerepo=epel install [pakage]

MySQL high CPU usage

Recently my servers CPU gone wild. After running a top command MySQL was using up to 80% of CPU while mytop was showing no connections.

It turned out that the problem was ntp service and a leap second which was added to UTC time to compensate for the slowing rotation of the Earth.

The same problem I had with ruby on local development server.


service ntpd stop
date -s "`date`"
service ntpd start

OS X: SSH tunnel in OS X Lion

Best and easiest way to secure your internet connection in untrusted network (like free Wi-Fi hotpot)?
SSH Tunnel :)

You’ll just need a shell account on a server and You’re ready to go. Fire up Terminal:

ssh -D 8080 -f -C -q -N

-D 8080 : This basically does a lot of dynamic stuff and makes it behave as a SOCKS server. Of course you could use any non privileged port here (above 1023).
-f : This will fork the process into the background after you type your password.
-C : Turns on compression.
-q : Quiet mode. Since this is just a tunnel we can make it quiet.
-N : Tells it no commands will be sent. (the -f will complain if we don’t specify this).

Then open System Preferences -> Network.

Select active network connection, click Advanced... -> Proxies -> SOCKS Proxy.

In SOCKS Proxy Server enter localhost:8080 and You’re DONE! :)

Now You can check if Your IP Address changed in