Skip to content

Instantly share code, notes, and snippets.

@libcrack
Created May 16, 2016 05:57
Show Gist options
  • Select an option

  • Save libcrack/e31f296cc935188749bfc32c93c424e7 to your computer and use it in GitHub Desktop.

Select an option

Save libcrack/e31f296cc935188749bfc32c93c424e7 to your computer and use it in GitHub Desktop.
Telegram daemon systemd user unit
# root@libcrack.so
# Sun may 15 23:39:17 CEST 2016
# ~/.local/share/systemd/user/telegramd.service
[Unit]
Description=Telegram systemd service
ConditionPathExists=/home/%u/.telegram-cli
After=network.target
; ===========================================================
; telegram-cli Usage
; --phone/-u specify username (would not be asked during authorization)
; --rsa-key/-k specify location of public key (possible multiple entries)
; --verbosity/-v increase verbosity (0-ERROR 1-WARNIN 2-NOTICE 3+-DEBUG-levels)
; --enable-msg-id/-N message num mode
; --config/-c config file name
; --profile/-p use specified profile
; --log-level/-l log level
; --sync-from-start/-f during authorization fetch all messages since registration
; --disable-auto-accept/-E disable auto accept of encrypted chats
; --lua-script/-s lua script file
; --wait-dialog-list/-W send dialog_list query and wait for answer before reading input
; --disable-colors/-C disable color output
; --disable-readline/-R disable readline
; --alert/-A enable bell notifications
; --daemonize/-d daemon mode
; --logname/-L <log-name> log file name
; --username/-U <user-name> change uid after start
; --groupname/-G <group-name> change gid after start
; --disable-output/-D disable output
; --tcp-port/-P <port> port to listen for input commands
; --udp-socket/-S <socket-name> unix socket to create
; --exec/-e <commands> make commands end exit
; --disable-names/-I use user and chat IDs in updates instead of names
; --enable-ipv6/-6 use ipv6 (may be unstable)
; --help/-h prints this help
; --accept-any-tcp accepts tcp connections from any src (only loopback by default)
; --disable-link-preview disables server-side previews to links
; --bot/-b bot mode
; --json prints answers and values in json format
; --permanent-msg-ids use permanent msg ids
; --permanent-peer-ids use permanent peer ids
;
; ===========================================================
; --tcp-port 2391
; --phone +34666123123 --rsa-key ~/rsa.key
; --config telegram-cli.cfg --profile daemon
; --lua-script test.lua --python-script test.py
; --disable-link-preview --bot --json --alert
; --disable-output --disable-colors --disable-readline
; ===========================================================
[Service]
Type=simple
ExecStart=/usr/bin/telegram-cli --daemonize --tcp-port 2391 --wait-dialog-list --logname /home/%u/.telegram-cli/telegramd.log --verbosity 1 --disable-output --disable-auto-accept --disable-link-preview --disable-readline
Restart=on-failure
TimeoutSec=10
;ExecStop=/usr/bin/nc -q 1 localhost 2391 <<< quit
ExecStop=/usr/bin/pkill -KILL -x /usr/bin/telegram-cli
KillMode=process
;KillSignal=SIGTERM
KillSignal=SIGKILL
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment