# Compiling the Telegram client "telegram-cli" in the jail

How to compile telegram-cli directly on the BQ. Make sure you have in the above constructed jail (see chap. 30) a working gcc:

```
# apt-get update
# apt-get install install gcc libc6-dev
```

Download the sources with 'git', and install its dependency. The required Python does not match the installed version:

```
# apt-get install git
# apt-get install libreadline-dev libconfig-dev libssl-dev                                  
# apt-get install lua5.2 liblua5.2-dev libevent-dev libjansson-dev make
$ git clone --recursive https://github.com/vysheng/tg.git
$ cd tg
$ ./configure  --disable-python
...
$ sudo mkdir /etc/telegram-cli
$ sudo cp server.pub /etc/telegram-cli
$ cp telegram-cli ..
```

```
$ ~/telegram-cli
Telegram-cli version 1.3.3, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
Telegram-cli uses libtgl version 2.0.3
Telegram-cli includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)
I: config dir=[/home/phablet/.telegram-cli]
> contact_list 
Emil Apitz
...
```

Now Emil sends a message from his mobile 'Got it?' which arrives in telegram-cli and I replied with 'ok'

```
[12:17]  Emil Apitz >>> Got it?
> msg Emil_Apitz ok
[12:18]  Emil Apitz <<< ok
User Emil Apitz marked read 1 outbox and 0 inbox messages
```

Note: The user Emit sent the message 'Got it?' and I received it with the Telegram client telegram-cli, and read it, but it stays in the device of Emil with only one single marker 'v'. This is what we wanted to have as PRIVACY.

And here is how to run this from outside the jail:

```
#!/bin/sh
# to run the telegram-cli which we have compiled in a jail below /home/phablet/myRoot
# from outside the jail
#
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/phablet/myRoot/usr/lib/arm-linux-gnueabihf
export LD_LIBRARY_PATH
eval ~/myRoot/home/phablet/telegram-cli -k ~/myRoot/etc/telegram-cli/server.pub
```

Last updated: Sat Oct 17 16:11:03 CEST 2015
