Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #245101

Re: Autostart command after network is available (usbip)

From Greg Wooledge <greg@wooledge.org>
Newsgroups linux.debian.user
Subject Re: Autostart command after network is available (usbip)
Date 2022-02-08 16:50 +0100
Message-ID <DOAUF-qrc-1@gated-at.bofh.it> (permalink)
References <DOzYB-pL9-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

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),
the interfaces that are maked as "auto" must be up, in order for Debian
to declare that the "network is available".

So, make sure your ethernet interface is marked as "auto" and NOT as
"allow-hotplug".

Once that's squared away, the rest is pretty straightforward.

Create a new systemd service (/etc/systemd/system/yourname.service),
and in the [Unit] section, make sure you've got this:

After=network-online.target

That's basically it.  Do the daemon-reload thing, then enable and start
the service, and if it works, reboot to really test it.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Autostart command after network is available (usbip) Christian Britz <cbritz@t-online.de> - 2022-02-08 15:50 +0100
  Re: Autostart command after network is available (usbip) Dan Ritter <dsr@randomstring.org> - 2022-02-08 16:20 +0100
  Re: Autostart command after network is available (usbip) Greg Wooledge <greg@wooledge.org> - 2022-02-08 16:50 +0100
    Re: Autostart command after network is available (usbip) Christian Britz <cbritz@t-online.de> - 2022-02-08 17:50 +0100
      Re: Autostart command after network is available (usbip) Greg Wooledge <greg@wooledge.org> - 2022-02-08 17:50 +0100
        OT: Network-Manager Christian Britz <cbritz@t-online.de> - 2022-02-08 18:00 +0100
      Re: Autostart command after network is available (usbip) Christian Britz <cbritz@t-online.de> - 2022-02-08 17:50 +0100
        Re: Autostart command after network is available (usbip) Andrei POPESCU <andreimpopescu@gmail.com> - 2022-02-09 15:50 +0100
      Re: Autostart command after network is available (usbip) Andy Smith <andy@strugglers.net> - 2022-02-09 07:10 +0100
        Re: Autostart command after network is available (usbip) 황병희 <soyeomul@doraji.xyz> - 2022-02-09 13:00 +0100

csiph-web