Skip to content

Commit

Permalink
Merge pull request #95 from kelvinfan001/cleanup-for-0.21
Browse files Browse the repository at this point in the history
Cleanup in preparation for v0.21
  • Loading branch information
kelvinfan001 authored Feb 5, 2021
2 parents 130a2c8 + 475c497 commit d0aafc8
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 69 deletions.
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ all:
install: all
(set -euo pipefail; \
# package-specific directories \
mkdir -p $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)/issue.d; \
mkdir -p $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)/motd.d; \
mkdir -p $(DESTDIR)$(SYSCONFDIR)/$(PACKAGE)/issue.d; \
mkdir -p $(DESTDIR)$(SYSCONFDIR)/$(PACKAGE)/motd.d; \
# external directories \
mkdir -p $(DESTDIR)$(SYSCONFDIR)/issue.d; \
mkdir -p $(DESTDIR)$(SYSCONFDIR)/motd.d; \
mkdir -p $(DESTDIR)$(SYSCONFDIR)/profile.d; \
# install \
# udev rules are not installed by default. \
Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Useful in situations where a desktop environment is not available and informatio
The following messages will show before or upon login after installing `console-login-helper-messages` and enabling the needed units (see [manual](doc/manual.md)).

- issuegen:
- [x] available ssh keys from `/etc/ssh`
- [x] ip addresses of network interfaces to SSH into
- SSH keys (before login)
- Network interface information (before login)
- motdgen:
- [x] system information from `/etc/os-release`
- OS release information (at login)
- profile:
- [x] failed systemd units
- Failed systemd units (at login)

### Example

Expand Down Expand Up @@ -62,11 +62,6 @@ To verify working package functionality manually (for now), see the
## Customizing

