Package init

This commit is contained in:
overweight 2019-09-30 11:02:43 -04:00
commit f2cb114f86
10 changed files with 281 additions and 0 deletions

8
lm_sensors-modprobe-r-wrapper Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
if [ $# -ne 0 ]; then
/usr/sbin/modprobe -abr "$@"
else
echo "No sensors with loadable kernel modules configured."
echo "Please, run 'sensors-detect' as root in order to search for available sensors."
exit 1
fi

8
lm_sensors-modprobe-wrapper Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
if [ $# -ne 0 ]; then
/usr/sbin/modprobe -ab "$@"
else
echo "No sensors with loadable kernel modules configured."
echo "Please, run 'sensors-detect' as root in order to search for available sensors."
exit 1
fi

13
lm_sensors.service Normal file
View File

@ -0,0 +1,13 @@
[Unit]
Description=Hardware Monitoring Sensors
[Service]
EnvironmentFile=/etc/sysconfig/lm_sensors
Type=oneshot
RemainAfterExit=yes
ExecStart=-@WRAPPER_DIR@/lm_sensors-modprobe-wrapper $BUS_MODULES $HWMON_MODULES
ExecStart=/usr/bin/sensors -s
ExecStop=-@WRAPPER_DIR@/lm_sensors-modprobe-r-wrapper $BUS_MODULES $HWMON_MODULES
[Install]
WantedBy=multi-user.target

170
lm_sensors.spec Normal file
View File

@ -0,0 +1,170 @@
Name: lm_sensors
Version: 3.4.0
Release: 18
Summary: Linux-monitoring sensors
# lib/libsensors.3 is licensed Verbatim
# dist-git files are licensed MIT
# and others are licensed by GPLv2+ or LGPLv2+
License: LGPLv2+ and GPLv2+ and Verbatim and MIT
URL: http://github.com/groeck/lm-sensors
Source0: lm-sensors-70f7e0848410b9ca4dde7abff669bbbecbf137e0.tar.gz
Source1: lm_sensors.sysconfig
Source2: sensord.sysconfig
Source3: lm_sensors-modprobe-wrapper
Source4: lm_sensors-modprobe-r-wrapper
Source5: sensord.service
Source6: sensord-service-wrapper
Source7: lm_sensors.service
Patch6000:pwmconfig-Fix-a-sed-expression.patch
Requires: kmod, systemd-units
BuildRequires: kernel-headers >= 2.2.16, bison, libsysfs-devel, flex, gawk
BuildRequires: perl-generators, rrdtool-devel, gcc
provides: %{name}-libs = %{version}-%{release}
%description
lm_sensors (Linux-monitoring sensors), is a free open source software-tool for Linux
that provides tools and drivers for monitoring temperatures, voltage,
humidity, and fans. It can also detect chassis intrusions.
%package devel
Summary: lm_sensors's development files
Requires: %{name}-libs = %{version}-%{release}
#only lib/libsensors.3 is licensed Verbatim.
License: LGPLv2+ and Verbatim
%description devel
libsensors offers a way for applications to access the hardware
monitoring chips of the system. A system-dependent configuration file
controls how the different inputs are labeled and what scaling factors
have to be applied for the specific hardware, so that the output makes
sense to the user.
%package sensord
Summary: hardware health monitoring daemon
Requires: %{name} = %{version}-%{release}
# only prog/sensord/sensord.8 is licensed Verbatim.
# dist-git files are licensed MIT.
License: GPLv2+ and Verbatim and MIT
%description sensord
Daemon that periodically logs sensor readings to syslog or a round-robin
database, and warns of sensor alarms.
%package help
Summary: Help information for user
%description help
Help information for user
%prep
%autosetup -n lm-sensors-70f7e0848410b9ca4dde7abff669bbbecbf137e0 -p1
rm -f prog/init/sysconfig-lm_sensors-convert prog/hotplug/unhide_ICH_SMBus
mv prog/init/README prog/init/README.initscripts
chmod -x prog/init/fancontrol.init
cp -p %{SOURCE5} sensord.service
cp -p %{SOURCE7} lm_sensors.service
sed -i "s|\@WRAPPER_DIR\@|%{_libexecdir}/%{name}|" sensord.service
sed -i "s|\@WRAPPER_DIR\@|%{_libexecdir}/%{name}|" lm_sensors.service
%build
%set_build_flags
%make_build PREFIX=%{_prefix} LIBDIR=%{_libdir} MANDIR=%{_mandir} \
EXLDFLAGS="$LDFLAGS" PROG_EXTRA=sensord BUILD_STATIC_LIB=0 user
%install
%make_build PREFIX=%{_prefix} LIBDIR=%{_libdir} MANDIR=%{_mandir} PROG_EXTRA=sensord \
DESTDIR=$RPM_BUILD_ROOT BUILD_STATIC_LIB=0 user_install
ln -s sensors.conf.5.gz $RPM_BUILD_ROOT%{_mandir}/man5/sensors3.conf.5.gz
mkdir -p -m 755 $RPM_BUILD_ROOT%{_initrddir}
mkdir -p -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/sensors.d
mkdir -p -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
install -pm 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/lm_sensors
install -pm 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/sensord
# service files
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
install -pm 644 prog/init/fancontrol.service $RPM_BUILD_ROOT%{_unitdir}
install -pm 644 lm_sensors.service $RPM_BUILD_ROOT%{_unitdir}
install -pm 644 sensord.service $RPM_BUILD_ROOT%{_unitdir}
# customized modprobe calls
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/%{name}
install -pm 755 %{SOURCE3} $RPM_BUILD_ROOT%{_libexecdir}/%{name}/lm_sensors-modprobe-wrapper
install -pm 755 %{SOURCE4} $RPM_BUILD_ROOT%{_libexecdir}/%{name}/lm_sensors-modprobe-r-wrapper
# sensord service wrapper
install -pm 755 %{SOURCE6} $RPM_BUILD_ROOT%{_libexecdir}/%{name}/sensord-service-wrapper
# Note non standard systemd scriptlets, since reload / stop makes no sense
# for lm_sensors
%triggerun -- lm_sensors < 3.3.0-2
if [ -L /etc/rc3.d/S26lm_sensors ]; then
/bin/systemctl enable lm_sensors.service >/dev/null 2>&1 || :
fi
/sbin/chkconfig --del lm_sensors
# ===== main =====
%post
%systemd_post lm_sensors.service
%preun
%systemd_preun lm_sensors.service
%postun
%systemd_postun_with_restart lm_sensors.service
# ==== sensord ===
%post sensord
%systemd_post sensord.service
%preun sensord
%systemd_preun sensord.service
%postun sensord
%systemd_postun_with_restart sensord.service
# ===== libs =====
%ldconfig_scriptlets
%files
%doc CHANGES CONTRIBUTORS doc README*
%doc prog/init/fancontrol.init prog/init/README.initscripts
%license COPYING COPYING.LGPL
%config %{_sysconfdir}/sensors3.conf
%config %{_sysconfdir}/sysconfig/lm_sensors
%dir %{_sysconfdir}/sensors.d
%{_bindir}/*
%{_sbindir}/*
%{_unitdir}/lm_sensors.service
%{_unitdir}/fancontrol.service
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/lm_sensors-modprobe*wrapper
%{_libdir}/*.so.*
%exclude %{_sbindir}/sensord
%files devel
%{_includedir}/sensors
%{_libdir}/lib*.so
%files sensord
%doc prog/sensord/README
%config(noreplace) %{_sysconfdir}/sysconfig/sensord
%{_sbindir}/sensord
%{_unitdir}/sensord.service
%{_libexecdir}/%{name}/sensord-service-wrapper
%files help
%{_mandir}/man*
%exclude %{_mandir}/man8/sensord.8.gz
%changelog
* Tue Apr 16 2019 yuejiayan<yuejiayan@huawei.com> - 3.4.0-18
- Type:bugfix
- ID:NA
- SUG:NA
DESC:pwmconfig: Fix a sed expression
* Mon Apr 1 2019 openEuler Buildteam <buildteam@openeuler.org> - 3.4.0-17
- Package init

2
lm_sensors.sysconfig Normal file
View File

@ -0,0 +1,2 @@
# /etc/sysconfig/lm_sensors - Defines modules loaded by the lm_sensors service
# Run 'sensors-detect' to generate this config file

View File

@ -0,0 +1,34 @@
From 38220cc2e97215588b662584d6ad84d63415842f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
Date: Thu, 20 Sep 2018 21:17:40 +0200
Subject: [PATCH 094/117] pwmconfig: Fix a sed expression
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This fixes commit 3daae37d58cd.
The escaping inside backticks is really kinda crazy.
Fixes #126
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
---
prog/pwm/pwmconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/prog/pwm/pwmconfig b/prog/pwm/pwmconfig
index c24c891..a40acd5 100755
--- a/prog/pwm/pwmconfig
+++ b/prog/pwm/pwmconfig
@@ -879,7 +879,7 @@ select pwms in $pwmactive "Change INTERVAL" "Just quit" "Save and quit" "Show co
break ;;
"$(echo ${pwmactive} |sed -e 's/ /\n/g' | egrep "${pwms}")" )
- pwmsed=$(echo ${pwms} | sed -e 's/\//\\\\\//g') #escape / for sed
+ pwmsed=$(echo ${pwms} | sed -e 's/\//\\\//g') #escape / for sed
echo
echo 'Devices:'
--
1.8.3.1

13
sensord-service-wrapper Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
. /etc/sysconfig/sensord
ARGS=""
[ "$INTERVAL" = "" ] || ARGS=`echo "$ARGS -i $INTERVAL"`
[ "$LOG_INTERVAL" = "" ] || ARGS=`echo "$ARGS -l $LOG_INTERVAL"`
[ "$RRD_INTERVAL" = "" ] || ARGS=`echo "$ARGS -t $RRD_INTERVAL"`
[ "$RRD_LOGFILE" = "" ] || ARGS=`echo "$ARGS -r $RRD_LOGFILE"`
[ "$RRD_NO_AVG" = "1" ] && ARGS=`echo "$ARGS -T"`
[ "$LOAD_AVG" = "1" ] && ARGS=`echo "$ARGS -a"`
/usr/sbin/sensord -f daemon $ARGS

12
sensord.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=Hardware Monitoring Data Logger
After=lm_sensors.service
[Service]
EnvironmentFile=-/etc/sysconfig/sensord
Type=forking
PIDFile=/var/run/sensord.pid
ExecStart=@WRAPPER_DIR@/sensord-service-wrapper
[Install]
WantedBy=multi-user.target

21
sensord.sysconfig Normal file
View File

@ -0,0 +1,21 @@
# configuration for harware sensors monitoring daemon
# use suffix "m" for minutes, "s" for seconds, "h" for hours
# 0 turns the facility off
# interval between scanning alarms
INTERVAL=1m
# interval between logging
LOG_INTERVAL=20m
# interval between RRD logging
# RRD_INTERVAL=1m
# RRD db location
# RRD_LOGFILE=/var/log/sensors.rrd
# Switch RRD in non-average mode ... 1 - enabled, 0 - disabled (default)
# RRD_NO_AVG=1
# Include load average in RRD ... 1 - enabled, 0 - disabled (default)
# LOAD_AVG=1