IP address instructions
[bpt/portal.git] / ip.mlt
1 <% @header [("title", ["IP address requests"])];
2
3 val admin = Group.inGroupName "server";
4
5 val nodeNum = case $"node" of
6 "" => 2
7 | node => Web.stoi node;
8
9 if $"new" <> "" then
10 val port = Web.stoi ($"port");
11 val msg = $"msg";
12
13 %>Are you sure you want to ask for an IP address with port <% port %> free on machine <% Init.nodeName nodeNum %>?<br><br>
14 <a href="ip?node=<% nodeNum %>&req=<% port %>&msg=<% Web.urlEncode msg %>">Yes, I want to request that.</a>
15
16 <% elseif $"req" <> "" then
17 val id = Ip.add {usr = Init.getUserId (), node = nodeNum, data = $"req", msg = $"msg"};
18 if not (Ip.notifyNew id) then
19 %><h3>Error sending e-mail notification</h3><%
20 end
21 %><h3>Request added</h3><%
22
23 elseif $"cmd" = "open" then
24 %><h3>Open requests</h3>
25 <a href="ip?cmd=list">List all requests</a><%
26
27 foreach (name, req) in Ip.listOpen () do %>
28 <br><hr><br>
29 <table class="blanks">
30 <tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
31 <tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
32 <tr> <td>Node:</td> <td><% Web.html (Init.nodeName (#node req)) %></td> </tr>
33 <tr> <td>Port:</td> <td><% #data req %></td> </tr>
34 <tr> <td>Reason:</td> <td><% Web.html (#msg req) %></td> </tr>
35 </table>
36
37 <% if admin then %>
38 <br>
39 <a href="ip?mod=<% #id req %>">[Modify]</a>
40 <a href="ip?del=<% #id req %>">[Delete]</a><br>
41 To install: <ol>
42 <li> Choose a new IP address <tt>69.90.123.<i>NNN</i></tt> from those available.</li>
43 <li> Add new entry to <tt>/etc/network/interfaces</tt> on mire, where <tt><i>N</i></tt> is some incremented number.
44 <blockquote><pre>auto eth0:N
45 iface eth0:N inet static
46 address 69.90.123.NNN
47 netmask 255.255.255.224
48 network 69.90.123.64
49 </pre></blockquote></li>
50 <li> Edit <tt>/etc/apache2/ports.conf</tt> and add the following lines:
51 <blockquote><pre>Listen 69.90.123.NNN:80
52 Listen 69.90.123.NNN:443</pre></blockquote></li>
53 <li> Run <tt>ifup eth0:<i>N</i></tt>.
54 <li> Restart Apache with <tt>/etc/init.d/apache2 restart</tt>.</li>
55 </ol>
56 <% end %>
57
58 <% end
59
60 elseif $"cmd" = "list" then
61 %><h3>All requests</h3><%
62
63 foreach (name, req) in Ip.list () do %>
64 <br><hr><br>
65 <table class="blanks">
66 <tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
67 <tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
68 <tr> <td>Node:</td> <td><% Web.html (Init.nodeName (#node req)) %></td> </tr>
69 <tr> <td>Port:</td> <td><% #data req %></td> </tr>
70 <tr> <td>Reason:</td> <td><% Web.html (#msg req) %></td> </tr>
71 </table>
72
73 <% if admin then %>
74 <br>
75 <a href="ip?mod=<% #id req %>">[Modify]</a>
76 <a href="ip?del=<% #id req %>">[Delete]</a>
77 <% end %>
78
79 <% end
80
81 elseif $"mod" <> "" then
82 Group.requireGroupName "server";
83 val id = Web.stoi ($"mod");
84 val req = Ip.lookup id;
85 val user = Init.lookupUser (#usr req) %>
86 <h3>Handle request</h3>
87
88 <form method="post">
89 <input type="hidden" name="save" value="<% id %>">
90 <table class="blanks">
91 <tr> <td>Requestor:</td> <td><a href="user?id=<% #usr req %>"><% #name user %></a></td> </tr>
92 <tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
93 <tr> <td>Node:</td> <td><select name="node">
94 <% foreach node in Init.listNodes () do %>
95 <option value="<% #id node %>"<% if #id node = #node req then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>; Debian <% Web.html (#debian node) %>)</option>
96 <% end %>
97 </select>
98 <tr> <td>Status:</td> <td><select name="status">
99 <option value="0"<% if #status req = Ip.NEW then %> selected<% end %>>New</option>
100 <option value="1"<% if #status req = Ip.INSTALLED then %> selected<% end %>>Installed</option>
101 <option value="2"<% if #status req = Ip.REJECTED then %> selected<% end %>>Rejected</option>
102 </select></td> </tr>
103 <tr> <td>Port:</td> <td><input name="port" size="6" value="<% Web.html (#data req) %>"></td> </tr>
104 <tr> <td>Message:</td> <td><textarea name="msg" rows="10" cols="80" wrap="soft"><% Web.html (#msg req) %></textarea></td> </tr>
105 <tr> <td><input type="submit" value="Save"></td> </tr>
106 </table>
107 </form>
108
109 <% elseif $"save" <> "" then
110 Group.requireGroupName "server";
111 val id = Web.stoi ($"save");
112 val node = Web.stoi ($"node");
113 val req = Ip.lookup id;
114 val oldStatus = #status req;
115 val newStatus = Ip.statusFromInt (Web.stoi ($"status"));
116 Ip.modify {req with node = node, data = $"port", msg = $"msg", status = newStatus};
117 if oldStatus <> newStatus then
118 if not (Ip.notifyMod {old = oldStatus, new = newStatus, changer = Init.getUserName(), req = id}) then
119 %><h3>Error sending e-mail notification</h3><%
120 end
121 end
122 %><h3>Request modified</h3>
123 Back to: <a href="ip?cmd=open">open requests</a>, <a href="ip?cmd=list">all requests</a>
124
125 <% elseif $"del" <> "" then
126 Group.requireGroupName "server";
127 val id = Web.stoi ($"del");
128 val req = Ip.lookup id;
129 val user = Init.lookupUser (#usr req)
130 %><h3>Are you sure you want to delete request by <% #name user %> for <tt><% #data req %></tt>?</h3>
131 <a href="ip?del2=<% id %>">Yes, I'm sure!</a>
132
133 <% elseif $"del2" <> "" then
134 Group.requireGroupName "server";
135 val id = Web.stoi ($"del2");
136 Ip.delete id
137 %><h3>Request deleted</b><h3>
138 Back to: <a href="ip?cmd=open">open requests</a>, <a href="ip?cmd=list">all requests</a>
139
140 <% else %>
141
142 <h3>Request an IP address</h3>
143
144 <p>Use this form to request use of a particular port. If your request is granted, you will be assigned rights to your port on a particular IP address. The most common use of this form is to ask for an IP address to use with an SSL virtual web host. We will grant requests in very few other cases. Try to use free ports on the base IP address of one of the machines on which we grant member log-in.</p>
145
146 <form method="post">
147 <input type="hidden" name="new" value="1">
148 <table class="blanks">
149 <tr> <td>Machine:</td> <td><select name="node">
150 <% foreach node in Init.listNodes () do %>
151 <option value="<% #id node %>"<% if #id node = nodeNum then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>; Debian <% Web.html (#debian node) %>)</option>
152 <% end %>
153 </select></td></tr>
154 <tr> <td>Port#:</td> <td><input name="port" size="6" value="443"></td> </tr>
155 <tr> <td>Reason:</td> <td><textarea name="msg" rows="5" cols="80" wrap="soft"></textarea></td> </tr>
156 <tr> <td><input type="submit" value="Request"></td> </tr>
157 </table>
158 </form>
159
160 <% end %>
161
162 <% @footer[] %>