File smstools3.spec of Package smstools3
#
# spec file for package smstools3
#
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{!?_initddir: %{expand: %%global _initddir %{_initrddir}}}
%{!?_rundir: %{expand: %%global _rundir %{_localstatedir}/run}}
%if ! %{defined _fillupdir}
%define _fillupdir %{_localstatedir}/adm/fillup-templates
%endif
%if 0%{?suse_version} >= 1210 || 0%{?centos_version} >= 600
%bcond_without systemd
%else
%bcond_with systemd
%endif
%define smsduser smsd
%if 0%{?suse_version} > 01110
%define smsdgroup dialout
%else
%define smsdgroup uucp
%endif
%define sendsmsgroup sendsms
%define nnmmsg logger -t %{name}/rpm
Name: smstools3
Version: 3.1.21
Release: 0
Summary: SMS server tools for GSM modems
License: GPL-2.0-or-later
Group: Productivity/Networking/System
URL: http://smstools3.kekekasvi.com/
Source0: http://smstools3.kekekasvi.com/packages/smstools3-%{version}.tar.gz
Source1: %{name}-init
Source2: %{name}-logrotate
Source3: %{name}-fillup
Source4: smsd.8
Source5: smsd.de.8
Source6: %{name}-README.SUSE
Source7: %{name}-rpmlintrc
Source8: %{name}-fillup-sle
Source9: %{name}-README.SLE
Source10: smstools3.service
# Script should be upstreamed but for now it is *suse only
Source11: sendsms
Source12: check_sms3status.pl
Source13: nrpe-check_check_sms3status.cfg
# https://sources.debian.org/patches/smstools/3.1.21-4/gcc10.patch/
Patch0: gcc10.patch
BuildRequires: acl
BuildRequires: nagios-rpm-macros
BuildRequires: ncurses-devel
BuildRequires: zlib-devel
Requires: acl
Requires(pre): %fillup_prereq
Requires(pre): /bin/logger
Requires(pre): coreutils
Requires(pre): shadow
Recommends: %{name}-doc = %{version}
Recommends: logrotate
%{?systemd_requires}
%if %{with systemd}
BuildRequires: systemd-rpm-macros
Requires(pre): sysvinit(network)
Requires(pre): sysvinit(syslog)
%{?systemd_requires}
%else
Requires(pre): %insserv_prereq
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
The SMS server tools allow setting up a central SMS gateway. It
sends and receives SMS messages using a simple file-based
interface. It can accommodate up to 20,000 messages a month.
It supports an event-handler option that allows calling customized
programs or scripts after sending or receiving SMS messages.
The SMS Server Tools use one or more (max. 32) GSM modems to send and
receive SMS messages. Some modems may be equipped with SIM cards such
as Vodafone or Telmi ones. All messages are sorted in queues by the
provider. If one modem fails, it will be deactivated for one hour
before the software retries, while other modems run without any
restriction. The status information and alarms are logged with
syslog.
%package doc
Summary: Documentation and example files for %{name}
Group: Documentation/Other
Requires: %{name} = %{version}
%description doc
This package contains additional documentation and example files
for the package %{name}.
%package -n monitoring-plugins-%{name}
Summary: Retrieves the status of an SMS Modem via smstools3
Group: System/Monitoring
Requires: nagios-plugins-common
%description -n monitoring-plugins-%{name}
This plugin checks the status of an SMS modem using the regular_run functionality
provided in smstools3
It does not directly access the modem, but instead reads a status file generated
by smstools3.
In order to work the following options need to be set in smsd.conf
regular_run_interval = 60
regular_run_cmd = AT+CREG?;+CSQ;+COPS?
regular_run_statfile = F<status_file>
The following performance data is returned
<signal dBm>;<% signal strength>;<Error rate>;<Network ID/Name>
%prep
%setup -q -n %{name}
%patch0 -p1
sed -ri 's/(^logfile.*)/#\1/g;s/(loglevel =).*/\1 5/g;/loglevel/aumask = 027' examples/smsd.conf.easy
# With systemd we are using journal logging so let it do its job directly (stdout)
%if 0%{?suse_version} >= 1210
sed -ri '/logfile/d' examples/smsd.conf.easy
%endif
%build
cd src
make CFLAGS="%{optflags} -DNUMBER_OF_MODEMS=64 -DNOSTATS" %{?%{jobs}:-j %{jobs}}
%install
# create directories
mkdir -p %{buildroot}/%{_sbindir}
mkdir -p %{buildroot}/%{_bindir}
mkdir -p %{buildroot}%{_docdir}/%{name}
# install docu
%if 0%{?suse_version} > 1110
install -m644 %{SOURCE6} %{buildroot}%{_docdir}/%{name}/README.SUSE
%else
install -m644 %{SOURCE9} %{buildroot}%{_docdir}/%{name}/README.SUSE
%endif
cp -av scripts examples doc %{buildroot}%{_docdir}/%{name}/
rm -vf %{buildroot}%{_docdir}/%{name}/*/*,v
install -m 644 LICENSE README %{buildroot}%{_docdir}/%{name}/
# install files
install -m755 src/smsd %{buildroot}/%{_sbindir}
# don't copy original scripts/sendsms too complicated
install -m755 %{SOURCE11} scripts/sms2html scripts/sms2unicode scripts/unicode2sms %{buildroot}/%{_bindir}/
install -Dm755 %{SOURCE12} %{buildroot}%{nagios_plugindir}/check_sms3status.pl
install -Dm644 %{SOURCE13} %{buildroot}%{nrpe_sysconfdir}/check_sms3status.cfg
# Installing config file
install -Dm640 examples/smsd.conf.easy %{buildroot}/%{_sysconfdir}/smsd.conf
# install init file
%if %{with systemd}
install -Dm644 %{SOURCE10} %{buildroot}%{_unitdir}/%{name}.service
mkdir -p %{buildroot}%{_prefix}/lib/tmpfiles.d
cat >> %{buildroot}%{_prefix}/lib/tmpfiles.d/%{name}.conf << EOF
# used by smstools3 package
d %{_rundir}/smsd 0755 %{smsduser} %{smsdgroup}
EOF
(ln -s service %{buildroot}/%{_sbindir}/rc%{name})
%else
mkdir -p %{buildroot}/%{_initddir} %{buildroot}%{_rundir}/smsd
install -m 755 %{SOURCE1} %{buildroot}/%{_initddir}/smsd
ln -s %{_initddir}/smsd %{buildroot}/%{_sbindir}/rcsmsd
%endif
# install man
install -Dm644 %{SOURCE4} %{buildroot}/%{_mandir}/man8/smsd.8
install -Dm644 %{SOURCE5} %{buildroot}/%{_mandir}/de/man8/smsd.8
# create needed directories
mkdir -p %{buildroot}%{_localstatedir}/{log,lib}/smsd
mkdir -p %{buildroot}%{_localstatedir}/spool/sms/{checked,incoming,outgoing,sent,scheduled,failed}
# install logrotate
install -Dm644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/logrotate.d/%{name}
# install fillup template
%if 0%{?suse_version} > 1110
install -Dm644 %{SOURCE3} %{buildroot}%{_fillupdir}/sysconfig.%{name}
%else
install -Dm644 %{SOURCE8} %{buildroot}%{_fillupdir}/sysconfig.%{name}
%endif
%pre
if
getent group %{smsdgroup} >/dev/null
then
: OK group %{smsdgroup} already present
else
groupadd -r %{smsdgroup} 2>/dev/null || :
%{nnmmsg} "Added group %{smsdgroup} for package %{name}"
fi
if
getent group %{sendsmsgroup} >/dev/null
then
: OK group %{sendsmsgroup} already present
else
groupadd -r %{sendsmsgroup} 2>/dev/null || :
%{nnmmsg} "Added group %{sendsmsgroup} for package %{name}"
fi
if
id %{smsduser} > /dev/null 2>&1
then
: OK user %{smsduser} already present
else
useradd -r -g %{smsdgroup} -G %{sendsmsgroup} -c "User for SMS Gateway" -d %{_localstatedir}/spool/sms %{smsduser} 2> /dev/null || :
%{nnmmsg} "Added user %{smsduser} for package %{name}"
fi
%if %{with systemd}
%service_add_pre %{name}.service
%endif
%post
setfacl -m g:%{sendsmsgroup}:rwx %{_localstatedir}/spool/sms/outgoing/ || :
setfacl -dm g:%{sendsmsgroup}:rwx %{_localstatedir}/spool/sms/outgoing/ || :
%if %{with systemd}
%service_add_post %{name}.service
systemd-tmpfiles --create %{_tmpfilesdir}/%{name}.conf
%{fillup_only -n %{name}}
%else
%{fillup_and_insserv -n %{name}}
%endif
%preun
%if %{with systemd}
%service_del_preun %{name}.service
%else
%stop_on_removal smsd
%endif
%postun
%if %{with systemd}
%service_del_postun %{name}.service
%else
%restart_on_update smsd
%insserv_cleanup
%endif
%files
%defattr(-,root,root)
%dir %{_docdir}/%{name}
%if 0%{?suse_version} >= 01500
%license %{_docdir}/%{name}/LICENSE
%else
%license %{_docdir}/%{name}/LICENSE
%endif
%doc %{_docdir}/%{name}/README
%doc %{_docdir}/%{name}/README.SUSE
%{_mandir}/man8/smsd.8%{?ext_man}
%{_mandir}/de/man8/smsd.8%{?ext_man}
%{_sbindir}/*
%{_bindir}/*
%if %{with systemd}
%{_unitdir}/%{name}.service
%{_prefix}/lib/tmpfiles.d/%{name}.conf
%else
%{_initddir}/smsd
%endif
# as smsd runs with smsdgroup file should be readable by it
%attr(640,root,%{smsdgroup}) %config(noreplace) %{_sysconfdir}/smsd.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_fillupdir}/sysconfig.%{name}
%if 0%{?suse_version} >= 01500
%dir %{_fillupdir}
%endif
%defattr(-,%{smsduser},%{smsdgroup})
%dir %{_localstatedir}/spool/sms
%attr(750,%{smsduser},%{smsdgroup}) %dir %{_localstatedir}/spool/sms/checked
%attr(750,%{smsduser},%{smsdgroup}) %dir %{_localstatedir}/spool/sms/incoming
%attr(730,%{smsduser},%{sendsmsgroup}) %dir %{_localstatedir}/spool/sms/outgoing
%attr(750,%{smsduser},%{smsdgroup}) %dir %{_localstatedir}/spool/sms/scheduled
%attr(750,%{smsduser},%{smsdgroup}) %dir %{_localstatedir}/spool/sms/sent
%ghost %attr(750,%{smsduser},%{smsdgroup}) %dir %{_rundir}/smsd
%dir %{_localstatedir}/log/smsd
%dir %{_localstatedir}/lib/smsd
%files doc
%defattr(-,root,root)
%defattr(0644,root,root,0755)
%dir %{_docdir}/%{name}
%doc %{_docdir}/%{name}/examples
%doc %{_docdir}/%{name}/doc
%doc %{_docdir}/%{name}/scripts
%files -n monitoring-plugins-%{name}
%defattr(-,root,root)
%defattr(0644,root,root,0755)
%dir %{nrpe_sysconfdir}
%config(noreplace) %{nrpe_sysconfdir}/check_sms3status.cfg
%if 0%{?suse_version} >= 01500
%license LICENSE
%else
%license LICENSE
%endif
%defattr(0755,root,root,0755)
%dir %{nagios_libdir}
%dir %{nagios_plugindir}
%{nagios_plugindir}/check_sms3status.pl
%changelog