]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/motd/templates/motd.erb
Last one. I hope
[dsa-puppet.git] / modules / motd / templates / motd.erb
1 <% if @lsbmajdistrelease >= '7' -%>
2 #!/bin/bash
3
4 cat <<EOD
5 <% end -%>
6
7 This device is for authorized users only.  All traffic on this device
8 is monitored and will be used as evidence for prosecutions.  By using
9 this machine you agree to abide by the Debian Machines Usage Policies
10 <URL:http://www.debian.org/devel/dmup>.
11
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13
14 <%=
15 def wrap(s, width=78)
16       s.gsub(/(.{1,#{width}})( +|\Z)/, "\\1\n ")
17 end
18
19 def markup(l)
20   l = l.gsub(/\[\[(.*?)\|(.*?)\]\]/, '\2')
21   l = l.gsub(/\[\[(\*|-)?(.*?)\]\]/, '\2')
22   return l
23 end
24
25 if scope.lookupvar('site::nodeinfo')['ldap'].has_key?('architecture')
26   arch = scope.lookupvar('site::nodeinfo')['ldap']['architecture'][0]
27 else
28   arch = 'unknown'
29 end
30
31 purp = ''
32 if scope.lookupvar('site::nodeinfo').has_key?('nameinfo')
33   purp += " " + wrap(scope.lookupvar('site::nodeinfo')['nameinfo']) + "\n"
34 end
35
36 ninfo = scope.lookupvar('site::nodeinfo')
37
38 extra = 'Welcome to ' + fqdn
39 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('purpose'))
40   p = scope.lookupvar('site::nodeinfo')['ldap']['purpose'].clone()
41   entries = ""
42
43   if p.delete('buildd')
44     entries += ", the Debian #{arch} build daemon"
45   end
46   if p.delete('porterbox') or classes.include?("porterbox")
47     entries += ", the Debian #{arch} porterbox"
48   end
49
50   if p.size() > 0
51     entries += (entries == "") ? ", " : ".  Also"
52     entries +="used for the following services:\n"
53     scope.lookupvar('site::nodeinfo')['ldap']['purpose'].sort.each do |l|
54       l = markup(l)
55       entries += "\t#{l}\n"
56     end
57   else
58     entries += ".\n"
59   end
60   extra += entries
61 else
62   extra += "."
63 end
64 purp += " " + wrap(extra)
65
66 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('physicalHost'))
67   if ninfo['ldap']['physicalHost'][0] =~ /ganeti/
68     phys_host = 'cluster'
69   else
70     phys_host = 'physical host'
71   end
72   purp += wrap(" This virtual server runs on the #{phys_host} #{ninfo['ldap']['physicalHost'][0]}, " +
73                "which is hosted at #{ninfo['hoster']['longname']}."
74                )
75 elsif scope.lookupvar('site::nodeinfo')['hoster']['name']
76   purp += wrap(" This server is hosted at #{ninfo['hoster']['longname']}.")
77 end
78
79
80 vms = []
81 scope.lookupvar('site::allnodeinfo').keys.sort.each do |node|
82   if scope.lookupvar('site::allnodeinfo')[node]['physicalHost'] and scope.lookupvar('site::allnodeinfo')[node]['physicalHost'].include?(fqdn)
83     vms << node
84   end
85 end
86 unless vms.empty?
87   purp += "\nThe following virtual machines run on this system:\n"
88   vms.each do |node|
89     purp += "\t- #{node}"
90     if scope.lookupvar('site::allnodeinfo')[node]['purpose']
91       purp += ":\n"
92       scope.lookupvar('site::allnodeinfo')[node]['purpose'].sort.each do |l|
93         l = markup(l)
94         purp += "\t    " + l + "\n"
95       end
96     else
97       purp += "\n"
98     end
99   end
100 end
101
102
103 if scope.lookupvar('::cluster').to_s != 'undefined'
104   purp += "\n This server is a node in ganeti cluster: "
105   purp += scope.lookupvar('::cluster').to_s + ":\n"
106   purp += "\t" + scope.lookupvar('::cluster_nodes').to_s.split.sort.map{ |x| x.split('.')[0] }.join(", ") + ".\n"
107
108   if @lsbmajdistrelease >= '7'
109     purp += ""
110     purp += "\tCurrently the master node is $(cat /var/lib/ganeti/ssconf_master_node).\n"
111   end
112   #nodes = scope.lookupvar('::cluster_nodes').to_s.split.sort
113   #nodes.each do |node|
114   #  purp += "\t" + node + "\n"
115   #end
116   #nodes.reject{|node| node.eql?(fqdn)}.each do |node|
117   #  purp += "\t" + node + "\n"
118   #  scope.lookupvar('site::allnodeinfo')[node]['ipHostNumber'].each do |ip|
119   #    purp += "\t\t" + ip + "\n"
120   #  end
121   #end
122 end
123
124
125 if classes.include?("porterbox")
126   purp += "\n " + wrap("Disk space on porter boxes is often limited.  Please respect your fellow porters by cleaning up after yourself and deleting schroots and source/build trees in your ~ as soon as feasible.  DSA reserves the right to recover disk space as necessary.  See <URL:http://dsa.debian.org/doc/schroot/> for a brief tutorial on using schroot.")
127 end
128
129 if ninfo['not-bacula-client'] then
130   purp += "\n " + wrap("Note that this host is _NOT_ being backed up.  If you care about your data, run your own backups.")
131 end
132
133 if scope.lookupvar('site::nodeinfo').has_key?('footer')
134   purp += "\n" + wrap(scope.lookupvar('site::nodeinfo')['footer'])
135 end
136
137 purp
138 -%>
139
140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141
142 <% if @lsbmajdistrelease >= '7' -%>
143 EOD
144 <% end -%>
145 <%
146 # vim:set et:
147 # vim:set sts=2 ts=2:
148 # vim:set shiftwidth=2:
149 -%>