Mess some more with the motd
[mirror/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}})(\s+|\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 purp += ' Welcome to ' + fqdn
39 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('purpose'))
40   p = scope.lookupvar('site::nodeinfo')['ldap']['purpose'].clone()
41   extra = ''
42
43   if p.delete('buildd')
44     extra += ", the Debian #{arch} build daemon."
45   end
46   if p.delete('porterbox') or classes.include?("porterbox")
47     extra += ", the Debian #{arch} porterbox. See\n"+
48     extra += " <URL:http://dsa.debian.org/doc/schroot/> for a brief schroot tutorial."
49   end
50
51   if p.size() > 0
52     extra += (extra == "") ? ", " : " Also"
53     extra +="used for the following services:\n"
54     scope.lookupvar('site::nodeinfo')['ldap']['purpose'].sort.each do |l|
55       l = markup(l)
56       extra += "\t#{l}\n"
57     end
58   else
59     extra += ".\n"
60   end
61
62   purp += extra
63 else
64   purp += ".\n"
65 end
66
67 purp += "\n"
68
69 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('physicalHost'))
70   if ninfo['ldap']['physicalHost'][0] =~ /ganeti/
71     phys_host = 'cluster'
72   else
73     phys_host = 'physical host'
74   end
75   purp += wrap(" This virtual server runs on the #{phys_host} #{ninfo['ldap']['physicalHost'][0]}, " +
76                "which is hosted at #{ninfo['hoster']['longname']}."
77                )
78 elsif scope.lookupvar('site::nodeinfo')['hoster']['name']
79   purp += wrap(" This server is hosted at #{ninfo['hoster']['longname']}.")
80 end
81
82
83 vms = []
84 scope.lookupvar('site::allnodeinfo').keys.sort.each do |node|
85   if scope.lookupvar('site::allnodeinfo')[node]['physicalHost'] and scope.lookupvar('site::allnodeinfo')[node]['physicalHost'].include?(fqdn)
86     vms << node
87   end
88 end
89 unless vms.empty?
90   purp += "\nThe following virtual machines run on this system:\n"
91   vms.each do |node|
92     purp += "\t- #{node}"
93     if scope.lookupvar('site::allnodeinfo')[node]['purpose']
94       purp += ":\n"
95       scope.lookupvar('site::allnodeinfo')[node]['purpose'].sort.each do |l|
96         l = markup(l)
97         purp += "\t    " + l + "\n"
98       end
99     else
100       purp += "\n"
101     end
102   end
103 end
104
105
106 if scope.lookupvar('::cluster').to_s != 'undefined'
107   purp += "\n This server is a node in ganeti cluster: "
108   purp += scope.lookupvar('::cluster').to_s + ":\n"
109   purp += "\t" + scope.lookupvar('::cluster_nodes').to_s.split.sort.map{ |x| x.split('.')[0] }.join(", ") + ".\n"
110
111   if @lsbmajdistrelease >= '7'
112     purp += ""
113     purp += "\tCurrently the master node is $(cat /var/lib/ganeti/ssconf_master_node).\n"
114   end
115   #nodes = scope.lookupvar('::cluster_nodes').to_s.split.sort
116   #nodes.each do |node|
117   #  purp += "\t" + node + "\n"
118   #end
119   #nodes.reject{|node| node.eql?(fqdn)}.each do |node|
120   #  purp += "\t" + node + "\n"
121   #  scope.lookupvar('site::allnodeinfo')[node]['ipHostNumber'].each do |ip|
122   #    purp += "\t\t" + ip + "\n"
123   #  end
124   #end
125 end
126
127
128 if classes.include?("porterbox")
129   purp += "\n " + wrap("Disk space on porter boxes is often limited.  Please respect your fellow porters by cleaning up after yourself by deleting schroots and source/build trees in your $HOME, as soon as feasible.  DSA reserves the right to recover disk space as necessary.")
130 end
131
132 if ninfo['not-bacula-client'] then
133   purp += "\n " + wrap("Note that this host is _NOT_ being backed up.  If you care about your data, run your own backups.")
134 end
135
136 if scope.lookupvar('site::nodeinfo').has_key?('footer')
137   purp += "\n" + wrap(scope.lookupvar('site::nodeinfo')['footer'])
138 end
139
140 purp
141 -%>
142
143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
144
145 <% if @lsbmajdistrelease >= '7' -%>
146 EOD
147 <% end -%>
148 <%
149 # vim:set et:
150 # vim:set sts=2 ts=2:
151 # vim:set shiftwidth=2:
152 -%>