From a01511a02869f292e2a92dc79f7ef2da86ced234 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 12 Apr 2023 17:45:17 +0100 Subject: [PATCH] Stop running hwraid status daemons --- cookbooks/hardware/recipes/default.rb | 55 +++---------- .../templates/default/cciss-vol-statusd.erb | 77 ------------------- .../templates/default/raid.default.erb | 5 -- 3 files changed, 12 insertions(+), 125 deletions(-) delete mode 100755 cookbooks/hardware/templates/default/cciss-vol-statusd.erb delete mode 100644 cookbooks/hardware/templates/default/raid.default.erb diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index 3272e91a1..119176cd6 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -339,63 +339,32 @@ end include_recipe "apt::hwraid" unless status_packages.empty? -if status_packages.include?("cciss-vol-status") - template "/usr/local/bin/cciss-vol-statusd" do - source "cciss-vol-statusd.erb" - owner "root" - group "root" - mode "755" - notifies :restart, "service[cciss-vol-statusd]" - end - - systemd_service "cciss-vol-statusd" do - description "Check cciss_vol_status values in the background" - exec_start "/usr/local/bin/cciss-vol-statusd" - nice 10 - private_tmp true - protect_system "full" - protect_home true - no_new_privileges true - notifies :restart, "service[cciss-vol-statusd]" - end -else - systemd_service "cciss-vol-statusd" do - action :delete - end - - template "/usr/local/bin/cciss-vol-statusd" do - action :delete - end -end - %w[cciss-vol-status mpt-status sas2ircu-status megaclisas-status aacraid-status].each do |status_package| if status_packages.include?(status_package) package status_package - template "/etc/default/#{status_package}d" do - source "raid.default.erb" - owner "root" - group "root" - mode "644" - variables :devices => status_packages[status_package] + service "#{status_package}d" do + action [:stop, :disable] end - service "#{status_package}d" do - action [:start, :enable] - supports :status => false, :restart => true, :reload => false - subscribes :restart, "template[/etc/default/#{status_package}d]" + file "/etc/default/#{status_package}d" do + action :delete end else package status_package do action :purge end - - file "/etc/default/#{status_package}d" do - action :delete - end end end +systemd_service "cciss-vol-statusd" do + action :delete +end + +template "/usr/local/bin/cciss-vol-statusd" do + action :delete +end + disks = if node[:hardware][:disk] node[:hardware][:disk][:disks] else diff --git a/cookbooks/hardware/templates/default/cciss-vol-statusd.erb b/cookbooks/hardware/templates/default/cciss-vol-statusd.erb deleted file mode 100755 index 8f256507f..000000000 --- a/cookbooks/hardware/templates/default/cciss-vol-statusd.erb +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -NAME="cciss-vol-statusd" -STATUSFILE=/var/run/$NAME.status - -# Do not touch you can configure this in /etc/default/cciss-vol-statusd -MAILTO=root # Where to report problems -PERIOD=600 # Seconds between each check (default 10 minutes) -REMIND=7200 # Seconds between each reminder (default 2 hours) -ID=/dev/cciss/c0d0 - -[ -e /etc/default/cciss-vol-statusd ] && . /etc/default/cciss-vol-statusd - -# Gracefully exit if the package has been removed. -test -x /usr/bin/cciss_vol_status || exit 0 - -while true ; do - # Check ever $PERIOD seconds, send email on every status - # change and repeat ever $REMIND seconds if the raid is still - # bad. - if (cciss_vol_status $ID); then - BADRAID=false - else - BADRAID=true - logger -t cciss-vol-statusd "detected non-optimal RAID status" - fi - STATUSCHANGE=false - if [ true = "$BADRAID" ] ; then - # RAID not OK - (cciss_vol_status $ID) > $STATUSFILE.new - if [ ! -f $STATUSFILE ] ; then # RAID just became broken - STATUSCHANGE=true - mv $STATUSFILE.new $STATUSFILE - elif cmp -s $STATUSFILE $STATUSFILE.new ; then - # No change. Should we send reminder? - LASTTIME="`stat -c '%Z' $STATUSFILE`" - NOW="`date +%s`" - SINCELAST="`expr $NOW - $LASTTIME`" - if [ $REMIND -le "$SINCELAST" ]; then - # Time to send reminder - STATUSCHANGE=true - mv $STATUSFILE.new $STATUSFILE - else - rm $STATUSFILE.new - fi - else - STATUSCHANGE=true - mv $STATUSFILE.new $STATUSFILE - fi - else - # RAID OK - if [ -f $STATUSFILE ] ; then - rm $STATUSFILE - STATUSCHANGE=true - fi - fi - - if [ true = "$STATUSCHANGE" ]; then - hostname="`uname -n`" - ( - cat < -ID="<%= @devices.sort.uniq.map { |d| "/dev/#{d}" }.join(" ") %>" -<% end -%> -- 2.45.1