%define name pl_dod %define version 0.2 %define release 12.planetlab%{?date:.%{date}} Summary: PlanetLab mom -- Cleans up your mess Name: %{name} Version: %{version} Release: %{release} Copyright: dontknow Group: System Environment/Kernel Source: %{name}-%{version}.tgz Vendor: PlanetLab Packager: PlanetLab Central Distribution: PlanetLab 2.0 URL: http://www.planet-lab.org BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description A small daemon that watches the consumed swap space. At 90% utilization, it resets the slice that is the biggest memory hog. At 95% utilization, it reboots the machine. %prep %setup %build %install mkdir -p $RPM_BUILD_ROOT/usr/local/planetlab/bin/ mkdir -p $RPM_BUILD_ROOT/etc/init.d/ cp pl_mom $RPM_BUILD_ROOT/etc/init.d/ cp pl_mom.pl $RPM_BUILD_ROOT/usr/local/planetlab/bin/ %clean [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT %files %defattr(0755, root, root) /etc/init.d/pl_mom /usr/local/planetlab/bin/pl_mom.pl %pre # Cleanup old stuff if [ -a /var/run/pl_dod.pid ]; then /etc/init.d/pl_dod stop fi cnt=0 while [ $cnt -le 6 ]; do file="/etc/rc$cnt.d/K02pl_dod" if [ -h $file ]; then rm -f $file fi file="/etc/rc$cnt.d/S98pl_dod" if [ -h $file ]; then rm -f $file fi let "cnt = $cnt + 1" done %post RUNLEVEL=`/sbin/runlevel` if [ "$1" -ge 1 ]; then chkconfig --add pl_mom chkconfig --level 3 pl_mom on if [[ "$RUNLEVEL" != "unknown" ]]; then /etc/init.d/pl_mom stop /etc/init.d/pl_mom start fi fi %preun RUNLEVEL=`/sbin/runlevel` if [ "$1" -eq 0 ]; then if [[ "$RUNLEVEL" != "unknown" ]]; then /etc/init.d/pl_mom stop fi fi %postun