Added systemd unit file.

Resolves: #820125
This commit is contained in:
Jan Safranek 2012-05-09 14:19:03 +02:00
parent c90df366b7
commit fc0f23c58f
4 changed files with 71 additions and 110 deletions

View File

@ -4,20 +4,22 @@
Summary: IPMI (Intelligent Platform Management Interface) library and tools
Name: OpenIPMI
Version: 2.0.18
Release: 13%{?dist}
Release: 14%{?dist}
License: LGPLv2+ and GPLv2+ or BSD
Group: System Environment/Base
URL: http://sourceforge.net/projects/openipmi/
Source: http://downloads.sourceforge.net/openipmi/%{name}-%{version}.tar.gz
Source1: openipmi.sysconf
Source2: openipmi.initscript
Source3: README.initscript
Source2: openipmi-helper
Source3: ipmi.service
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: gdbm-devel swig glib2-devel net-snmp-devel ncurses-devel
BuildRequires: openssl-devel python-devel perl-devel tcl-devel tkinter
BuildRequires: desktop-file-utils
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
Requires(post): systemd-sysv
Patch1: OpenIPMI-2.0.18-pthread-pkgconfig.patch
@ -85,39 +87,58 @@ rm -rf $RPM_BUILD_ROOT/%{_libdir}/*.la
install -d ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig
install -m 644 %SOURCE1 ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/ipmi
install -d ${RPM_BUILD_ROOT}%{_initrddir}
install -m 755 %SOURCE2 ${RPM_BUILD_ROOT}%{_initrddir}/ipmi
install -m 644 %SOURCE3 .
install -d ${RPM_BUILD_ROOT}%{_libexecdir}
install -m 755 %SOURCE2 ${RPM_BUILD_ROOT}%{_libexecdir}/openipmi-helper
install -d ${RPM_BUILD_ROOT}%{_unitdir}
install -m 644 %SOURCE3 ${RPM_BUILD_ROOT}%{_unitdir}/ipmi.service
rm ${RPM_BUILD_ROOT}/%{_mandir}/man1/openipmigui.1
%post
/sbin/chkconfig --add ipmi
if [ $1 -eq 1 ] ; then
# Initial installation
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%preun
if [ $1 = 0 ]; then
service ipmi stop >/dev/null 2>&1
/sbin/chkconfig --del ipmi
if [ $1 -eq 0 ] ; then
# Package removal, not upgrade
/bin/systemctl --no-reload disable ipmi.service > /dev/null 2>&1 || :
/bin/systemctl stop ipmi.service > /dev/null 2>&1 || :
fi
%postun
if [ "$1" -ge "1" ]; then
service ipmi condrestart >/dev/null 2>&1 || :
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
# Package upgrade, not uninstall
/bin/systemctl try-restart ipmi.service >/dev/null 2>&1 || :
fi
%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig
### A sysv => systemd migration contains all of the same scriptlets as a
### systemd package. These are additional scriptlets
%triggerun -- OpenIPMI < 2.0.18-14
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply httpd
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save ipmi >/dev/null 2>&1 ||:
/bin/systemctl --no-reload enable ipmi.service >/dev/null 2>&1 ||:
# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del ipmi >/dev/null 2>&1 || :
/bin/systemctl try-restart ipmi.service >/dev/null 2>&1 || :
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%doc CONFIGURING_FOR_LAN COPYING COPYING.BSD COPYING.LIB FAQ README README.Force README.MotorolaMXP README.initscript
%doc CONFIGURING_FOR_LAN COPYING COPYING.BSD COPYING.LIB FAQ README README.Force README.MotorolaMXP
%config(noreplace) %{_sysconfdir}/sysconfig/ipmi
%{_initrddir}/ipmi
%{_libexecdir}/openipmi-helper
%{_bindir}/ipmicmd
%{_bindir}/ipmilan
%{_bindir}/ipmish
@ -126,6 +147,7 @@ rm -rf $RPM_BUILD_ROOT
%{_bindir}/openipmish
%{_bindir}/rmcp_ping
%{_bindir}/solterm
%{_unitdir}/ipmi.service
%{_mandir}/man1/ipmi_ui*
%{_mandir}/man1/openipmicmd*
%{_mandir}/man1/openipmish*
@ -155,6 +177,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/pkgconfig/*.pc
%changelog
* Mon May 7 2012 Jan Safranek <jsafrane@redhat.com> - 2.0.18-14
- Added ipmi systemd unit
* Thu Jan 12 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.18-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

View File

@ -1,2 +0,0 @@
Please note that the /etc/init.d/ipmi init script is not LSB compliant and
uses non-standard exit codes. See the init script for detailed description.

12
ipmi.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=IPMI Driver
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/libexec/openipmi-helper start
ExecStop=/usr/libexec/openipmi-helper stop
[Install]
WantedBy=multi-user.target

View File

@ -1,24 +1,14 @@
#!/bin/sh
#############################################################################
#
# ipmi: OpenIPMI Driver init script
# ipmi: OpenIPMI Driver helper script
#
# Authors: Matt Domsch <Matt_Domsch@dell.com>
# Authors: Jan Safranek <jsafrane@redhat.com>
#
# Based on IPMI init script by:
# Matt Domsch <Matt_Domsch@dell.com>
# Chris Poblete <Chris_Poblete@dell.com>
#
# chkconfig: - 13 87
# description: OpenIPMI Driver init script
#
### BEGIN INIT INFO
# Provides: ipmidrv
# Required-Start: $local_fs $remote_fs $syslog
# Required-Stop: $local_fs $remote_fs $syslog
# Default-Start:
# Default-Stop:
# Short-Description: OpenIPMI Driver init script
# Description: OpenIPMI Driver init script
### END INIT INFO
#
# Status return code bits
# no bits set = no errors
# bit 0 set = minimum modules aren't loaded
@ -28,54 +18,6 @@
# bit 4 set = lockfile doesn't exist
# bit 5 set = modules are loaded even when asked to be unloaded
#
#############################################################################
# for log_success_msg and friends
if [ -r /lib/lsb/init-functions ]; then
# LSB, SLES, ...
. /lib/lsb/init-functions
elif [ -r /etc/init.d/functions ]; then
# Red Hat / VMware
. /etc/init.d/functions
my_log_message()
{
ACTION=$1
shift
case "$ACTION" in
success)
echo -n $*
success "$*"
echo
;;
failure)
echo -n $*
failure "$*"
echo
;;
warning)
echo -n $*
warning "$*"
echo
;;
*)
;;
esac
}
log_success_msg()
{
my_log_message success "$*"
}
log_failure_msg()
{
my_log_message failure "$*"
}
log_warning_msg()
{
my_log_message warning "$*"
}
fi
CONFIGFILE=/etc/sysconfig/ipmi
# source config info
[ -r ${CONFIGFILE} ] && . ${CONFIGFILE}
@ -210,49 +152,44 @@ start_watchdog_common()
modules_loaded ipmi_watchdog
[ ${OnePlusUnloaded} -ne 0 ] &&
RETVAL=$((RETVAL | 2)) &&
log_failure_msg &&
echo "Watchdog startup failed: cannot load ipmi_watchdog module" &&
return
if [ ${UDEV_EXISTS} -eq 0 -a ! -e /dev/watchdog ]; then
mknod -m 0600 /dev/watchdog c 10 130
[ $? -ne 0 ] &&
RETVAL=$((RETVAL | 8)) &&
log_failure_msg &&
echo "Watchdog startup failed: cannot create /dev/watchdog" &&
return
fi
log_success_msg
}
start_watchdog_quiet()
{
[ "${IPMI_WATCHDOG}" != "yes" ] &&
return
echo -n $"Starting ipmi_watchdog driver: "
start_watchdog_common
}
start_watchdog()
{
echo -n $"Starting ipmi_watchdog driver: "
[ "${IPMI_WATCHDOG}" != "yes" ] &&
RETVAL=$((RETVAL | 2)) &&
log_failure_msg "not configured" &&
echo "Watchdog not configured" &&
return
start_watchdog_common
}
stop_watchdog()
{
echo -n $"Stopping ipmi_watchdog driver: "
modprobe -q -r ipmi_watchdog > /dev/null 2>&1
modules_loaded ipmi_watchdog
if [ ${OnePlusLoaded} -ne 0 ]; then
RETVAL=$((RETVAL | 32))
log_failure_msg
echo "Watchog shutdown failed: cannot unload ipmi_watchdog module"
else
if [ "${IPMI_WATCHDOG}" = "yes" ]; then
[ ${UDEV_EXISTS} -eq 0 ] && rm -f /dev/watchdog
fi
log_success_msg
fi
}
@ -283,39 +220,33 @@ start_powercontrol_common()
modules_loaded ipmi_poweroff
[ ${OnePlusUnloaded} -ne 0 ] &&
RETVAL=$((RETVAL | 2)) &&
log_failure_msg &&
echo "Powercontroll startup failed: cannot load ipmi_poweroff module" &&
return
log_success_msg
}
start_powercontrol_quiet()
{
[ "${IPMI_POWEROFF}" != "yes" ] &&
return
echo -n $"Starting ipmi_poweroff driver: "
start_powercontrol_common
}
start_powercontrol()
{
echo -n $"Starting ipmi_poweroff driver: "
[ "${IPMI_POWEROFF}" != "yes" ] &&
RETVAL=$((RETVAL | 2)) &&
log_failure_msg "not configured" &&
echo "Powercontroll not configured" &&
return
start_powercontrol_common
}
stop_powercontrol()
{
echo -n $"Stopping ipmi_poweroff driver: "
modprobe -q -r ipmi_poweroff > /dev/null 2>&1
modules_loaded ipmi_poweroff
if [ ${OnePlusLoaded} -ne 0 ]; then
RETVAL=$((RETVAL | 32))
log_failure_msg
else
log_success_msg
echo "Powercontroll shutdown failed: cannot unload ipmi_poweroff module"
fi
}
@ -410,15 +341,14 @@ load_ipmi_modules ()
#############################################################################
start()
{
echo -n "Starting ${MODULE_NAME} drivers: "
load_ipmi_modules
if [ ${RETVAL} -eq 0 ]; then
touch ${LOCKFILE} && log_success_msg
touch ${LOCKFILE}
else
if [ $((RETVAL & 1)) -eq 1 ]; then
log_failure_msg
echo "Startup failed."
else
touch ${LOCKFILE} && log_warning_msg
touch ${LOCKFILE} && echo "Warning!?"
fi
fi
start_watchdog_quiet
@ -428,29 +358,25 @@ start()
#############################################################################
stop()
{
echo -n "Stopping ${MODULE_NAME} drivers: "
unload_ipmi_modules_leave_features
modules_loaded ${MODULES_INTERFACES}
if [ ${OnePlusLoaded} -ne 0 ]; then
RETVAL=$((RETVAL | 32))
log_failure_msg "may be in use"
echo "Shutdown failed, something may be in use"
else
rm -f ${LOCKFILE}
log_success_msg
fi
}
stop_all()
{
echo -n $"Stopping all ${MODULE_NAME} drivers: "
unload_all_ipmi_modules
modules_loaded ${MODULES}
if [ ${OnePlusLoaded} -ne 0 ]; then
RETVAL=$((RETVAL | 32))
log_failure_msg "may be in use"
echo "Shutdown failed, something may be in use"
else
rm -f ${LOCKFILE}
log_success_msg
fi
}