]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/motd/templates/motd.erb
56328234f210df15ccef8e7a9a97e8a0f996d2ac
[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   s.split("\n").map{ |x|
18     if (x.length > width) then
19       #x.gsub!(/(.{1,#{width}}) +(?=\S)/, "\\1\n ")
20       x.gsub!(/(.{1,#{width}})( +|\Z)/, "\\1\n ")
21     end
22     x
23   }.join("\n")+"\n"
24 end
25
26 def markup(l)
27   l = l.gsub(/\[\[(.*?)\|(.*?)\]\]/, '\2')
28   l = l.gsub(/\[\[(\*|-)?(.*?)\]\]/, '\2')
29   return l
30 end
31
32 if scope.lookupvar('site::nodeinfo')['ldap'].has_key?('architecture')
33   arch = scope.lookupvar('site::nodeinfo')['ldap']['architecture'][0]
34 else
35   arch = 'unknown'
36 end
37
38 purp = ''
39 if scope.lookupvar('site::nodeinfo').has_key?('nameinfo')
40   purp += " " + wrap(scope.lookupvar('site::nodeinfo')['nameinfo']) + "\n"
41 end
42
43 ninfo = scope.lookupvar('site::nodeinfo')
44
45 extra = 'Welcome to ' + fqdn
46 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('purpose'))
47   p = scope.lookupvar('site::nodeinfo')['ldap']['purpose'].clone()
48   entries = ""
49
50   if p.delete('buildd')
51     entries += ", the Debian #{arch} build daemon"
52   end
53   if p.delete('porterbox') or classes.include?("porterbox")
54     entries += ", the Debian #{arch} porterbox"
55   end
56
57   if p.size() > 0
58     entries += (entries == "") ? ", " : ".  Also"
59     entries +="used for the following services:\n"
60     scope.lookupvar('site::nodeinfo')['ldap']['purpose'].sort.each do |l|
61       l = markup(l)
62       entries += "\t#{l}\n"
63     end
64   else
65     entries += ".\n"
66   end
67   extra += entries
68 else
69   extra += "."
70 end
71 purp += " " + wrap(extra) + "\n"
72
73 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('physicalHost'))
74   if ninfo['ldap']['physicalHost'][0] =~ /ganeti/
75     phys_host = 'cluster'
76   else
77     phys_host = 'physical host'
78   end
79   purp += wrap(" This virtual server runs on the #{phys_host} #{ninfo['ldap']['physicalHost'][0]}, " +
80                "which is hosted at #{ninfo['hoster']['longname']}."
81                )
82 elsif scope.lookupvar('site::nodeinfo')['hoster']['name']
83   purp += wrap(" This server is hosted at #{ninfo['hoster']['longname']}.")
84 end
85
86
87 vms = []
88 scope.lookupvar('site::allnodeinfo').keys.sort.each do |node|
89   if scope.lookupvar('site::allnodeinfo')[node]['physicalHost'] and scope.lookupvar('site::allnodeinfo')[node]['physicalHost'].include?(fqdn)
90     vms << node
91   end
92 end
93 unless vms.empty?
94   purp += "\nThe following virtual machines run on this system:\n"
95   vms.each do |node|
96     purp += "\t- #{node}"
97     if scope.lookupvar('site::allnodeinfo')[node]['purpose']
98       purp += ":\n"
99       scope.lookupvar('site::allnodeinfo')[node]['purpose'].sort.each do |l|
100         l = markup(l)
101         purp += "\t    " + l + "\n"
102       end
103     else
104       purp += "\n"
105     end
106   end
107 end
108
109
110 if scope.lookupvar('::cluster')
111   purp += "\n This server is a node in ganeti cluster: "
112   purp += scope.lookupvar('::cluster').to_s + ":\n"
113   purp += "\t" + scope.lookupvar('::cluster_nodes').split.sort.map{ |x| x.split('.')[0] }.join(", ") + ".\n"
114
115   if @lsbmajdistrelease >= '7'
116     purp += ""
117     purp += "\tCurrently the master node is $(cat /var/lib/ganeti/ssconf_master_node).\n"
118   end
119   #nodes = scope.lookupvar('::cluster_nodes').sort
120   #nodes.each do |node|
121   #  purp += "\t" + node + "\n"
122   #end
123   #nodes.reject{|node| node.eql?(fqdn)}.each do |node|
124   #  purp += "\t" + node + "\n"
125   #  scope.lookupvar('site::allnodeinfo')[node]['ipHostNumber'].each do |ip|
126   #    purp += "\t\t" + ip + "\n"
127   #  end
128   #end
129 end
130
131
132 if classes.include?("porterbox")
133   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.  There may be chroots for architectures other than #{arch} available, please list available chroots to check.")
134 end
135
136 if ninfo['not-bacula-client'] then
137   purp += "\n " + wrap("Note that this host is _NOT_ being backed up.  If you care about your data, run your own backups.")
138 end
139
140 if scope.lookupvar('site::nodeinfo').has_key?('footer')
141   purp += "\n" + wrap(scope.lookupvar('site::nodeinfo')['footer'])
142 end
143
144 purp
145 -%>
146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147
148 <% if @lsbmajdistrelease >= '7' -%>
149 EOD
150 <% end -%>
151 <%
152 # vim:set et:
153 # vim:set sts=2 ts=2:
154 # vim:set shiftwidth=2:
155 -%>