forked from coreos/console-login-helper-messages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issuegen: split out
if_snippets_gen
, add path unit
Split out `if_snippets_gen` from the `issuegen` script. This makes the udev rule `90-console-login-helper-messages-if_snippets_gen.rules` responsible only for writing snippets with information about network interfaces to the runtime issue snippets directory (`/run/console-login-helper-messages/issue.d`) read by `issuegen` to generate the final `/run/console-login-helper-messages/40_console-login-helper-messages.issue` file read by the serial terminal (agetty). This is beneficial as it helps avoid situations where multiple invocations of `issuegen` are executed concurrently (leading to bugs like coreos#35). This is also a first step towards making the shown information more configurable (coreos#15). Preparation also for coreos#7, reducing the number of places in the code that `issuegen` is called directly, reducing potential downstream patching needed to pass in a `--legacy` option to the script (coreos#7 (comment)). Add `console-login-helper-messages.path`, so that `issuegen` is run whenever snippets are written to `/run/console-login-helper-messages/issue.d`. This should be the main way of triggering a run of `issuegen` (first trigger the path, which starts the service, which will run `issuegen`). The only other time the `issuegen` service is invoked is on boot (if the unit is enabled). Note, enablement of the path unit is required upon installation.
- Loading branch information
Robert Fairley
committed
Apr 20, 2020
1 parent
39d74ee
commit a2f0dc9
Showing
7 changed files
with
72 additions
and
26 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
usr/lib/systemd/system/console-login-helper-messages-issuegen.path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Unit] | ||
Description=Monitor console-login-helper-messages runtime issue snippets directory for changes | ||
|
||
[Path] | ||
PathChanged=/run/console-login-helper-messages/issue.d | ||
Unit=console-login-helper-messages-issuegen.service | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
24 changes: 22 additions & 2 deletions
24
usr/lib/systemd/system/console-login-helper-messages-issuegen.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
usr/lib/udev/rules.d/90-console-login-helper-messages-if_snippets_gen.rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ACTION=="add", SUBSYSTEM=="net", ENV{INTERFACE}=="e*", RUN+="/usr/libexec/console-login-helper-messages/if_snippets_gen add $env{INTERFACE}" | ||
ACTION=="remove", SUBSYSTEM=="net", ENV{INTERFACE}=="e*", RUN+="/usr/libexec/console-login-helper-messages/if_snippets_gen remove $env{INTERFACE}" |
2 changes: 0 additions & 2 deletions
2
usr/lib/udev/rules.d/90-console-login-helper-messages-issuegen.rules
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# Generate snippets for network devices, invoked by a udev rule. | ||
|
||
# Copyright (c) 2019 Fedora CoreOS Authors. All rights reserved. | ||
# Copyright (c) 2013 The CoreOS Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
# Modified from the CoreOS repository: | ||
# * https://github.com/coreos/init/blob/master/scripts/issuegen | ||
|
||
set -e | ||
|
||
. "$(dirname ${0})/issue_defs" | ||
|
||
# Add/remove data from udev rules. | ||
case "$1" in | ||
add) | ||
echo "${2}: \\4{${2}} \\6{${2}}" > "${RUN_SNIPPETS}/22_${2}" | ||
;; | ||
remove) | ||
rm -f "${RUN_SNIPPETS}/22_${2}" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
PKG_NAME=console-login-helper-messages | ||
ISSUE_SNIPPETS_PATH=${PKG_NAME}/issue.d | ||
ETC_SNIPPETS="/etc/${ISSUE_SNIPPETS_PATH}" | ||
RUN_SNIPPETS="/run/${ISSUE_SNIPPETS_PATH}" | ||
USR_LIB_SNIPPETS="/usr/lib/${ISSUE_SNIPPETS_PATH}" | ||
|
||
|
||
# Make sure the `${RUN_SNIPPETS}` directory is created upfront, | ||
# as it may be written to by callers of this script. | ||
mkdir -p "${RUN_SNIPPETS}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters