-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d94209f
Showing
12 changed files
with
549 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,18 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
install: | ||
runs-on: macos-12 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: vmactions/freebsd-vm@v0 | ||
with: | ||
copyback: false | ||
release: "13.0" | ||
run: | | ||
setenv DESTDIR `mktemp -d` | ||
make install |
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,11 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
jobs: | ||
release: | ||
runs-on: macos-12 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: softprops/action-gh-release@v1 |
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,56 @@ | ||
# Contributing | ||
|
||
If you have an idea or feature request please open an [issue][1], even if you | ||
don't have time to contribute! | ||
|
||
## Making Changes | ||
|
||
> **Note**: This guide assumes you have a working FreeBSD 13.0 or later | ||
> installation. | ||
To get started, [fork][2] this repository on GitHub and clone a working copy for | ||
development: | ||
|
||
$ git clone [email protected]:YOUR-USERNAME/dynamic_motd.git | ||
|
||
Once you are finished, be sure to test changes locally and verify installation | ||
by issuing: | ||
|
||
# setenv DESTDIR `mktemp -d` | ||
# make install | ||
|
||
Finally, commit your changes and create a [pull request][3] against the `master` | ||
branch for review. | ||
|
||
## Making New Releases | ||
|
||
Making new releases is automated by GitHub Actions. Releases should only be | ||
created from the `master` branch. | ||
|
||
To make a new release, follow these steps: | ||
|
||
1. Verify the latest results of the [CI][4] workflow on the `master` branch. | ||
|
||
2. Create a release tag by issuing: | ||
|
||
$ git tag -a -m "Release v<version>" v<version> | ||
|
||
3. Push the release tag to the remote repository and verify the results of the | ||
[Release][5] workflow: | ||
|
||
$ git push origin --tags | ||
|
||
4. Submit a patch downstream for the `sysutils/dynamic_motd` port. See the | ||
[FreeBSD Porter's Handbook][6] for more details. | ||
|
||
## License | ||
|
||
By contributing to this repository, you agree that your contributions will be | ||
licensed under its Simplified BSD License. | ||
|
||
[1]: https://github.com/sstallion/dynamic_motd/issues | ||
[2]: https://docs.github.com/en/github/getting-started-with-github/fork-a-repo | ||
[3]: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request | ||
[4]: https://github.com/sstallion/dynamic_motd/actions/workflows/ci.yml | ||
[5]: https://github.com/sstallion/dynamic_motd/actions/workflows/release.yml | ||
[6]: https://docs.freebsd.org/en/books/porters-handbook/upgrading/ |
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,22 @@ | ||
Copyright (c) 2022 Steven Stallion <[email protected]> | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
SUCH DAMAGE. |
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,59 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# Copyright (c) 2022 Steven Stallion <[email protected]> | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND | ||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
# SUCH DAMAGE. | ||
|
||
NO_OBJ= | ||
|
||
LOCALBASE?= /usr/local | ||
PREFIX?= ${LOCALBASE} | ||
|
||
CONFDIR= ${PREFIX}/etc | ||
LIBEXECDIR= ${PREFIX}/libexec | ||
SHAREDIR= ${PREFIX}/share | ||
|
||
DIRS= SCRIPTSDIR | ||
|
||
SCRIPTS= dynamic_motd | ||
SCRIPTSDIR= ${LIBEXECDIR} | ||
|
||
FILESGROUPS= DOCS EXAMPLES | ||
|
||
DOCS= CONTRIBUTING.md README.md | ||
DOCSDIR= ${SHAREDIR}/doc/dynamic_motd | ||
|
||
EXAMPLES= examples/rc.motd examples/motd.subr | ||
EXAMPLESDIR= ${SHAREDIR}/examples/dynamic_motd | ||
|
||
CONFGROUPS= CONFETC CONFRCD | ||
|
||
CONFETC= rc.motd.sample | ||
|
||
CONFRCD= rc.d/dynamic_motd | ||
CONFRCDDIR= ${CONFDIR}/rc.d | ||
CONFRCDMODE= ${BINMODE} | ||
|
||
beforeinstall: installdirs | ||
afterinstall: installconfig | ||
|
||
.include <bsd.prog.mk> |
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,77 @@ | ||
# Dynamic /var/run/motd | ||
|
||
[![](https://github.com/sstallion/dynamic_motd/actions/workflows/ci.yml/badge.svg?branch=master)][1] | ||
[![](https://img.shields.io/github/v/release/sstallion/dynamic_motd)][2] | ||
[![](https://img.shields.io/github/license/sstallion/vimwiki-cli)][3] | ||
|
||
`dynamic_motd` is a drop-in replacement for generating messages of the day on | ||
FreeBSD 13.0 or later. During system startup, the file `/var/run/motd` is | ||
replaced with a fifo whose content is generated by a user-configurable shell | ||
script that is executed on each login. All other aspects of [motd(5)][4] are | ||
preserved. | ||
|
||
See [Configuration](#configuration) below for more details. | ||
|
||
<div align="center"> | ||
<img src=".github/images/screenshot.png" width="80%"/> | ||
</div> | ||
|
||
## Installation | ||
|
||
### FreeBSD Packages | ||
|
||
The `sysutils/dynamic_motd` package can be installed by issuing: | ||
|
||
# pkg install -y sysutils/dynamic_motd | ||
|
||
### FreeBSD Ports | ||
|
||
The `sysutils/dynamic_motd` port can be installed by issuing: | ||
|
||
# cd /usr/ports/sysutils/dynamic_motd | ||
# make install clean | ||
|
||
### From Source | ||
|
||
Installing from source should be avoided unless testing changes that have not | ||
yet been released downstream. By default, files will be installed in | ||
`/usr/local`, however this can be changed by specifying the `PREFIX` variable. | ||
|
||
# git clone https://github.com/sstallion/dynamic_motd.git /usr/local/src/dynamic_motd | ||
# cd /usr/local/src/dynamic_motd | ||
# make install | ||
|
||
## Configuration | ||
|
||
The `${PREFIX}/etc/rc.motd` script is responsible for generating content for | ||
`/var/run/motd` on each login. A sample script is provided in | ||
`${PREFIX}/etc/rc.motd.sample` that emulates the default [motd(5)][4] behavior. | ||
More extensive examples can be found in `${PREFIX}/share/examples/dynamic_motd`. | ||
|
||
To enable the `dynamic_motd` service, `update_motd` should be disabled in | ||
`/etc/rc.conf` as it is no longer needed at system startup: | ||
|
||
# sysrc update_motd="NO" | ||
|
||
The `dynamic_motd` service can then be enabled by issuing: | ||
|
||
# sysrc dynamic_motd="YES" | ||
# service dynamic_motd start | ||
|
||
> **Note**: `${PREFIX}/etc/rc.motd` can be updated without restarting the | ||
> `dynamic_motd` service; changes are automatically picked up on next login. | ||
## Contributing | ||
|
||
Pull requests are welcome! See [CONTRIBUTING.md][5] for more details. | ||
|
||
## License | ||
|
||
Source code in this repository is licensed under a Simplified BSD License. See | ||
[LICENSE][3] for more details. | ||
|
||
[1]: https://github.com/sstallion/dynamic_motd/actions/workflows/ci.yml | ||
[2]: https://github.com/sstallion/dynamic_motd/releases/latest | ||
[3]: https://github.com/sstallion/dynamic_motd/blob/master/LICENSE | ||
[4]: https://www.freebsd.org/cgi/man.cgi?query=motd&manpath=FreeBSD+13.0-RELEASE+and+Ports | ||
[5]: https://github.com/sstallion/dynamic_motd/blob/master/CONTRIBUTING.md |
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,51 @@ | ||
#!/bin/sh | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# Copyright (c) 2022 Steven Stallion <[email protected]> | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in the | ||
# documentation and/or other materials provided with the distribution. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND | ||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
# SUCH DAMAGE. | ||
|
||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 motd_script" >&2 | ||
exit 1 | ||
fi | ||
|
||
motd_script="$1" | ||
motd_file="/var/run/motd" | ||
motd_perms="644" | ||
|
||
# Remove existing motd before creating fifo: | ||
rm -f "${motd_file}" | ||
|
||
mkfifo -m $motd_perms "${motd_file}" || exit 1 | ||
( | ||
# Care should be taken to remove the fifo when not in use to prevent | ||
# hangs on login. Woe be to the one who issues SIGKILL: | ||
trap "rm -f ${motd_file}; exit" HUP INT QUIT TERM | ||
|
||
while true; do | ||
# Execute script in the background to quiesce job control | ||
# messages when the service is stopped: | ||
env -i sh "${motd_script}" >"${motd_file}" 2>&1 & | ||
wait 2>/dev/null | ||
done | ||
) & |
Oops, something went wrong.