The motd/issue messages are defaults and can be disabled following the [manual](doc/manual.md#Disabling-messages).

Messages can be appended to the motd or issue, by placing
files in the directories sourced by motdgen/issuegen to generate
the message (see [manual](doc/manual.md#Appending-messages)).

## Development

For information on contributing and testing changes in a virtual
Expand Down
34 changes: 18 additions & 16 deletions doc/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@
## Architecture overview

By default, `console-login-helper-messages` provides several units and scripts
for displaying helpful messages before or at login. Currently, the following
for displaying helpful messages before or upon login. Currently, the following
messages are displayed:
- issuegen:
- SSH keys (before login)
- Network interface information (before login)
- OS release information (after login)
- Failed systemd units (after login)
- motdgen:
- OS release information (at login)
- profile:
- Failed systemd units (at login)

The following default units and scripts are in charge of generating the information
that needs to be displayed in a MOTD or issue, and placing the sourced information to
the public runtime directories `/run/{issue,motd}.d`:
that needs to be displayed in a MOTD or issue, and displaying the sourced information
upon and before login:
- `console-login-helper-messages-gensnippet-ssh-keys.service` (SSH keys)
- `etc/NetworkManager/dispatcher.d/90-console-login-helper-messages-gensnippet-if` (Network interface info)
- `console-login-helper-messages-gensnippet-os-release.service` (OS release info)
- `share/profile.sh` (Failed systemd units)

## Installation

Expand All @@ -54,8 +58,8 @@ subpackages in the following way:
| package | function |
| -------------------------------------- | -------- |
| console-login-helper-messages | base directory layout for this packge (required by all subpackages) |
| console-login-helper-messages-issuegen | messages shown on serial console using issue (SSH keys, IP address for SSH) |
| console-login-helper-messages-motdgen | messages shown using the motd paths after SSH in (OS release information) |
| console-login-helper-messages-issuegen | messages shown before login via serial console using issue (SSH keys, IP address for SSH) |
| console-login-helper-messages-motdgen | messages shown using the motd paths at login (OS release information) |
| console-login-helper-messages-profile | messages shown using /etc/profile.d script, shown on login to bash terminal (failed systemd units) |

The `install` target of the [Makefile](../Makefile) is the source of truth
Expand Down Expand Up @@ -148,9 +152,7 @@ systemctl enable console-login-helper-messages-gensnippet-ssh-keys.service

Network interface information is shown via a
[NetworkManager Dispatcher script](/etc/NetworkManager/dispatcher.d/90-console-login-helper-messages-gensnippet_if),
and will display in `issue` by default. If using private runtime directories,
the `-issuegen` subpackage must also be installed and `-issuegen.path` shown
above must be enabled.
and will display in `issue` by default.

On systems where NetworkManager is unavailable, udev rules could be used to
detect new interfaces being added/removed. Udev rules are disabled by default and
Expand All @@ -166,10 +168,10 @@ However, provided that the configurations described in
[Integrating into a distribution](#integrating-into-a-distribution) are configured
and the right versions of upstream tools are installed, then:

- To have a message appended to the MOTD, the files (ending in `.motd`) to append
can be dropped in `/etc/motd.d/`.
- To have a message appended to the issue, the files (ending in `.issue`)
to append can be dropped in `/etc/issue.d/`.
- To have a message appended to the MOTD, the files to append can be dropped
in `/etc/motd.d/`.
- To have a message appended to the issue, the files to append can be dropped
in `/etc/issue.d/`.

### Disabling messages

Expand All @@ -184,11 +186,11 @@ systemctl disable console-login-helper-messages-gensnippet-os-release.service
systemctl disable console-login-helper-messages-gensnippet-ssh-keys.service
```

The `profile` messages can be disabled only by uninstalling
The `profile` messages (failed systemd units) can be disabled only by uninstalling
`console-login-helper-messages-profile`.

The network interface information can only be disabled by uninstalling
`console-login-helper-messages-issue`.
`console-login-helper-messages-issuegen`.

## Troubleshooting

Expand Down
17 changes: 2 additions & 15 deletions tests/kola/basic/test-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,13 @@ faketty () {
script -c "$(printf "%q " "$@")" "${outfile}"
}

for unit in issuegen.path gensnippet-ssh-keys.service; do
if ! systemctl is-enabled ${PKG_NAME}-${unit}; then
if ! systemctl is-enabled ${PKG_NAME}-gensnippet-ssh-keys.service; then
fatal "unit ${unit} not enabled"
fi
done
fi
ok "systemd units enabled"

cd $(mktemp -d)

# If using private runtime directory, check that the issue symlink was created.
# `issuegen` generates an issue at runtime, and places the generated file in
# /run/issue.d/. To have agetty display this, a symlink from /etc/issue.d/ to
# /run/issue.d/ is needed.
if [ ${USE_PUBLIC_RUN_DIR} == "false" ]; then
ls -l /etc/issue.d/40_${PKG_NAME}.issue > symlink.txt
assert_file_has_content symlink.txt '->'
assert_file_has_content symlink.txt '/run/console-login-helper-messages/40_console-login-helper-messages.issue'
ok "symlink"
fi

# If SSH keys are present, check that SSH keys snippets were generated by
# `gensnippet_ssh_keys` and shown by `agetty`.
if test -n "$(find /etc/ssh -name 'ssh_host_*_key' -print -quit)"; then
Expand Down
8 changes: 3 additions & 5 deletions tests/kola/basic/test-motd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ set -xeuo pipefail

. ${KOLA_EXT_DATA}/test-util.sh

for unit in motdgen.path gensnippet-os-release.service; do
if ! systemctl is-enabled ${PKG_NAME}-${unit}; then
fatal "unit ${unit} not enabled"
fi
done
if ! systemctl is-enabled ${PKG_NAME}-gensnippet-os-release.service; then
fatal "unit ${unit} not enabled"
fi

# Check that the OS Release snippet was created.
assert_has_file ${MOTD_RUN_SNIPPETS_PATH}/21_os_release.motd
Expand Down
17 changes: 2 additions & 15 deletions tests/kola/test-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,5 @@ PKG_NAME="console-login-helper-messages"

. ${KOLA_EXT_DATA}/libtest.sh

# ISSUE_RUN_SNIPPETS, MOTD_RUN_SNIPPETS may be different, depending on the
# version of console-login-helper-messages.
# Source `libutil.sh` to determine whether the version of
# console-login-helper-messages that we are testing is using public or
# private directories for dropping issue/motd files.
. /usr/lib/${PKG_NAME}/libutil.sh
if [ ${USE_PUBLIC_RUN_DIR} == "true" ]; then
# Use public runtime directories
ISSUE_RUN_SNIPPETS_PATH="/etc/issue.d"
MOTD_RUN_SNIPPETS_PATH="/run/motd.d"
else
# Use private runtime directories
ISSUE_RUN_SNIPPETS_PATH="/run/${PKG_NAME}/issue.d"
MOTD_RUN_SNIPPETS_PATH="/run/${PKG_NAME}/motd.d"
fi
ISSUE_RUN_SNIPPETS_PATH="/etc/issue.d"
MOTD_RUN_SNIPPETS_PATH="/run/motd.d"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
r /etc/issue.d/*_clhm_*.issue - - - - -
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d /run/motd.d - - - - -
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
L /etc/profile.d/console-login-helper-messages-profile.sh - - - - ../../usr/share/console-login-helper-messages/profile.sh
4 changes: 0 additions & 4 deletions usr/lib/tmpfiles.d/console-login-helper-messages.conf

This file was deleted.

0 comments on commit d0aafc8

Please sign in to comment.