pl_mom -- cleans up your mess
[mom.git] / pl_dod.spec
1 %define name pl_dod
2 %define version 0.2
3 %define release 12.planetlab%{?date:.%{date}}
4  
5 Summary: PlanetLab mom -- Cleans up your mess
6 Name: %{name}
7 Version: %{version}
8 Release: %{release}
9 Copyright: dontknow
10 Group: System Environment/Kernel
11 Source: %{name}-%{version}.tgz
12 Vendor: PlanetLab
13 Packager: PlanetLab Central <support@planet-lab.org>
14 Distribution: PlanetLab 2.0
15 URL: http://www.planet-lab.org
16 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
17  
18 %description
19
20 A small daemon that watches the consumed swap space.  At 90% utilization, it
21 resets the slice that is the biggest memory hog.  At 95% utilization, it 
22 reboots the machine.
23
24 %prep
25
26 %setup
27
28 %build
29
30 %install
31 mkdir -p $RPM_BUILD_ROOT/usr/local/planetlab/bin/
32 mkdir -p $RPM_BUILD_ROOT/etc/init.d/
33
34 cp pl_mom $RPM_BUILD_ROOT/etc/init.d/
35 cp pl_mom.pl $RPM_BUILD_ROOT/usr/local/planetlab/bin/
36
37 %clean
38 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
39
40 %files
41 %defattr(0755, root, root)
42 /etc/init.d/pl_mom
43 /usr/local/planetlab/bin/pl_mom.pl
44
45 %pre
46 # Cleanup old stuff
47 if [ -a /var/run/pl_dod.pid ]; then
48         /etc/init.d/pl_dod stop
49 fi
50 cnt=0
51 while [ $cnt -le 6 ]; do
52         file="/etc/rc$cnt.d/K02pl_dod"
53         if [ -h $file ]; then
54                 rm -f $file
55         fi
56         file="/etc/rc$cnt.d/S98pl_dod"
57         if [ -h $file ]; then
58                 rm -f $file
59         fi
60         let "cnt = $cnt + 1"
61 done
62
63 %post 
64 RUNLEVEL=`/sbin/runlevel`
65
66 if [ "$1" -ge 1 ]; then
67
68         chkconfig --add pl_mom
69         chkconfig --level 3 pl_mom on
70
71         if [[ "$RUNLEVEL" != "unknown" ]]; then
72                 /etc/init.d/pl_mom stop
73                 /etc/init.d/pl_mom start
74         fi
75 fi
76
77 %preun
78 RUNLEVEL=`/sbin/runlevel`
79
80 if [ "$1" -eq 0 ]; then
81         if [[ "$RUNLEVEL" != "unknown" ]]; then
82                 /etc/init.d/pl_mom stop
83         fi
84 fi
85
86
87 %postun
88
89