From 793c49934ae9d58332a0796432e542e9f82cf357 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Mon, 24 Aug 2020 14:26:14 +0100 Subject: [PATCH 01/17] Added rake task to add printers from database --- lib/tasks/create_printers.rake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/tasks/create_printers.rake diff --git a/lib/tasks/create_printers.rake b/lib/tasks/create_printers.rake new file mode 100644 index 0000000..0b77adf --- /dev/null +++ b/lib/tasks/create_printers.rake @@ -0,0 +1,15 @@ +# frozen_string_literal: true + + namespace :printers do + desc 'generate list of printers' + task create: :environment do |_t| + existing_printers = `lpstat -a` + Printer.all.each do |printer| + if existing_printers.include? printer.name + else + sh "sudo lpadmin -p #{printer.name} -v socket://#{printer.name}.internal.sanger.ac.uk -E" + puts "Added printer ~> #{printer.name}" + end + end + end + end \ No newline at end of file From aed7e4e6c7b6b8a2bf8cdeb8ca48fe8f8860b50f Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Tue, 25 Aug 2020 11:07:52 +0100 Subject: [PATCH 02/17] Printer is automatically added to cupsd upon creation --- app/controllers/v1/printers_controller.rb | 9 +++++++++ config/environments/development.rb | 3 +++ config/environments/production.rb | 3 +++ config/environments/test.rb | 3 +++ 4 files changed, 18 insertions(+) diff --git a/app/controllers/v1/printers_controller.rb b/app/controllers/v1/printers_controller.rb index 16bc319..4be6b0f 100644 --- a/app/controllers/v1/printers_controller.rb +++ b/app/controllers/v1/printers_controller.rb @@ -15,6 +15,7 @@ def create printer = Printer.new(printer_params) if printer.save render json: printer, status: :created + create_printer_in_cups(printer) else render_error printer end @@ -33,5 +34,13 @@ def printer_params def filter_params params.permit(filter: %i[name protocol]) end + + def create_printer_in_cups(printer) + existing_printers = `lpstat -a` + if existing_printers.include? printer.name + elsif Rails.configuration.auto_create_printer_in_cupsd + sh "sudo lpadmin -p #{printer.name} -v socket://#{printer.name}.internal.sanger.ac.uk -E" + end + end end end diff --git a/config/environments/development.rb b/config/environments/development.rb index 739aa0e..4d77294 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -52,6 +52,9 @@ # Suppress logger output for asset requests. config.assets.quiet = true + # Default setting for adding printers to cupsd server on printer create + config.auto_create_printer_in_cupsd = true + # Raises error for missing translations # config.action_view.raise_on_missing_translations = true diff --git a/config/environments/production.rb b/config/environments/production.rb index f7c9893..db1727a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -79,6 +79,9 @@ # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + # Default setting for adding printers to cupsd server on printer create + config.auto_create_printer_in_cupsd = true + # Use a different logger for distributed setups. # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') diff --git a/config/environments/test.rb b/config/environments/test.rb index 2b4f7a0..af01a62 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -38,6 +38,9 @@ # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Default setting for adding printers to cupsd server on printer create + config.auto_create_printer_in_cupsd = true + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr From 0dc4594bc541aca2a9689cf15d52ff3dec05b1b2 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Tue, 25 Aug 2020 13:57:40 +0100 Subject: [PATCH 03/17] linted and fixed tests --- app/controllers/v1/printers_controller.rb | 4 ++-- lib/tasks/create_printers.rake | 26 +++++++++++------------ spec/v1/printers_spec.rb | 3 +++ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/app/controllers/v1/printers_controller.rb b/app/controllers/v1/printers_controller.rb index 4be6b0f..44b9666 100644 --- a/app/controllers/v1/printers_controller.rb +++ b/app/controllers/v1/printers_controller.rb @@ -38,8 +38,8 @@ def filter_params def create_printer_in_cups(printer) existing_printers = `lpstat -a` if existing_printers.include? printer.name - elsif Rails.configuration.auto_create_printer_in_cupsd - sh "sudo lpadmin -p #{printer.name} -v socket://#{printer.name}.internal.sanger.ac.uk -E" + elsifRails.configuration.auto_create_printer_in_cupsd + `sudo lpadmin -p #{printer.name} -v socket://#{printer.name}.internal.sanger.ac.uk -E` end end end diff --git a/lib/tasks/create_printers.rake b/lib/tasks/create_printers.rake index 0b77adf..9b5cf86 100644 --- a/lib/tasks/create_printers.rake +++ b/lib/tasks/create_printers.rake @@ -1,15 +1,15 @@ # frozen_string_literal: true - namespace :printers do - desc 'generate list of printers' - task create: :environment do |_t| - existing_printers = `lpstat -a` - Printer.all.each do |printer| - if existing_printers.include? printer.name - else - sh "sudo lpadmin -p #{printer.name} -v socket://#{printer.name}.internal.sanger.ac.uk -E" - puts "Added printer ~> #{printer.name}" - end - end - end - end \ No newline at end of file +namespace :printers do + desc 'generate list of printers' + task create: :environment do |_t| + existing_printers = `lpstat -a` + Printer.all.each do |printer| + if existing_printers.include? printer.name + else + `sudo lpadmin -p #{printer.name} -v socket://#{printer.name}.internal.sanger.ac.uk -E` + puts "Added printer ~> #{printer.name}" + end + end + end +end diff --git a/spec/v1/printers_spec.rb b/spec/v1/printers_spec.rb index db8f175..fc51f2d 100644 --- a/spec/v1/printers_spec.rb +++ b/spec/v1/printers_spec.rb @@ -5,6 +5,7 @@ RSpec.describe V1::PrintersController, type: :request, helpers: true do |_variable| let(:headers) { { 'CONTENT_TYPE' => 'application/vnd.api+json' } } + it 'should allow retrieval of all printers' do printers = create_list(:printer, 5) get v1_printers_path @@ -52,6 +53,7 @@ end it 'should allow creation of a new printer' do + Rails.configuration.auto_create_printer_in_cupsd = false expect do post v1_printers_path, params: { data: { attributes: attributes_for(:printer) } }.to_json, headers: headers end.to change(Printer, :count).by(1) @@ -60,6 +62,7 @@ end it 'allows creation of a printer with a specified protocol' do + Rails.configuration.auto_create_printer_in_cupsd = false expect do post v1_printers_path, params: { data: { attributes: { name: 'Printer Juan', protocol: 'IPP' } } }.to_json, headers: headers end.to change(Printer, :count).by(1) From 5c2e7e9960733c18d995dba01a3b746ce61c4b75 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Tue, 25 Aug 2020 14:00:46 +0100 Subject: [PATCH 04/17] mis-compiled code --- app/controllers/v1/printers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/v1/printers_controller.rb b/app/controllers/v1/printers_controller.rb index 44b9666..8ae42ee 100644 --- a/app/controllers/v1/printers_controller.rb +++ b/app/controllers/v1/printers_controller.rb @@ -38,7 +38,7 @@ def filter_params def create_printer_in_cups(printer) existing_printers = `lpstat -a` if existing_printers.include? printer.name - elsifRails.configuration.auto_create_printer_in_cupsd + elsif Rails.configuration.auto_create_printer_in_cupsd `sudo lpadmin -p #{printer.name} -v socket://#{printer.name}.internal.sanger.ac.uk -E` end end From 2c82d5f9a78c8589018577f0265949491637f2e0 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Tue, 25 Aug 2020 14:42:15 +0100 Subject: [PATCH 05/17] bypass travis --- .github/workflows/ci-docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index e56930e..0f57c8e 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -6,6 +6,7 @@ on: - develop - master - gpl592_pmb_into_fce + - printers_rake_task paths-ignore: - "README.md" tags: From 6f6c484afee5a63f61f54c8490c5bd4fe3746518 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 26 Aug 2020 10:43:17 +0100 Subject: [PATCH 06/17] refactored rake task and creating printer in cupsd function --- app/controllers/v1/printers_controller.rb | 9 --------- app/models/printer.rb | 10 ++++++++++ config/environments/development.rb | 2 +- config/environments/test.rb | 2 +- lib/tasks/create_printers.rake | 6 +++--- spec/v1/printers_spec.rb | 2 -- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/controllers/v1/printers_controller.rb b/app/controllers/v1/printers_controller.rb index 8ae42ee..16bc319 100644 --- a/app/controllers/v1/printers_controller.rb +++ b/app/controllers/v1/printers_controller.rb @@ -15,7 +15,6 @@ def create printer = Printer.new(printer_params) if printer.save render json: printer, status: :created - create_printer_in_cups(printer) else render_error printer end @@ -34,13 +33,5 @@ def printer_params def filter_params params.permit(filter: %i[name protocol]) end - - def create_printer_in_cups(printer) - existing_printers = `lpstat -a` - if existing_printers.include? printer.name - elsif Rails.configuration.auto_create_printer_in_cupsd - `sudo lpadmin -p #{printer.name} -v socket://#{printer.name}.internal.sanger.ac.uk -E` - end - end end end diff --git a/app/models/printer.rb b/app/models/printer.rb index 96b7023..16498ff 100644 --- a/app/models/printer.rb +++ b/app/models/printer.rb @@ -19,4 +19,14 @@ class Printer < ApplicationRecord filters end end + + after_save do + existing_printers = `lpstat -a`.split("\n") + existing_printers.map! { |printer| printer.split(' ').first } + unless existing_printers.include? name + if Rails.configuration.auto_create_printer_in_cupsd + `sudo lpadmin -p #{name} -v socket://#{name}.internal.sanger.ac.uk -E` + end + end + end end diff --git a/config/environments/development.rb b/config/environments/development.rb index 4d77294..60a9637 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -53,7 +53,7 @@ config.assets.quiet = true # Default setting for adding printers to cupsd server on printer create - config.auto_create_printer_in_cupsd = true + config.auto_create_printer_in_cupsd = false # Raises error for missing translations # config.action_view.raise_on_missing_translations = true diff --git a/config/environments/test.rb b/config/environments/test.rb index af01a62..67b8f76 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -39,7 +39,7 @@ config.action_mailer.delivery_method = :test # Default setting for adding printers to cupsd server on printer create - config.auto_create_printer_in_cupsd = true + config.auto_create_printer_in_cupsd = false # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/lib/tasks/create_printers.rake b/lib/tasks/create_printers.rake index 9b5cf86..fe78a00 100644 --- a/lib/tasks/create_printers.rake +++ b/lib/tasks/create_printers.rake @@ -3,10 +3,10 @@ namespace :printers do desc 'generate list of printers' task create: :environment do |_t| - existing_printers = `lpstat -a` + existing_printers = `lpstat -a`.split("\n") + existing_printers.map! { |printer| printer.split(' ').first } Printer.all.each do |printer| - if existing_printers.include? printer.name - else + unless existing_printers.include? printer.name `sudo lpadmin -p #{printer.name} -v socket://#{printer.name}.internal.sanger.ac.uk -E` puts "Added printer ~> #{printer.name}" end diff --git a/spec/v1/printers_spec.rb b/spec/v1/printers_spec.rb index fc51f2d..24bd2a2 100644 --- a/spec/v1/printers_spec.rb +++ b/spec/v1/printers_spec.rb @@ -53,7 +53,6 @@ end it 'should allow creation of a new printer' do - Rails.configuration.auto_create_printer_in_cupsd = false expect do post v1_printers_path, params: { data: { attributes: attributes_for(:printer) } }.to_json, headers: headers end.to change(Printer, :count).by(1) @@ -62,7 +61,6 @@ end it 'allows creation of a printer with a specified protocol' do - Rails.configuration.auto_create_printer_in_cupsd = false expect do post v1_printers_path, params: { data: { attributes: { name: 'Printer Juan', protocol: 'IPP' } } }.to_json, headers: headers end.to change(Printer, :count).by(1) From 05d213b86c08990dc622004cc62622a3329144d0 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 26 Aug 2020 15:02:42 +0100 Subject: [PATCH 07/17] refactored repeated code --- app/models/printer.rb | 17 +++++++++++------ lib/tasks/create_printers.rake | 6 ++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/models/printer.rb b/app/models/printer.rb index 16498ff..ba8d809 100644 --- a/app/models/printer.rb +++ b/app/models/printer.rb @@ -20,13 +20,18 @@ class Printer < ApplicationRecord end end - after_save do + after_save :update_printer_in_cups + + def update_printer_in_cups existing_printers = `lpstat -a`.split("\n") existing_printers.map! { |printer| printer.split(' ').first } - unless existing_printers.include? name - if Rails.configuration.auto_create_printer_in_cupsd - `sudo lpadmin -p #{name} -v socket://#{name}.internal.sanger.ac.uk -E` - end - end + check_if_printer_exists(existing_printers) + end + + def check_if_printer_exists(existing_printers) + return if existing_printers.include? name + return unless Rails.configuration.auto_create_printer_in_cupsd + + `sudo lpadmin -p #{name} -v socket://#{name}.internal.sanger.ac.uk -E` end end diff --git a/lib/tasks/create_printers.rake b/lib/tasks/create_printers.rake index fe78a00..a74efa4 100644 --- a/lib/tasks/create_printers.rake +++ b/lib/tasks/create_printers.rake @@ -1,15 +1,13 @@ # frozen_string_literal: true +# Can only run in production, unless config for auto_create_printer_in_cupsd is changed namespace :printers do desc 'generate list of printers' task create: :environment do |_t| existing_printers = `lpstat -a`.split("\n") existing_printers.map! { |printer| printer.split(' ').first } Printer.all.each do |printer| - unless existing_printers.include? printer.name - `sudo lpadmin -p #{printer.name} -v socket://#{printer.name}.internal.sanger.ac.uk -E` - puts "Added printer ~> #{printer.name}" - end + printer.check_if_printer_exists(existing_printers) end end end From 163b9083dfdddfe56413defeb421a0ee39237f37 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Mon, 7 Sep 2020 15:04:48 +0100 Subject: [PATCH 08/17] refactor getting cups printers for rake task and on printer creation --- app/models/printer.rb | 12 +++++++++--- lib/tasks/create_printers.rake | 3 +-- spec/v1/printers_spec.rb | 1 - 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models/printer.rb b/app/models/printer.rb index ba8d809..d4868ef 100644 --- a/app/models/printer.rb +++ b/app/models/printer.rb @@ -23,15 +23,21 @@ class Printer < ApplicationRecord after_save :update_printer_in_cups def update_printer_in_cups - existing_printers = `lpstat -a`.split("\n") - existing_printers.map! { |printer| printer.split(' ').first } + return unless Rails.configuration.auto_create_printer_in_cupsd + + existing_printers = Printer.existing_cups_printers check_if_printer_exists(existing_printers) end def check_if_printer_exists(existing_printers) return if existing_printers.include? name - return unless Rails.configuration.auto_create_printer_in_cupsd `sudo lpadmin -p #{name} -v socket://#{name}.internal.sanger.ac.uk -E` end + + def self.existing_cups_printers + existing_printers = `lpstat -a`.split("\n") + existing_printers.map! { |printer| printer.split(' ').first } + existing_printers + end end diff --git a/lib/tasks/create_printers.rake b/lib/tasks/create_printers.rake index a74efa4..67debdb 100644 --- a/lib/tasks/create_printers.rake +++ b/lib/tasks/create_printers.rake @@ -4,8 +4,7 @@ namespace :printers do desc 'generate list of printers' task create: :environment do |_t| - existing_printers = `lpstat -a`.split("\n") - existing_printers.map! { |printer| printer.split(' ').first } + existing_printers = Printer.existing_cups_printers Printer.all.each do |printer| printer.check_if_printer_exists(existing_printers) end diff --git a/spec/v1/printers_spec.rb b/spec/v1/printers_spec.rb index 24bd2a2..db8f175 100644 --- a/spec/v1/printers_spec.rb +++ b/spec/v1/printers_spec.rb @@ -5,7 +5,6 @@ RSpec.describe V1::PrintersController, type: :request, helpers: true do |_variable| let(:headers) { { 'CONTENT_TYPE' => 'application/vnd.api+json' } } - it 'should allow retrieval of all printers' do printers = create_list(:printer, 5) get v1_printers_path From 575738d73ad5b47b6ef8b155b4627cbc68b1063c Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 9 Sep 2020 10:42:30 +0100 Subject: [PATCH 09/17] Added create-cups-printer script, modified dockerfile to install expect --- Dockerfile | 1 + app/models/printer.rb | 2 +- create-cups-printer.sh | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 create-cups-printer.sh diff --git a/Dockerfile b/Dockerfile index 1fc73ae..3c5932f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ ENV BUNDLER_VERSION=2.1.4 RUN apt-get update -qq && apt-get install -y RUN apt-get -y install cups-client +RUN apt-get install expect WORKDIR /code diff --git a/app/models/printer.rb b/app/models/printer.rb index d4868ef..b32437e 100644 --- a/app/models/printer.rb +++ b/app/models/printer.rb @@ -32,7 +32,7 @@ def update_printer_in_cups def check_if_printer_exists(existing_printers) return if existing_printers.include? name - `sudo lpadmin -p #{name} -v socket://#{name}.internal.sanger.ac.uk -E` + `sh create-cups-printer.sh #{name}` end def self.existing_cups_printers diff --git a/create-cups-printer.sh b/create-cups-printer.sh new file mode 100644 index 0000000..8ffc037 --- /dev/null +++ b/create-cups-printer.sh @@ -0,0 +1,6 @@ +#!/usr/bin/expect +set printername [lindex $argv 0]; +spawn lpadmin -U "$env(CUPSD_USERNAME)" -p $printername -v socket://$printername.psd.sanger.ac.uk -E +expect "Password for $env(CUPSD_USERNAME) on cupsd?" +send -- "$env(CUPSD_PASSWORD)\n" +expect eof \ No newline at end of file From 12325b59a51a813163fd8de081bbca01b5c5023b Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 9 Sep 2020 14:06:58 +0100 Subject: [PATCH 10/17] added y flag for expect installation --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 22245e1..183fa26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ ENV BUNDLER_VERSION=2.1.4 RUN apt-get update -qq && apt-get install -y RUN apt-get -y install cups-client cups-bsd -RUN apt-get install expect +RUN apt-get -y install expect WORKDIR /code From 446ae861c71a01166f31d6275fd991b785308e47 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 9 Sep 2020 14:56:19 +0100 Subject: [PATCH 11/17] updated shell call command --- app/models/printer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/printer.rb b/app/models/printer.rb index b32437e..2f19e73 100644 --- a/app/models/printer.rb +++ b/app/models/printer.rb @@ -32,7 +32,7 @@ def update_printer_in_cups def check_if_printer_exists(existing_printers) return if existing_printers.include? name - `sh create-cups-printer.sh #{name}` + `./create-cups-printer.sh #{name}` end def self.existing_cups_printers From 8edd12d5970d3c32c8d7379c1a78b133c5d813ab Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 9 Sep 2020 15:31:04 +0100 Subject: [PATCH 12/17] added rake task on docker build, permission change for cups shell script --- Dockerfile | 3 +++ docker-entrypoint.sh | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Dockerfile b/Dockerfile index 183fa26..b36d70b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,9 @@ ADD . /code/ RUN gem install bundler RUN bundle install +COPY create-cups-printer.sh / +RUN ["chmod", "+x", "/create-cups-printer.sh"] + COPY docker-entrypoint.sh / RUN ["chmod", "+x", "/docker-entrypoint.sh"] ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index f4bb7f5..4cf107f 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,4 +1,8 @@ #!/bin/bash mkdir /etc/cups/ echo "ServerName $CUPSD_SERVER_NAME" > /etc/cups/client.conf +if [ $CUPSD_UPDATE == "true"]; then +then + bundle exec rails printers:create +fi exec "$@" \ No newline at end of file From 62d6f48c6105b970ea3790b7614f35d9d12ad23d Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 9 Sep 2020 15:34:23 +0100 Subject: [PATCH 13/17] shell fix --- docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 4cf107f..bac85ec 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash mkdir /etc/cups/ echo "ServerName $CUPSD_SERVER_NAME" > /etc/cups/client.conf -if [ $CUPSD_UPDATE == "true"]; then +if [ $CUPSD_UPDATE == "true" ] then bundle exec rails printers:create fi From 26bfef329ccaff0a48c37249547ce3acf4239481 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 9 Sep 2020 15:38:52 +0100 Subject: [PATCH 14/17] added echo to show printers rake task runnning --- docker-entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index bac85ec..cde8e39 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -3,6 +3,8 @@ mkdir /etc/cups/ echo "ServerName $CUPSD_SERVER_NAME" > /etc/cups/client.conf if [ $CUPSD_UPDATE == "true" ] then + echo "-> Running printers rake task" bundle exec rails printers:create + echo "-> Printers rake task complete" fi exec "$@" \ No newline at end of file From b696b67c9c2abc705c70a614b16028baacd35075 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 9 Sep 2020 15:48:54 +0100 Subject: [PATCH 15/17] fix to shell command --- app/models/printer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/printer.rb b/app/models/printer.rb index 2f19e73..3d37110 100644 --- a/app/models/printer.rb +++ b/app/models/printer.rb @@ -32,7 +32,7 @@ def update_printer_in_cups def check_if_printer_exists(existing_printers) return if existing_printers.include? name - `./create-cups-printer.sh #{name}` + `/create-cups-printer.sh #{name}` end def self.existing_cups_printers From 18ad18aafe62a31d13c758106350f6cbc37cfa11 Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Wed, 9 Sep 2020 16:07:53 +0100 Subject: [PATCH 16/17] removed from docker exempt branches --- .github/workflows/ci-docker.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 0f57c8e..e56930e 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -6,7 +6,6 @@ on: - develop - master - gpl592_pmb_into_fce - - printers_rake_task paths-ignore: - "README.md" tags: From a60178b454f941b6c923296a5a2144bd0503a64c Mon Sep 17 00:00:00 2001 From: Ben Topping Date: Tue, 6 Oct 2020 11:12:33 +0100 Subject: [PATCH 17/17] Adding printer to cups Printer now points to .internal instead of .psd, this is due to issues in production, this branch can be tested on UAT or Training --- create-cups-printer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create-cups-printer.sh b/create-cups-printer.sh index 8ffc037..7be261f 100644 --- a/create-cups-printer.sh +++ b/create-cups-printer.sh @@ -1,6 +1,6 @@ #!/usr/bin/expect set printername [lindex $argv 0]; -spawn lpadmin -U "$env(CUPSD_USERNAME)" -p $printername -v socket://$printername.psd.sanger.ac.uk -E +spawn lpadmin -U "$env(CUPSD_USERNAME)" -p $printername -v socket://$printername.internal.sanger.ac.uk -E expect "Password for $env(CUPSD_USERNAME) on cupsd?" send -- "$env(CUPSD_PASSWORD)\n" expect eof \ No newline at end of file