Try to avoid reserved site keyword
[mirror/dsa-puppet.git] / modules / motd / templates / motd.erb
1 <%- if scope.call_function('versioncmp', [@lsbmajdistrelease, '8']) <= 0 -%>
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:https://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('deprecated::nodeinfo')['ldap'].has_key?('architecture')
33   arch = scope.lookupvar('deprecated::nodeinfo')['ldap']['architecture'][0]
34 else
35   arch = 'unknown'
36 end
37
38 purp = ''
39 if scope.lookupvar('deprecated::nodeinfo').has_key?('nameinfo')
40   purp += " " + wrap(scope.lookupvar('deprecated::nodeinfo')['nameinfo']) + "\n"
41 end
42
43 ninfo = scope.lookupvar('deprecated::nodeinfo')
44
45 extra = 'Welcome to ' + @fqdn
46 if (scope.lookupvar('deprecated::nodeinfo')['ldap'].has_key?('purpose'))
47   p = scope.lookupvar('deprecated::nodeinfo')['ldap']['purpose'].clone()
48   entries = ""
49
50   if classes.include?("roles::buildd")
51     entries += ", the Debian #{arch} build daemon"
52     p.delete('buildd')
53   end
54   if classes.include?("roles::porterbox")
55     entries += ", the Debian #{arch} porterbox"
56     p.delete('porterbox')
57   end
58
59   if p.size() > 0
60     entries += (entries == "") ? ", " : ".  Also "
61     entries +="used for the following services:\n"
62     scope.lookupvar('deprecated::nodeinfo')['ldap']['purpose'].sort.each do |l|
63       l = markup(l)
64       entries += "\t#{l}\n"
65     end
66   else
67     entries += ".\n"
68   end
69   extra += entries
70 else
71   extra += "."
72 end
73 purp += " " + wrap(extra) + "\n"
74
75 if (scope.lookupvar('deprecated::nodeinfo')['ldap'].has_key?('physicalHost'))
76   if ninfo['ldap']['physicalHost'][0] =~ /ganeti/
77     phys_host = 'cluster'
78   else
79     phys_host = 'physical host'
80   end
81   purp += wrap(" This virtual server runs on the #{phys_host} #{ninfo['ldap']['physicalHost'][0]}, " +
82                "which is hosted at #{ninfo['hoster']['longname']}."
83                )
84 elsif scope.lookupvar('deprecated::nodeinfo')['hoster']['name']
85   purp += wrap(" This server is hosted at #{ninfo['hoster']['longname']}.")
86 end
87
88
89 vms = []
90 scope.lookupvar('deprecated::allnodeinfo').keys.sort.each do |node|
91   if scope.lookupvar('deprecated::allnodeinfo')[node]['physicalHost'] and scope.lookupvar('site::allnodeinfo')[node]['physicalHost'].include?(@fqdn)
92     vms << node
93   end
94 end
95 unless vms.empty?
96   purp += "\nThe following virtual machines run on this system:\n"
97   vms.each do |node|
98     purp += "\t- #{node}"
99     if scope.lookupvar('deprecated::allnodeinfo')[node]['purpose']
100       purp += ":\n"
101       scope.lookupvar('deprecated::allnodeinfo')[node]['purpose'].sort.each do |l|
102         l = markup(l)
103         purp += "\t    " + l + "\n"
104       end
105     else
106       purp += "\n"
107     end
108   end
109 end
110
111
112 if scope.lookupvar('::cluster')
113   purp += "\n This server is a node in ganeti cluster: "
114   purp += scope.lookupvar('::cluster').to_s + ":\n"
115   purp += "\t" + scope.lookupvar('::cluster_nodes').split.sort.map{ |x| x.split('.')[0] }.join(", ") + ".\n"
116
117   purp += ""
118   purp += "\tCurrently the master node is $(cat /var/lib/ganeti/ssconf_master_node).\n"
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('deprecated::allnodeinfo')[node]['ipHostNumber'].each do |ip|
126   #    purp += "\t\t" + ip + "\n"
127   #  end
128   #end
129 end
130
131
132 if classes.include?("roles::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:https://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 classes.include?('bacula::not_a_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('deprecated::nodeinfo').has_key?('footer')
141   purp += "\n" + wrap(scope.lookupvar('deprecated::nodeinfo')['footer'])
142 end
143
144 purp
145 -%>
146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147
148 <%- if scope.call_function('versioncmp', [@lsbmajdistrelease, '8']) <= 0 -%>
149 EOD
150 <%- end -%>
151 <%
152 # vim:set et:
153 # vim:set sts=2 ts=2:
154 # vim:set shiftwidth=2:
155 -%>