Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jekl053 opened this issue Dec 20, 2014 · 18 comments

Comments

@jekl053
Copy link

jekl053 commented Dec 20, 2014

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
Copy link
Owner

vysheng commented Jan 12, 2015

probably you named your conf file wrong

@candoshi
Copy link

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
Copy link
Owner

vysheng commented Jan 17, 2015

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

@mosqueiro
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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

Thanks!

@danielmunoz
Copy link

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

Did anyone got it running as daemon?

@candoshi
Copy link

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
Copy link

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

@giuliotripi
Copy link

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

@beMoD
Copy link

beMoD commented Dec 17, 2015

@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
Copy link

@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
Copy link

beMoD commented Dec 17, 2015

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

@karaFe
Copy link

karaFe commented Apr 27, 2016

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
Copy link

Can somebody fix this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests