[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Autostart command after network is available (usbip)



On 2022-02-08 16:46 UTC+0100, Greg Wooledge wrote:
> On Tue, Feb 08, 2022 at 03:46:09PM +0100, Christian Britz wrote:
>> I want to know how I can execute a command as root once after the
>> network is available.
> 
>> Is this to be done via systemd?
> 
> Yes, that's where you should be doing this.

That is what I thought of initially. And I think I am _almost_ there.
The script works, after several hours of trial, errors and your and
Dan's advice, when I manually execute it via systemctl. Start and stop
works.

It still does not work during boot time, though:
Feb 08 17:34:53 amiga5000 usbip[1014]: usbip: error: tcp connect
Feb 08 17:34:53 amiga5000 systemd[1]: Starting usbip client service...
Feb 08 17:34:53 amiga5000 systemd[1]: usbip.service: Main process
exited, code=exited, status=1/FAILURE
Feb 08 17:34:53 amiga5000 systemd[1]: usbip.service: Failed with result
'exit-code'.
Feb 08 17:34:53 amiga5000 systemd[1]: Failed to start usbip client service.

I am almost sure I got the targets wrong. I _am_ actually using
Network-Manager. Here is my service file:

Unit]
Description=usbip client service
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/usbip attach -r raspberrypi -b 1-1.4
RemainAfterExit=true
ExecStop=/usr/sbin/usbip detach -p 00
StandardOutput=journal

[Install]
WantedBy=multiuser.target

> 
> There's one thing in particular that you need to know first, and that's
> how Debian defines interfaces for the purposes of determining that
> "the network is available".  Assuming that you're using
> /etc/network/interfaces (and not Network-Manager or some other thing)
Yes, I need some more help in the context of using Network-Manager.

-- 
http://www.cb-fraggle.de


Reply to: