linux:telegram
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:telegram [2015/06/16 21:41] – rlunaro | linux:telegram [2022/12/02 21:02] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 21: | Line 21: | ||
| $ sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev | $ sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev | ||
| $ sudo apt-get install libevent-1.4-2 libevent1-dev | $ sudo apt-get install libevent-1.4-2 libevent1-dev | ||
| + | $ sudo apt-get install libpython3.4 libpython3.4-dev | ||
| + | $ sudo apt-get install libjansson4 libjansson-dev | ||
| </ | </ | ||
| Line 35: | Line 37: | ||
| Afterwards you can move the project to the destination machine. | Afterwards you can move the project to the destination machine. | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | Up to date (01/ | ||
| + | which works correctly. | ||
| + | </ | ||
| + | |||
| + | ===== Step 3: configure and build the project ===== | ||
| + | |||
| + | Nothing special here. Go to the directory where you have downloaded the project and: | ||
| + | |||
| + | < | ||
| + | $ ./configure | ||
| + | $ make | ||
| + | </ | ||
| + | |||
| + | ===== Step 4: a basic test ===== | ||
| + | |||
| + | Make a simple confirmation that the program is working. You can skip this test because we will have to create another user --telegramd-- to run the service and we will have to do it again. | ||
| + | |||
| + | The program is called '' | ||
| + | |||
| + | < | ||
| + | $ ./ | ||
| + | </ | ||
| + | |||
| + | Something similar to this will appear: | ||
| + | |||
| + | < | ||
| + | $: | ||
| + | Telegram-cli version 1.0.5, Copyright (C) 2013-2014 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' | ||
| + | Telephone number (with ' | ||
| + | </ | ||
| + | |||
| + | You have to provide the telephone number of this account --normally your telephone number-- but with your national prefix. | ||
| + | |||
| + | Then the sms will be requested, so it is advisable to have this phone near when doing this. | ||
| + | |||
| + | You can issue a contact_list command to check thet that this client is working: | ||
| + | |||
| + | < | ||
| + | > contact_list | ||
| + | .... | ||
| + | .... | ||
| + | </ | ||
| + | |||
| + | ===== Step 5: install the client ===== | ||
| + | |||
| + | I've opted for manually install the client. I've copied the '' | ||
| + | |||
| + | < | ||
| + | # mkdir / | ||
| + | # cp telegram-cli / | ||
| + | </ | ||
| + | |||
| + | I've also created a directory called ''/ | ||
| + | |||
| + | </ | ||
| + | # mkdir / | ||
| + | # chmod u=rwx, | ||
| + | # cp tg-server.pub / | ||
| + | # chmod g=r,o=r,u=r / | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Step 6: create the system user telegramd ===== | ||
| + | |||
| + | In order to run the telegram-daemon as root, you will need to create the user telegramd. I've opted | ||
| + | to create this user as a system user: | ||
| + | |||
| + | < | ||
| + | # useradd -M --user-group --system --shell=/ | ||
| + | </ | ||
| + | |||
| + | |||
| + | Impersonate this user and run the telegram-cli program again, to create a proper configuration file: | ||
| + | |||
| + | < | ||
| + | telegramd@: | ||
| + | Telegram-cli version 1.0.5, Copyright (C) 2013-2014 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' | ||
| + | Telephone number (with ' | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ===== Step 7: create a daemon and install it ===== | ||
| + | |||
| + | Telegram-cli has a bug that provokes that, unless '' | ||
| + | |||
| + | Let's go for it. The code for the daemon is this (customize the adequate variables): | ||
| + | |||
| + | |||
| + | < | ||
| + | #!/bin/bash | ||
| + | # | ||
| + | # telegram.sh | ||
| + | # | ||
| + | # | ||
| + | |||
| + | ### BEGIN INIT INFO | ||
| + | # Provides: | ||
| + | # Required-Start: | ||
| + | # Required-Stop: | ||
| + | # Default-Start: | ||
| + | # Default-Stop: | ||
| + | # Short-Description: | ||
| + | ### END INIT INFO | ||
| + | |||
| + | TELEGRAM_BIN="/ | ||
| + | TELEGRAM_PORT=1234 | ||
| + | TELEGRAM_ARGS=" | ||
| + | PID_FILE=/ | ||
| + | |||
| + | umask 022 | ||
| + | |||
| + | test -f " | ||
| + | |||
| + | |||
| + | case $1 in | ||
| + | start) | ||
| + | echo " | ||
| + | $TELEGRAM_BIN $TELEGRAM_ARGS & | ||
| + | echo $! > " | ||
| + | # issue the command " | ||
| + | # for sending messages | ||
| + | sleep 5 | ||
| + | echo " | ||
| + | echo " | ||
| + | ;; | ||
| + | stop) | ||
| + | echo " | ||
| + | # first make a gentle kill | ||
| + | kill $(cat " | ||
| + | # then sleep and make a hard kill | ||
| + | sleep 4s | ||
| + | kill -9 $(cat " | ||
| + | rm " | ||
| + | echo " | ||
| + | ;; | ||
| + | reload) | ||
| + | $0 stop | ||
| + | $0 start | ||
| + | ;; | ||
| + | status) | ||
| + | if kill -0 $(cat " | ||
| + | echo " | ||
| + | else | ||
| + | echo " | ||
| + | fi | ||
| + | ;; | ||
| + | *) | ||
| + | echo " | ||
| + | ;; | ||
| + | esac | ||
| + | |||
| + | exit 0 | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | Install it under ''/ | ||
| + | |||
| + | < | ||
| + | sudo mv telegram-daemon /etc/init.d | ||
| + | sudo chown root:root / | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Step 8: install the telegram-msg program ===== | ||
| + | |||
| + | After that I've created a '' | ||
| + | |||
| + | < | ||
| + | #!/bin/bash | ||
| + | # | ||
| + | # telegram-msg - sends a telegram message | ||
| + | # | ||
| + | # | ||
| + | |||
| + | |||
| + | echo "msg $1 $2" | nc 127.0.0.1 1234 | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Step 8: first test ===== | ||
| + | |||
| + | < | ||
| + | $ sudo / | ||
| + | $ telegram-msg somebody "some message you want to send" | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
linux/telegram.1434490884.txt.gz · Last modified: 2022/12/02 21:02 (external edit)
