Commit | Line | Data |
---|---|---|
9a4c122a AC |
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 | |
95a4653e | 17 | val id = Ip.add {usr = Init.getUserId (), node = nodeNum, data = $"req", msg = $"msg"}; |
9a4c122a AC |
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> | |
6b8b767b | 31 | <tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr> |
9a4c122a AC |
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> | |
ccb53e5b AC |
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> | |
3fa0efda | 55 | <li> Run <tt>domtool-admin grant <i><% name %></i> ip 69.90.123.<i>NNN</i></tt> |
ccb53e5b | 56 | </ol> |
9a4c122a AC |
57 | <% end %> |
58 | ||
59 | <% end | |
60 | ||
61 | elseif $"cmd" = "list" then | |
62 | %><h3>All requests</h3><% | |
63 | ||
64 | foreach (name, req) in Ip.list () do %> | |
65 | <br><hr><br> | |
66 | <table class="blanks"> | |
67 | <tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr> | |
6b8b767b | 68 | <tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr> |
9a4c122a AC |
69 | <tr> <td>Node:</td> <td><% Web.html (Init.nodeName (#node req)) %></td> </tr> |
70 | <tr> <td>Port:</td> <td><% #data req %></td> </tr> | |
71 | <tr> <td>Reason:</td> <td><% Web.html (#msg req) %></td> </tr> | |
72 | </table> | |
73 | ||
74 | <% if admin then %> | |
75 | <br> | |
76 | <a href="ip?mod=<% #id req %>">[Modify]</a> | |
77 | <a href="ip?del=<% #id req %>">[Delete]</a> | |
78 | <% end %> | |
79 | ||
80 | <% end | |
81 | ||
82 | elseif $"mod" <> "" then | |
83 | Group.requireGroupName "server"; | |
84 | val id = Web.stoi ($"mod"); | |
85 | val req = Ip.lookup id; | |
86 | val user = Init.lookupUser (#usr req) %> | |
87 | <h3>Handle request</h3> | |
88 | ||
89 | <form method="post"> | |
90 | <input type="hidden" name="save" value="<% id %>"> | |
91 | <table class="blanks"> | |
92 | <tr> <td>Requestor:</td> <td><a href="user?id=<% #usr req %>"><% #name user %></a></td> </tr> | |
6b8b767b | 93 | <tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr> |
9a4c122a AC |
94 | <tr> <td>Node:</td> <td><select name="node"> |
95 | <% foreach node in Init.listNodes () do %> | |
96 | <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> | |
97 | <% end %> | |
98 | </select> | |
99 | <tr> <td>Status:</td> <td><select name="status"> | |
100 | <option value="0"<% if #status req = Ip.NEW then %> selected<% end %>>New</option> | |
101 | <option value="1"<% if #status req = Ip.INSTALLED then %> selected<% end %>>Installed</option> | |
102 | <option value="2"<% if #status req = Ip.REJECTED then %> selected<% end %>>Rejected</option> | |
103 | </select></td> </tr> | |
104 | <tr> <td>Port:</td> <td><input name="port" size="6" value="<% Web.html (#data req) %>"></td> </tr> | |
105 | <tr> <td>Message:</td> <td><textarea name="msg" rows="10" cols="80" wrap="soft"><% Web.html (#msg req) %></textarea></td> </tr> | |
106 | <tr> <td><input type="submit" value="Save"></td> </tr> | |
107 | </table> | |
108 | </form> | |
109 | ||
110 | <% elseif $"save" <> "" then | |
111 | Group.requireGroupName "server"; | |
112 | val id = Web.stoi ($"save"); | |
113 | val node = Web.stoi ($"node"); | |
114 | val req = Ip.lookup id; | |
115 | val oldStatus = #status req; | |
116 | val newStatus = Ip.statusFromInt (Web.stoi ($"status")); | |
117 | Ip.modify {req with node = node, data = $"port", msg = $"msg", status = newStatus}; | |
8812fb4d AC |
118 | if not (Ip.notifyMod {old = oldStatus, new = newStatus, changer = Init.getUserName(), req = id}) then |
119 | %><h3>Error sending e-mail notification</h3><% | |
9a4c122a AC |
120 | end |
121 | %><h3>Request modified</h3> | |
122 | Back to: <a href="ip?cmd=open">open requests</a>, <a href="ip?cmd=list">all requests</a> | |
123 | ||
124 | <% elseif $"del" <> "" then | |
125 | Group.requireGroupName "server"; | |
126 | val id = Web.stoi ($"del"); | |
127 | val req = Ip.lookup id; | |
128 | val user = Init.lookupUser (#usr req) | |
129 | %><h3>Are you sure you want to delete request by <% #name user %> for <tt><% #data req %></tt>?</h3> | |
130 | <a href="ip?del2=<% id %>">Yes, I'm sure!</a> | |
131 | ||
132 | <% elseif $"del2" <> "" then | |
133 | Group.requireGroupName "server"; | |
134 | val id = Web.stoi ($"del2"); | |
135 | Ip.delete id | |
136 | %><h3>Request deleted</b><h3> | |
137 | Back to: <a href="ip?cmd=open">open requests</a>, <a href="ip?cmd=list">all requests</a> | |
138 | ||
139 | <% else %> | |
140 | ||
141 | <h3>Request an IP address</h3> | |
142 | ||
143 | <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> | |
144 | ||
145 | <form method="post"> | |
146 | <input type="hidden" name="new" value="1"> | |
147 | <table class="blanks"> | |
148 | <tr> <td>Machine:</td> <td><select name="node"> | |
149 | <% foreach node in Init.listNodes () do %> | |
150 | <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> | |
151 | <% end %> | |
152 | </select></td></tr> | |
153 | <tr> <td>Port#:</td> <td><input name="port" size="6" value="443"></td> </tr> | |
154 | <tr> <td>Reason:</td> <td><textarea name="msg" rows="5" cols="80" wrap="soft"></textarea></td> </tr> | |
155 | <tr> <td><input type="submit" value="Request"></td> </tr> | |
156 | </table> | |
157 | </form> | |
158 | ||
159 | <% end %> | |
160 | ||
161 | <% @footer[] %> |