ibz / lightning-shell

The shell for your personal server
https://lightningshell.app
MIT License
24 stars 13 forks source link

bos command run on startup #9

Open JMskch opened 2 years ago

JMskch commented 2 years ago

Hello,

is there a way to run some command on the startup of the docker? e.g.

bos telegram --connect 1726156086 1> /tmp/bos.log 2>&1 & disown

to connect telegram bos and run it in the background? It would be best if the upgrade did not override this setting.

Thanks in advance.

JMskch commented 2 years ago

I also found that even the telegram bot API key did not remain saved after node reboot. Can this be saved in any way or it must be set every reboot?

AaronDewes commented 2 years ago

I'm doing it this way:

tmux

This starts a tmux session.

You can run any command from there and when you run tmux detach, the command stays running in a shell you can connect to at any time by tmux attach

JMskch commented 2 years ago

@AaronDewes Does tmux solve previously stated problems? -node reboot --> automatic startup telegram connection(API + connect code) within lightning shell -lightning shell upgrade

ibz commented 2 years ago

Hey @JMskch. Very good point. For now you could do it by editing /start.sh, which is the script that gets run when the container starts. That will of course be overriden by updates though... I'll add a way to make it stay (by having start.sh call another script that stays in your data/ directory). But until the next update, this is the way to go.

PS: to edit start.sh you need to get into the container as root: docker exec -u root -it <container_id> bash

ibz commented 2 years ago

Sorry @JMskch, I said something stupid. There is no start.sh in Lightning Shell, only in usocial. I am working on 2 Umbrel apps in parallel and sometimes confuse the two. :)

So no, you can't do it for now. Unless you rebuild the Docker image yourself.

ibz commented 2 years ago

Sorry @JMskch, I said something stupid. There is no start.sh in Lightning Shell, only in usocial. I am working on 2 Umbrel apps in parallel and sometimes confuse the two. :)

So no, you can't do it for now. Unless you rebuild the Docker image yourself.

ibz commented 2 years ago

@JMskch Added this feature in v0.1.7 https://lightningshell.app/history/#v0.1.7

Either wait for the official Umbrel update, or upgrade Lightning Shell yourself to v0.1.7.

JMskch commented 2 years ago

That was fast, many thanks.

JMskch commented 2 years ago

Hi @ibz, how to run commands for connecting bos telegram? when I use cli commands, which normally works like(dummy token and key) printf '%s\n' "9823545168:HHUJHhP8Io8P95495LPb656ra7Q8Jc" | timeout -s SIGINT 20s bos telegram --reset-api-key bos telegram --connect 0540461554 1> /tmp/bos.log 2>&1 & disown

I tried many different commands...things like changing shebang and so on, but I cannot make it work.

on_start.sh seems executing...tried with basic command echo to file, which worked on docker restart.

ibz commented 2 years ago

I haven't tried running the telegram bot myself, so I can't answer this, but I will reopen this issue and hopefully somebody will reply.

jonathanalevi commented 2 years ago

I'm also struggling with it, actually. Did you end up figuring it out @JMskch ?

JMskch commented 2 years ago

@jonathanalevi unfortunately not.

decentropy commented 2 years ago

To clarify ... the on_start.sh script does not resolve this issue. The problem is, BOS normal behavior is to retain the API key between reboots. For some reason, the LightningShell container is not remembering the API key after reboot. This is a problem, because BOS initiates API key through an interactive prompt which cannot be scripted (i.e. on_start.sh won't work).

If this issue gets resolved (BOS remembers API key after reboot), then BOS connection could be automated with on_start.sh. BOS telegram bot is probably one of the most popular things to run on an LND node. (It's the only way I know of, to be notified of node activity). It would be really sweet if this worked on LightningShell, because it would save lots of Umbrel users the hassle of installing BOS manually.

That said... sorry, I can't say what cause might be. Meanwhile - the workaround would be to open LightningShell and manually step through "bos telegram" after every reboot.

sz3k commented 2 years ago

I have now once again run into this issue - ln-shell forgets the telegram API key for BoS on reboot.

@ibz any ideas on why this could be, or strategies we could use for a fix or workaround for this?