From 4d6e568fe684b1c88376102fa7ba803f6e4f46c7 Mon Sep 17 00:00:00 2001 From: Sascha Wilde Date: Mon, 18 Jan 2021 17:49:36 +0100 Subject: [PATCH 1/7] Added rpm packaging for megaclisas-status. --- README.rpm.md | 10 + packaging/rpm/megaclisas-status/README | 23 ++ packaging/rpm/megaclisas-status/RPM/SPEC | 55 +++++ .../megaclisas-status.megaclisas-statusd.init | 200 ++++++++++++++++++ 4 files changed, 288 insertions(+) create mode 100644 README.rpm.md create mode 100644 packaging/rpm/megaclisas-status/README create mode 100644 packaging/rpm/megaclisas-status/RPM/SPEC create mode 100644 packaging/rpm/megaclisas-status/megaclisas-status.megaclisas-statusd.init diff --git a/README.rpm.md b/README.rpm.md new file mode 100644 index 0000000..f66369f --- /dev/null +++ b/README.rpm.md @@ -0,0 +1,10 @@ +RPM packages +============ + +Currently RPM packaging is only available for *megaclisas-status*. + +To build execute from the top level directory: +``` +rpmbuild --define "_sourcedir $PWD" \ + -bb packaging/rpm/megaclisas-status/RPM/SPEC +``` diff --git a/packaging/rpm/megaclisas-status/README b/packaging/rpm/megaclisas-status/README new file mode 100644 index 0000000..ec8dc94 --- /dev/null +++ b/packaging/rpm/megaclisas-status/README @@ -0,0 +1,23 @@ +README.Debian for megaclisas-status package +------------------------------------------- + +Possible configuration: +---------------------- + +If you want to change the default configuration of the init script you +can create the file /etc/default/megaclisas-statusd and specify the following +values. + +MAILTO= +PERIOD= +REMIND= + +Use MAILTO to specify which user shall get the status mails +(default is root). + +With PERIOD you can fix the seconds between each check. + +And REMIND specifies the seconds between each reminder. + + + -- Adam Cécile (Le_Vert) Tue, 11 Dec 2007 17:06:56 +0100 diff --git a/packaging/rpm/megaclisas-status/RPM/SPEC b/packaging/rpm/megaclisas-status/RPM/SPEC new file mode 100644 index 0000000..ff5bd93 --- /dev/null +++ b/packaging/rpm/megaclisas-status/RPM/SPEC @@ -0,0 +1,55 @@ +%define name megaclisas-status +%define version 0.17 +%define release 1 + +%define extradir %{_sourcedir}/packaging/rpm/megaclisas-status + +Name: %{name} +Summary: get RAID status out of LSI MegaRAID SAS HW RAID controllers +Version: %{version} +Release: %{release} +License: GPL +Group: Applications/Internet +BuildArch: noarch +BuildRoot: %{_builddir}/%{name}-root +Distribution: whatever +Vendor: Adam Cécile (Le_Vert) +Packager: wilde@intevation.de +Requires: python, bash, MegaCli, daemonize +BuildRequires: systemd + +%description +The megacli-status software is a query tool to access the running +configuration and status of LSI MegaRAID SAS HBAs. + +It uses LSI MegaCli proprietary command line tool. + +%prep +exit 0 + +%build +exit 0 + +%install +rm -rf %{buildroot} +install -d %{buildroot}%{_sbindir} +install -d %{buildroot}%{_initddir} +install -d %{buildroot}%{_defaultdocdir}/%{name} + +# main package README +install %{_sourcedir}/wrapper-scripts/megaclisas-status \ + %{buildroot}%{_sbindir} +install %{extradir}/megaclisas-status.megaclisas-statusd.init \ + %{buildroot}%{_initddir}/megaclisas-statusd +install -m 644 %{extradir}/README \ + %{buildroot}%{_defaultdocdir}/%{name} + +%clean +exit 0 + +%files +%{_sbindir}/megaclisas-status +%{_initddir}/megaclisas-statusd +%doc %{_defaultdocdir}/%{name}/README + +# vim: ft=spec: diff --git a/packaging/rpm/megaclisas-status/megaclisas-status.megaclisas-statusd.init b/packaging/rpm/megaclisas-status/megaclisas-status.megaclisas-statusd.init new file mode 100644 index 0000000..36802cc --- /dev/null +++ b/packaging/rpm/megaclisas-status/megaclisas-status.megaclisas-statusd.init @@ -0,0 +1,200 @@ +#! /bin/bash + +# Author: Petter Reinholdtsen +# Adapted for CentOS by: Sascha Wilde +# License: GNU General Public License v2 or later +# +# chkconfig: - 50 50 +# description: Check megaclisas-status values in the background. +# config: /etc/default/megaclisas-statusd +# +### BEGIN INIT INFO +# Provides: megaclisas-statusd +# Description: Check megaclisas-status values in the background. +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Check megaclisas-status values in the background. +### END INIT INFO + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +DESC="megaclisas-status monitor" +NAME=megaclisas-statusd +PIDFILE=/var/run/$NAME.pid +STATUSFILE=/var/run/$NAME.status +SCRIPTNAME=/etc/init.d/$NAME + + +# Do not touch you can configure this in /etc/default/megaclisas-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) +RUN_DAEMON=yes + +[ -e /etc/default/megaclisas-statusd ] && . /etc/default/megaclisas-statusd + +# Gracefully exit if the package has been removed. +test -x /usr/sbin/megaclisas-status || exit 0 + +# Source function library. +. /etc/rc.d/init.d/functions + +if [ $RUN_DAEMON = "no" ] ; then + echo >&2 "megaclisas-statusd is disabled in /etc/default/megaclisas-statusd, not starting." + exit 0 +fi + +check_megaclisas() { + echo $$ > $PIDFILE.new && mv $PIDFILE.new $PIDFILE + 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 (megaclisas-status --notemp); then + BADRAID=false + else + BADRAID=true + logger -t megaclisas-statusd "detected non-optimal RAID status" + fi + STATUSCHANGE=false + if [ true = "$BADRAID" ] ; then + # RAID not OK + (megaclisas-status --notemp) > $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 <&2 "Daemon already running. Refusing to start another" + return 0 + elif check_daemon ; then + # Use the daemon package to turn this script into a daemon + daemon --pidfile $PIDFILE \ + /usr/sbin/daemonize $SCRIPTNAME check_megaclisas + return 0 + else + echo >&2 "Daemon is already running. Refusing to start another" + return 0 + fi +} + +# +# Function that stops the daemon/service. +# +d_stop() { + if [ -f $PIDFILE ] ; then + killproc -p $PIDFILE /usr/sbin/daemonize + rm -f $PIDFILE + else + echo >&2 "Daemon is already stopped." + return 0 + fi +} + +# This is a workaround function which does not directly exit and +# therefore can be used by a restart +d_stop_by_restart() { + if [ -f $PIDFILE ] ; then + killproc -p $PIDFILE /usr/sbin/daemonize + rm -f $PIDFILE + else + echo >&2 "Daemon is already stopped." + fi +} + +case "$1" in + start) + echo -n "" + echo >&2 "Starting $DESC: $NAME" + d_start ; CODE=$? + ;; + stop) + echo >&2 "Stopping $DESC: $NAME" + d_stop ; CODE=$? + ;; + check_megaclisas) + check_megaclisas + ;; + status) + status -p $PIDFILE /usr/sbin/daemonize + exit $? + ;; + restart|force-reload) + echo >&2 "Restarting $DESC: $NAME" + d_stop_by_restart + sleep 1 + d_start || CODE=$? + ;; + *) + # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 From 9d8439bc41bbbad1095a8a7becd73e2fecd8065e Mon Sep 17 00:00:00 2001 From: Sascha Wilde Date: Tue, 19 Jan 2021 15:30:36 +0100 Subject: [PATCH 2/7] Removed reference to Debian from README in rpm package. --- packaging/rpm/megaclisas-status/README | 4 ++-- packaging/rpm/megaclisas-status/RPM/SPEC | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packaging/rpm/megaclisas-status/README b/packaging/rpm/megaclisas-status/README index ec8dc94..0979ab6 100644 --- a/packaging/rpm/megaclisas-status/README +++ b/packaging/rpm/megaclisas-status/README @@ -1,5 +1,5 @@ -README.Debian for megaclisas-status package -------------------------------------------- +README for megaclisas-status package +------------------------------------ Possible configuration: ---------------------- diff --git a/packaging/rpm/megaclisas-status/RPM/SPEC b/packaging/rpm/megaclisas-status/RPM/SPEC index ff5bd93..7028482 100644 --- a/packaging/rpm/megaclisas-status/RPM/SPEC +++ b/packaging/rpm/megaclisas-status/RPM/SPEC @@ -1,6 +1,6 @@ %define name megaclisas-status %define version 0.17 -%define release 1 +%define release 2 %define extradir %{_sourcedir}/packaging/rpm/megaclisas-status From ff3e8b827e0b877ba4cb7a3271893a46c485384e Mon Sep 17 00:00:00 2001 From: Sascha Wilde Date: Tue, 19 Jan 2021 16:01:33 +0100 Subject: [PATCH 3/7] Require mailx for megaclisas-status --- packaging/rpm/megaclisas-status/RPM/SPEC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/rpm/megaclisas-status/RPM/SPEC b/packaging/rpm/megaclisas-status/RPM/SPEC index 7028482..206dc3a 100644 --- a/packaging/rpm/megaclisas-status/RPM/SPEC +++ b/packaging/rpm/megaclisas-status/RPM/SPEC @@ -15,7 +15,7 @@ BuildRoot: %{_builddir}/%{name}-root Distribution: whatever Vendor: Adam Cécile (Le_Vert) Packager: wilde@intevation.de -Requires: python, bash, MegaCli, daemonize +Requires: python, bash, MegaCli, daemonize, mailx BuildRequires: systemd %description From 7cbe05d0b0276b761d4e7b6ec593810aedeb8c1a Mon Sep 17 00:00:00 2001 From: Sascha Wilde Date: Tue, 19 Jan 2021 16:12:54 +0100 Subject: [PATCH 4/7] Created sas2ircu-status rpm packaging. --- README.rpm.md | 6 +- packaging/rpm/sas2ircu-status/README | 23 ++ packaging/rpm/sas2ircu-status/RPM/SPEC | 58 +++++ .../rpm/sas2ircu-status/sas2ircu-status.8 | 68 ++++++ .../sas2ircu-status.sas2ircu-statusd.init | 199 ++++++++++++++++++ 5 files changed, 353 insertions(+), 1 deletion(-) create mode 100644 packaging/rpm/sas2ircu-status/README create mode 100644 packaging/rpm/sas2ircu-status/RPM/SPEC create mode 100644 packaging/rpm/sas2ircu-status/sas2ircu-status.8 create mode 100644 packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init diff --git a/README.rpm.md b/README.rpm.md index f66369f..4e1ebdd 100644 --- a/README.rpm.md +++ b/README.rpm.md @@ -1,10 +1,14 @@ RPM packages ============ -Currently RPM packaging is only available for *megaclisas-status*. +Currently RPM packaging is only available for *megaclisas-status* and +*sas2ircu-status*. To build execute from the top level directory: ``` rpmbuild --define "_sourcedir $PWD" \ -bb packaging/rpm/megaclisas-status/RPM/SPEC + +rpmbuild --define "_sourcedir $PWD" \ + -bb packaging/rpm/sas2ircu-status/RPM/SPEC ``` diff --git a/packaging/rpm/sas2ircu-status/README b/packaging/rpm/sas2ircu-status/README new file mode 100644 index 0000000..01c262f --- /dev/null +++ b/packaging/rpm/sas2ircu-status/README @@ -0,0 +1,23 @@ +README for sas2ircu-status package +---------------------------------- + +Possible configuration: +---------------------- + +If you want to change the default configuration of the init script you +can create the file /etc/default/sas2ircu-statusd and specify the following +values. + +MAILTO= +PERIOD= +REMIND= + +Use MAILTO to specify which user shall get the status mails +(default is root). + +With PERIOD you can fix the seconds between each check. + +And REMIND specifies the seconds between each reminder. + + + -- Adam Cécile (Le_Vert) Mon, 24 Sep 2007 15:55:09 +0200 diff --git a/packaging/rpm/sas2ircu-status/RPM/SPEC b/packaging/rpm/sas2ircu-status/RPM/SPEC new file mode 100644 index 0000000..2a35fc3 --- /dev/null +++ b/packaging/rpm/sas2ircu-status/RPM/SPEC @@ -0,0 +1,58 @@ +%define name sas2ircu-status +%define version 0.8 +%define release 1 + +%define extradir %{_sourcedir}/packaging/rpm/sas2ircu-status + +Name: %{name} +Summary: get RAID status out of LSI Fusion MPT SAS2 HW RAID controllers +Version: %{version} +Release: %{release} +License: GPL +Group: Applications/Internet +BuildArch: noarch +BuildRoot: %{_builddir}/%{name}-root +Distribution: whatever +Vendor: Adam Cécile (Le_Vert) +Packager: wilde@intevation.de +Requires: python, bash, daemonize, mailx +BuildRequires: systemd + +%description +The sas2ircu-status software is a query tool to access the running +configuration and status of LSI Fusion MPT SAS2 HBAs. sas2ircu-status allows +you to monitor the health and status of your RAID setup. + +%prep +exit 0 + +%build +exit 0 + +%install +rm -rf %{buildroot} +install -d %{buildroot}%{_sbindir} +install -d %{buildroot}%{_initddir} +install -d %{buildroot}%{_mandir}/man8 +install -d %{buildroot}%{_defaultdocdir}/%{name} + +# main package README +install %{_sourcedir}/wrapper-scripts/sas2ircu-status \ + %{buildroot}%{_sbindir} +install %{extradir}/sas2ircu-status.sas2ircu-statusd.init \ + %{buildroot}%{_initddir}/sas2ircu-statusd +install -m 644 %{extradir}/sas2ircu-status.8 \ + %{buildroot}%{_mandir}/man8 +install -m 644 %{extradir}/README \ + %{buildroot}%{_defaultdocdir}/%{name} + +%clean +exit 0 + +%files +%{_sbindir}/sas2ircu-status +%{_initddir}/sas2ircu-statusd +%doc %{_mandir}/man8/sas2ircu-status.8.gz +%doc %{_defaultdocdir}/%{name}/README + +# vim: ft=spec: diff --git a/packaging/rpm/sas2ircu-status/sas2ircu-status.8 b/packaging/rpm/sas2ircu-status/sas2ircu-status.8 new file mode 100644 index 0000000..92653a9 --- /dev/null +++ b/packaging/rpm/sas2ircu-status/sas2ircu-status.8 @@ -0,0 +1,68 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" (C) Copyright 2013 Adam Cécile (Le_Vert) , +.\" +.TH SAS2IRCU-STATUS 8 "2014-01-26" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +sas2ircu-status \- display RAID status of LSI FusionMPT2 adapters in a human-readable way +.SH SYNOPSIS +.B sas2ircu-status +.RI [ --nagios ] +.SH DESCRIPTION +This wrapper will call LSI proprietary "sas2ircu" command-line tool to display +status of all your +.B disks/arrays connected +to an +.B LSI FusionMPT2 adapter. +.br +It will also run +.B periodic checks +and notify the +.B root user (by mail) +if anything goes wrong. Reminders will be sent every two hours until the +status goes back to normal. +.sp +Here is an output example: +.sp +.br +-- Controller informations -- +.br +-- ID | Model +.br +c0 | SAS2008 +.sp +-- Arrays informations -- +.br +-- ID | Type | Size | Status +.br +c0u0 | RAID1 | 1800G | Okay (OKY) +.sp +-- Disks informations +.br +-- ID | Model | Status +.br +c0u0p0 | Hitachi HUA72202 (JK1151YAHUYAZZ) | Optimal (OPT) +.br +c0u0p1 | Hitachi HUA72202 (JK1151YAHUW1DZ) | Optimal (OPT) +.SH OPTIONS +.TP +.B \-\-nagios +Use nagios compatible output (and return code for OK/WARNING/CRITICAL states) +.sp +Example: +.br +RAID OK - Arrays: OK:1 Bad:0 - Disks: OK:2 Bad:0 +.SH SEE ALSO +More information about this adapters family: +.B http://hwraid.le-vert.net/wiki/LSIFusionMPTSAS2 diff --git a/packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init b/packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init new file mode 100644 index 0000000..80c986f --- /dev/null +++ b/packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init @@ -0,0 +1,199 @@ +#! /bin/sh + +# Author: Petter Reinholdtsen +# License: GNU General Public License v2 or later +# +### BEGIN INIT INFO +# Provides: sas2ircu-statusd +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Check sas2ircu-status values in the background. +### END INIT INFO + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +DESC="sas2ircu-status monitor" +NAME=sas2ircu-statusd +PIDFILE=/var/run/$NAME.pid +STATUSFILE=/var/run/$NAME.status +SCRIPTNAME=/etc/init.d/$NAME + + +# Do not touch you can configure this in /etc/default/sas2ircu-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) +RUN_DAEMON=yes + +[ -e /etc/default/sas2ircu-statusd ] && . /etc/default/sas2ircu-statusd + +# Gracefully exit if the package has been removed. +test -x /usr/sbin/sas2ircu-status || exit 0 + +. /lib/lsb/init-functions +[ -e /etc/default/rcS ] && . /etc/default/rcS + +if [ $RUN_DAEMON = "no" ] ; then + log_begin_msg "sas2ircu-statusd is disabled in /etc/default/sas2ircu-statusd, not starting." + log_end_msg 0 + exit 0 +fi + +check_sas2ircu() { + echo $$ > $PIDFILE.new && mv $PIDFILE.new $PIDFILE + 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 (sas2ircu-status) |grep -q 'NOT OPTIMAL' ; then + BADRAID=true + logger -t sas2ircu-statusd "detected non-optimal RAID status" + else + BADRAID=false + fi + STATUSCHANGE=false + if [ true = "$BADRAID" ] ; then + # RAID not OK + (sas2ircu-status) > $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 < /dev/null 2>&1 + DAEMONPID=`ps aux | grep '/usr/bin/daemon /etc/init.d/sas2ircu-statusd check_sas2ircu' | grep -v 'grep' | awk '{ print $2 }'` + SCRIPTPID=`cat $PIDFILE` + kill -9 $DAEMONPID $SCRIPTPID || true + rm -f $PIDFILE + else + log_progress_msg "Daemon is already stopped." + return 0 + fi +} + +# This is a workaround function which does not directly exit and +# therefore can be used by a restart +d_stop_by_restart() { + if [ -f $PIDFILE ] ; then + # Doesn't work (kill init script instance, but not daemon...) + #start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE + DAEMONPID=`ps aux | grep '/usr/bin/daemon /etc/init.d/sas2ircu-statusd check_sas2ircu' | grep -v 'grep' | awk '{ print $2 }'` + SCRIPTPID=`cat $PIDFILE` + kill -9 $DAEMONPID $SCRIPTPID || true + rm -f $PIDFILE + log_end_msg 0 + else + log_progress_msg "Daemon is already stopped." + log_end_msg 0 + fi +} + +case "$1" in + start) + echo -n "" + log_begin_msg "Starting $DESC: $NAME" + d_start ; CODE=$? + log_end_msg $CODE + ;; + stop) + log_begin_msg "Stopping $DESC: $NAME" + d_stop ; CODE=$? + log_end_msg $CODE + ;; + check_sas2ircu) + check_sas2ircu + ;; + restart|force-reload) + log_begin_msg "Restarting $DESC: $NAME" + d_stop_by_restart + sleep 1 + d_start || CODE=$? + log_end_msg $CODE + ;; + *) + # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 From f25760361bbd5bf7b2bc0cd0dfaab13f7f0d4cbd Mon Sep 17 00:00:00 2001 From: Sascha Wilde Date: Tue, 19 Jan 2021 16:30:05 +0100 Subject: [PATCH 5/7] Adapted sas2ircu-status.sas2ircu-statusd.init for CentOS. --- .../sas2ircu-status.sas2ircu-statusd.init | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init b/packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init index 80c986f..186000b 100644 --- a/packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init +++ b/packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init @@ -1,10 +1,16 @@ -#! /bin/sh +#! /bin/bash # Author: Petter Reinholdtsen +# Adapted for CentOS by: Sascha Wilde # License: GNU General Public License v2 or later # +# chkconfig: - 50 50 +# description: Check sas2ircu-status values in the background. +# config: /etc/default/sas2ircu-statusd +# ### BEGIN INIT INFO # Provides: sas2ircu-statusd +# Description: Check sas2ircu-status values in the background. # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 @@ -31,12 +37,11 @@ RUN_DAEMON=yes # Gracefully exit if the package has been removed. test -x /usr/sbin/sas2ircu-status || exit 0 -. /lib/lsb/init-functions -[ -e /etc/default/rcS ] && . /etc/default/rcS +# Source function library. +. /etc/rc.d/init.d/functions if [ $RUN_DAEMON = "no" ] ; then - log_begin_msg "sas2ircu-statusd is disabled in /etc/default/sas2ircu-statusd, not starting." - log_end_msg 0 + echo >&2 "sas2ircu-statusd is disabled in /etc/default/sas2ircu-statusd, not starting." exit 0 fi @@ -106,7 +111,7 @@ EOF check_daemon() { # Let's check if there is a daemon which is really running and not timing out - DAEMON_RUN=`ps aux | grep "/etc/init.d/sas2ircu-statusd check_sas2ircu" | grep -v grep | grep -v daemon` + DAEMON_RUN=`ps aux | grep "sas2ircu-statusd check_sas2ircu" | grep -v grep | grep -v daemon` if [ -n "$DAEMON_RUN" ] ; then return 1; else @@ -120,15 +125,15 @@ check_daemon() { d_start() { [ -f $PIDFILE ] && PID="`cat $PIDFILE`" if [ "$PID" ] ; then - log_progress_msg "Daemon already running. Refusing to start another" + echo >&2 "Daemon already running. Refusing to start another" return 0 elif check_daemon ; then # Use the daemon package to turn this script into a daemon - start-stop-daemon --start --quiet --pidfile $PIDFILE \ - --oknodo --exec /usr/bin/daemon /usr/bin/daemon $SCRIPTNAME check_sas2ircu + daemon --pidfile $PIDFILE \ + /usr/sbin/daemonize $SCRIPTNAME check_sas2ircu return 0 else - log_progress_msg "Daemon is already running. Refusing to start another" + echo >&2 "Daemon is already running. Refusing to start another" return 0 fi } @@ -138,14 +143,10 @@ d_start() { # d_stop() { if [ -f $PIDFILE ] ; then - # Doesn't work (kill init script instance, but not daemon...) - #start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE > /dev/null 2>&1 - DAEMONPID=`ps aux | grep '/usr/bin/daemon /etc/init.d/sas2ircu-statusd check_sas2ircu' | grep -v 'grep' | awk '{ print $2 }'` - SCRIPTPID=`cat $PIDFILE` - kill -9 $DAEMONPID $SCRIPTPID || true + killproc -p $PIDFILE /usr/sbin/daemonize rm -f $PIDFILE else - log_progress_msg "Daemon is already stopped." + echo >&2 "Daemon is already stopped." return 0 fi } @@ -154,40 +155,35 @@ d_stop() { # therefore can be used by a restart d_stop_by_restart() { if [ -f $PIDFILE ] ; then - # Doesn't work (kill init script instance, but not daemon...) - #start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE - DAEMONPID=`ps aux | grep '/usr/bin/daemon /etc/init.d/sas2ircu-statusd check_sas2ircu' | grep -v 'grep' | awk '{ print $2 }'` - SCRIPTPID=`cat $PIDFILE` - kill -9 $DAEMONPID $SCRIPTPID || true + killproc -p $PIDFILE /usr/sbin/daemonize rm -f $PIDFILE - log_end_msg 0 else - log_progress_msg "Daemon is already stopped." - log_end_msg 0 + echo >&2 "Daemon is already stopped." fi } case "$1" in start) echo -n "" - log_begin_msg "Starting $DESC: $NAME" + echo >&2 "Starting $DESC: $NAME" d_start ; CODE=$? - log_end_msg $CODE ;; stop) - log_begin_msg "Stopping $DESC: $NAME" + echo >&2 "Stopping $DESC: $NAME" d_stop ; CODE=$? - log_end_msg $CODE ;; check_sas2ircu) check_sas2ircu ;; + status) + status -p $PIDFILE /usr/sbin/daemonize + exit $? + ;; restart|force-reload) - log_begin_msg "Restarting $DESC: $NAME" + echo >&2 "Restarting $DESC: $NAME" d_stop_by_restart sleep 1 d_start || CODE=$? - log_end_msg $CODE ;; *) # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 From 2d0cd5b7292037a337c8b2a3a9b38d96bafe94eb Mon Sep 17 00:00:00 2001 From: Sascha Wilde Date: Tue, 19 Jan 2021 16:52:07 +0100 Subject: [PATCH 6/7] Dependency on sas2ircu for sas2ircu-status. --- packaging/rpm/sas2ircu-status/RPM/SPEC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/rpm/sas2ircu-status/RPM/SPEC b/packaging/rpm/sas2ircu-status/RPM/SPEC index 2a35fc3..45ae601 100644 --- a/packaging/rpm/sas2ircu-status/RPM/SPEC +++ b/packaging/rpm/sas2ircu-status/RPM/SPEC @@ -15,7 +15,7 @@ BuildRoot: %{_builddir}/%{name}-root Distribution: whatever Vendor: Adam Cécile (Le_Vert) Packager: wilde@intevation.de -Requires: python, bash, daemonize, mailx +Requires: python, bash, daemonize, mailx, sas2ircu BuildRequires: systemd %description From fc0b9d15736a5bbeeecde3fa3e2a3673fc956637 Mon Sep 17 00:00:00 2001 From: Sascha Wilde Date: Tue, 19 Jan 2021 17:04:43 +0100 Subject: [PATCH 7/7] Created minimal sas2ircu rpm packaging. --- README.rpm.md | 14 ++++++++--- packaging/rpm/sas2ircu/RPM/SPEC | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 packaging/rpm/sas2ircu/RPM/SPEC diff --git a/README.rpm.md b/README.rpm.md index 4e1ebdd..b03fdb9 100644 --- a/README.rpm.md +++ b/README.rpm.md @@ -1,14 +1,22 @@ RPM packages ============ -Currently RPM packaging is only available for *megaclisas-status* and -*sas2ircu-status*. +Currently RPM packaging is only available for: +- *megaclisas-status* +- *sas2ircu* +- *sas2ircu-status* To build execute from the top level directory: -``` +```bash rpmbuild --define "_sourcedir $PWD" \ -bb packaging/rpm/megaclisas-status/RPM/SPEC +# sas2ircu has to be downloaded from: +# https://docs.broadcom.com/docs/SAS2IRCU_P20.zip +unzip SAS2IRCU_P20.zip +rpmbuild --define "_sourcedir $PWD" \ + -bb packaging/rpm/sas2ircu/RPM/SPEC + rpmbuild --define "_sourcedir $PWD" \ -bb packaging/rpm/sas2ircu-status/RPM/SPEC ``` diff --git a/packaging/rpm/sas2ircu/RPM/SPEC b/packaging/rpm/sas2ircu/RPM/SPEC new file mode 100644 index 0000000..2216cba --- /dev/null +++ b/packaging/rpm/sas2ircu/RPM/SPEC @@ -0,0 +1,41 @@ +%define name sas2ircu +%define version 20.00.00.00 +%define release 1 + +Name: %{name} +Summary: LSI Logic Fusion MPT SAS2 command line management tool +Version: %{version} +Release: %{release} +License: LSI Corporation, All Rights Reserved. +Group: Applications/Internet +BuildArch: x86_64 +BuildRoot: %{_builddir}/%{name}-root +Distribution: whatever +Vendor: LSI Corporation +Packager: wilde@intevation.de + +%description +Tool to read and setup LSI Logic Fusion MTP SAS2 HW RAID HBAs (mpt2sas +driver). + +%prep +exit 0 + +%build +exit 0 + +%install +rm -rf %{buildroot} +install -d %{buildroot}%{_sbindir} + +# main package +install %{_sourcedir}/SAS2IRCU_P20/sas2ircu_linux_x86_rel/sas2ircu \ + %{buildroot}%{_sbindir} + +%clean +exit 0 + +%files +%{_sbindir}/sas2ircu + +# vim: ft=spec: