vysheng / tg

telegram-cli
GNU General Public License v2.0
6.44k stars 1.52k forks source link

running as daemon: executable /usr/share/telegram-daemon/bin/msg-search-engine not found #373

Open jekl053 opened 9 years ago

jekl053 commented 9 years ago

Thanks for all the great working, the cli works great!

I tried to run te telegram-cli as daemon on my raspberry pi as described in the wiki page.

When I start the script, I get the following error/output:

/etc/init.d/telegram-daemon start z5 executable /usr/share/telegram-daemon/bin/msg-search-engine not found

Please help :)

vysheng commented 9 years ago

probably you named your conf file wrong

candoshi commented 9 years ago

I have the same problem. I did it with the wiki instructions and I have two empty files in /etc/telegram-daemon/ : telegram-daemon.achat.conf telegram-daemon.z5.conf And then the file /etc/telegram-daemon.achat.conf filled wit this content:

execute telegram-cli 
-d 
-vvvv 
-E 
-R 
-D
-C
-P 2391

And the contents of /etc/telegram-cli/ are: server.pub Contents of /usr/share/telegram-daemon/bin/: start-telegram-daemon telegram-cli telegram-cli.old (copied from my compiled /tg/bin/) At /var/lib/telegram-daemon/ I'm not sure which scripts I should generate and which are generated by telegram... What is with "downloads script-achat.lua script-z5.lua"?

vysheng commented 9 years ago

downloads folder will contain downloads, it is generated automatically. lua scripts are generated by you.

mosqueiro commented 9 years ago

I'm also having the same problem in Debian. I made the configurations step by step correctly, but it does not find this executable . And I see it in the Telegram -cli package:

executable /usr/share/telegram-daemon/bin/msg-search-engine not found

jossie67 commented 9 years ago

I have also the same issue in Debian

root@telegram:/etc/init.d# ./start-telegram-daemon executable /usr/share/telegram-daemon/bin/msg-search-engine not found root@telegram:/etc/init.d#

candoshi commented 9 years ago

vysheng and how do I generate the lua scripts in /var/lib/telegram-daemon/ and the executable /usr/share/telegram-daemon/bin/msg-search-engine ?

antonioacsj commented 9 years ago

Same problem: executable /usr/share/telegram-daemon/bin/msg-search-engine not found

I saw that "msg-search-engine" is called from script https://github.com/vysheng/tg/blob/master/start-telegram-daemon in :

my %Vars = ( "execute" => "msg-search-engine", "work_dir" => "$root/var/lib/telegram-daemon" ); Is a separeted binarie? Where i found it ?

Thanks..

timetravel0 commented 9 years ago

I solved this substituting

my %Vars = ( "execute" => "msg-search-engine", "work_dir" => "$root/var/lib/telegram-daemon" );

with

my %Vars = ( "execute" => "telegram-cli", "work_dir" => "$root/var/lib/telegram-daemon" );

Ciao

antonioacsj commented 9 years ago

Solved !! Timetrave0, your solution worked for me too!

Thanks!

danielmunoz commented 9 years ago

I applied the timetravel0 solution, but after starting the daemon, there is no process running.

Did anyone got it running as daemon?

candoshi commented 9 years ago

I made a little workaround to get it working. I wrote my own /etc/init.d/ file and added it into the linux runlevels so I can start the service with "sudo service telegram-daemon start/stop/restart" Here is a sample /etc/init.d/telegram-daemon file: "daemonuser" is the user your standard telegram-cli (set-up in non-daemon mode before!) is running under


#! /bin/sh
### BEGIN INIT INFO
# Provides:          telegram-daemon
# Required-Start:    
# Required-Stop:     
# Default-Start:     S 2 3 4 5
# Default-Stop:      0 6
# Short-Description: telegram daemon
# Description:       telegram daemon
### END INIT INFO
# Author: fizzzel

# actions
case "$1" in
    start)
        echo "Telegram daemon is starting..."
        su daemonuser -c '/path/to/telegram-cli -vvvvRC -k tg-server.pub -W -dL tg.log -P 1234 &'
        echo "...done" 
        ;;
    stop)
        echo "stopping telegram daemon..."
        sudo pkill telegram
        echo "..done"
        ;;
    restart)
        echo "stopping telegram daemon..."
        sudo pkill telegram
        echo "..done -- restarting..."
        su daemonuser -c '/path/to/telegram-cli -vvvvRC -k tg-server.pub -W -dL tg.log -P 1234 &'
        echo "...done" 
        ;;
