From 5844c5bc2edf22e4d6a4316f887adf758584a008 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 5 Mar 2020 20:13:28 +0000 Subject: [PATCH] Replace cgiirc with a form frontend for webchat.oftc.net --- .github/workflows/test-kitchen.yml | 1 + .kitchen.yml | 3 + cookbooks/cgiirc/README.md | 4 - .../templates/default/cgiirc.config.erb | 24 ------ .../cgiirc/templates/default/ipaccess.erb | 16 ---- cookbooks/irc/README.md | 3 + cookbooks/irc/files/default/html/index.html | 73 +++++++++++++++++++ cookbooks/irc/files/default/html/style.css | 9 +++ cookbooks/{cgiirc => irc}/metadata.rb | 4 +- cookbooks/{cgiirc => irc}/recipes/default.rb | 30 ++++---- .../templates/default/apache.erb | 32 +++----- roles/irc.rb | 2 +- .../integration/irc/serverspec/apache_spec.rb | 21 ++++++ 13 files changed, 137 insertions(+), 85 deletions(-) delete mode 100644 cookbooks/cgiirc/README.md delete mode 100644 cookbooks/cgiirc/templates/default/cgiirc.config.erb delete mode 100644 cookbooks/cgiirc/templates/default/ipaccess.erb create mode 100644 cookbooks/irc/README.md create mode 100644 cookbooks/irc/files/default/html/index.html create mode 100644 cookbooks/irc/files/default/html/style.css rename cookbooks/{cgiirc => irc}/metadata.rb (72%) rename cookbooks/{cgiirc => irc}/recipes/default.rb (77%) rename cookbooks/{cgiirc => irc}/templates/default/apache.erb (60%) create mode 100644 test/integration/irc/serverspec/apache_spec.rb diff --git a/.github/workflows/test-kitchen.yml b/.github/workflows/test-kitchen.yml index 613addabd..27cc47d85 100644 --- a/.github/workflows/test-kitchen.yml +++ b/.github/workflows/test-kitchen.yml @@ -40,6 +40,7 @@ jobs: - hardware - hot - incron + - irc - kibana - letsencrypt - logstash diff --git a/.kitchen.yml b/.kitchen.yml index c116e2411..a9e3949c9 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -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 index 49eeb3d54..000000000 --- a/cookbooks/cgiirc/README.md +++ /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 index 794b4cb01..000000000 --- a/cookbooks/cgiirc/templates/default/cgiirc.config.erb +++ /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 index ba2851cf2..000000000 --- a/cookbooks/cgiirc/templates/default/ipaccess.erb +++ /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 index 000000000..051982fe7 --- /dev/null +++ b/cookbooks/irc/README.md @@ -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 index 000000000..3e770fd8a --- /dev/null +++ b/cookbooks/irc/files/default/html/index.html @@ -0,0 +1,73 @@ + + + + irc.openstreetmap.org + + + +

irc.openstreetmap.org

+
+ + + + + + + + + + + + + +
Nickname
Channel + +
+
+ + diff --git a/cookbooks/irc/files/default/html/style.css b/cookbooks/irc/files/default/html/style.css new file mode 100644 index 000000000..ba5a1cd94 --- /dev/null +++ b/cookbooks/irc/files/default/html/style.css @@ -0,0 +1,9 @@ +h1 { + display: inline-block; + text-align: center; +} + +form { + display: inline-block; + text-align: center; +} diff --git a/cookbooks/cgiirc/metadata.rb b/cookbooks/irc/metadata.rb similarity index 72% rename from cookbooks/cgiirc/metadata.rb rename to cookbooks/irc/metadata.rb index 3b4b82071..6e745f6e6 100644 --- a/cookbooks/cgiirc/metadata.rb +++ b/cookbooks/irc/metadata.rb @@ -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" diff --git a/cookbooks/cgiirc/recipes/default.rb b/cookbooks/irc/recipes/default.rb similarity index 77% rename from cookbooks/cgiirc/recipes/default.rb rename to cookbooks/irc/recipes/default.rb index 4e8a9c1cc..238c17c8a 100644 --- a/cookbooks/cgiirc/recipes/default.rb +++ b/cookbooks/irc/recipes/default.rb @@ -1,5 +1,5 @@ # -# Cookbook:: cgiirc +# Cookbook:: irc # Recipe:: default # # Copyright:: 2011, OpenStreetMap Foundation @@ -19,31 +19,29 @@ 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 diff --git a/cookbooks/cgiirc/templates/default/apache.erb b/cookbooks/irc/templates/default/apache.erb similarity index 60% rename from cookbooks/cgiirc/templates/default/apache.erb rename to cookbooks/irc/templates/default/apache.erb index 1afb107ba..ceb112e18 100644 --- a/cookbooks/cgiirc/templates/default/apache.erb +++ b/cookbooks/irc/templates/default/apache.erb @@ -11,23 +11,7 @@ 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 - - - AddHandler cgi-script .cgi - Require all granted - - - - Require all granted - - - - RemoveOutputFilter DEFLATE - SetEnv no-gzip - + DocumentRoot <%= @directory %> <% unless @aliases.empty? -%> @@ -54,11 +38,15 @@ <% @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 %>/ + +> + Require all granted + diff --git a/roles/irc.rb b/roles/irc.rb index f12e2691e..732542e69 100644 --- a/roles/irc.rb +++ b/roles/irc.rb @@ -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 index 000000000..446d3b915 --- /dev/null +++ b/test/integration/irc/serverspec/apache_spec.rb @@ -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 -- 2.39.5