]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/motd/templates/motd.erb
Replace porterbox motd with link to wiki.
[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 purp = ''
26 if scope.lookupvar('site::nodeinfo').has_key?('nameinfo')
27   purp += wrap(scope.lookupvar('site::nodeinfo')['nameinfo']) + "\n\n"
28 end
29
30 ninfo = scope.lookupvar('site::nodeinfo')
31
32 purp += 'Welcome to ' + fqdn
33 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('purpose'))
34   p = scope.lookupvar('site::nodeinfo')['ldap']['purpose'].clone()
35   extra = ''
36
37   if p.delete('buildd')
38     purp += ", the Debian "
39     if scope.lookupvar('site::nodeinfo')['ldap'].has_key?('architecture')
40       purp += scope.lookupvar('site::nodeinfo')['ldap']['architecture'][0]
41     end
42     purp += " build daemon"
43   end
44
45   if p.delete('porterbox')
46     purp += ", the Debian "
47     if scope.lookupvar('site::nodeinfo')['ldap'].has_key?('architecture')
48       purp += scope.lookupvar('site::nodeinfo')['ldap']['architecture'][0]
49     end
50     purp += " porterbox"
51     extra += "\n"
52     if classes.include?("porterbox")
53       extra += "For an introduction to the porterbox 'schroot' tool, see:\n"
54       extra += "  <URL:http://dsa.debian.org/doc/schroot/>.\n"
55     else
56       extra += "See 'dchroot -l' or 'schroot -l' for a list of available chroots.\n"
57       if scope.lookupvar('site::nodeinfo')['ldap'].has_key?('admin')
58         extra += "Please contact #{ninfo['ldap']['admin'][0]} for install requests,\n"
59         extra += "following the recommendations in <URL:http://dsa.debian.org/doc/install-req/>.\n"
60       end
61     end
62   end
63
64   if p.size() > 0
65     purp += ", used for the following services:\n"
66     scope.lookupvar('site::nodeinfo')['ldap']['purpose'].sort.each do |l|
67       l = markup(l)
68       purp += "\t" + l + "\n"
69     end
70   else
71     purp += ".\n"
72   end
73
74   purp += extra
75 else
76   purp += ".\n"
77 end
78
79 purp += "\n"
80
81 if (scope.lookupvar('site::nodeinfo')['ldap'].has_key?('physicalHost'))
82   if ninfo['ldap']['physicalHost'][0] =~ /ganeti/
83     phys_host = 'cluster'
84   else
85     phys_host = 'physical host'
86   end
87   purp += wrap("This virtual server runs on the #{phys_host} #{ninfo['ldap']['physicalHost'][0]}, " +
88                "which is hosted at #{ninfo['hoster']['longname']}."
89                )
90 elsif scope.lookupvar('site::nodeinfo')['hoster']['name']
91   purp += wrap("This server is hosted at #{ninfo['hoster']['longname']}.")
92 end
93
94
95 vms = []
96 scope.lookupvar('site::allnodeinfo').keys.sort.each do |node|
97   if scope.lookupvar('site::allnodeinfo')[node]['physicalHost'] and scope.lookupvar('site::allnodeinfo')[node]['physicalHost'].include?(fqdn)
98     vms << node
99   end
100 end
101 unless vms.empty?
102   purp += "\nThe following virtual machines run on this system:\n"
103   vms.each do |node|
104     purp += "\t- #{node}"
105     if scope.lookupvar('site::allnodeinfo')[node]['purpose']
106       purp += ":\n"
107       scope.lookupvar('site::allnodeinfo')[node]['purpose'].sort.each do |l|
108         l = markup(l)
109         purp += "\t    " + l + "\n"
110       end
111     else
112       purp += "\n"
113     end
114   end
115 end
116
117
118 if scope.lookupvar('::cluster').to_s != 'undefined'
119   purp += "\nThis server is a node in ganeti cluster: "
120   purp += scope.lookupvar('::cluster').to_s + ":\n"
121   purp += "\t" + scope.lookupvar('::cluster_nodes').to_s.split.sort.map{ |x| x.split('.')[0] }.join(", ") + ".\n"
122
123   if @lsbmajdistrelease >= '7'
124     purp += ""
125     purp += "\tCurrently the master node is $(cat /var/lib/ganeti/ssconf_master_node).\n"
126   end
127   #nodes = scope.lookupvar('::cluster_nodes').to_s.split.sort
128   #nodes.each do |node|
129   #  purp += "\t" + node + "\n"
130   #end
131   #nodes.reject{|node| node.eql?(fqdn)}.each do |node|
132   #  purp += "\t" + node + "\n"
133   #  scope.lookupvar('site::allnodeinfo')[node]['ipHostNumber'].each do |ip|
134   #    purp += "\t\t" + ip + "\n"
135   #  end
136   #end
137 end
138
139
140 if scope.lookupvar('site::nodeinfo').has_key?('footer')
141   purp += "\n" + wrap(scope.lookupvar('site::nodeinfo')['footer']) + "\n"
142 end
143
144 purp
145 -%>
146
147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148
149 <% if @lsbmajdistrelease >= '7' -%>
150 EOD
151 <% end -%>
152 <%
153 # vim:set et:
154 # vim:set sts=2 ts=2:
155 # vim:set shiftwidth=2:
156 -%>