File ipt_sysrq.spec of Package ipt_sysrq
%trace
%{echo: %(whoami)}
%{echo: %(pwd)}
%{echo: %(set)}
%{!?home: %{expand: %%define home %(echo $HOME)}}
%{echo: home=%{home}}
%{!?iptlib: %{expand: %%define iptlib %( (rpm -ql iptables | grep '/libipt_icmp.so$'|sed 's/\/libipt\_icmp\.so//') 2>/dev/null )}}
%{!?iptlib: %{expand: %%define iptlib %{_libdir}} }
%{echo: iptlib=%{iptlib}}
%{!?iptver: %{expand: %%define iptver %( rpm -q --qf %{VERSION} iptables|sed 's/\([0-9]*\.[0-9]\).*/\1/' )}}
%{echo: iptver=%{iptver}}
%if "%{iptver}" == "1.4"
%define bldreq iptables-devel iptables
%endif
%if "%{iptver}" == "1.3"
%define bldreq iptables-devel iptables libupnp libupnp-devel
%endif
%{echo: bldreq=%{bldreq}}
Summary: ipt_sysrq is an IPtables module to execute sysrq commands received over the network.
Name: ipt_sysrq
Version: 0.7.2
Release: 4
BuildRoot: %{home}/rpmbuild/%{name}-%{version}
Source: ipt-sysrq-%{version}.tbz
License: GPL
Group: System Environment/Kernel
Distribution: RH Fedora, openSUSE
Requires: iptables >= 1.4
BuildRequires: rpm sed iptables-devel iptables
%description
ipt_sysrq is a new iptables target that allows you to do the same as the magic sysrq key on a keyboard does, but over the network.
send_sysrq is a client to send sysrq over the network to ipt_SysRQ module that works in IP Tables.
An rc service ipt-sysrq will be installed but can be started only after you install kernel module ipt_sysrq-kmdl.
%prep
%setup -n ipt-sysrq-%{version}
%build
(rpm -q %{bldreq}; echo .)
make build-ipt
%install
make DESTDIR=$RPM_BUILD_ROOT install-ipt
make DESTDIR=$RPM_BUILD_ROOT install-service-rpmb
%post
/sbin/ldconfig
if [ "$1" -eq "1" ]; then
PSW=`head -c 200 /dev/urandom |tr -cd '[:graph:]'|sed 's/[^a-zA-Z0-9]//g'|cut -c-8`
sed 's/PASSWORD="my_secret_password"$/PASSWORD="'${PSW}'"/' /etc/ipt-sysrq.conf >/etc/ipt-sysrq.conf.new
cat /etc/ipt-sysrq.conf.new > /etc/ipt-sysrq.conf
rm -f /etc/ipt-sysrq.conf.new
echo Default ipt-sysrq password may has been changed. Check /etc/ipt-sysrq.conf
fi
/sbin/chkconfig --add ipt-sysrq
echo Service ipt-sysrq is added but not started.
echo Make sure to install a kernel module ipt_sysrq-kmdl before starting the service.
%preun
/sbin/service ipt-sysrq stop
/sbin/chkconfig --del ipt-sysrq
%postun
/sbin/ldconfig
%files
%defattr(-,root,root)
%{iptlib}/libipt_SYSRQ.so
%doc %attr(0444,root,root) %{_mandir}/man1/ipt_sysrq.1.gz
%doc COPYING AUTHORS README CHANGELOG
%config %attr(0600,root,root) /etc/ipt-sysrq.conf
%attr(0755,root,root) /etc/init.d/ipt-sysrq