quiniouben / vban

VBAN protocol open-source implementation
GNU General Public License v3.0
450 stars 63 forks source link

Receptor and Emitter Autostart after boot #81

Open DL1DMS opened 2 years ago

DL1DMS commented 2 years ago

Hello,

I use vban for Amateur radio purposes.... How it is possible to "autostart" vban_emitter and vban_receptor at boot? It works fine by entering the commands by shell but I doesn't run by adding the following lines to the /etc/rc.local

vban_emitter -i 192.168.125.31 -p 6980 -s RX vban_emitter -i 192.168.125.20 -p 6980 -s RX vban_receptor -i 192.168.125.31 -p 6980 -s TX vban_receptor -i 192.168.125.20 -p 6980 -s TX

Probably it's a stupid question but I'm still a greenhorn when it comes to Linux......

Best regards

Manuel

tilleul commented 2 years ago

1) make sure you include the full path to your vban_emitter/receptor 2) you need to end your commands with "&" (without quotes) to make them run in the background 3) you possibly want to redirect those programs outputs to /dev/null

So you should have for your first line something like this:

/path/to/vban_emitter -i 192.168.125.31 -p 6980 -s RX >/dev/null &

DL1DMS commented 2 years ago

Hey Tilleul,

Thanks for ur reply. My commands in /etc/rc.local look like this now.....

(sleep 10 /usr/local/bin/vban_emitter -i 192.168.125.20 -p 6980 -s RX >/dev/null & /usr/local/bin/vban_receptor -i 192.168.125.20 -p 6980 -s TX >/dev/null )

But it doesn't work. Even without "(sleep 10" and ")" it doesn't wanna run. When it open the console and enter both commands it works perfectly.

Any help appreciated. :)

Best regards Manuel

tilleul commented 2 years ago

you should check your logs for error messages ... maybe the network is not ready ?

Also your second line also needs a final "&" to make it run in the background (but it won't solve your current problem)

DL1DMS commented 2 years ago

Hello Tilleul,

thanks again for ur quick reply. Thanks for the hint with the "&". I think my network should be ready after 10 seconds but I'm not sure. Don't know how to enter the log files. First I tried the same stuff (using an amateur radio device by network) with mumble which was starting up and working after a delay of 10 seconds. But since I haven't had a possibility to control the audio levels (it was not possible to disable AGC) I now use VBAN which works just the way I want. Just the autostart doesn't work.

Best regards Manuel

tilleul commented 2 years ago

Depending on your linux distro, check

journalctl

or probably the logs are in /var/log (lots of files in there)

DL1DMS commented 2 years ago

Good morning,

didn't know the linux distribution makes a difference. I got Raspberry PI OS running. I'll try to check the logs and let u know. :)

Best regards

Manuel

NeroBurner commented 2 years ago

Raspberry PI OS uses systemd as init-daemon (the first process, that starts all the other processes). I recommend to try to create a systemd-service for the startup-commands vban-emitter and receptor (I suggest one service per command)

https://www.raspberrypi.com/documentation/computers/using_linux.html#creating-a-service

One nice thing (among many others) about systemd services is, that you can explicitly state, that the service starts after the network is up (After=network.target)

edit: because it's not mentioned in the linked documentation: you can check the status (running and log output) with systemctl status name-of-your-service.service

DL1DMS commented 2 years ago

Hello again, sorry foy the long delay. I had much work and a deathcase in my family. Now I can focus on the boot problem again. I created the following file:

/etc/systemd/system/vban-emitter-start.service

Content of the file:

[Unit]
Description=VBA-EMITTER-START
After=network.target

[Service]
ExecStart=/usr/local/bin/vban_emitter -i 192.168.125.20 -p 6980 -s RX >/dev/null &
WorkingDirectory=
StandardOutput=null
StandardError=inherit
Restart=always
user=

[Install]
WantedBy=multi-user.target

(There's also a file for receptor looking almost the same except of the 2 lines which are "Description=VBA-EMITTER-START" and "ExecStart=/usr/local/bin/vban_receptor -i 192.168.125.20 -p 6980 -s TV >/dev/null &" but I wanna keep it simple right now.)

Ok.... I saves the file(s).... Then I enabled the service (sudo systemctl enable vban-emitter-start.service) Then I reloaded the daemon (sudo systemctl daemon-reload) Then I started the service (sudo systemctl stop vban-emitter-start.service) ...and then I checked if the service is running properly..... but then I get an error message......again and again.

● vban-emitter-start.service - VBAN-EMITTER-START
     Loaded: loaded (/etc/systemd/system/vban-emitter-start.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2022-03-23 19:57:47 CET; 4s ago
    Process: 1573 ExecStart=/usr/local/bin/vban_emitter -i 192.168.125.20 -p 6980 -s RX >/dev/null & (code=exited, status=254)
   Main PID: 1573 (code=exited, status=254)
        CPU: 67ms

Mär 23 19:57:47 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Scheduled restart job, restart counter is at 5.
Mär 23 19:57:47 YAESU-FT-DX10 systemd[1]: Stopped VBAN-EMITTER-START.
Mär 23 19:57:47 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Start request repeated too quickly.
Mär 23 19:57:47 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Failed with result 'exit-code'.
Mär 23 19:57:47 YAESU-FT-DX10 systemd[1]: Failed to start VBAN-EMITTER-START.

I tried to reboot the raspberry, I tried to enter different users (su, pi) un the "user"-line but that didn't help either. I don't know what to do and how to solve the problem. Anyone has an idea?

Saludos Manuel

NeroBurner commented 2 years ago

try to drop the redirection part >/dev/null & of the exec command. I think that isn't supported

DL1DMS commented 2 years ago

Hello,

I dropped it... but then I keep gettin' the same error I think.....

● vban-emitter-start.service - VBAN-EMITTER-START Loaded: loaded (/etc/systemd/system/vban-emitter-start.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2022-03-23 20:22:30 CET; 7s ago Process: 1697 ExecStart=/usr/local/bin/vban_emitter -i 192.168.125.20 -p 6980 -s RX (code=exited, status=254) Main PID: 1697 (code=exited, status=254) CPU: 59ms

Mär 23 20:22:30 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Scheduled restart job, restart counter is at 5. Mär 23 20:22:30 YAESU-FT-DX10 systemd[1]: Stopped VBAN-EMITTER-START. Mär 23 20:22:30 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Start request repeated too quickly. Mär 23 20:22:30 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Failed with result 'exit-code'. Mär 23 20:22:30 YAESU-FT-DX10 systemd[1]: Failed to start VBAN-EMITTER-START.

Saludos

Manuel

NeroBurner commented 2 years ago

maybe the script starts too early. Does it work if you start the service by hand when you're having network connectivity? If that is working, then try to depend on the systemd-networkd-wait-online.service target instead of the multi-user target

https://www.freedesktop.org/software/systemd/man/systemd-networkd-wait-online.service.html

DL1DMS commented 2 years ago

Hey NeroBurner,

thanks for u r reply. It frankly doesn't. At the moment I still always try to start the service by hand... If that would work I would implement it to start automatically. But right now I just get this error message. I have no idea what could be wrong. :( Best regards Manuel

NeroBurner commented 2 years ago

maybe the system unit doesn't have the environment variables set to connect to the pulseaudio server. Maybe try to look into that

alterNERDtive commented 1 year ago

After=network.target

Well, how about your sound system?

Either require sound.target or w/e does your sound, in my case pipewire-pulse.service. I also have it bound to the latter so it restarts when that restarts.