diff options
author | Scott Moser <smoser@brickies.net> | 2017-02-28 16:53:56 -0500 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-03-02 22:03:54 -0500 |
commit | 33518d7d62493c7d00e3792146399c9572abe915 (patch) | |
tree | 9af996394adbb3dcbfdb7b9ae123eff7783a76a9 /tools/Z99-cloudinit-warnings.sh | |
parent | ce63e63d7aaf900bac4339503c5d79ff3bd03d18 (diff) | |
download | vyos-cloud-init-33518d7d62493c7d00e3792146399c9572abe915.tar.gz vyos-cloud-init-33518d7d62493c7d00e3792146399c9572abe915.zip |
Add profile.d script for showing warnings on login.
Z99-cloudinit-warnings.sh can be dropped into /etc/profile.d.
Warnings that are written to /var/lib/cloud/instance/warnings
will be displayed to the user on stderr when they log in.
Diffstat (limited to 'tools/Z99-cloudinit-warnings.sh')
-rw-r--r-- | tools/Z99-cloudinit-warnings.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/Z99-cloudinit-warnings.sh b/tools/Z99-cloudinit-warnings.sh new file mode 100644 index 00000000..b237786b --- /dev/null +++ b/tools/Z99-cloudinit-warnings.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# This file is part of cloud-init. See LICENSE file for license information. + +# Purpose: show user warnings on login. + +cloud_init_warnings() { + local skipf="" warning="" idir="/var/lib/cloud/instance" n=0 + local warndir="$idir/warnings" + local ufile="$HOME/.cloud-warnings.skip" sfile="$warndir/.skip" + [ -d "$warndir" ] || return 0 + [ ! -f "$ufile" ] || return 0 + [ ! -f "$skipf" ] || return 0 + + for warning in "$warndir"/*; do + [ -f "$warning" ] || continue + cat "$warning" + n=$((n+1)) + done + [ $n -eq 0 ] && return 0 + echo "" + echo "Disable the warnings above by:" + echo " touch $ufile" + echo "or" + echo " touch $sfile" +} + +cloud_init_warnings 1>&2 +unset cloud_init_warnings + +# vi: syntax=sh ts=4 expandtab |