Projekt

Allgemein

Profil

Setup motd » Historie » Version 1

Jeremias Keihsler, 12.01.2017 11:41

1 1 Jeremias Keihsler
h1. Preliminary note motd
2
3
You may find additional useful information at
4
* http://wiki.centos.org/TipsAndTricks/BannerFiles
5
6
h1. Setup motd
7
8
The @/etc/motd@ is a file on Unix-like systems that contains a "message of the day".
9
This file is just static text, therefore we recreate this file every 10 mins with updated information.
10
11
I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take.
12
13
h2. add /usr/local/bin/gen_motd.sh
14
15
<pre><code class="bash">
16
vim /usr/local/bin/gen_motd.sh
17
</code></pre>
18
19
basic example:
20
<pre>
21
#!/bin/bash
22
# JKE 2011-05-14
23
# create /etc/motd
24
# to be called by /etc/cron.d/gen_motd
25
#
26
echo -e "
27
*******************************************************************
28
* xxyyy Janus Server                                            *
29
*
30
======h1.                                            *
31
*                                                               *
32
* This system is for the use of authorized users only. Usage of *
33
* this system will be monitored and recorded by system personnel. *
34
*                                                               *
35
* Anyone using this system expressly consents to such monitoring*
36
* and is advised that if such monitoring reveals possible       *
37
* evidence of criminal activity, system personel may provide the*
38
* evidence from such monitoring to law enforcement officials.   *
39
*                                                               *
40
*******************************************************************
41
* Version   = `cat /etc/centos-release`
42
* Kernel    = `uname -r`
43
* Uptime    = `uptime | sed 's/.*up \([^,]*\), .*/\1/'`
44
* Mem /free = `cat /proc/meminfo | grep MemTotal | awk {'print $2'}` kB / `cat /proc/meminfo | grep MemFree | awk {'print $2'}` kB 
45
* Swap/free = `cat /proc/meminfo | grep SwapTotal | awk {'print $2'}` kB / `cat /proc/meminfo | grep SwapFree | awk {'print $2'}` kB
46
* last updt = `date`
47
*******************************************************************
48
" > /etc/motd
49
</pre>
50
51
set shell-script being executeable
52
<pre><code class="bash">
53
chmod +x /usr/local/bin/gen_motd.sh
54
</code></pre>
55
56
h2. add /etc/cron.d/gen_motd
57
58
<pre><code class="bash">
59
vim /etc/cron.d/gen_motd
60
</code></pre>
61
62
basic example:
63
<pre>
64
# JKE 2011-05-14
65
#
66
#	min			hr	dom	month	dow	user	command
67
#	-			-	-	-	-
68
#	|			|	|	|	|
69
#	|			|	|	|	+-day of week (0-7) sunday=0 or 7
70
#	|			|	|	+---------month (1-12)
71
#	|			|	+-----------------day of month (1-31)
72
#	|			+-------------------------hour (0-23)
73
#	+-------------------------------------------------min (0-59)
74
# 
75
	5,15,25,35,45,55	*	*	*	*	root	/usr/local/bin/gen_motd.sh
76
</pre>
77
78
h1. Check motd
79
80
* recreate @motd@ manually
81
* login and check the output (you should see the motd)
82
<pre><code class="bash">
83
/usr/local/bin/gen_motd.sh
84
ssh root@localhost
85
exit
86
</code></pre>
87
* wait minimum 10 mins
88
* login once more, you should have an updated output