<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">On Oct 10, 2015, at 23:16, Andrei Borzenkov <<a href="mailto:arvidjaar@gmail.com" class="">arvidjaar@gmail.com</a>> wrote:<br class=""><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><span style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">11.10.2015 07:14, Johannes Ernst пишет:</span><br style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I understand that if foo.service specifies:<br class=""><br class="">PropagatesReloadTo=bar.service<br class=""><br class="">and I execute “systemctl reload foo”, this will trigger a reload of bar as well. Typically I might do that if I have changed some config file, and I want the daemon(s) to pick it up.<br class=""><br class="">Is there a similar mechanism that triggers a reload in bar when foo stops, or when foo starts, or events like that?<br class=""><br class="">I found a thread from 3 years ago on an OnStop= rule, but I don’t think that made it into the mainline? [1]<br class=""><br class="">My use case is that if I switch from foo.service to foo2.service (both require bar, and are mutually exclusive to each other), I’d like bar to reload.<br class=""></blockquote><br style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Usually if service A requires service B, service B need not be aware about service A starting or stopping. In your case it actually sounds like "bar requires either foo or foo2", otherwise why bar would need restart?</span><br style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote></div><br class=""><div class="">I guess I need to explain what I’m trying to do:</div><div class=""><br class=""></div><div class="">I want a single command to reconfigure networking for different situations that a device running UBOS [2] might encounter. Example syntax:</div><div class=""><br class=""></div><div class="">> ubos-admin setnetconfig client</div><div class=""># sets up DHCP client on all network interfaces, advertises http and https sites on device via Avahi, runs firewall</div><div class="">> ubos-admin setnetconfig static</div><div class=""># allocates static IP addresses on all network interfaces, advertises http and https sites via Avahi, runs firewall</div><div class="">> ubos-admin setnetconfig gateway</div><div class=""># sets up DHCP client on first Ethernet interface (WAN), allocates static IP addresses to all other interfaces (LAN), advertises via Avahi but only on LAN, runs firewall and NAT</div><div class="">> ubos-admin setnetconfig cloud</div><div class=""><div class=""># sets up DHCP client on all network interfaces, no Avahi, runs firewall, also runs cloud-init</div></div><div class=""><br class=""></div><div class="">The idea is to take drudgery and needed competence out of network configuration and make it “fool proof” by identifying the situation on a high level (“this is my home gateway”, “this is just some device on my network” etc) and let software make it so.</div><div class=""><br class=""></div><div class="">My implementation of ‘ubos-admin setnetconfig XXX’ basically goes like this:</div><div class=""><br class=""></div><div class="">1. Generate/update configuration files for the configuration XXX</div><div class="">2. systemctl start ubos-networking-XXX.service (where XXX=client, static, gateway, …), with all the ubos-networking-XXX.service files declaring a Conflict with all others, so systemd will only run one of them at a time.</div><div class=""><br class=""></div><div class="">To get back to the problem on the beginning of the thread, let’s take an example:</div><div class=""><br class=""></div><div class="">ubos-networking-client.service depends on systemd-networkd.service, with a config file like this:</div><div class=""><div class=""><br class=""></div><div class="">[Match]</div><div class="">Name=*</div><div class="">[Network]</div><div class="">DHCP=ipv4</div></div><div class=""><br class=""></div><div class=""><div class="">ubos-networking-gateway.service depends on systemd-networkd.service, with a config file like this:</div><div class=""><div class=""><br class=""></div><div class=""><div class=""><div class="">[Match]</div><div class="">Name=enp0s3</div><div class="">[Network]</div><div class="">DHCP=ipv4</div></div></div></div></div><div class=""><div class="">[Match]</div><div class="">Name=*</div><div class="">[Network]</div><div class="">Address=0.0.0.0/16</div></div><div class=""><br class=""></div><div class="">Now, if the current state is “client” and the user executes “ubos-admin setnetconfig gateway”, after updating the config files, the following things need to occur:</div><div class="">1. ubos-networking-client.service needs to be stopped</div><div class="">2. ubos-networking-gateway.service needs to be started</div><div class="">3. systemd-networkd.service needs to be reloaded, because its configuration has changed.</div><div class=""><br class=""></div><div class="">So I was wondering whether there is a mechanism to have systemd reload systemd-networkd, in response to an event such as ubos-networking-client.service being stopped, or ubos-networking-gateway.service being started.</div><div class=""><br class=""></div><div class="">Does this make sense?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">[2] <a href="http://ubos.net/" class="">http://ubos.net/</a></div><div class=""><br class=""></div></body></html>