Replace cgiirc with a form frontend for webchat.oftc.net
authorTom Hughes <tom@compton.nu>
Thu, 5 Mar 2020 20:13:28 +0000 (20:13 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 5 Mar 2020 20:14:30 +0000 (20:14 +0000)
13 files changed:
.github/workflows/test-kitchen.yml
.kitchen.yml
cookbooks/cgiirc/README.md [deleted file]
cookbooks/cgiirc/templates/default/cgiirc.config.erb [deleted file]
cookbooks/cgiirc/templates/default/ipaccess.erb [deleted file]
cookbooks/irc/README.md [new file with mode: 0644]
cookbooks/irc/files/default/html/index.html [new file with mode: 0644]
cookbooks/irc/files/default/html/style.css [new file with mode: 0644]
cookbooks/irc/metadata.rb [moved from cookbooks/cgiirc/metadata.rb with 72% similarity]
cookbooks/irc/recipes/default.rb [moved from cookbooks/cgiirc/recipes/default.rb with 77% similarity]
cookbooks/irc/templates/default/apache.erb [moved from cookbooks/cgiirc/templates/default/apache.erb with 60% similarity]
roles/irc.rb
test/integration/irc/serverspec/apache_spec.rb [new file with mode: 0644]

index 613addabd8e243c9f0a693e43f7010a8a3899edd..27cc47d85c156de68cb4d875e3d9ee4819debd27 100644 (file)
@@ -40,6 +40,7 @@ jobs:
           - hardware
           - hot
           - incron
+          - irc
           - kibana
           - letsencrypt
           - logstash
index c116e2411ab8597fe899871e1d1e14372ed7cef2..a9e3949c96a33584d1e67d5eeb1becbd49bce0e3 100644 (file)
@@ -141,6 +141,9 @@ suites:
   - name: incron
     run_list:
       - recipe[incron::default]
+  - name: irc
+    run_list:
+      - recipe[irc::default]
   - name: kibana
     run_list:
       - recipe[kibana::default]
diff --git a/cookbooks/cgiirc/README.md b/cookbooks/cgiirc/README.md
deleted file mode 100644 (file)
index 49eeb3d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# Cgiirc Cookbook
-
-This cookbook installs and configures the `cgiirc` program that powers the
-web interface to the OSM IRC channels, found at irc.openstreetmap.org
diff --git a/cookbooks/cgiirc/templates/default/cgiirc.config.erb b/cookbooks/cgiirc/templates/default/cgiirc.config.erb
deleted file mode 100644 (file)
index 794b4cb..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-# CGI:IRC configuration file.
-#
-# Check /usr/share/doc/cgiirc/examples/cgiirc.config.full.gz
-# for more details.
-
-# Configure defaults
-default_server = irc.oftc.net
-default_port = 6667
-default_channel = #osm,#osm-dev,#osm-ewg,#osm-cwg,#osm-ar,#osm-asia,#osm-au,#osm-br,#osm-bw,#osm-by,#osm-ca,#osm-ch,#osm-cz,#osm-de,#osm-dk,#osm-es,#osm-fi,#osm-fr,#osm-gb,#osm-gr,#osm-gsoc,#osm-ht,#osm-ie,#osm-it,#osm-ke,#osm-latam,#osm-local,#osm-lv,#osm-nl,#osm-no,#osm-nominatim,#osm-pl,#osm-pt,#osm-ru,#osm.se,#osm-strategic,#osm-ua,#osm-us,#osm-za,#osm-zh,#osmf-gm,#osrm,#openrailwaymap,#hot
-default_name = CGI:IRC User
-default_nick = CGI???
-
-# Path to images
-image_path = /images
-
-# Paths to CGI scripts
-script_nph = nph-irc.cgi
-script_form = client-perl.cgi
-script_login = irc.cgi
-
-# Access control file
-ip_access_file = ipaccess
diff --git a/cookbooks/cgiirc/templates/default/ipaccess.erb b/cookbooks/cgiirc/templates/default/ipaccess.erb
deleted file mode 100644 (file)
index ba2851c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# DO NOT EDIT - This file is being maintained by Chef
-
-# CGI:IRC ipaccess file. (For CGI:IRC versions from 0.5.3).
-#
-# Check /usr/share/doc/cgiirc/examples/ipaccess.example
-# for more details.
-
-<% @blocks.each do |name,addresses| -%>
-# Block <%= name %>
-<% addresses.each do |address| -%>
-<%= address %> 0
-<% end -%>
-
-<% end -%>
-# Allow everybody.
-0.0.0.0/0
diff --git a/cookbooks/irc/README.md b/cookbooks/irc/README.md
new file mode 100644 (file)
index 0000000..051982f
--- /dev/null
@@ -0,0 +1,3 @@
+# Irc Cookbook
+
+This cookbook installs and configures the irc.openstreetmap.org web site.
diff --git a/cookbooks/irc/files/default/html/index.html b/cookbooks/irc/files/default/html/index.html
new file mode 100644 (file)
index 0000000..3e770fd
--- /dev/null
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>irc.openstreetmap.org</title>
+    <link rel="stylesheet" href="style.css" />
+  </head>
+  <body>
+    <h1>irc.openstreetmap.org</h1>
+    <form method="get" action="https://webchat.oftc.net/">
+      <table>
+        <tr>
+          <th>Nickname</th>
+          <td><input name="nick" type="text" /></td>
+        </tr>
+        <tr>
+          <th>Channel</th>
+          <td>
+            <select name="channels">
+              <option value="#osm">#osm</option>
+              <option value="#osm-dev">#osm-dev</option>
+              <option value="#osm-ewg">#osm-ewg</option>
+              <option value="#osm-cwg">#osm-cwg</option>
+              <option value="#osm-ar">#osm-ar</option>
+              <option value="#osm-asia">#osm-asia</option>
+              <option value="#osm-au">#osm-au</option>
+              <option value="#osm-br">#osm-br</option>
+              <option value="#osm-bw">#osm-bw</option>
+              <option value="#osm-by">#osm-by</option>
+              <option value="#osm-ca">#osm-ca</option>
+              <option value="#osm-ch">#osm-ch</option>
+              <option value="#osm-cz">#osm-cz</option>
+              <option value="#osm-de">#osm-de</option>
+              <option value="#osm-dk">#osm-dk</option>
+              <option value="#osm-es">#osm-es</option>
+              <option value="#osm-fi">#osm-fi</option>
+              <option value="#osm-fr">#osm-fr</option>
+              <option value="#osm-gb">#osm-gb</option>
+              <option value="#osm-gr">#osm-gr</option>
+              <option value="#osm-gsoc">#osm-gsoc</option>
+              <option value="#osm-ht">#osm-ht</option>
+              <option value="#osm-ie">#osm-ie</option>
+              <option value="#osm-it">#osm-it</option>
+              <option value="#osm-ke">#osm-ke</option>
+              <option value="#osm-latam">#osm-latam</option>
+              <option value="#osm-local">#osm-local</option>
+              <option value="#osm-lv">#osm-lv</option>
+              <option value="#osm-nl">#osm-nl</option>
+              <option value="#osm-no">#osm-no</option>
+              <option value="#osm-nominatim">#osm-nominatim</option>
+              <option value="#osm-pl">#osm-pl</option>
+              <option value="#osm-pt">#osm-pt</option>
+              <option value="#osm-ru">#osm-ru</option>
+              <option value="#osm.se">#osm.se</option>
+              <option value="#osm-strategic">#osm-strategic</option>
+              <option value="#osm-ua">#osm-ua</option>
+              <option value="#osm-us">#osm-us</option>
+              <option value="#osm-za">#osm-za</option>
+              <option value="#osm-zh">#osm-zh</option>
+              <option value="#osmf-gm">#osmf-gm</option>
+              <option value="#osrm">#osrm</option>
+              <option value="#openrailwaymap">#openrailwaymap</option>
+              <option value="#hot">#hot</option>
+            </select>
+          </td>
+        </tr>
+        <tr>
+          <th></th>
+          <td><input type="submit" value="Connect" /></td>
+        </tr>
+      </table>
+    </form>
+  </body>
+</html>
diff --git a/cookbooks/irc/files/default/html/style.css b/cookbooks/irc/files/default/html/style.css
new file mode 100644 (file)
index 0000000..ba5a1cd
--- /dev/null
@@ -0,0 +1,9 @@
+h1 {
+  display: inline-block;
+  text-align: center;
+}
+
+form {
+  display: inline-block;
+  text-align: center;
+}
similarity index 72%
rename from cookbooks/cgiirc/metadata.rb
rename to cookbooks/irc/metadata.rb
index 3b4b8207171a401ec66b0e8ea592af207e52ca81..6e745f6e6c2ef9c399190f602a6eb66f3486fe61 100644 (file)
@@ -1,8 +1,8 @@
-name              "cgiirc"
+name              "irc"
 maintainer        "OpenStreetMap Administrators"
 maintainer_email  "admins@openstreetmap.org"
 license           "Apache-2.0"
-description       "Installs and configures cgiirc"
+description       "Configures irc.openstreetmap.org"
 
 version           "1.0.0"
 supports          "ubuntu"
similarity index 77%
rename from cookbooks/cgiirc/recipes/default.rb
rename to cookbooks/irc/recipes/default.rb
index 4e8a9c1cc934da05de1dacbcd7a35cb81075257f..238c17c8a5c0de1715162aed836ece60bed5c5ba 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Cookbook:: cgiirc
+# Cookbook:: irc
 # Recipe:: default
 #
 # Copyright:: 2011, OpenStreetMap Foundation
 
 include_recipe "apache"
 
-blocks = data_bag_item("cgiirc", "blocks")
-
-package "cgiirc"
+ssl_certificate "irc.openstreetmap.org" do
+  domains ["irc.openstreetmap.org", "irc.osm.org"]
+  notifies :reload, "service[apache2]"
+end
 
-template "/etc/cgiirc/cgiirc.config" do
-  source "cgiirc.config.erb"
+directory "/srv/irc.openstreetmap.org" do
   owner "root"
   group "root"
-  mode 0o644
+  mode 0755
 end
 
-template "/etc/cgiirc/ipaccess" do
-  source "ipaccess.erb"
+remote_directory "/srv/irc.openstreetmap.org/html" do
+  source "html"
   owner "root"
   group "root"
-  mode 0o644
-  variables :blocks => blocks["addresses"]
-end
-
-ssl_certificate "irc.openstreetmap.org" do
-  domains ["irc.openstreetmap.org", "irc.osm.org"]
-  notifies :reload, "service[apache2]"
+  mode 0o755
+  files_owner "root"
+  files_group "root"
+  files_mode 0o644
 end
 
 apache_site "irc.openstreetmap.org" do
   template "apache.erb"
+  directory "/srv/irc.openstreetmap.org/html"
   variables :aliases => ["irc.osm.org"]
 end
similarity index 60%
rename from cookbooks/cgiirc/templates/default/apache.erb
rename to cookbooks/irc/templates/default/apache.erb
index 1afb107ba1d2326fb69417c46796741b5c40c58d..ceb112e184fbbee3f9e15fa693f47c9648a28d2f 100644 (file)
   CustomLog /var/log/apache2/<%= @name %>-access.log combined
   ErrorLog /var/log/apache2/<%= @name %>-error.log
 
-  DocumentRoot /usr/lib/cgi-bin/cgiirc
-  DirectoryIndex irc.cgi
-  Alias /images /usr/share/images/cgiirc
-
-  <Directory "/usr/lib/cgi-bin/cgiirc">
-    AddHandler cgi-script .cgi
-    Require all granted
-  </Directory>
-
-  <Directory "/usr/share/images/cgiirc">
-    Require all granted
-  </Directory>
-
-  <IfModule mod_deflate.c>
-    RemoveOutputFilter DEFLATE
-    SetEnv no-gzip
-  </IfModule>
+  DocumentRoot <%= @directory %>
 </VirtualHost>
 <% unless @aliases.empty? -%>
 
 <% @aliases.each do |alias_name| -%>
   ServerAlias <%= alias_name %>
 <% end -%>
-       ServerAdmin webmaster@openstreetmap.org
+  ServerAdmin webmaster@openstreetmap.org
 
-       CustomLog /var/log/apache2/<%= @name %>-access.log combined
-       ErrorLog /var/log/apache2/<%= @name %>-error.log
+  CustomLog /var/log/apache2/<%= @name %>-access.log combined
+  ErrorLog /var/log/apache2/<%= @name %>-error.log
 
-       RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
-       RedirectPermanent / https://<%= @name %>/
+  RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
+  RedirectPermanent / https://<%= @name %>/
 </VirtualHost>
+
+<Directory <%= @directory %>>
+  Require all granted
+</Directory>
index f12e2691e9d0be208d120df607764f5bcbcb5934..732542e69a0350cc3460e6d1033336a97eecd0f8 100644 (file)
@@ -2,5 +2,5 @@ name "irc"
 description "Role applied to all IRC gateways"
 
 run_list(
-  "recipe[cgiirc]"
+  "recipe[irc]"
 )
diff --git a/test/integration/irc/serverspec/apache_spec.rb b/test/integration/irc/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+  it { should be_installed }
+end
+
+describe service("apache2") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(80) do
+  it { should be_listening.with("tcp") }
+end
+
+describe port(443) do
+  it { should be_listening.with("tcp") }
+end