source: hybrid/trunk/nanobsd/files/usr/local/etc/rc.d/nanobsd-motd@ 10123

Last change on this file since 10123 was 10123, checked in by richardvm, 13 years ago

creating trunk based on 9.0

  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/bin/sh
2#
3# $FreeBSD: src/etc/rc.d/motd,v 1.9.10.1.4.1 2009/04/15 03:14:26 kensmith Exp $
4#
5
6# PROVIDE: nanobsd-motd
7# REQUIRE: mountcritremote
8# BEFORE: LOGIN
9
10. /etc/rc.subr
11
12name="nanobsd_motd"
13rcvar="update_nanobsd_motd"
14start_cmd="motd_start"
15stop_cmd=":"
16
17PERMS="644"
18
19motd_start()
20{
21 # Update kernel info in /etc/motd
22 # Must be done *before* interactive logins are possible
23 # to prevent possible race conditions.
24 #
25 echo -n 'Updating motd'
26 if [ ! -f /etc/motd ]; then
27 install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd
28 fi
29
30 if [ ! -w /etc/motd ]; then
31 echo ' ... /etc/motd is not writable, update failed.'
32 return
33 fi
34
35 T=`mktemp -t motd`
36 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
37 awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
38
39 cmp -s $T /etc/motd || {
40 # XXX: Hack quick and dirty combine of /etc/rc.d/motd and /tools/savesshkeys
41 trap "umount /cfg" 1 2 15 EXIT
42 mount /cfg
43 cp $T /cfg/motd
44 chmod ${PERMS} /etc/motd
45 umount /cfg
46 trap 1 2 15 EXIT
47
48 trap "mount -uro noatime /" 1 2 15 EXIT
49 mount -uwo noatime /
50 cp $T /etc/motd
51 chmod ${PERMS} /etc/motd
52 mount -uro noatime /
53 trap 1 2 15 EXIT
54 }
55 rm -f $T
56
57 echo .
58}
59
60load_rc_config $name
61run_rc_command "$1"
Note: See TracBrowser for help on using the repository browser.