esac

exit 0
jmtatsch commented 9 years ago

@Fizzzel thank you for your start script, this is the only one i got to work. The other approach is severely broken...

giuliotripi commented 8 years ago

@Fizzzel Thank you for your script, it works fine!

beMoD commented 8 years ago

@Fizzzel Why do you use sudo to run telegram-cli as the daemonuser? Why don't you use the -U and -G option of telegram-cli?

Here is my version of the init script, note the -b though if copying, as this is a bot:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          telegram-cli
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Commandline interface for Telegram chat program
# Description:       Telegram-cli is a (unofficial) cli version of Telegram to chat from your console.
#                    This is an init script do make it a daemon.
#                    When used as daemon in conjuction  with LUA (scripting) you can use it to send your system
#                    commands to execute via other Telegram apps (PC - Phone - Web or other) while not
#                    logged in to the system.
#
#                    Note #1: This version of the init script is developed for raspbian (rapberry PI port of Debian Wheezy).
#
#
#                    See: https://github.com/vysheng/tg for more information.
#                    Derived from https://github.com/vysheng/tg/issues/436 (updated 9th April 2015)
#                    Further derived from: https://www.domoticz.com/wiki/Installing_Telegram_Notification_System#.2Fetc.2Finit.d.2Ftelegram-cli
### END INIT INFO

# Set some variables
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DESC="Telegram Messaging System"
NAME=telegram-cli
USERNAME=telegramd
GROUPNAME=telegramd
LOGFILE=/var/log/telegramd.log
DAEMON=/usr/bin/telegram-cli
TGPORT=1234

TelegramKeyFile="/etc/telegram-cli/server.pub"
ReceiveLua=/usr/local/lib/tg-handler.lua

DAEMON_ARGS="-W -b -U $USERNAME -G $GROUPNAME -k $TelegramKeyFile -L $LOGFILE -P $TGPORT -s $ReceiveLua -d -vvvRC"
#DAEMON_ARGS="-W -U telegramd -G telegramd -k $TelegramKeyFile -L /var/log/telegramd.log -P $TGPORT -d -vvvRC"

PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Carry out specific functions when asked to by the system
case "$1" in

    start)
        echo -n "Starting $DESC ... "
        start-stop-daemon --start --background --make-pidfile $PIDFILE --pidfile $PIDFILE \
            --exec $DAEMON -- $DAEMON_ARGS || true
        echo "Done."
    ;;

    stop)
        echo -n "Stopping $DESC ... "
        start-stop-daemon --stop --retry 2 --pidfile $PIDFILE \
            --exec $DAEMON || true
    rm -f $PIDFILE
    echo "Done."

    ;;
    restart)
        echo -n "Restarting $DESC "
        start-stop-daemon --stop --retry 2 --pidfile $PIDFILE \
            --exec $DAEMON || true
        rm -f $PIDFILE
        start-stop-daemon --start --background --make-pidfile $PIDFILE --pidfile $PIDFILE \
            --exec $DAEMON -- $DAEMON_ARGS || true
        echo "Done."
    ;;

    status)
        if [ -f $PIDFILE ]; then
                PID=`cat $PIDFILE`
        else
                echo "No pid file, telegramd not running?"
                exit 1
        fi
        if [ "`ps -p $PID -o comm=`" = "telegram-cli" ]; then
                echo "telegramd running with pid $PID"
        else
                echo "telegramd not running. removing $PIDFILE"
                rm -f $PIDFILE
                exit 1
        fi
    ;;

    *)
        N=/etc/init.d/$NAME
        echo "Usage $NAME: $SCRIPTNAME {start|stop|restart|status}"
        exit 1
    ;;

esac
candoshi commented 8 years ago

@beMoD I wrote my script in 2min, and I was excited that it worked instantly :D If beMoD's script is better, then you're all welcome to use it instead of mine!!!

beMoD commented 8 years ago

Ah, i see. Just thought there is a special reason you did it that way, thats why I asked :-)

karaFe commented 8 years ago

For me it helped to edit the script /usr/share/telegram-daemon/bin/start-telegram-daemon at the part where it writes the config: ..... binlog_enabled=false; ..... #lua_script=...

ModisDone commented 6 years ago

Can somebody fix this problem?